Java 类com.sun.jna.ptr.DoubleByReference 实例源码

项目:BIMplatform    文件:IfcEngine.java   
/**
 * Returns advanced bounding box measures, can be used in combination with
 * getInstanceDerivedTransformationMatrix().
 * 
 * @param model
 *            Unique number identifying the model in the opened file.
 * @param instance
 *            A numeric instanceID that uniquely identifies an instance.
 * @return InstanceDerivedBoundingBox object
 * @throws Exception
 */
public InstanceDerivedBoundingBox getInstanceDerivedBoundingBox(Pointer model, Pointer instance) {
    DoubleByReference pOx = new DoubleByReference();
    DoubleByReference pOy = new DoubleByReference();
    DoubleByReference pOz = new DoubleByReference();
    DoubleByReference pVx = new DoubleByReference();
    DoubleByReference pVy = new DoubleByReference();
    DoubleByReference pVz = new DoubleByReference();
    engine._getInstanceDerivedBoundingBox(model, instance, pOx, pOy, pOz, pVx, pVy, pVz);
    double ox = pOx.getValue();
    double oy = pOy.getValue();
    double oz = pOz.getValue();
    double vx = pVx.getValue();
    double vy = pVy.getValue();
    double vz = pVz.getValue();
    return new InstanceDerivedBoundingBox(model, instance, ox, oy, oz, vx, vy, vz);
}
项目:BIMplatform    文件:IfcEngine.java   
/**
 * Adds an attribute value at the end of an attribute list.
 * 
 * @param list
 * @param valueType
 * @param value
 */
public void sdaiAppend(int list, SdaiTypes valueType, Object value) {
    switch (valueType) {
    case INTEGER:
    case BOOLEAN:
    case LOGICAL:
        IntByReference iVal = new IntByReference((Integer) value);
        engine.sdaiAppend(list, valueType.ordinal(), iVal);
        break;
    case REAL:
        DoubleByReference dVal = new DoubleByReference((Double) value);
        engine.sdaiAppend(list, valueType.ordinal(), dVal);
        break;
    case STRING:
        engine.sdaiAppend(list, valueType.ordinal(), (String) value);
        break;
    default:
        engine.sdaiAppend(list, valueType.ordinal(), (Pointer) value);
        break;
    }
}
项目:BIMplatform    文件:IfcEngine.java   
/**
 * Creates an Attribute Data Block (ADB).
 * 
 * @param valueType
 *            identifies the type of parameter value.
 * @param value
 *            identifies the data to be stored in the new ADB.
 * @return the handle of the newly created ADB.
 */
public Pointer sdaiCreateADB(SdaiTypes valueType, Object value) {
    Pointer returnValue = null;
    switch (valueType) {
    case INTEGER:
    case BOOLEAN:
    case LOGICAL:
        IntByReference iVal = new IntByReference((Integer) value);
        returnValue = engine.sdaiCreateADB(valueType.ordinal(), iVal);
        break;
    case REAL:
        DoubleByReference dVal = new DoubleByReference((Double) value);
        returnValue = engine.sdaiCreateADB(valueType.ordinal(), dVal);
        break;
    case STRING:
        returnValue = engine.sdaiCreateADB(valueType.ordinal(), (String) value);
        break;
    default:
        returnValue = engine.sdaiCreateADB(valueType.ordinal(), (Pointer) value);
        break;
    }

    return returnValue;
}
项目:OpenDA    文件:D3dFlowDll.java   
public static int setBoundaryNoise(int boundaryNoiseId, double value, int operation) {
    int retVal;
    double startTime = 0.0;
    double endTime = 0.0;
    int nvals = 1;
    double[] valuearray = new double[]{value};

    if (platform == D3dFlowModelConfig.DllType.win32_ifort) {
        retVal = winIfortDll.SE_SET_NOISE_FOR_TIME_SPAN(new IntByReference(boundaryNoiseId),
                new DoubleByReference(startTime), new DoubleByReference(endTime),
                new IntByReference(operation),
                new IntByReference(nvals), valuearray);
    } else if (platform == D3dFlowModelConfig.DllType.linux64_gnu) {
        retVal = linuxGnuDll.se_set_noise_for_time_span_(new IntByReference(boundaryNoiseId),
                new DoubleByReference(startTime), new DoubleByReference(endTime),
                new IntByReference(operation),
                new IntByReference(nvals), valuearray);
    } else {
        throw new RuntimeException("setBoundaryNoise: DLL/so type not known for model");
    }
    if (retVal < 0) {
        throw new RuntimeException("Error in D3dFlowDll.setBoundaryNoise, retVal " + retVal);
    }
    return retVal;
}
项目:OpenDA    文件:D3dFlowDll.java   
public static ITime getTimeHorizon() {
    int retVal;
    DoubleByReference startTime = new DoubleByReference(Double.NaN);
    DoubleByReference endTime = new DoubleByReference(Double.NaN);
    if (platform == D3dFlowModelConfig.DllType.win32_ifort) {
        retVal = winIfortDll.SE_GETTIMEHORIZON(componentID, modelIdentifier,
                startTime, endTime, componentID.length(), modelIdentifier.length());
    } else if (platform == D3dFlowModelConfig.DllType.linux64_gnu) {
        retVal = linuxGnuDll.se_gettimehorizon_(componentID, modelIdentifier,
                startTime, endTime, componentID.length(), modelIdentifier.length());
    } else {
        throw new RuntimeException("getTimeHorizon: DLL/so type not known for model");
    }
    if (retVal != 0) {
        throw new RuntimeException("Error in D3dFlowDll.getTimeHorizon(), retVal " + retVal);
    }
    return new Time(startTime.getValue(), endTime.getValue());
}
项目:OpenDA    文件:EfdcDLL.java   
/**
 * Returns selected values for a scalar time series parameter.
 *
 * @param parameterNumber
 * @param locationNumber
 * @param layerNumber
 * @param startTime
 * @param endTime
 * @return values
 */
