areaDetector 3-14
EPICS areaDetector framework
EuresysFeature.h
Go to the documentation of this file.
1#ifndef EURESYS_FEATURE_H
2#define EURESYS_FEATURE_H
3
4#include <GenICamFeature.h>
5
6#include <ADEuresys.h>
7
8#include "EGrabber.h"
9using namespace Euresys;
10
11static const char *className = "EuresysFeature";
12
13template <typename ModuleType> class EuresysFeature : public GenICamFeature
14{
15public:
16
18 std::string const & asynName, asynParamType asynType, int asynIndex,
19 std::string const & featureName, GCFeatureType_t featureType)
20
21 : GenICamFeature(set, asynName, asynType, asynIndex, featureName, featureType),
22 mAsynUser(set->getUser()),
23 mFeatureName(featureName)
24 {
25 static const char *functionName = "EuresysFeature";
26
28 mGrabber = pDrv->getGrabber();
29 try {
30 mIsImplemented = mGrabber->getInteger<ModuleType>(query::implemented(mFeatureName)) ? true : false;
31 }
32 catch (std::exception &e) {
33 asynPrint(mAsynUser, ASYN_TRACE_ERROR, "%s::%s query error for implemented=%s\n",
34 className, functionName, e.what());
35 }
36 }
37
38
39 bool isImplemented() {
40 return mIsImplemented;
41 }
42
43 bool isAvailable() {
44 static const char *functionName = "isAvailable";
45 bool value = false;
46 if (!mIsImplemented) return value;
47 try {
48 value = mGrabber->getInteger<ModuleType>(query::available(mFeatureName)) ? true : false;
49 }
50 catch (std::exception &e) {
51 reportError(functionName, "query error for available", e.what());
52 }
53 return value;
54 }
55
56 bool isReadable() {
57 static const char *functionName = "isReadable";
58 bool value = false;
59 if (!mIsImplemented) return value;
60 try {
61 value = mGrabber->getInteger<ModuleType>(query::readable(mFeatureName)) ? true : false;
62 }
63 catch (std::exception &e) {
64 reportError(functionName, "query error for readable", e.what());
65 }
66 return value;
67 }
68
69 bool isWritable() {
70 static const char *functionName = "isWritable";
71 bool value = false;
72 if (!mIsImplemented) return value;
73 try {
74 value = mGrabber->getInteger<ModuleType>(query::writeable(mFeatureName)) ? true : false;
75 }
76 catch (std::exception &e) {
77 reportError(functionName, "query error for writeable", e.what());
78 }
79 return value;
80 }
81
82 epicsInt64 readInteger() {
83 static const char *functionName = "readInteger";
84 epicsInt64 value = 0;
85 try {
86 value = mGrabber->getInteger<ModuleType>(mFeatureName);
87 }
88 catch (std::exception &e) {
89 reportError(functionName, "error calling getInteger", e.what());
90 }
91 return value;
92 }
93
94 epicsInt64 readIntegerMin() {
95 static const char *functionName = "readIntegerMin";
96 epicsInt64 value = 0;
97 try {
98 value = mGrabber->getInteger<ModuleType>(mFeatureName+".Min");
99 }
100 catch (std::exception &e) {
101 reportError(functionName, "error calling getInteger", e.what());
102 }
103 return value;
104 }
105
106 epicsInt64 readIntegerMax() {
107 static const char *functionName = "readIntegerMax";
108 epicsInt64 value = 0;
109 try {
110 value = mGrabber->getInteger<ModuleType>(mFeatureName+".Max");
111 }
112 catch (std::exception &e) {
113 reportError(functionName, "error calling getInteger", e.what());
114 }
115 return value;
116 }
117
118 epicsInt64 readIncrement() {
119 static const char *functionName = "readIncrement";
120 epicsInt64 value = 0;
121 try {
122 value = mGrabber->getInteger<ModuleType>(mFeatureName+".Inc");
123 }
124 catch (std::exception &e) {
125 reportError(functionName, "error calling getInteger", e.what());
126 }
127 return value;
128 }
129
130 void writeInteger(epicsInt64 value) {
131 static const char *functionName = "writeInteger";
132 try {
133 mGrabber->setInteger<ModuleType>(mFeatureName, value);
134 }
135 catch (std::exception &e) {
136 reportError(functionName, "error calling setInteger", e.what());
137 }
138 }
139
140 bool readBoolean() {
141 static const char *functionName = "readBoolean";
142 epicsInt64 value = 0;
143 try {
144 value = mGrabber->getInteger<ModuleType>(mFeatureName);
145 }
146 catch (std::exception &e) {
147 reportError(functionName, "error calling getInteger", e.what());
148 }
149 return value ? true : false;
150 }
151
152 void writeBoolean(bool bval) {
153 static const char *functionName = "writeBoolean";
154 epicsInt64 value = bval ? 1 : 0;
155 try {
156 mGrabber->setInteger<ModuleType>(mFeatureName, value);
157 }
158 catch (std::exception &e) {
159 reportError(functionName, "error calling setInteger", e.what());
160 }
161 }
162
163 // The Mikrotron cameras use integer node types for ExposureTime and AcquisitionFrameRate but ADGenICam expects these to be float nodes.
164 // These double methods need to handle integers
165 double readDouble() {
166 static const char *functionName = "readDouble";
167 epicsFloat64 value = 0;
168 try {
169 value = mGrabber->getFloat<ModuleType>(mFeatureName);
170 }
171 catch (std::exception &e) {
172 reportError(functionName, "error calling getFloat", e.what());
173 }
174 return value;
175 }
176
177 void writeDouble(double value) {
178 static const char *functionName = "writeDouble";
179 try {
180 mGrabber->setFloat<ModuleType>(mFeatureName, value);
181 }
182 catch (std::exception &e) {
183 reportError(functionName, "error calling setFloat", e.what());
184 }
185 }
186
187 double readDoubleMin() {
188 static const char *functionName = "readDoubleMin";
189 epicsFloat64 value = 0;
190 try {
191 value = mGrabber->getFloat<ModuleType>(mFeatureName+".Min");
192 }
193 catch (std::exception &e) {
194 reportError(functionName, "error calling getFloat", e.what());
195 }
196 return value;
197 }
198
199 double readDoubleMax() {
200 static const char *functionName = "readDoubleMax";
201 epicsFloat64 value = 0;
202 try {
203 value = mGrabber->getFloat<ModuleType>(mFeatureName+".Max");
204 }
205 catch (std::exception &e) {
206 reportError(functionName, "error calling getFloat", e.what());
207 }
208 return value;
209 }
210
212 static const char *functionName = "readEnumIndex";
213 epicsInt64 value=0;
214 try {
215 value = mGrabber->getInteger<ModuleType>(mFeatureName);
216 }
217 catch (std::exception &e) {
218 reportError(functionName, "error calling getInteger", e.what());
219 }
220 return (int) value;
221 }
222
223 void writeEnumIndex(int value) {
224 static const char *functionName = "writeEnumIndex";
225 try {
226 mGrabber->setInteger<ModuleType>(mFeatureName, (epicsInt64)value);
227 }
228 catch (std::exception &e) {
229 reportError(functionName, "error calling setInteger", e.what());
230 }
231 }
232
233 std::string readEnumString() {
234 static const char *functionName = "readEnumString";
235 std::string value;
236 try {
237 value = mGrabber->getString<ModuleType>(mFeatureName);
238 }
239 catch (std::exception &e) {
240 reportError(functionName, "error calling getString", e.what());
241 }
242 return value;
243 }
244
245 void writeEnumString(std::string const &value) {
246 }
247
248 std::string readString() {
249 static const char *functionName = "readString";
250 std::string value;
251 try {
252 value = mGrabber->getString<ModuleType>(mFeatureName);
253 }
254 catch (std::exception &e) {
255 reportError(functionName, "error calling getString", e.what());
256 }
257 return value;
258 }
259
260 void writeString(std::string const & value) {
261 static const char *functionName = "writeString";
262 try {
263 mGrabber->setString<ModuleType>(mFeatureName, value);
264 }
265 catch (std::exception &e) {
266 reportError(functionName, "error calling setString", e.what());
267 }
268 }
269
271 static const char *functionName = "writeCommand";
272 try {
273 mGrabber->execute<ModuleType>(mFeatureName);
274 }
275 catch (std::exception &e) {
276 reportError(functionName, "error calling execute", e.what());
277 }
278 }
279
280 void readEnumChoices(std::vector<std::string>& enumStrings, std::vector<int>& enumValues) {
281 static const char *functionName = "readEnumChoices";
282 std::vector<std::string> strs;
283 try {
284 strs = mGrabber->getStringList<ModuleType>(query::enumEntries(mFeatureName));
285 }
286 catch (std::exception &e) {
287 reportError(functionName, "error calling getStrings", e.what());
288 }
289 enumStrings = strs;
290 epicsInt64 ival=0;
291 for (size_t i=0; i<strs.size(); i++) {
292 try {
293 ival = mGrabber->getInteger<ModuleType>(mFeatureName+".Entry."+enumStrings[i]);
294 }
295 catch (std::exception &e) {
296 reportError(functionName, "error calling getInteger", e.what());
297 }
298 enumValues.push_back((int)ival);
299 }
300 }
301
302private:
303 void reportError(const char *functionName, const char *errorSource, const char *errorWhat) {
304 asynPrint(mAsynUser, ASYN_TRACE_ERROR, "%s::%s feature=%s %s=%s\n",
305 className, functionName, mFeatureName.c_str(), errorSource, errorWhat);
306 }
307 asynUser *mAsynUser;
308 EGRABBER_CALLBACK *mGrabber;
309 std::string mFeatureName;
310 bool mIsImplemented;
311
312};
313
314#endif
EGrabber< CallbackSingleThread > EGRABBER_CALLBACK
Definition ADEuresys.h:11
GCFeatureType_t
Definition GenICamFeature.h:13
Main driver class inherited from areaDetectors ADDriver class.
Definition ADEuresys.h:30
EGRABBER_CALLBACK * getGrabber()
Definition ADEuresys.cpp:148
Definition EuresysFeature.h:14
bool readBoolean()
Definition EuresysFeature.h:140
std::string readString()
Definition EuresysFeature.h:248
EuresysFeature(GenICamFeatureSet *set, std::string const &asynName, asynParamType asynType, int asynIndex, std::string const &featureName, GCFeatureType_t featureType)
Definition EuresysFeature.h:17
double readDoubleMin()
Definition EuresysFeature.h:187
epicsInt64 readIntegerMin()
Definition EuresysFeature.h:94
void writeString(std::string const &value)
Definition EuresysFeature.h:260
void writeCommand()
Definition EuresysFeature.h:270
void writeDouble(double value)
Definition EuresysFeature.h:177
void writeBoolean(bool bval)
Definition EuresysFeature.h:152
epicsInt64 readIncrement()
Definition EuresysFeature.h:118
bool isImplemented()
Definition EuresysFeature.h:39
bool isReadable()
Definition EuresysFeature.h:56
bool isWritable()
Definition EuresysFeature.h:69
void writeInteger(epicsInt64 value)
Definition EuresysFeature.h:130
std::string readEnumString()
Definition EuresysFeature.h:233
epicsInt64 readIntegerMax()
Definition EuresysFeature.h:106
bool isAvailable()
Definition EuresysFeature.h:43
void readEnumChoices(std::vector< std::string > &enumStrings, std::vector< int > &enumValues)
Definition EuresysFeature.h:280
double readDoubleMax()
Definition EuresysFeature.h:199
epicsInt64 readInteger()
Definition EuresysFeature.h:82
void writeEnumString(std::string const &value)
Definition EuresysFeature.h:245
double readDouble()
Definition EuresysFeature.h:165
void writeEnumIndex(int value)
Definition EuresysFeature.h:223
int readEnumIndex()
Definition EuresysFeature.h:211
Definition GenICamFeature.h:41
GenICamFeatureSet * mSet
Definition GenICamFeature.h:65
Definition GenICamFeature.h:123
asynPortDriver * getPortDriver(void)
Definition GenICamFeature.cpp:587