17 #include <epicsThread.h>
18 #include <epicsEvent.h>
19 #include <epicsString.h>
22 #include <epicsExport.h>
28 #include "asynOctetSyncIO.h"
31 #define SPECS_MAX_STRING 4096
33 #define SPECS_TIMEOUT 10
35 #define SPECS_UPDATE_RATE 0.1
37 #define SPECS_OK_STRING "OK"
38 #define SPECS_ERROR_STRING "ERROR"
41 #define SPECS_RUN_FAT 0
42 #define SPECS_RUN_SFAT 1
43 #define SPECS_RUN_FRR 2
44 #define SPECS_RUN_FE 3
47 #define SPECS_TYPE_DOUBLE "double"
48 #define SPECS_TYPE_INTEGER "integer"
49 #define SPECS_TYPE_STRING "string"
50 #define SPECS_TYPE_BOOL "bool"
53 #define SPECS_CMD_CONNECT "Connect"
54 #define SPECS_CMD_DISCONNECT "Disconnect"
55 #define SPECS_CMD_DEFINE_FAT "DefineSpectrumFAT"
56 #define SPECS_CMD_DEFINE_SFAT "DefineSpectrumSFAT"
57 #define SPECS_CMD_DEFINE_FRR "DefineSpectrumFRR"
58 #define SPECS_CMD_DEFINE_FE "DefineSpectrumFE"
59 #define SPECS_CMD_VALIDATE "ValidateSpectrum"
60 #define SPECS_CMD_START "Start"
61 #define SPECS_CMD_PAUSE "Pause"
62 #define SPECS_CMD_RESUME "Resume"
63 #define SPECS_CMD_ABORT "Abort"
64 #define SPECS_CMD_GET_STATUS "GetAcquisitionStatus"
65 #define SPECS_CMD_GET_DATA "GetAcquisitionData"
66 #define SPECS_CMD_CLEAR "ClearSpectrum"
67 #define SPECS_CMD_GET_NAMES "GetAllAnalyzerParameterNames"
68 #define SPECS_CMD_GET_INFO "GetAnalyzerParameterInfo"
69 #define SPECS_CMD_GET_VISNAME "GetAnalyzerVisibleName"
70 #define SPECS_CMD_GET_VALUE "GetAnalyzerParameterValue"
71 #define SPECS_CMD_SET_VALUE "SetAnalyzerParameterValue"
72 #define SPECS_CMD_GET_SPECTRUM "GetSpectrumParameterInfo"
73 #define SPECS_CMD_GET_DATA_INFO "GetSpectrumDataInfo"
74 #define SPECS_CMD_SET_SAFE_STATE "SetSafeState"
77 #define SPECSConnectString "SPECS_CONNECT"
78 #define SPECSConnectedString "SPECS_CONNECTED"
79 #define SPECSPauseAcqString "SPECS_PAUSE_ACQ"
80 #define SPECSMsgCounterString "SPECS_MSG_COUNTER"
81 #define SPECSServerNameString "SPECS_SERVER_NAME"
82 #define SPECSProtocolVersionString "SPECS_PROTOCOL_VERSION"
83 #define SPECSProtocolVersionMinorString "SPECS_PROTOCOL_VER_MINOR"
84 #define SPECSProtocolVersionMajorString "SPECS_PROTOCOL_VER_MAJOR"
85 #define SPECSStartEnergyString "SPECS_START_ENERGY"
86 #define SPECSEndEnergyString "SPECS_END_ENERGY"
87 #define SPECSRetardingRatioString "SPECS_RETARDING_RATIO"
88 #define SPECSKineticEnergyString "SPECS_KINETIC_ENERGY"
89 #define SPECSStepWidthString "SPECS_STEP_WIDTH"
90 #define SPECSSamplesString "SPECS_SAMPLES"
91 #define SPECSSamplesIterationString "SPECS_SAMPLES_ITERATION"
92 #define SPECSSnapshotValuesString "SPECS_SNAPSHOT_VALUES"
93 #define SPECSPassEnergyString "SPECS_PASS_ENERGY"
94 #define SPECSLensModeString "SPECS_LENS_MODE"
95 #define SPECSScanRangeString "SPECS_SCAN_RANGE"
96 #define SPECSCurrentSampleString "SPECS_CURRENT_SAMPLE"
97 #define SPECSPercentCompleteString "SPECS_PERCENT_COMPLETE"
98 #define SPECSRemainingTimeString "SPECS_REMAINING_TIME"
99 #define SPECSCurrentSampleIterationString "SPECS_CRT_SAMPLE_ITER"
100 #define SPECSPercentCompleteIterationString "SPECS_PCT_COMPLETE_ITER"
101 #define SPECSRemainingTimeIterationString "SPECS_RMG_TIME_ITER"
102 #define SPECSAcqSpectrumString "SPECS_ACQ_SPECTRUM"
103 #define SPECSAcqImageString "SPECS_ACQ_IMAGE"
105 #define SPECSRunModeString "SPECS_RUN_MODE"
106 #define SPECSDefineString "SPECS_DEFINE"
107 #define SPECSValidateString "SPECS_VALIDATE"
109 #define SPECSNonEnergyChannelsString "SPECS_NON_ENERGY_CHANNELS"
110 #define SPECSNonEnergyUnitsString "SPECS_NON_ENERGY_UNITS"
111 #define SPECSNonEnergyMinString "SPECS_NON_ENERGY_MIN"
112 #define SPECSNonEnergyMaxString "SPECS_NON_ENERGY_MAX"
113 #define SPECSSafeStateString "SPECS_SAFE_STATE"
114 #define SPECSDataDelayMaxString "SPECS_DATA_DELAY_MAX"
132 SpecsAnalyser(
const char *portName,
const char *driverPort,
int maxBuffers,
size_t maxMemory,
int priority,
int stackSize);
138 asynStatus
readEnum(asynUser *pasynUser,
char *strings[],
int values[],
int severities[],
size_t nElements,
size_t *nIn);
164 asynStatus
asynPortConnect(
const char *port,
int addr, asynUser **ppasynUser,
const char *inputEos,
const char *outputEos);
184 #define FIRST_SPECS_PARAM SPECSConnect_
222 #define LAST_SPECS_PARAM SPECSDataDelayMax_
227 std::map<std::string, int> debugMap_;
228 epicsEventId startEventId_;
229 epicsEventId stopEventId_;
230 std::vector<std::string> lensModes_;
231 std::vector<std::string> scanRanges_;
232 std::vector<std::string> runModes_;
233 std::map<std::string, std::string> paramMap_;
234 std::map<int, std::string> paramIndexes_;
240 #define NUM_SPECS_PARAMS ((int)(&LAST_SPECS_PARAM - &FIRST_SPECS_PARAM + 100))
Class from which areaDetector drivers are directly derived.
Definition: ADDriver.h:132
Definition: specsAnalyser.h:130
asynStatus getAnalyserParameter(const std::string &name, int &value)
Definition: specsAnalyser.cpp:1518
int SPECSStartEnergy_
Definition: specsAnalyser.h:192
asynStatus makeConnection()
Definition: specsAnalyser.cpp:180
asynStatus readRunModes()
Definition: specsAnalyser.cpp:1740
int SPECSConnected_
Definition: specsAnalyser.h:185
int SPECSLensMode_
Definition: specsAnalyser.h:201
asynStatus readDeviceVisibleName()
This method queries the analyser for its device name to populate the ADModel parameter.
Definition: specsAnalyser.cpp:1345
int SPECSCurrentSample_
Definition: specsAnalyser.h:203
int SPECSEndEnergy_
Definition: specsAnalyser.h:193
int SPECSScanRange_
Definition: specsAnalyser.h:202
SpecsAnalyser(const char *portName, const char *driverPort, int maxBuffers, size_t maxMemory, int priority, int stackSize)
Definition: specsAnalyser.cpp:44
asynStatus defineSpectrumFE()
Definition: specsAnalyser.cpp:1231
int SPECSNonEnergyMin_
Definition: specsAnalyser.h:218
asynStatus debug(const std::string &method, const std::string &msg)
Definition: specsAnalyser.cpp:2204
asynStatus readEnum(asynUser *pasynUser, char *strings[], int values[], int severities[], size_t nElements, size_t *nIn)
Called when asyn clients call pasynEnum->read().
Definition: specsAnalyser.cpp:716
asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value)
Called when asyn clients call pasynInt32->write().
Definition: specsAnalyser.cpp:770
asynStatus asynPortDisconnect(asynUser *pasynUser)
Definition: specsAnalyser.cpp:1873
int SPECSNonEnergyMax_
Definition: specsAnalyser.h:219
int SPECSMsgCounter_
Definition: specsAnalyser.h:187
asynStatus disconnect()
Definition: specsAnalyser.cpp:243
int SPECSRetardingRatio_
Definition: specsAnalyser.h:194
asynStatus setAnalyserParameter(const std::string &name, int value)
Definition: specsAnalyser.cpp:1592
int SPECSPauseAcq_
Definition: specsAnalyser.h:186
int SPECSProtocolVersionMinor_
Definition: specsAnalyser.h:190
asynStatus readSpectrumParameter(int param)
Definition: specsAnalyser.cpp:1663
asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value)
Called when asyn clients call pasynFloat64->write().
Definition: specsAnalyser.cpp:927
asynStatus asynPortConnect(const char *port, int addr, asynUser **ppasynUser, const char *inputEos, const char *outputEos)
Connect to the underlying low level Asyn port that is used for comms.
Definition: specsAnalyser.cpp:1831
int SPECSProtocolVersionMajor_
Definition: specsAnalyser.h:191
int SPECSNonEnergyChannels_
Definition: specsAnalyser.h:216
int SPECSSamplesIteration_
Definition: specsAnalyser.h:198
asynStatus asynWriteRead(const char *command, char *response)
Wrapper for asynOctetSyncIO write/read functions.
Definition: specsAnalyser.cpp:2042
asynStatus setupEPICSParameters()
This method sets up the analyser parameters that are not known prior to connecting to the device.
Definition: specsAnalyser.cpp:1367
asynStatus readAcquisitionData(int startIndex, int endIndex, std::vector< double > &values)
Definition: specsAnalyser.cpp:1269
int SPECSValidate_
Definition: specsAnalyser.h:214
void specsAnalyserTask()
Task to listen to the SPECS prodigy application and update the higher level software.
Definition: specsAnalyser.cpp:268
asynStatus debugLevel(const std::string &method, int onOff)
Definition: specsAnalyser.cpp:2172
int SPECSSnapshotValues_
Definition: specsAnalyser.h:199
int SPECSConnect_
Definition: specsAnalyser.h:183
int SPECSRunMode_
Definition: specsAnalyser.h:212
asynStatus readSpectrumDataInfo(SPECSDataInfoParam_t param)
Send the GetSpectrumDataInfo method to query the spectrum metadata.
Definition: specsAnalyser.cpp:1764
int SPECSDefine_
Definition: specsAnalyser.h:213
asynStatus getAnalyserParameterType(const std::string &name, SPECSValueType_t &value)
Definition: specsAnalyser.cpp:1495
asynStatus validateSpectrum()
Validate the currently defined spectrum.
Definition: specsAnalyser.cpp:979
int SPECSSafeState_
Definition: specsAnalyser.h:220
int SPECSPercentComplete_
Definition: specsAnalyser.h:204
int SPECSPercentCompleteIteration_
Definition: specsAnalyser.h:207
asynStatus sendSimpleCommand(const std::string &command, std::map< std::string, std::string > *data=NULL)
Method for sending a simple command (no parameters) that will check the error status and do the right...
Definition: specsAnalyser.cpp:1313
asynStatus readIntegerData(std::map< std::string, std::string > data, const std::string &name, int &value)
Definition: specsAnalyser.cpp:1635
asynStatus cleanString(std::string &str, const std::string &search=": \n", int where=0)
Utility function, returns strings with unwanted characters stripped.
Definition: specsAnalyser.cpp:2126
asynStatus sendStartCommand(bool safeAfter)
Send the start command to the analyser.
Definition: specsAnalyser.cpp:1078
int SPECSNonEnergyUnits_
Definition: specsAnalyser.h:217
int SPECSCurrentSampleIteration_
Definition: specsAnalyser.h:206
asynStatus defineSpectrumFAT()
Define a Fixed Analyser Transmission spectrum.
Definition: specsAnalyser.cpp:1106
asynStatus defineSpectrumSFAT()
Define a Snapshot Fixed Analyser Transmission spectrum.
Definition: specsAnalyser.cpp:1152
asynStatus defineSpectrumFRR()
Definition: specsAnalyser.cpp:1190
virtual ~SpecsAnalyser()
specsAnalyser destructor
Definition: specsAnalyser.cpp:40
int SPECSServerName_
Definition: specsAnalyser.h:188
asynStatus connect()
Definition: specsAnalyser.cpp:220
int SPECSStepWidth_
Definition: specsAnalyser.h:196
asynStatus readDoubleData(std::map< std::string, std::string > data, const std::string &name, double &value)
Definition: specsAnalyser.cpp:1649
int SPECSKineticEnergy_
Definition: specsAnalyser.h:195
int SPECSProtocolVersion_
Definition: specsAnalyser.h:189
int SPECSPassEnergy_
Definition: specsAnalyser.h:200
int SPECSRemainingTimeIteration_
Definition: specsAnalyser.h:208
int SPECSRemainingTime_
Definition: specsAnalyser.h:205
int SPECSAcqImage_
Definition: specsAnalyser.h:210
int SPECSDataDelayMax_
Definition: specsAnalyser.h:221
asynStatus commandResponse(const std::string &command, std::string &response, std::map< std::string, std::string > &data)
This sends a command to the device and parses the response.
Definition: specsAnalyser.cpp:1897
int SPECSAcqSpectrum_
Definition: specsAnalyser.h:209
asynStatus initDebugger(int initDebug)
Definition: specsAnalyser.cpp:2143
int SPECSSamples_
Definition: specsAnalyser.h:197
@ string
Definition: NDFileHDF5Layout.h:44
name
Definition: makeDbAndEdl.py:232
list value
Definition: makeDbAndEdl.py:234
SPECSValueType_t
Definition: specsAnalyser.h:117
@ SPECSTypeString
Definition: specsAnalyser.h:120
@ SPECSTypeInteger
Definition: specsAnalyser.h:119
@ SPECSTypeDouble
Definition: specsAnalyser.h:118
@ SPECSTypeBool
Definition: specsAnalyser.h:121
#define SPECS_MAX_STRING
Definition: specsAnalyser.h:31
SPECSDataInfoParam_t
Definition: specsAnalyser.h:125
@ SPECSOrdinateRange
Definition: specsAnalyser.h:126
Definition: restApi.cpp:92