public double[] getValues(int parameterNumber, int locationNumber, int layerNumber, ITime startTime, ITime endTime) {
    int valuesCount = getValuesCount(parameterNumber, locationNumber, startTime, endTime);
    double[] values = new double[valuesCount];
    int retVal = nativeDLL.m_openda_wrapper_get_values_for_time_span_(
            new IntByReference(myModelInstanceId),
            new IntByReference(parameterNumber), new IntByReference(locationNumber), new IntByReference(layerNumber),
            new DoubleByReference(startTime.getMJD() - referenceDateInMjd ),
            new DoubleByReference(endTime.getMJD() - referenceDateInMjd),
            new IntByReference(valuesCount), values);
    if (retVal != 0) {
        nativeDLL.m_openda_wrapper_finish_(new IntByReference(currentModelInstance));
        throw new RuntimeException("Invalid result from dll.GET_VALUES_FOR_TIME_SPAN call, retVal= " + retVal);
    }
    return values;
}
项目:OpenDA    文件:EfdcDLL.java   
/**
 * Sets selected values for a scalar time series parameter.
 *
 * @param parameterNumber
 * @param values
 * @param locationNumber
 * @param layerNumber
 * @param startTime
 * @param endTime
 */
public void setValues(int parameterNumber, double[] values, int locationNumber, int layerNumber, ITime startTime, ITime endTime) {
    int valuesCount = getValuesCount(parameterNumber, locationNumber, startTime, endTime);
    if (valuesCount != values.length) {
        nativeDLL.m_openda_wrapper_finish_(new IntByReference(currentModelInstance));
        throw new RuntimeException("Invalid number of values in setValues(exchangeItemId=" +
                parameterNumber + "). #Values=" + values.length + ", #expected=" + valuesCount);
    }
    int retVal = nativeDLL.m_openda_wrapper_set_values_for_time_span_(
            new IntByReference(myModelInstanceId),
            new IntByReference(parameterNumber), new IntByReference(locationNumber), new IntByReference(layerNumber),
            new DoubleByReference(startTime.getMJD() - referenceDateInMjd),
            new DoubleByReference(endTime.getMJD() - referenceDateInMjd),
            new IntByReference(valuesCount), values);
    if (retVal != 0) {
        nativeDLL.m_openda_wrapper_finish_(new IntByReference(currentModelInstance));
        throw new RuntimeException("Invalid result from dll.SET_VALUES_FOR_TIME_SPAN call, retVal= " + retVal);
    }
}
项目:OpenDA    文件:SimpleModelDLL.java   
public double[] getValues(int exchangeItemId, int locationIndex, ITime startTime, ITime endTime) {
    int valuesCount = getValuesCount(exchangeItemId, locationIndex, startTime, endTime);
    double[] values = new double[valuesCount];
    startModelInstanceAccess();
    int retVal = nativeDLL.m_simple_model_mp_get_values_for_time_span_(
            new IntByReference(myModelInstanceId),
            new IntByReference(exchangeItemId), new IntByReference(locationIndex),
            new DoubleByReference(startTime.getMJD()), new DoubleByReference(endTime.getMJD()),
            new IntByReference(valuesCount), values);
    endModelInstanceAccess();
    if (retVal != 0) {
        nativeDLL.m_simple_model_mp_finish_(new IntByReference(currentModelInstance));
        throw new RuntimeException("Invalid result from dll.GET_VALUES call, retVal= " + retVal);
    }
    return values;
}
项目:OpenDA    文件:SimpleModelDLL.java   
public void setValues(int exchangeItemId, double[] values, int locationIndex, ITime startTime, ITime endTime) {
    int valuesCount = getValuesCount(exchangeItemId, locationIndex, startTime, endTime);
    if (valuesCount != values.length) {
        nativeDLL.m_simple_model_mp_finish_(new IntByReference(currentModelInstance));
        throw new RuntimeException("Invalid #values in setValues(exchangeItemId=" +
                exchangeItemId + "). #Values=" + values.length + ", #expected=" + valuesCount);
    }
    startModelInstanceAccess();
    int retVal = nativeDLL.m_simple_model_mp_set_values_for_time_span_(
            new IntByReference(myModelInstanceId),
            new IntByReference(exchangeItemId), new IntByReference(locationIndex),
            new DoubleByReference(startTime.getMJD()), new DoubleByReference(endTime.getMJD()),
            new IntByReference(valuesCount), values);
    endModelInstanceAccess();
    if (retVal != 0) {
        nativeDLL.m_simple_model_mp_finish_(new IntByReference(currentModelInstance));
        throw new RuntimeException("Invalid result from dll.SET_VALUES call, retVal= " + retVal);
    }
}
项目:hackrf-spectrum-analyzer    文件:HackRFSweepNativeBridge.java   
public static synchronized void start(HackRFSweepDataCallback dataCallback, int freq_min_MHz, int freq_max_MHz, int fft_bin_width, int num_samples,
        int lna_gain, int vga_gain, boolean antennaPowerEnable)
{
    hackrf_sweep_lib_start__fft_power_callback_callback callback = new hackrf_sweep_lib_start__fft_power_callback_callback()
    {
        @Override public void apply(byte sweep_started, int bins, DoubleByReference freqStart, float fftBinWidth, FloatByReference powerdBm)
        {
            double[] freqStartArr = bins == 0 ? null : freqStart.getPointer().getDoubleArray(0, bins);
            float[] powerArr =  bins == 0 ? null : powerdBm.getPointer().getFloatArray(0, bins);
            dataCallback.newSpectrumData(sweep_started==0 ? false : true, freqStartArr, fftBinWidth, powerArr);
        }
    };
    Native.setCallbackThreadInitializer(callback, new CallbackThreadInitializer(true));

    HackrfSweepLibrary.hackrf_sweep_lib_start(callback, freq_min_MHz, freq_max_MHz, fft_bin_width, num_samples, lna_gain, vga_gain, antennaPowerEnable ? 1 : 0);
}
项目:jSensors    文件:UnixSensorsManager.java   
private void addSubFeatures(CSensors cSensors, CChip chip, List<CSubFeature> subFeatures) {
    for (final CSubFeature subFeature : subFeatures) {
        addDebugData(String.format("SubFeature type: %d", subFeature.type));
        addDebugData(String.format("SubFeature name: %s", subFeature.name));

        double value = 0.0;
        DoubleByReference pValue = new DoubleByReference(value);
        if (cSensors.sensors_get_value(chip, subFeature.number, pValue) == 0) {
            addDebugData(String.format("SubFeature value: %s", pValue.getValue()));

            if (subFeature.name.endsWith("_input")) {
                addData(String.format("%s", pValue.getValue()));
                break;
            }
        } else {
            addData("Could not retrieve value");
        }
    }
}
项目:jchai3d    文件:JFalconDevice.java   
/**
 * Read the position of the device. Units are meters [m].
 * @param aPosition - Return value.
 * @return - Return 0 if no error occurred.
 */    
