Exemple #1
0
asynStatus shamrock::getStatus()
{
    int error;
    asynStatus status;
    int grating;
    float wavelength;
    float width;
    int i;
    static const char *functionName = "getStatus";
    int port;

    //Get Flipper Status
    for (i=0; i<MAX_FLIPPER_MIRRORS; i++) {
        if (flipperMirrorIsPresent_[i] == 0) continue;
        error = ShamrockGetFlipperMirror(shamrockId_, i+1, &port);
        status = checkError(error, functionName, "ShamrockGetFlipperMirror");
        if (status) return asynError;
        setIntegerParam(i, SRFlipperMirrorPort_, port);
    }


    error = ShamrockGetGrating(shamrockId_, &grating);
    status = checkError(error, functionName, "ShamrockGetGrating");
    if (status) return asynError;
    setIntegerParam(SRGrating_, grating);
    
    error = ShamrockGetWavelength(shamrockId_, &wavelength);
    status = checkError(error, functionName, "ShamrockGetWavelength");
    if (status) return asynError;
    setDoubleParam(SRWavelength_, wavelength);

    for (i=0; i<MAX_SLITS; i++) {
        setDoubleParam(i, SRSlitSize_, 0.);
        if (slitIsPresent_[i] == 0) continue;
        error = ShamrockGetAutoSlitWidth(shamrockId_, i+1, &width);
        status = checkError(error, functionName, "ShamrockGetAutoSlitWidth");
        if (status) return asynError;
        setDoubleParam(i, SRSlitSize_, width);
    }
    
    error = ShamrockGetCalibration(shamrockId_, calibration_, numPixels_);
    status = checkError(error, functionName, "ShamrockGetCalibration");
    setDoubleParam(0, SRMinWavelength_, calibration_[0]);
    setDoubleParam(0, SRMaxWavelength_, calibration_[numPixels_-1]);
    // We need to find a C/C++ library to do 3'rd order polynomial fit
    // For now we do a first order fit!
    //double slope = (calibration_[numPixels_-1] - calibration_[0]) / (numPixels_-1);

    for (i=0; i<MAX_ADDR; i++) {
        callParamCallbacks(i);
    }
    
    doCallbacksFloat32Array(calibration_, numPixels_, SRCalibration_, 0);

    return asynSuccess;
}
Exemple #2
0
/** Callback task that runs as a separate thread. */
void testErrors::callbackTask(void)
{
    asynStatus currentStatus;
    int itemp;
    epicsInt32 iVal;
    epicsFloat64 dVal;
    int i;
    char octetValue[20];
    
    /* Loop forever */    
    while (1) {
        lock();
        getIntegerParam(P_StatusReturn, &itemp); currentStatus = (asynStatus)itemp;
        getIntegerParam(P_Int32Value, &iVal);
        iVal++;
        if (iVal > 15) iVal=0;
        setIntegerParam(P_Int32Value, iVal);
        setParamStatus(P_Int32Value, currentStatus);
        getDoubleParam(P_Float64Value, &dVal);
        dVal += 0.1;
        setDoubleParam(P_Float64Value, dVal);
        setParamStatus(P_Float64Value, currentStatus);
        sprintf(octetValue, "%.1f", dVal); 
        setParamStatus(P_UInt32DigitalValue, currentStatus);
        setStringParam(P_OctetValue, octetValue);
        setParamStatus(P_OctetValue, currentStatus);
        setParamStatus(P_Float64ArrayValue, currentStatus);
        for (i=0; i<MAX_ARRAY_POINTS; i++) {
            int8ArrayValue_[i]    = iVal;
            int16ArrayValue_[i]   = iVal;
            int32ArrayValue_[i]   = iVal;
            float32ArrayValue_[i] = (epicsFloat32)dVal;
            float64ArrayValue_[i] = dVal;
        }
        callParamCallbacks();
        setParamStatus(P_Int8ArrayValue, currentStatus);
        doCallbacksInt8Array(int8ArrayValue_, MAX_ARRAY_POINTS, P_Int8ArrayValue, 0);
        setParamStatus(P_Int16ArrayValue, currentStatus);
        doCallbacksInt16Array(int16ArrayValue_, MAX_ARRAY_POINTS, P_Int16ArrayValue, 0);
        setParamStatus(P_Int32ArrayValue, currentStatus);
        doCallbacksInt32Array(int32ArrayValue_, MAX_ARRAY_POINTS, P_Int32ArrayValue, 0);
        setParamStatus(P_Float32ArrayValue, currentStatus);
        doCallbacksFloat32Array(float32ArrayValue_, MAX_ARRAY_POINTS, P_Float32ArrayValue, 0);
        setParamStatus(P_Float64ArrayValue, currentStatus);
        doCallbacksFloat64Array(float64ArrayValue_, MAX_ARRAY_POINTS, P_Float64ArrayValue, 0);
        unlock();
        epicsThreadSleep(CALLBACK_PERIOD);
    }
}
Exemple #3
0
/** Callback task that runs as a separate thread. */
void testErrors::callbackTask(void)
{
    asynStatus currentStatus;
    int itemp;
    epicsInt32 iVal;
    epicsUInt32 uiVal;
    epicsFloat64 dVal;
    int i;
    char octetValue[20];
    
    /* Loop forever */    
    while (1) {
        lock();
        updateTimeStamp();
        getIntegerParam(P_StatusReturn, &itemp); currentStatus = (asynStatus)itemp;

        getIntegerParam(P_Int32Value, &iVal);
        iVal++;
        if (iVal > 64) iVal=0;
        setIntegerParam(P_Int32Value, iVal);
        setParamStatus( P_Int32Value, currentStatus);

        getIntegerParam(P_BinaryInt32Value, &iVal);
        iVal++;
        if (iVal > 1) iVal=0;
        setIntegerParam(P_BinaryInt32Value, iVal);
        setParamStatus( P_BinaryInt32Value, currentStatus);

        getIntegerParam(P_MultibitInt32Value, &iVal);
        iVal++;
        if (iVal > MAX_INT32_ENUMS-1) iVal=0;
        setIntegerParam(P_MultibitInt32Value, iVal);
        setParamStatus( P_MultibitInt32Value, currentStatus);

        getUIntDigitalParam(P_UInt32DigitalValue, &uiVal, UINT32_DIGITAL_MASK);
        uiVal++;
        if (uiVal > 64) uiVal=0;
        setUIntDigitalParam(P_UInt32DigitalValue, uiVal, UINT32_DIGITAL_MASK);
        setParamStatus(     P_UInt32DigitalValue, currentStatus);

        getUIntDigitalParam(P_BinaryUInt32DigitalValue, &uiVal, UINT32_DIGITAL_MASK);
        uiVal++;
        if (uiVal > 1) uiVal=0;
        setUIntDigitalParam(P_BinaryUInt32DigitalValue, uiVal, UINT32_DIGITAL_MASK);
        setParamStatus(     P_BinaryUInt32DigitalValue, currentStatus);

        getUIntDigitalParam(P_MultibitUInt32DigitalValue, &uiVal, UINT32_DIGITAL_MASK);
        uiVal++;
        if (uiVal > MAX_UINT32_ENUMS-1) uiVal=0;
        setUIntDigitalParam(P_MultibitUInt32DigitalValue, uiVal, UINT32_DIGITAL_MASK);
        setParamStatus(     P_MultibitUInt32DigitalValue, currentStatus);

        getDoubleParam(P_Float64Value, &dVal);
        dVal += 0.1;
        setDoubleParam(P_Float64Value, dVal);
        setParamStatus(P_Float64Value, currentStatus);

        sprintf(octetValue, "%.1f", dVal); 
        setStringParam(P_OctetValue, octetValue);
        setParamStatus(P_OctetValue, currentStatus);

        for (i=0; i<MAX_ARRAY_POINTS; i++) {
            int8ArrayValue_[i]    = iVal;
            int16ArrayValue_[i]   = iVal;
            int32ArrayValue_[i]   = iVal;
            float32ArrayValue_[i] = (epicsFloat32)dVal;
            float64ArrayValue_[i] = dVal;
        }
        callParamCallbacks();
        setParamStatus(P_Int8ArrayValue,    currentStatus);
        setParamStatus(P_Int16ArrayValue,   currentStatus);
        setParamStatus(P_Int32ArrayValue,   currentStatus);
        setParamStatus(P_Float32ArrayValue, currentStatus);
        setParamStatus(P_Float64ArrayValue, currentStatus);
        doCallbacksInt8Array(int8ArrayValue_,       MAX_ARRAY_POINTS, P_Int8ArrayValue,    0);
        doCallbacksInt16Array(int16ArrayValue_,     MAX_ARRAY_POINTS, P_Int16ArrayValue,   0);
        doCallbacksInt32Array(int32ArrayValue_,     MAX_ARRAY_POINTS, P_Int32ArrayValue,   0);
        doCallbacksFloat32Array(float32ArrayValue_, MAX_ARRAY_POINTS, P_Float32ArrayValue, 0);
        doCallbacksFloat64Array(float64ArrayValue_, MAX_ARRAY_POINTS, P_Float64ArrayValue, 0);
        unlock();
        epicsEventWait(eventId_);
    }
}