/** 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); } }
/** Called when asyn clients call pasynOctet->write(). * Simply sets the value in the parameter library and * calls any registered callbacks for this pasynUser->reason and address. * \param[in] pasynUser pasynUser structure that encodes the reason and address. * \param[in] value Address of the string to write. * \param[in] nChars Number of characters to write. * \param[out] nActual Number of characters actually written. */ asynStatus testErrors::writeOctet(asynUser *pasynUser, const char *value, size_t nChars, size_t *nActual) { int function = pasynUser->reason; asynStatus status = asynSuccess; int itemp; const char *functionName = "writeOctet"; /* Get the current error status */ getIntegerParam(P_StatusReturn, &itemp); status = (asynStatus)itemp; /* Set the parameter in the parameter library. */ setStringParam(function, (char *)value); /* Set the parameter status in the parameter library. */ setParamStatus(function, status); /* Do callbacks so higher layers see any changes */ callParamCallbacks(); if (status) epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, "%s:%s: status=%d, function=%d, value=%s", driverName, functionName, status, function, value); else asynPrint(pasynUser, ASYN_TRACEIO_DRIVER, "%s:%s: function=%d, value=%s\n", driverName, functionName, function, value); *nActual = nChars; return status; }
/** Called when asyn clients call pasynUInt32D->write(). * For all parameters it sets the value in the parameter library and calls any registered callbacks.. * \param[in] pasynUser pasynUser structure that encodes the reason and address. * \param[in] value Value to write. */ asynStatus testErrors::writeUInt32Digital(asynUser *pasynUser, epicsUInt32 value, epicsUInt32 mask) { int function = pasynUser->reason; asynStatus status = asynSuccess; int itemp; const char *paramName; const char* functionName = "writeUInt32D"; /* Get the current error status */ getIntegerParam(P_StatusReturn, &itemp); status = (asynStatus)itemp; /* Fetch the parameter string name for use in debugging */ getParamName(function, ¶mName); /* Set the parameter value in the parameter library. */ setUIntDigitalParam(function, value, mask); /* Set the parameter status in the parameter library. */ setParamStatus(function, status); /* Do callbacks so higher layers see any changes */ callParamCallbacks(); if (status) epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, "%s:%s: status=%d, function=%d, name=%s, value=0x%X", driverName, functionName, status, function, paramName, value); else asynPrint(pasynUser, ASYN_TRACEIO_DRIVER, "%s:%s: function=%d, name=%s, value=0x%X\n", driverName, functionName, function, paramName, value); return status; }
/** Called when asyn clients call pasynFloat64->write(). * \param[in] pasynUser pasynUser structure that encodes the reason and address. * \param[in] value Value to write. */ asynStatus testErrors::writeFloat64(asynUser *pasynUser, epicsFloat64 value) { int function = pasynUser->reason; asynStatus status = asynSuccess; const char *paramName; const char* functionName = "writeFloat64"; /* Get the current error status */ getIntegerParam(P_StatusReturn, (int*)&status); /* Fetch the parameter string name for use in debugging */ getParamName(function, ¶mName); /* Set the parameter in the parameter library. */ setDoubleParam(function, value); /* Set the parameter status in the parameter library. */ setParamStatus(function, status); /* Do callbacks so higher layers see any changes */ callParamCallbacks(); if (status) epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, "%s:%s: status=%d, function=%d, name=%s, value=%f", driverName, functionName, status, function, paramName, value); else asynPrint(pasynUser, ASYN_TRACEIO_DRIVER, "%s:%s: function=%d, name=%s, value=%f\n", driverName, functionName, function, paramName, value); return status; }
asynStatus FastCCD::writeOctet(asynUser *pasynUser, const char *value, size_t nc, size_t *na){ int function = pasynUser->reason; int addr = 0; asynStatus status = asynSuccess; static const char *functionName = "writeOctet"; status = getAddress(pasynUser, &addr); if(status != asynSuccess){ return(status); } status = (asynStatus)setStringParam(addr, function, (char *)value); if(status != asynSuccess){ return(status); } if(function == FastCCDFirmwarePath || function == FastCCDClockPath || function == FastCCDFCRICPath || function == FastCCDBiasPath ){ struct stat s; int _status = stat(value, &s); if(_status){ setParamStatus(function, asynError); } else { setParamStatus(function, asynSuccess); } } else { // Call base class to handle strings status = ADDriver::writeOctet(pasynUser, value, nc, na); } if (status) { asynPrint(pasynUser, ASYN_TRACE_ERROR, "%s:%s: error, status=%d function=%d, value=%s\n", driverName, functionName, status, function, value); } else { asynPrint(pasynUser, ASYN_TRACEIO_DRIVER, "%s:%s: function=%d, value=%s\n", driverName, functionName, function, value); } /* Do callbacks so higher layers see any changes */ callParamCallbacks(); // Set the number of characters written *na = nc; return status; }
/// Read the file ramp file based on the parameters in dir and base asynStatus ReadASCII::readFileBasedOnParameters() { char localDir[DIR_LENGTH], dirBase[DIR_LENGTH * 2 + 1]; getStringParam(P_DirBase, DIR_LENGTH, dirBase); getStringParam(P_Dir, DIR_LENGTH, localDir); strcat(dirBase, "/"); strcat(dirBase, localDir); asynStatus status = readFile(dirBase); setParamStatus(P_Dir, (asynStatus) status); return status; }
asynStatus FastCCD::writeFloat64(asynUser *pasynUser, epicsFloat64 value){ int function = pasynUser->reason; asynStatus status = asynSuccess; int _status = 0; const char *paramName; static const char *functionName = "writeFloat64"; getParamName(function, ¶mName); status = setDoubleParam(function, value); if(status != asynSuccess){ return status; } if(function == ADAcquireTime){ _status = cin_ctl_set_exposure_time(&cin_ctl_port, (float)value); } else if (function == ADAcquirePeriod) { _status = cin_ctl_set_cycle_time(&cin_ctl_port, (float)value); } else if (function == FastCCDPollingPeriod){ // Set the new polling period and poll statusPollingPeriod = value; epicsEventSignal(statusEvent); } else { ADDriver::writeFloat64(pasynUser, value); } if(_status){ setParamStatus(function, asynError); status = asynError; } if(status){ asynPrint(pasynUser, ASYN_TRACE_ERROR, "%s:%s: error, status=%d function=%d, value=%f\n", driverName, functionName, status, function, value); } else { asynPrint(pasynUser, ASYN_TRACEIO_DRIVER, "%s:%s: function=%d, value=%f\n", driverName, functionName, function, value); } return status; }
int FastCCD::uploadConfig(int status, int path){ int _status = 0; char _path[256]; getStringParam(path, sizeof(_path), _path); setIntegerParam(status, 1); setStringParam(ADStatusMessage, "Uploading Config File"); callParamCallbacks(); _status = cin_ctl_load_config(&cin_ctl_port, _path); setIntegerParam(status, 0); if(!_status){ setStringParam(ADStatusMessage, "Config Uploaded to CIN"); setParamStatus(path, asynSuccess); } else { setStringParam(ADStatusMessage, "ERROR Uploading Config to CIN"); setParamStatus(path, asynError); } return _status; }
/** Called when asyn clients call pasynInt32->write(). * This function sends a signal to the simTask thread if the value of P_Run has changed. * For all parameters it sets the value in the parameter library and calls any registered callbacks.. * \param[in] pasynUser pasynUser structure that encodes the reason and address. * \param[in] value Value to write. */ asynStatus testErrors::writeInt32(asynUser *pasynUser, epicsInt32 value) { int function = pasynUser->reason; asynStatus status = asynSuccess; int itemp; const char *paramName; const char* functionName = "writeInt32"; /* Fetch the parameter string name for use in debugging */ getParamName(function, ¶mName); /* Set the parameter value in the parameter library. */ setIntegerParam(function, value); if (function == P_DoUpdate) { epicsEventSignal(eventId_); } else if (function == P_StatusReturn) { } else if (function == P_EnumOrder) { setEnums(); } else { /* Set the parameter status in the parameter library except for the above commands with always return OK */ /* Get the current error status */ getIntegerParam(P_StatusReturn, &itemp); status = (asynStatus)itemp; setParamStatus(function, status); } /* Do callbacks so higher layers see any changes */ callParamCallbacks(); if (status) epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, "%s:%s: status=%d, function=%d, name=%s, value=%d", driverName, functionName, status, function, paramName, value); else asynPrint(pasynUser, ASYN_TRACEIO_DRIVER, "%s:%s: function=%d, name=%s, value=%d\n", driverName, functionName, function, paramName, value); return status; }
/** Constructor for the testOutputReadback class. * Calls constructor for the asynPortDriver base class. * \param[in] portName The name of the asyn port driver to be created. */ testOutputReadback::testOutputReadback(const char *portName, int initialReadStatus) : asynPortDriver(portName, 1, /* maxAddr */ (int)NUM_PARAMS, /* Interface mask */ asynInt32Mask | asynFloat64Mask | asynUInt32DigitalMask | asynDrvUserMask, /* Interrupt mask */ asynInt32Mask | asynFloat64Mask | asynUInt32DigitalMask, 0, /* asynFlags. This driver does not block and it is not multi-device, so flag is 0 */ 1, /* Autoconnect */ 0, /* Default priority */ 0) /* Default stack size*/, initialReadStatus_((asynStatus)initialReadStatus) { createParam(P_Int32ValueString, asynParamInt32, &P_Int32Value); createParam(P_BinaryInt32ValueString, asynParamInt32, &P_BinaryInt32Value); createParam(P_MultibitInt32ValueString, asynParamInt32, &P_MultibitInt32Value); createParam(P_Float64ValueString, asynParamFloat64, &P_Float64Value); createParam(P_UInt32DigitalValueString, asynParamUInt32Digital, &P_UInt32DigitalValue); createParam(P_BinaryUInt32DigitalValueString, asynParamUInt32Digital, &P_BinaryUInt32DigitalValue); createParam(P_MultibitUInt32DigitalValueString, asynParamUInt32Digital, &P_MultibitUInt32DigitalValue); setIntegerParam (P_Int32Value, 7); setParamStatus (P_Int32Value, asynSuccess); setIntegerParam (P_BinaryInt32Value, 1); setParamStatus (P_BinaryInt32Value, asynSuccess); setIntegerParam (P_MultibitInt32Value, 1); setParamStatus (P_MultibitInt32Value, asynSuccess); setDoubleParam (P_Float64Value, 50.); setParamStatus (P_Float64Value, asynSuccess); setUIntDigitalParam(P_UInt32DigitalValue, (epicsUInt32)0xFF, 0xFFFFFFFF, 0xFFFFFFFF); setParamStatus (P_UInt32DigitalValue, asynSuccess); setUIntDigitalParam(P_BinaryUInt32DigitalValue, (epicsUInt32)0x1, 0xFFFFFFFF, 0xFFFFFFFF); setParamStatus (P_BinaryUInt32DigitalValue, asynSuccess); setUIntDigitalParam(P_MultibitUInt32DigitalValue, (epicsUInt32)0x2, 0xFFFFFFFF, 0xFFFFFFFF); setParamStatus (P_BinaryUInt32DigitalValue, asynSuccess); }
/** 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_); } }
void FastCCD::getCameraStatus(void){ cin_ctl_id_t id; int cin_status = 0; cin_ctl_pwr_mon_t pwr_value; int pwr = 0; int full = 0; cin_status |= cin_ctl_get_id(&cin_ctl_port, &id); if(!cin_status){ setIntegerParam(FastCCDBoardID, id.board_id); setIntegerParam(FastCCDSerialNum, id.serial_no); setIntegerParam(FastCCDFPGAVersion, id.fpga_ver); setParamStatus(FastCCDBoardID, asynSuccess); setParamStatus(FastCCDSerialNum, asynSuccess); setParamStatus(FastCCDFPGAVersion, asynSuccess); } else { setParamStatus(FastCCDBoardID, asynDisconnected); setParamStatus(FastCCDSerialNum, asynDisconnected); setParamStatus(FastCCDFPGAVersion, asynDisconnected); } cin_status = cin_ctl_get_power_status(&cin_ctl_port, full, &pwr, &pwr_value); if(!cin_status){ // Power Status if(pwr){ setIntegerParam(FastCCDPower, 1); if(pwr == 2){ setIntegerParam(FastCCDFPPower, 1); } else { setIntegerParam(FastCCDFPPower, 0); } // Voltage Values setDoubleParam(FastCCDVBus12V0, pwr_value.bus_12v0.v); setDoubleParam(FastCCDIBus12V0, pwr_value.bus_12v0.i); setParamStatus(FastCCDVBus12V0, asynSuccess); setParamStatus(FastCCDIBus12V0, asynSuccess); if(full){ setDoubleParam(FastCCDVMgmt3v3, pwr_value.mgmt_3v3.v); setDoubleParam(FastCCDVMgmt2v5, pwr_value.mgmt_2v5.v); setDoubleParam(FastCCDVMgmt1v2, pwr_value.mgmt_1v2.v); setDoubleParam(FastCCDVEnet1v0, pwr_value.enet_1v0.v); setDoubleParam(FastCCDVS3E3v3, pwr_value.s3e_3v3.v); setDoubleParam(FastCCDVGen3v3, pwr_value.gen_3v3.v); setDoubleParam(FastCCDVGen2v5, pwr_value.gen_2v5.v); setDoubleParam(FastCCDV60v9, pwr_value.v6_0v9.v); setDoubleParam(FastCCDV61v0, pwr_value.v6_1v0.v); setDoubleParam(FastCCDV62v5, pwr_value.v6_2v5.v); setParamStatus(FastCCDVMgmt3v3, asynSuccess); setParamStatus(FastCCDVMgmt2v5, asynSuccess); setParamStatus(FastCCDVMgmt1v2, asynSuccess); setParamStatus(FastCCDVEnet1v0, asynSuccess); setParamStatus(FastCCDVS3E3v3, asynSuccess); setParamStatus(FastCCDVGen3v3, asynSuccess); setParamStatus(FastCCDVGen2v5, asynSuccess); setParamStatus(FastCCDV60v9, asynSuccess); setParamStatus(FastCCDV61v0, asynSuccess); setParamStatus(FastCCDV62v5, asynSuccess); // Current Values setDoubleParam(FastCCDIMgmt3v3, pwr_value.mgmt_3v3.i); setDoubleParam(FastCCDIMgmt2v5, pwr_value.mgmt_2v5.i); setDoubleParam(FastCCDIMgmt1v2, pwr_value.mgmt_1v2.i); setDoubleParam(FastCCDIEnet1v0, pwr_value.enet_1v0.i); setDoubleParam(FastCCDIS3E3v3, pwr_value.s3e_3v3.i); setDoubleParam(FastCCDIGen3v3, pwr_value.gen_3v3.i); setDoubleParam(FastCCDIGen2v5, pwr_value.gen_2v5.i); setDoubleParam(FastCCDI60v9, pwr_value.v6_0v9.i); setDoubleParam(FastCCDI61v0, pwr_value.v6_1v0.i); setDoubleParam(FastCCDI62v5, pwr_value.v6_2v5.i); setParamStatus(FastCCDIMgmt3v3, asynSuccess); setParamStatus(FastCCDIMgmt2v5, asynSuccess); setParamStatus(FastCCDIMgmt1v2, asynSuccess); setParamStatus(FastCCDIEnet1v0, asynSuccess); setParamStatus(FastCCDIS3E3v3, asynSuccess); setParamStatus(FastCCDIGen3v3, asynSuccess); setParamStatus(FastCCDIGen2v5, asynSuccess); setParamStatus(FastCCDI60v9, asynSuccess); setParamStatus(FastCCDI61v0, asynSuccess); setParamStatus(FastCCDI62v5, asynSuccess); } setDoubleParam(FastCCDVFp, pwr_value.fp.v); setDoubleParam(FastCCDIFp, pwr_value.fp.i); setParamStatus(FastCCDVFp, asynSuccess); setParamStatus(FastCCDIFp, asynSuccess); } else { setIntegerParam(FastCCDPower, 0); setIntegerParam(FastCCDFPPower, 0); } setParamStatus(FastCCDPower, asynSuccess); setParamStatus(FastCCDFPPower, asynSuccess); } if(cin_status || !pwr){ setParamStatus(FastCCDVBus12V0, asynDisconnected); setParamStatus(FastCCDIBus12V0, asynDisconnected); setParamStatus(FastCCDVFp, asynDisconnected); setParamStatus(FastCCDIFp, asynDisconnected); } if(!full || cin_status || !pwr){ // Voltage Values setParamStatus(FastCCDVMgmt3v3, asynDisconnected); setParamStatus(FastCCDVMgmt2v5, asynDisconnected); setParamStatus(FastCCDVMgmt1v2, asynDisconnected); setParamStatus(FastCCDVEnet1v0, asynDisconnected); setParamStatus(FastCCDVS3E3v3, asynDisconnected); setParamStatus(FastCCDVGen3v3, asynDisconnected); setParamStatus(FastCCDVGen2v5, asynDisconnected); setParamStatus(FastCCDV60v9, asynDisconnected); setParamStatus(FastCCDV61v0, asynDisconnected); setParamStatus(FastCCDV62v5, asynDisconnected); // Current Values setParamStatus(FastCCDIMgmt3v3, asynDisconnected); setParamStatus(FastCCDIMgmt2v5, asynDisconnected); setParamStatus(FastCCDIMgmt1v2, asynDisconnected); setParamStatus(FastCCDIEnet1v0, asynDisconnected); setParamStatus(FastCCDIS3E3v3, asynDisconnected); setParamStatus(FastCCDIGen3v3, asynDisconnected); setParamStatus(FastCCDIGen2v5, asynDisconnected); setParamStatus(FastCCDI60v9, asynDisconnected); setParamStatus(FastCCDI61v0, asynDisconnected); setParamStatus(FastCCDI62v5, asynDisconnected); } // Status uint16_t fpga_status, dcm_status; cin_status = cin_ctl_get_cfg_fpga_status(&cin_ctl_port, &fpga_status); if(!cin_status){ setUIntDigitalParam(FastCCDFPGAStatus, fpga_status, 0xFFFF); setParamStatus(FastCCDFPGAStatus, asynSuccess); } else { setParamStatus(FastCCDFPGAStatus, asynDisconnected); } cin_status = cin_ctl_get_dcm_status(&cin_ctl_port, &dcm_status); if(!cin_status){ setUIntDigitalParam(FastCCDDCMStatus, dcm_status, 0xFFFF); setParamStatus(FastCCDDCMStatus, asynSuccess); } else { setParamStatus(FastCCDDCMStatus, asynDisconnected); } /* Are we powered up and configured? */ if(fpga_status & CIN_CTL_FPGA_STS_CFG){ // Clock and Bias status int _val; cin_status = cin_ctl_get_camera_pwr(&cin_ctl_port, &_val); if(!cin_status){ setIntegerParam(FastCCDCameraPower, _val); setParamStatus(FastCCDCameraPower, asynSuccess); } else { setParamStatus(FastCCDCameraPower, asynDisconnected); } cin_status = cin_ctl_get_clocks(&cin_ctl_port, &_val); if(!cin_status){ setIntegerParam(FastCCDClocks, _val); setParamStatus(FastCCDClocks, asynSuccess); } else { setParamStatus(FastCCDClocks, asynDisconnected); } cin_status = cin_ctl_get_bias(&cin_ctl_port, &_val); if(!cin_status){ setIntegerParam(FastCCDBias, _val); setParamStatus(FastCCDBias, asynSuccess); } else { setParamStatus(FastCCDBias, asynDisconnected); } // Get Mux Settings int mux; cin_status = cin_ctl_get_mux(&cin_ctl_port, &mux); if(!cin_status){ setIntegerParam(FastCCDMux1, (mux & 0x000F)); setIntegerParam(FastCCDMux2, (mux & 0x00F0) >> 4); setParamStatus(FastCCDMux1, asynSuccess); setParamStatus(FastCCDMux2, asynSuccess); } else {
/** Called when asyn clients call pasynInt32->write(). * This function performs actions for some parameters, including ADAcquire, ADBinX, etc. * For all parameters it sets the value in the parameter library and calls any registered callbacks.. * \param[in] pasynUser pasynUser structure that encodes the reason and address. * \param[in] value Value to write. */ asynStatus FastCCD::writeInt32(asynUser *pasynUser, epicsInt32 value) { int function = pasynUser->reason; asynStatus status = asynSuccess; static const char *functionName = "writeInt32"; //Set in param lib so the user sees a readback straight away. Save a backup in case of errors. setIntegerParam(function, value); int _status = 0; // For return of cin functions if(function == ADAcquire){ if(value){ // User clicked 'Start' button // Send the hardware a start trigger command int n_images, t_mode, i_mode; double t_exp, t_period; getIntegerParam(ADTriggerMode, &t_mode); getIntegerParam(ADImageMode, &i_mode); getIntegerParam(ADNumImages, &n_images); getDoubleParam(ADAcquireTime, &t_exp); getDoubleParam(ADAcquirePeriod, &t_period); switch(i_mode) { case ADImageSingle: this->framesRemaining = 1; n_images = 1; break; case ADImageMultiple: this->framesRemaining = n_images; break; case ADImageContinuous: this->framesRemaining = -1; n_images = 0; break; } if(t_mode == 0){ _status |= cin_ctl_set_cycle_time(&cin_ctl_port, (float)t_period); _status |= cin_ctl_set_exposure_time(&cin_ctl_port, (float)t_exp); if(!_status){ _status |= cin_ctl_int_trigger_start(&cin_ctl_port, n_images); } } else { _status |= cin_ctl_ext_trigger_start(&cin_ctl_port, t_mode); } if(!_status){ setIntegerParam(ADAcquire, 1); setIntegerParam(ADStatus, ADStatusAcquire); setParamStatus(ADAcquire, asynSuccess); setParamStatus(ADStatus, asynSuccess); } else { setIntegerParam(ADAcquire, 1); setIntegerParam(ADStatus, ADStatusIdle); setParamStatus(ADAcquire, asynError); setParamStatus(ADStatus, asynError); } } else { // Send the hardware a stop trigger command if(!cin_ctl_int_trigger_stop(&cin_ctl_port)){ setIntegerParam(ADStatus, ADStatusIdle); setIntegerParam(ADAcquire, 0); } if(!cin_ctl_ext_trigger_stop(&cin_ctl_port)){ setIntegerParam(ADStatus, ADStatusIdle); setIntegerParam(ADAcquire, 0); } } } else if (function == FastCCDFirmwareUpload) { uploadFirmware(); epicsEventSignal(statusEvent); } else if (function == FastCCDClockUpload) { _status = uploadConfig(FastCCDClockUpload, FastCCDClockPath); } else if (function == FastCCDBiasUpload) { _status = uploadConfig(FastCCDBiasUpload, FastCCDBiasPath); } else if (function == FastCCDFCRICUpload) { _status = uploadConfig(FastCCDFCRICUpload, FastCCDFCRICPath); } else if (function == FastCCDPower) { if(value) { _status |= cin_ctl_pwr(&cin_ctl_port, 1); } else { _status |= cin_ctl_pwr(&cin_ctl_port, 0); } epicsEventSignal(statusEvent); } else if (function == FastCCDFPPower) { if(value) { _status |= cin_ctl_fp_pwr(&cin_ctl_port, 1); } else { _status |= cin_ctl_fp_pwr(&cin_ctl_port, 0); } epicsEventSignal(statusEvent); } else if (function == FastCCDCameraPower) { if(value){ _status |= cin_ctl_set_camera_pwr(&cin_ctl_port, 1); } else { _status |= cin_ctl_set_camera_pwr(&cin_ctl_port, 0); } epicsEventSignal(statusEvent); } else if ((function == FastCCDMux1) || (function == FastCCDMux2)) { int _val, _val1, _val2; getIntegerParam(FastCCDMux1, &_val1); getIntegerParam(FastCCDMux2, &_val2); _val = (_val2 << 4) | _val1; _status |= cin_ctl_set_mux(&cin_ctl_port, _val); epicsEventSignal(statusEvent); } else if (function == FastCCDResetStats) { cin_data_reset_stats(); } else if ((function == ADSizeY) || (function == FastCCDOverscan)) { // The Y size changed, change the descramble routine int _val1, _val2; getIntegerParam(ADSizeY, &_val1); getIntegerParam(FastCCDOverscan, &_val2); _status |= cin_data_set_descramble_params(_val1, _val2); // Read back to check all OK int _x, _y; cin_data_get_descramble_params(&_val1, &_val2, &_x, &_y); setIntegerParam(ADSizeX, _x); setIntegerParam(ADSizeY, _y); } else if (function == FastCCDFclk) { _status |= cin_ctl_set_fclk(&cin_ctl_port, value); epicsEventSignal(statusEvent); } else if (function == FastCCDFCRICGain){ _status |= cin_ctl_set_fcric_gain(&cin_ctl_port, value); } else { status = ADDriver::writeInt32(pasynUser, value); } if(_status){ status = asynError; setParamStatus(function, asynError); } else { setParamStatus(function, asynSuccess); } if (status) { asynPrint(pasynUser, ASYN_TRACE_ERROR, "%s:%s: error, status=%d function=%d, value=%d\n", driverName, functionName, status, function, value); } else { asynPrint(pasynUser, ASYN_TRACEIO_DRIVER, "%s:%s: function=%d, value=%d\n", driverName, functionName, function, value); } /* Do callbacks so higher layers see any changes */ callParamCallbacks(); return status; }
void ecAsyn::on_pdo_message(PDO_MESSAGE * pdo, int size) { lock(); char * meta = pdo->buffer + pdo->size + SLAVE_METADATA_CNT * devid; assert(meta + 1 - pdo->buffer < size); epicsInt32 slave_info = meta[0]; epicsInt32 al_state = meta[1]; epicsInt32 error_flag = meta[2]; epicsInt32 disable = pdo->wc_state != EC_WC_COMPLETE || al_state != EC_AL_STATE_OP || slave_info != 0; asynStatus paramStatus = asynSuccess; if (slave_info != 0) { paramStatus = asynDisconnected; } // perhaps set paramStatus to // asynDisabled if pdo->wc_state != EC_WC_COMPLETE setIntegerParam(P_SLAVEINFO, slave_info); setIntegerParam(P_AL_STATE, al_state); setParamStatus(P_AL_STATE, paramStatus); setIntegerParam(P_ERROR_FLAG, error_flag); setParamStatus(P_ERROR_FLAG, paramStatus); setIntegerParam(P_DISABLE, disable); setParamStatus(P_DISABLE, paramStatus); for(ELLNODE * node = ellFirst(&device->pdo_entry_mappings); node; node = ellNext(node)) { EC_PDO_ENTRY_MAPPING * mapping = (EC_PDO_ENTRY_MAPPING *)node; int mpdoe_param = mapping->pdo_entry->parameter; if (mapping->pdo_entry->datatype[0] == 'F') { double val = cast_double(mapping, pdo->buffer, 0); if (disable) { setDoubleParam(mpdoe_param, MINFLOAT); } else { setDoubleParam(mpdoe_param, val); } setParamStatus(mpdoe_param, paramStatus); } else { int32_t val = cast_int32(mapping, pdo->buffer, 0); // can't make SDIS work with I/O intr (some values get lost) // so using this for now if(disable) { setIntegerParam(mpdoe_param, INT32_MIN); } else { setIntegerParam(mpdoe_param, val); } setParamStatus(mpdoe_param, paramStatus); } } callParamCallbacks(); unlock(); }