@Override
public int getPosition(JVector3d aPosition)
{
    // check if drivers are installed
    if (!mDriverInstalled) return (-1);

    DoubleByReference   x = new DoubleByReference(),
                        y = new DoubleByReference(),
                        z = new DoubleByReference();

    int error = 0;
    try{
        error = hdFalcon.hdFalconGetPosition(mDeviceID, x, y, z);
    }catch(Exception e)
    {e.printStackTrace();}

    // add a small offset for zero centering
    x.setValue(x.getValue() + 0.01);
    aPosition.set(x.getValue(), y.getValue(), z.getValue());
    estimateLinearVelocity(aPosition);
    return (error);
}
项目:jchai3d    文件:JFalconDevice.java   
/**
 * Send a force [N] to the Falcon haptic device.
 * @param aForce - Force command to be applied to device.
 * @return - Return 0 if no error occurred.
 */    
@Override
public int setForce(JVector3d aForce)
{
    // check if drivers are installed
    if (!mDriverInstalled) return (-1);

    DoubleByReference   x = new DoubleByReference(aForce.getX()),
                        y = new DoubleByReference(aForce.getY()),
                        z = new DoubleByReference(aForce.getZ());

    int error = 0;
    try{
        error = hdFalcon.hdFalconSetForce(mDeviceID, x, y, z);
    }catch(Exception e)
    {e.printStackTrace();}

    aForce.setX(x.getValue());
    aForce.setY(y.getValue());
    aForce.setZ(z.getValue());

    setPrevForce(aForce);
    return (error);
}
项目:jchai3d    文件:JDeltaDevice.java   
/**
 * Read the linear velocity of the device. Units are in [m/s].
 * @return - Return 0 if no error occurred.
 */
@Override
public int getLinearVelocity(JVector3d aLinearVelocity) {
    // check if the system is available
    if (!mSystemAvailable) {
        return (-1);
    }

    int error = -1;

    DoubleByReference vx = new DoubleByReference(),
            vy = new DoubleByReference(),
            vz = new DoubleByReference();

    try {
        error = dhd.dhdGetLinearVelocity(vx, vy, vz, (char) mDeviceID);
    } catch (Exception e) {
        e.printStackTrace();
    }

    mLinearVelocity.set(vx.getValue(), vy.getValue(), vz.getValue());

    aLinearVelocity.copyFrom(mLinearVelocity);

    return (error);
}
项目:jchai3d    文件:JPhantomDevice.java   
/**
 * Read the position of the device. Units are meters [m].
 * @param aPosition - Return value.
 * @return - Return 0 if no error occurred.
 */    
