1 #include <epicsEvent.h>
10 #define BYTE unsigned char
14 #define STRING(x) _STRING(x)
15 #define __Note__(x) message(__FILE__ "(" STRING(__LINE__) ") : Note >>>> " x )
22 virtual asynStatus
Initialize(asynPortDriver& driver) = 0;
31 return driver.setIntegerParam(parameterIndex,
value);
36 return driver.setDoubleParam(parameterIndex,
value);
41 return driver.getIntegerParam(parameterIndex, &
value);
46 return driver.getDoubleParam(parameterIndex, &
value);
89 if (status == asynSuccess)
97 virtual T
Value(asynPortDriver& driver)
105 virtual asynStatus
SetValue(asynPortDriver& driver, T newValue)
121 T currentValue =
Value(driver);
122 if (currentValue >= minimumValue)
126 int scaled = (int)ceil(minimumValue /
_scale);
127 T newValue = scaled *
_scale;
129 assert(newValue >= minimumValue);
138 T internalValue = (T)newValue *
_scale;
139 return SetValue(driver, internalValue);
180 return driver.createParam(
name.c_str(), asynParamInt32, ¶meterIndex);
185 return driver.createParam(
name.c_str(), asynParamFloat64, ¶meterIndex);
189 template <
typename T>
194 const T& minimumValue,
const T& maximumValue,
const T& defaultValue) :
196 _minValue(minimumValue),
197 _maxValue(maximumValue)
199 assert(minimumValue <= maximumValue);
200 assert(minimumValue <= defaultValue);
201 assert(defaultValue <= maximumValue);
205 const T& minimumValue,
const T& maximumValue,
const T& defaultValue,
const T& scale) :
207 _minValue(minimumValue),
208 _maxValue(maximumValue)
210 assert(minimumValue <= maximumValue);
211 assert(minimumValue <= defaultValue);
212 assert(defaultValue <= maximumValue);
215 virtual T
Value(asynPortDriver& driver)
224 else if (
_value > _maxValue)
238 template <
int valueCount,
typename T>
243 const T& minimumValue,
const T& maximumValue,
const T& defaultValue,
const T& scale) :
250 assert(minimumValue <= maximumValue);
251 assert(minimumValue <= defaultValue);
252 assert(defaultValue <= maximumValue);
254 for (
size_t i = 0;
i < valueCount; ++
i)
256 std::stringstream fullName;
257 fullName <<
_name <<
"_" << (
i + 1);
268 status = parameter.Initialize(driver);
269 if (status != asynSuccess)
276 T
Value(asynPortDriver& driver,
size_t index)
286 asynStatus
SetValue(asynPortDriver& driver,
size_t index, T newValue)
288 return _parameters[index].SetValue(driver, newValue);
293 return _parameters[index].SetValueAtMinimum(driver, minimumValue);
298 return _parameters[index].SetScaledValue(driver, newValue);
310 if (parameter.HasParameterIndex(indexToMatch))
319 return _parameters[index].InternalIndex() + (short)(index + 1) * indexStep;
334 xcamCamera(
const char *portName,
int maxSizeX,
int maxSizeY,
335 int maxBuffers,
size_t maxMemory,
336 int priority,
int stackSize);
340 virtual asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64
value);
341 virtual asynStatus
writeOctet(asynUser *pasynUser,
const char *
value,
size_t maxChars,
size_t *nActual);
343 virtual void report(FILE *fp,
int details);
347 void temperatureTask(
void);
352 #define FIRST_XCAM_CAMERA_PARAM SoftVersion
357 #define LAST_XCAM_CAMERA_PARAM SeqFilename
361 epicsMutex _xcmclmMutex;
363 const size_t _sensorSizeX = 1600;
364 const size_t _sensorSizeY = 1600;
367 const double _acquireTimeoutSeconds = 0.2;
371 #pragma warning (push)
372 #pragma warning (disable: 4251)
374 bool _newImageRequired;
376 static const char* _driverName;
379 std::vector<int> _serialNumbers;
380 vector<NDArray*> _ccdImages;
383 const static int _ccdCountMax = 3;
418 Parameter<epicsInt32> _paramTEMP_ACCUMULATED_ERROR_LIMIT{
"TEMP_ACCUMULATED_ERROR_LIMIT", 16, 0, 16777215, 0};
428 const static int _parameterContainerCount = 43;
429 const static int _parameterCount = 67;
431 std::vector<ParameterBase*> _allParams;
434 bool _CCDPowerChanged;
435 bool _sequencerFilenameChanged;
437 bool _TriggerModeChanged;
439 const short _voltageIndexStep = 16;
440 std::vector<MultiParameter<_ccdCountMax, epicsFloat64>*> _voltageParams;
441 bool _voltageParamsChanged;
443 std::vector<Parameter<epicsInt32>*> _tempControllerParams;
444 bool _tempControllerParamsChanged;
446 std::vector<Parameter<epicsInt32>*> _sequencerParams;
447 bool _SequencerParametersChanged;
449 bool _acquireTimeChanged;
450 bool _adcGainOffsetChanged;
451 bool _shutterModeChanged;
452 bool _shutterDelayChanged;
454 double _grabWaitValue;
460 bool _roiParametersChanged;
462 bool _switchModeCheck;
464 std::set<int> _roiParameterIndices;
466 #pragma warning (pop)
468 size_t CCDCount()
const {
return _serialNumbers.size(); };
471 bool xcamCamera::LoadSequencer();
475 bool SetCCDPower(
bool on,
bool force =
false);
477 bool SetCCDVoltages();
478 bool ApplyVoltageConstraints();
480 void SetExposureTime();
482 void SetTemperatureController();
484 void ConfigureROIBinning();
486 void ConfigureROIBinningAxis(
const int binID,
const int minID,
const int sizeID,
const int maxID,
487 int& bin,
int& origin,
int& count);
488 void ConstrainToSensorAxis(
const int globalOrigin,
const int globalSize,
const int globalBin,
489 const int localOrigin,
const int localSize,
490 int& originOut,
int& countOut);
492 int computeRIXSArray(
int sizeX,
int sizeY);
495 enum temperatureControllerCommands
497 CMD_TEMP_GET_RAW_PLANT_VALUE = 0,
498 CMD_TEMP_GET_SETPOINT = 1,
499 CMD_TEMP_SET_SETPOINT = 2,
500 CMD_TEMP_GET_PROPORTIONAL_GAIN = 3,
501 CMD_TEMP_SET_PROPORTIONAL_GAIN = 4,
502 CMD_TEMP_GET_INTEGRAL_GAIN = 5,
503 CMD_TEMP_SET_INTEGRAL_GAIN = 6,
504 CMD_TEMP_GET_DERIVATIVE_GAIN = 7,
505 CMD_TEMP_SET_DERIVATIVE_GAIN = 8,
506 CMD_TEMP_GET_PROPORTIONAL_TIME = 9,
507 CMD_TEMP_SET_PROPORTIONAL_TIME = 10,
508 CMD_TEMP_GET_INTEGRAL_RATE = 11,
509 CMD_TEMP_SET_INTEGRAL_RATE = 12,
510 CMD_TEMP_GET_DERIVATIVE_RATE = 13,
511 CMD_TEMP_SET_DERIVATIVE_RATE = 14,
512 CMD_TEMP_GET_ACCUMULATED_ERROR_LIMIT = 15,
513 CMD_TEMP_SET_ACCUMULATED_ERROR_LIMIT = 16,
514 CMD_TEMP_GET_OUTPUT_BIAS_VALUE = 17,
515 CMD_TEMP_SET_OUTPUT_BIAS_VALUE = 18,
516 CMD_TEMP_SET_MANUAL_MODE = 19,
517 CMD_TEMP_SET_ENABLE_CONTROL = 20
520 int EncodeTemperatureCelsius(
double tempDegreesC) {
return (
int)(0.5 + (tempDegreesC + 260.0) / 0.0000277); };
521 double DecodeTemperatureCelsius(
int encoded) {
return ((
double)encoded * 0.0000277) - 260.0; }
523 void ReportWriteStatus(asynUser *pasynUser,
const asynStatus status,
const char * methodName);
526 epicsEventId startEventId;
527 epicsEventId stopEventId;
531 #define NUM_XCAM_CAMERA_PARAMS ((int)(&LAST_XCAM_CAMERA_PARAM - &FIRST_XCAM_CAMERA_PARAM + 1))
Class from which areaDetector drivers are directly derived.
Definition: ADDriver.h:132
virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value)
Sets an int32 parameter.
Definition: ADDriver.cpp:84
virtual void setShutter(int open)
Set the shutter position.
Definition: ADDriver.cpp:29
Definition: rixscam.h:240
short InternalIndex(size_t index, short indexStep)
Definition: rixscam.h:317
bool SetValueAtMinimum(asynPortDriver &driver, size_t index, T minimumValue)
Definition: rixscam.h:291
int ScaledValue(asynPortDriver &driver, size_t index)
Definition: rixscam.h:281
const T _maxValue
Definition: rixscam.h:326
asynStatus Initialize(asynPortDriver &driver)
Definition: rixscam.h:263
MultiParameter(const std::string &rootName, const short internalIndex, const T &minimumValue, const T &maximumValue, const T &defaultValue, const T &scale)
Definition: rixscam.h:242
asynStatus SetScaledValue(asynPortDriver &driver, size_t index, int newValue)
Definition: rixscam.h:296
T Value(asynPortDriver &driver, size_t index)
Definition: rixscam.h:276
const T _defaultValue
Definition: rixscam.h:324
bool Normalize(asynPortDriver &driver, size_t index)
Definition: rixscam.h:301
bool HasParameterIndex(int indexToMatch) const
Definition: rixscam.h:306
std::vector< Parameter< T > > _parameters
Definition: rixscam.h:327
const T _minValue
Definition: rixscam.h:325
asynStatus SetValue(asynPortDriver &driver, size_t index, T newValue)
Definition: rixscam.h:286
const short _internalIndex
Definition: rixscam.h:323
N-dimensional array class; each array has a set of dimensions, a data type, pointer to data,...
Definition: NDArray.h:99
ParameterBase(const std::string &name)
Definition: rixscam.h:25
asynStatus GetParameter(asynPortDriver &driver, const int parameterIndex, epicsInt32 &value)
Definition: rixscam.h:39
virtual asynStatus Initialize(asynPortDriver &driver)=0
const std::string _name
Definition: rixscam.h:49
asynStatus SetParameter(asynPortDriver &driver, const int parameterIndex, const epicsInt32 value)
Definition: rixscam.h:29
Definition: rixscam.h:191
virtual T Value(asynPortDriver &driver)
Definition: rixscam.h:215
Parameter(const std::string &name, const short internalIndex, const T &minimumValue, const T &maximumValue, const T &defaultValue, const T &scale)
Definition: rixscam.h:204
Parameter(const std::string &name, const short internalIndex, const T &minimumValue, const T &maximumValue, const T &defaultValue)
Definition: rixscam.h:193
T _value
Definition: rixscam.h:171
int _parameterIndex
Definition: rixscam.h:172
virtual asynStatus Initialize(asynPortDriver &driver)
Definition: rixscam.h:86
ReadOnlyParameter(const std::string &name, const short internalIndex, const T &defaultValue, const T &scale)
Definition: rixscam.h:59
const T _scale
Definition: rixscam.h:174
virtual bool SetValueAtMinimum(asynPortDriver &driver, T minimumValue)
Definition: rixscam.h:119
virtual bool HasParameterIndex(int indexToMatch) const
Definition: rixscam.h:154
virtual int ScaledValue(asynPortDriver &driver)
Definition: rixscam.h:114
ReadOnlyParameter(const std::string &name, const short internalIndex)
Definition: rixscam.h:77
virtual asynStatus Create(asynPortDriver &driver, const std::string &name, int ¶meterIndex)
Definition: rixscam.h:166
virtual T Value(asynPortDriver &driver)
Definition: rixscam.h:97
virtual short InternalIndex() const
Definition: rixscam.h:160
const int _internalIndex
Definition: rixscam.h:173
virtual asynStatus SetValue(asynPortDriver &driver, T newValue)
Definition: rixscam.h:105
ReadOnlyParameter(const std::string &name, const short internalIndex, const T &defaultValue)
Definition: rixscam.h:68
virtual asynStatus SetScaledValue(asynPortDriver &driver, int newValue)
Definition: rixscam.h:136
virtual bool Normalize(asynPortDriver &driver)
Definition: rixscam.h:142
virtual asynStatus writeOctet(asynUser *pasynUser, const char *value, size_t maxChars, size_t *nActual)
Called when asyn clients call pasynOctet->write().
Definition: asynNDArrayDriver.cpp:511
virtual void report(FILE *fp, int details)
Report status of the driver.
Definition: asynNDArrayDriver.cpp:753
Definition: rixscam.h:332
int IFSVersion
Definition: rixscam.h:353
int SoftVersion
Definition: rixscam.h:351
int SeqFilename
Definition: rixscam.h:356
int FPGAVersion
Definition: rixscam.h:354
int CamSerial
Definition: rixscam.h:355
@ string
Definition: NDFileHDF5Layout.h:44
int i
Definition: makeAdl.py:479
name
Definition: makeDbAndEdl.py:232
list value
Definition: makeDbAndEdl.py:234