@Override
public int getPosition(JVector3d aPosition)
{
    // check if drivers are installed
    if (!mDriverInstalled) return (-1);

    DoubleByReference   x=new DoubleByReference(),
                        y=new DoubleByReference(),
                        z=new DoubleByReference();

    int error = -1;
    try{
        error = hdPhantom.hdPhantomGetPosition(mDeviceID, x, y, z);
    }catch(Exception e)
    {e.printStackTrace();}

    aPosition.set(x.getValue(), y.getValue(), z.getValue());
    estimateLinearVelocity(aPosition);
    return (error);
}
项目:jchai3d    文件:JPhantomDevice.java   
/**
 * Send a force [N] to the haptic device
 * @param aForce - Force command to be applied to device.
 * @return - Return 0 if no error occurred.
 */    
@Override
public int setForce(JVector3d aForce)
{
    // check if drivers are installed
    if (!mDriverInstalled) return (-1);


    DoubleByReference   x=new DoubleByReference(aForce.getX()),
                        y=new DoubleByReference(aForce.getY()),
                        z=new DoubleByReference(aForce.getZ());

    int error = -1;
    try{
        error = hdPhantom.hdPhantomSetForce(mDeviceID, x, y, z);
    }catch(Exception e)
    {e.printStackTrace();}

    aForce.setX(x.getValue());
    aForce.setY(y.getValue());
    aForce.setZ(z.getValue());

    setPrevForce(aForce);
    return (error);
}
项目:jchai3d    文件:JPhantomDevice.java   
/**
 * Send a torque [N*m] to the haptic device
 * @param aTorque - Force command to be applied to device.
 * @return - Return 0 if no error occurred.
 */    
@Override
public int setTorque(JVector3d aTorque)
{
    // check if drivers are installed
    if (!mDriverInstalled) return (-1);

    DoubleByReference   x=new DoubleByReference(aTorque.getX()),
                        y=new DoubleByReference(aTorque.getY()),
                        z=new DoubleByReference(aTorque.getZ());

    int error = -1;
    try{
        error = hdPhantom.hdPhantomSetTorque(mDeviceID, x, y, z);
    }catch(Exception e)
    {e.printStackTrace();}

    aTorque.setX(x.getValue());
    aTorque.setY(y.getValue());
    aTorque.setZ(z.getValue());

    setPrevTorque(aTorque);
    return (error);
}
项目:BIMplatform    文件:IfcEngine.java   
/**
 * Returns a data field in the actual aggregate element.
 * 
 * @param aggregate
 *            Existing aggregation
 * @param elementIndex
 *            Position in the existing aggregation, first position is 0
 * @param valueType
 *            Type of output value
 * @return Value of the specific element in the aggregation
 */
public Object engiGetAggrElement(Pointer aggregate, int elementIndex, SdaiTypes valueType) {
    Object returnValue = null;
    switch (valueType) {
    case INTEGER:
        IntByReference intRef = new IntByReference();
        engine.engiGetAggrElement(aggregate, elementIndex, valueType.ordinal(), intRef);
        returnValue = new Integer(intRef.getValue());
        break;
    case REAL:
        DoubleByReference dblRef = new DoubleByReference();
        engine.engiGetAggrElement(aggregate, elementIndex, valueType.ordinal(), dblRef);
        returnValue = new Double(dblRef.getValue());
        break;
    case STRING:
        PointerByReference strRef = new PointerByReference();
        engine.engiGetAggrElement(aggregate, elementIndex, valueType.ordinal(), strRef);
        Pointer strPtr = strRef.getValue();
        if (strPtr != null)
            returnValue = strPtr.getString(0);
        break;
    default:
        PointerByReference ptrRef = new PointerByReference();
        engine.engiGetAggrElement(aggregate, elementIndex, valueType.ordinal(), ptrRef);
        returnValue = ptrRef.getValue();
        break;
    }
    return returnValue;
}
项目:BIMplatform    文件:IfcEngine.java   
/**
 * Return derived properties from the 3D visualisation.
 * 
 * @param model
 *            Unique number identifying the model in the opened file.
 * @param instance
 *            A numeric instanceID that uniquely identifies an instance.
 * @return InstanceDerivedProperties object
 */
public InstanceDerivedProperties getInstanceDerivedPropertiesInModelling(int model, Pointer instance) {
    DoubleByReference pH = new DoubleByReference();
    DoubleByReference pW = new DoubleByReference();
    DoubleByReference pT = new DoubleByReference();
    engine.getInstanceDerivedPropertiesInModelling(model, instance, pH, pW, pT);
    double height = pH.getValue();
    double width = pW.getValue();
    double thickness = pT.getValue();
    return new InstanceDerivedProperties(model, instance, height, width, thickness);
}
项目:BIMplatform    文件:IfcEngine.java   
/**
 * Returns internally created transformation matrix. This function can be
 * applied to every instance that needs a transformation matrix (i.e.
 * IfcColumn, IfcLocalPlacement, IfcPolyline).
 * 
 * @param model
 *            Unique number identifying the model in the opened file.
 * @param instance
 *            A numeric instanceID that uniquely identifies an instance.
 * @return InstanceDerivedTransformationMatrix object
 */
public InstanceDerivedTransformationMatrix getInstanceDerivedTransformationMatrix(Pointer model, Pointer instance) {
    DoubleByReference p_11 = new DoubleByReference();
    DoubleByReference p_12 = new DoubleByReference();
    DoubleByReference p_13 = new DoubleByReference();
    DoubleByReference p_14 = new DoubleByReference();
    DoubleByReference p_21 = new DoubleByReference();
    DoubleByReference p_22 = new DoubleByReference();
    DoubleByReference p_23 = new DoubleByReference();
    DoubleByReference p_24 = new DoubleByReference();
    DoubleByReference p_31 = new DoubleByReference();
    DoubleByReference p_32 = new DoubleByReference();
    DoubleByReference p_33 = new DoubleByReference();
    DoubleByReference p_34 = new DoubleByReference();
    DoubleByReference p_41 = new DoubleByReference();
    DoubleByReference p_42 = new DoubleByReference();
    DoubleByReference p_43 = new DoubleByReference();
    DoubleByReference p_44 = new DoubleByReference();
    engine.getInstanceDerivedTransformationMatrix(model, instance, p_11, p_12, p_13, p_14, p_21, p_22, p_23, p_24, p_31, p_32, p_33, p_34, p_41, p_42, p_43, p_44);
    double _11 = p_11.getValue();
    double _12 = p_12.getValue();
    double _13 = p_13.getValue();
    double _14 = p_14.getValue();
    double _21 = p_21.getValue();
    double _22 = p_22.getValue();
    double _23 = p_23.getValue();
    double _24 = p_24.getValue();
    double _31 = p_31.getValue();
    double _32 = p_32.getValue();
    double _33 = p_33.getValue();
    double _34 = p_34.getValue();
    double _41 = p_41.getValue();
    double _42 = p_42.getValue();
    double _43 = p_43.getValue();
    double _44 = p_44.getValue();
    return new InstanceDerivedTransformationMatrix(model, instance, _11, _12, _13, _14, _21, _22, _23, _24, _31, _32, _33, _34, _41, _42, _43, _44);
}
项目:BIMplatform    文件:IfcEngine.java   
public InstanceTransformationMatrix getInstanceTransformationMatrix(Pointer model, Pointer instance) {
    DoubleByReference p_11 = new DoubleByReference();
    DoubleByReference p_12 = new DoubleByReference();
    DoubleByReference p_13 = new DoubleByReference();
    DoubleByReference p_14 = new DoubleByReference();
    DoubleByReference p_21 = new DoubleByReference();
    DoubleByReference p_22 = new DoubleByReference();
    DoubleByReference p_23 = new DoubleByReference();
    DoubleByReference p_24 = new DoubleByReference();
    DoubleByReference p_31 = new DoubleByReference();
    DoubleByReference p_32 = new DoubleByReference();
    DoubleByReference p_33 = new DoubleByReference();
    DoubleByReference p_34 = new DoubleByReference();
    DoubleByReference p_41 = new DoubleByReference();
    DoubleByReference p_42 = new DoubleByReference();
    DoubleByReference p_43 = new DoubleByReference();
    DoubleByReference p_44 = new DoubleByReference();
    engine.getInstanceDerivedTransformationMatrix(model, instance, p_11, p_12, p_13, p_14, p_21, p_22, p_23, p_24, p_31, p_32, p_33, p_34, p_41, p_42, p_43, p_44);
    double _11 = p_11.getValue();
    double _12 = p_12.getValue();
    double _13 = p_13.getValue();
    double _14 = p_14.getValue();
    double _21 = p_21.getValue();
    double _22 = p_22.getValue();
    double _23 = p_23.getValue();
    double _24 = p_24.getValue();
    double _31 = p_31.getValue();
    double _32 = p_32.getValue();
    double _33 = p_33.getValue();
    double _34 = p_34.getValue();
    double _41 = p_41.getValue();
    double _42 = p_42.getValue();
    double _43 = p_43.getValue();
    double _44 = p_44.getValue();
    return new InstanceTransformationMatrix(model, instance, _11, _12, _13, _14, _21, _22, _23, _24, _31, _32, _33, _34, _41, _42, _43, _44);
}
项目:BIMplatform    文件:IfcEngine.java   
/**
 * Implementation postponed till version 1.10
 * 
 * @param iterator
 *            Existing iterator
 * @param valueType
 *            Type of output value
 * @return
 */
public Object sdaiGetAggrByIterator(Pointer iterator, SdaiTypes valueType) {
    Object returnValue = null;

    switch (valueType) {
    case REAL:
        DoubleByReference dVal = new DoubleByReference();
        engine.sdaiGetAggrByIterator(iterator, valueType.ordinal(), dVal);
        returnValue = new Double(dVal.getValue());
        break;
    case INTEGER:
    case BOOLEAN:
    case LOGICAL:
        IntByReference iVal = new IntByReference();
        engine.sdaiGetAggrByIterator(iterator, valueType.ordinal(), iVal);
        returnValue = new Integer(iVal.getValue());
        break;
    case STRING:
        PointerByReference sVal = new PointerByReference();
        engine.sdaiGetAggrByIterator(iterator, valueType.ordinal(), sVal);
        returnValue = (String) sVal.getValue().getString(0);
        break;
    default:
        PointerByReference ptr = new PointerByReference();
        engine.sdaiGetAggrByIterator(iterator, valueType.ordinal(), ptr);
        returnValue = ptr.getValue();
        break;
    }
    return returnValue;
}
项目:BIMplatform    文件:IfcEngine.java   
/**
 * Returns the data value of the specified attribute in the actual instance.
 * The actual instance is specified by a numeric instanceID that uniquely
 * identifies an instance.
 * 
 * @param instance
 *            A numeric instanceID that uniquely identifies an instance.
 * @param attribute
 *            A numeric attributerID that uniquely identifies an attribute
 *            definition instance.
 * @param valueType
 *            Type of output value.
 * @return Output value of the specific element in the aggregation.
 */
public Object sdaiGetAttr(Pointer instance, int attribute, SdaiTypes valueType) {
    Object returnValue = null;

    switch (valueType) {
    case REAL:
        DoubleByReference dVal = new DoubleByReference();
        engine.sdaiGetAggrByIterator(instance, valueType.ordinal(), dVal);
        returnValue = new Double(dVal.getValue());
        break;
    case INTEGER:
    case BOOLEAN:
    case LOGICAL:
        IntByReference iVal = new IntByReference();
        engine.sdaiGetAggrByIterator(instance, valueType.ordinal(), iVal);
        returnValue = new Integer(iVal.getValue());
        break;
    case STRING:
        PointerByReference sVal = new PointerByReference();
        engine.sdaiGetAggrByIterator(instance, valueType.ordinal(), sVal);
        returnValue = (String) sVal.getValue().getString(0);
        break;
    default:
        PointerByReference ptr = new PointerByReference();
        engine.sdaiGetAggrByIterator(instance, valueType.ordinal(), ptr);
        returnValue = ptr.getValue();
        break;
    }
    return returnValue;
}
项目:OpenDA    文件:D3dFlowDll.java   
public static int setBoundaryGridNoise(int boundaryNoiseId, double alpha, double[] values, int operation) {
    // a crude way for the model to give the metadata (location) is to provide
    // all these locations as well. For the moment, we will implement it this way:
    // the double array can be subdivided into triples of (xloc, yloc, value).
    int retVal ;
    double startTime = 0.0;
    double endTime = 0.0;
    int nvals = values.length/3;
    for (int i = 0; i < nvals; i++) {
        values[3*i+2] = alpha * values[3*i+2]; //only adjust  the values, not the locations
    }
    if (platform == D3dFlowModelConfig.DllType.win32_ifort) {
        retVal = winIfortDll.SE_SET_NOISE_FOR_TIME_SPAN(new IntByReference(boundaryNoiseId),
                new DoubleByReference(startTime), new DoubleByReference(endTime),
                new IntByReference(operation),
                new IntByReference(values.length), values);
    } else if (platform == D3dFlowModelConfig.DllType.linux64_gnu) {
        retVal = linuxGnuDll.se_set_noise_for_time_span_(new IntByReference(boundaryNoiseId),
                new DoubleByReference(startTime), new DoubleByReference(endTime),
                new IntByReference(operation),
                new IntByReference(values.length), values);
    } else {
        throw new RuntimeException("setBoundaryNoise: DLL/so type not known for model");
    }
    if (retVal < 0) {
        throw new RuntimeException("Error in D3dFlowDll.setBoundaryNoise, retVal " + retVal);
    }
    return retVal;
}
项目:OpenDA    文件:D3dFlowDll.java   
public static double getResultValue(int monitorpointId) {
    int retVal;
    double startTime = 0.0;
    double endTime = 0.0;
    int nvals = 1;
    double[] valuearray = new double[nvals];

    if (platform == D3dFlowModelConfig.DllType.win32_ifort) {
        retVal = winIfortDll.SE_GET_VALUES_FOR_TIME_SPAN(new IntByReference(monitorpointId),
                new DoubleByReference(startTime), new DoubleByReference(endTime),
                new IntByReference(nvals), valuearray);
        if (retVal < 0) {
            throw new RuntimeException("Error in D3dFlowDll.getValue, retVal " + retVal);
        }
        return valuearray[0];
    } else if (platform == D3dFlowModelConfig.DllType.linux64_gnu) {
        retVal = linuxGnuDll.se_get_values_for_time_span_(new IntByReference(monitorpointId),
                new DoubleByReference(startTime), new DoubleByReference(endTime),
                new IntByReference(nvals), valuearray);
        if (retVal < 0) {
            throw new RuntimeException("Error in D3dFlowDll.getValue, retVal " + retVal);
        }
        return valuearray[0];
    } else {
        throw new RuntimeException("getValue: DLL/so type not known for model");
    }
}
项目:OpenDA    文件:D3dFlowDll.java   
public static double getCurrentTime() {
    DoubleByReference currentTime = new DoubleByReference(Double.NaN);
    if (platform == D3dFlowModelConfig.DllType.win32_ifort) {
        winIfortDll.SE_GETCURRENTTIME(componentID, modelIdentifier, currentTime,
                componentID.length(), modelIdentifier.length());
    } else if (platform == D3dFlowModelConfig.DllType.linux64_gnu) {
        linuxGnuDll.se_getcurrenttime_(componentID, modelIdentifier, currentTime,
                componentID.length(), modelIdentifier.length());
    } else {
        throw new RuntimeException("getCurrentTime: DLL/so type not known for model");
    }
    return currentTime.getValue();
}
项目:OpenDA    文件:EfdcDLL.java   
/**
 * Returns the time step used by the EFDC model in days
 *
 * @return deltaT.getValue()
 */
public double getDeltaT() {
    DoubleByReference deltaT = new DoubleByReference();
    int retVal = nativeDLL.m_openda_wrapper_get_delta_t_(deltaT);
    if (retVal != 0) {
        nativeDLL.m_openda_wrapper_finish_(new IntByReference(currentModelInstance));
        throw new RuntimeException("Invalid result from dll.GET_DELTA_T call, retVal= " + retVal);
    }
    return deltaT.getValue();
}
项目:OpenDA    文件:EfdcDLL.java   
/**
 * Returns the reference period as set in the EFDC.INP file in days
 * The EFDC model can only be run in multiples of the reference period
 *
 * @return referencePeriod.getValue()
 */
public double getReferencePeriod() {
    DoubleByReference referencePeriod = new DoubleByReference();
    int retVal = nativeDLL.m_openda_wrapper_get_reference_period_(referencePeriod);
    if (retVal != 0) {
        nativeDLL.m_openda_wrapper_finish_(new IntByReference(currentModelInstance));
        throw new RuntimeException("Invalid result from dll.GET_REFERENCE_PERIOD call, retVal= " + retVal);
    }
    return referencePeriod.getValue();
}
项目:OpenDA    文件:EfdcDLL.java   
/**
 * Returns the start time of simulation in MJD (i.e. in GMT timeZone).
 *
 * @return startTime.getValue() + referenceDateInMjd
 */
public double getStartTime() {
    DoubleByReference startTime = new DoubleByReference();
    int retVal = nativeDLL.m_openda_wrapper_get_start_time_(new IntByReference(myModelInstanceId), startTime);
    if (retVal != 0) {
        nativeDLL.m_openda_wrapper_finish_(new IntByReference(currentModelInstance));
        throw new RuntimeException("Invalid result from dll.GET_START_TIME call, retVal= " + retVal);
    }
    return startTime.getValue() + referenceDateInMjd;
    //return startTime.getValue();
}
项目:OpenDA    文件:EfdcDLL.java   
/**
 * Returns the end time of simulation in MJD (i.e. in GMT timeZone).
 *
 * @return endTime.getValue() + referenceDateInMjd
 */
public double getEndTime() {
    DoubleByReference endTime = new DoubleByReference();
    int retVal = nativeDLL.m_openda_wrapper_get_end_time_(new IntByReference(myModelInstanceId), endTime);
    if (retVal != 0) {
        nativeDLL.m_openda_wrapper_finish_(new IntByReference(currentModelInstance));
        throw new RuntimeException("Invalid result from dll.GET_END_TIME call, retVal= " + retVal);
    }
    return endTime.getValue() + referenceDateInMjd;
    //return endTime.getValue();
}
项目:OpenDA    文件:EfdcDLL.java   
/**
 * Returns the current time of the model in MJD (i.e. in GMT timeZone).
 *
 * @return current time of the model.
 */
public double getCurrentTime() {
    DoubleByReference currentTime = new DoubleByReference();
    //startModelInstanceAccess();
    int retVal = nativeDLL.m_openda_wrapper_get_current_time_(new IntByReference(myModelInstanceId), currentTime);
    //endModelInstanceAccess();
    if (retVal != 0) {
        nativeDLL.m_openda_wrapper_finish_(new IntByReference(currentModelInstance));
        throw new RuntimeException("Invalid result from dll.GET_CURRENT_TIME call, retVal= " + retVal);
    }
    return currentTime.getValue() + referenceDateInMjd;
    //return currentTime.getValue();
}
项目:OpenDA    文件:EfdcDLL.java   
/**
 * Returns valuesCount for the given subPeriod of a scalar time series parameter.
 * This should return te product of timesCount and layerCount
 *
 *
 * @param parameterNumber
 * @param locationNumber
 * @param startTime
 * @param endTime
 * @return valuesCount
 */
private int getValuesCount(int parameterNumber, int locationNumber, ITime startTime, ITime endTime) {
    // The dll can handle different length time series, but we do not in this function
    int valuesCount = nativeDLL.m_openda_wrapper_get_values_count_for_time_span_(
            new IntByReference(myModelInstanceId),
            new IntByReference(parameterNumber), new IntByReference(locationNumber),
            new DoubleByReference(startTime.getMJD() - referenceDateInMjd),
            new DoubleByReference(endTime.getMJD() - referenceDateInMjd));
    if (valuesCount < 0) {
        nativeDLL.m_openda_wrapper_finish_(new IntByReference(currentModelInstance));
        throw new RuntimeException("Invalid result from dll.GET_VALUES_COUNT_FOR_TIME_SPAN call, valuesCount= " + valuesCount);
    }
    return valuesCount;
}
项目:OpenDA    文件:EfdcDLL.java   
/**
 * Returns the number of time series (number of locations)
 * for the given subPeriod of a scalar time series parameter.
 *
 * @param parameterNumber
 * @param locationNumber
 * @param startTime
 * @param endTime
 * @return timesCount
 */
private int getTimesCount(int parameterNumber, int locationNumber, ITime startTime, ITime endTime) {
    // The dll can handle different length time series, but we do not in this function
    int timesCount = nativeDLL.m_openda_wrapper_get_times_count_for_time_span_(
            new IntByReference(myModelInstanceId),
            new IntByReference(parameterNumber), new IntByReference(locationNumber),
            new DoubleByReference(startTime.getMJD() - referenceDateInMjd),
            new DoubleByReference(endTime.getMJD() - referenceDateInMjd));
    if (timesCount < 0) {
        nativeDLL.m_openda_wrapper_finish_(new IntByReference(currentModelInstance));
        throw new RuntimeException("Invalid result from dll.GET_TIMES_COUNT_FOR_TIME_SPAN call, timesCount= " + timesCount);
    }
    return timesCount;
}
项目:OpenDA    文件:EfdcDLL.java   
/**
 * In the EFDC model the model run period is divided in a number of referenceTimePeriods.
 * Each referenceTimePeriod is in turn divided in a number of timeSteps.
 * This method can only be called for a time period that is equal to an integer number of referenceTimePeriods.
 *
 * @param fromTime
 * @param toTime
 */
public void compute(ITime fromTime, ITime toTime) {
    startModelInstanceAccess();
    int retVal = nativeDLL.m_openda_wrapper_compute_(
            new IntByReference(myModelInstanceId),
            new DoubleByReference(fromTime.getMJD() - referenceDateInMjd ),
            new DoubleByReference(toTime.getMJD() - referenceDateInMjd ));
    endModelInstanceAccess();
    if (retVal != 0) {
        nativeDLL.m_openda_wrapper_finish_(new IntByReference(currentModelInstance));
        throw new RuntimeException("Invalid result from dll.COMPUTE call, retVal= " + retVal);
    }
}
项目:OpenDA    文件:SimpleModelDLL.java   
public double getDeltaT() {
    DoubleByReference deltaT = new DoubleByReference();
    int retVal = nativeDLL.m_simple_model_mp_get_delta_t_(deltaT);
    if (retVal != 0) {
        nativeDLL.m_simple_model_mp_finish_(new IntByReference(currentModelInstance));
        throw new RuntimeException("Invalid result from dll.GET_DELTA_T call, retVal= " + retVal);
    }
    return deltaT.getValue();
}
项目:OpenDA    文件:SimpleModelDLL.java   
public double getStartTime() {
    DoubleByReference startTime = new DoubleByReference();
    int retVal = nativeDLL.m_simple_model_mp_get_start_time_(startTime);
    if (retVal != 0) {
        nativeDLL.m_simple_model_mp_finish_(new IntByReference(currentModelInstance));
        throw new RuntimeException("Invalid result from dll.GET_START_TIME call, retVal= " + retVal);
    }
    return startTime.getValue();
}
项目:OpenDA    文件:SimpleModelDLL.java   
public double getEndTime() {
    DoubleByReference endTime = new DoubleByReference();
    int retVal = nativeDLL.m_simple_model_mp_get_end_time_(endTime);
    if (retVal != 0) {
        nativeDLL.m_simple_model_mp_finish_(new IntByReference(currentModelInstance));
        throw new RuntimeException("Invalid result from dll.GET_END_TIME call, retVal= " + retVal);
    }
    return endTime.getValue();
}
项目:OpenDA    文件:SimpleModelDLL.java   
public double getCurrentTime() {
    DoubleByReference currentTime = new DoubleByReference();
    startModelInstanceAccess();
    int retVal = nativeDLL.m_simple_model_mp_get_current_time_(new IntByReference(myModelInstanceId), currentTime);
    endModelInstanceAccess();
    if (retVal != 0) {
        nativeDLL.m_simple_model_mp_finish_(new IntByReference(currentModelInstance));
        throw new RuntimeException("Invalid result from dll.GET_CURRENT_TIME call, retVal= " + retVal);
    }
    return currentTime.getValue();
}
项目:OpenDA    文件:SimpleModelDLL.java   
private int getValuesCount(int exchangeItemId, int locationIndex, ITime startTime, ITime endTime) {
    int valuesCount = nativeDLL.m_simple_model_mp_get_values_count_for_time_span_(
            new IntByReference(exchangeItemId), new IntByReference(locationIndex),
            new DoubleByReference(startTime.getMJD()), new DoubleByReference(endTime.getMJD()));
    if (valuesCount < 0) {
        nativeDLL.m_simple_model_mp_finish_(new IntByReference(currentModelInstance));
        throw new RuntimeException("Invalid result from dll.GET_VALUES_COUNT_FOR_TIMESPAN call, valuesCount= " + valuesCount);
    }
    return valuesCount;
}
项目:OpenDA    文件:SimpleModelDLL.java   
public void compute(ITime fromTime, ITime toTime) {
    startModelInstanceAccess();
    int retVal = nativeDLL.m_simple_model_mp_compute_(
            new DoubleByReference(fromTime.getMJD()),
            new DoubleByReference(toTime.getMJD()));
    endModelInstanceAccess();
    if (retVal != 0) {
        nativeDLL.m_simple_model_mp_finish_(new IntByReference(currentModelInstance));
        throw new RuntimeException("Invalid result from dll.COMPUTE call, retVal= " + retVal);
    }
}