areaDetector  3-5-0
EPICS areaDetector framework
eigerParam.h
Go to the documentation of this file.
1 #ifndef EIGER_PARAM_H
2 #define EIGER_PARAM_H
3 
4 #include <string>
5 #include <vector>
6 #include <map>
7 #include <asynPortDriver.h>
8 #include <frozen.h>
9 
10 #include "restApi.h"
11 
12 typedef enum
13 {
23 
24 typedef enum
25 {
30 
31 typedef struct
32 {
33  bool exists;
34  union
35  {
36  int valInt;
37  double valDouble;
38  };
40 
41 class EigerParamSet;
42 
44 {
45 
46 private:
47  EigerParamSet *mSet;
48  std::string mAsynName;
49  asynParamType mAsynType;
50  sys_t mSubSystem;
51  std::string mName;
52  bool mRemote;
53 
54  int mAsynIndex;
55  eiger_param_type_t mType;
56  eiger_access_mode_t mAccessMode;
57  eiger_min_max_t mMin, mMax;
58  std::vector <std::string> mEnumValues, mCriticalValues;
59  double mEpsilon;
60  bool mCustomEnum;
61 
62  std::vector<std::string> parseArray (struct json_token *tokens,
63  std::string const & name = "");
64  int parseType (struct json_token *tokens, eiger_param_type_t & type);
65  int parseAccessMode (struct json_token *tokens,
66  eiger_access_mode_t & accessMode);
67  int parseMinMax (struct json_token *tokens, std::string const & key,
68  eiger_min_max_t & minMax);
69 
70  int parseValue (struct json_token *tokens, std::string & rawValue);
71  int parseValue (std::string const & rawValue, bool & value);
72  int parseValue (std::string const & rawValue, int & value);
73  int parseValue (std::string const & rawValue, double & value);
74 
75  std::string toString (bool value);
76  std::string toString (int value);
77  std::string toString (double value);
78  std::string toString (std::string const & value);
79 
80  int getEnumIndex (std::string const & value, size_t & index);
81  bool isCritical (std::string const & value);
82 
83  int getParam (int & value);
84  int getParam (double & value);
85  int getParam (std::string & value);
86 
87  int setParam (int value);
88  int setParam (double value);
89  int setParam (std::string const & value);
90 
91  int baseFetch (std::string & rawValue, int timeout = DEFAULT_TIMEOUT);
92  int basePut (std::string const & rawValue, int timeout = DEFAULT_TIMEOUT);
93 
94 public:
95  EigerParam (EigerParamSet *set, std::string const & asynName,
96  asynParamType asynType, sys_t ss = (sys_t) 0,
97  std::string const & name = "");
98 
99  void setEpsilon (double epsilon);
100  int getIndex (void);
101  void setEnumValues (std::vector<std::string> const & values);
102 
103  // Get the underlying asyn parameter value
104  int get (bool & value);
105  int get (int & value);
106  int get (double & value);
107  int get (std::string & value);
108 
109  // Fetch the current value from the detector, update underlying asyn parameter
110  // and return the value
111  int fetch (void);
112  int fetch (bool & value, int timeout = DEFAULT_TIMEOUT);
113  int fetch (int & value, int timeout = DEFAULT_TIMEOUT);
114  int fetch (double & value, int timeout = DEFAULT_TIMEOUT);
115  int fetch (std::string & value, int timeout = DEFAULT_TIMEOUT);
116 
117  // Put the value both to the detector (if it is connected to a detector
118  // parameter) and to the underlying asyn parameter if successful. Update
119  // other modified parameters automatically.
120  int put (bool value, int timeout = DEFAULT_TIMEOUT);
121  int put (int value, int timeout = DEFAULT_TIMEOUT);
122  int put (double value, int timeout = DEFAULT_TIMEOUT);
123  int put (std::string const & value, int timeout = DEFAULT_TIMEOUT);
124  int put (const char *value, int timeout = DEFAULT_TIMEOUT);
125 };
126 
127 typedef std::map<std::string, EigerParam*> eiger_param_map_t;
128 typedef std::map<int, EigerParam*> eiger_asyn_map_t;
129 
131 {
132 private:
133  asynPortDriver *mPortDriver;
134  RestAPI *mApi;
135  asynUser *mUser;
136 
137  eiger_param_map_t mDetConfigMap;
138  eiger_asyn_map_t mAsynMap;
139 
140 public:
141  EigerParamSet (asynPortDriver *portDriver, RestAPI *api, asynUser *user);
142 
143  EigerParam *create(std::string const & asynName, asynParamType asynType,
144  sys_t ss = (sys_t)0, std::string const & name = "");
145 
147  RestAPI *getApi (void);
149  EigerParam *getByIndex (int index);
150  asynUser *getUser (void);
151  int fetchAll (void);
152 
153  int fetchParams (std::vector<std::string> const & params);
154 };
155 
156 
157 
158 #endif
std::map< std::string, EigerParam * > eiger_param_map_t
Definition: eigerParam.h:127
Definition: eigerParam.h:28
Definition: restApi.h:39
Definition: eigerParam.h:26
Definition: eigerParam.h:27
Base class for asyn port drivers; handles most of the bookkeeping for writing an asyn port driver wit...
Definition: asynPortDriver.h:41
int put(bool value, int timeout=DEFAULT_TIMEOUT)
Definition: eigerParam.cpp:747
Definition: eigerParam.h:18
name
Definition: makeDbAndEdl.py:232
Definition: eigerParam.h:31
int fetchAll(void)
Definition: eigerParam.cpp:984
eiger_access_mode_t
Definition: eigerParam.h:24
list value
Definition: makeDbAndEdl.py:234
Definition: eigerParam.h:19
bool exists
Definition: eigerParam.h:33
RestAPI * getApi(void)
Definition: eigerParam.cpp:956
EigerParam(EigerParamSet *set, std::string const &asynName, asynParamType asynType, sys_t ss=(sys_t) 0, std::string const &name="")
Definition: eigerParam.cpp:305
int fetchParams(std::vector< std::string > const &params)
Definition: eigerParam.cpp:995
double valDouble
Definition: eigerParam.h:37
eiger_param_type_t
Definition: eigerParam.h:12
Definition: eigerParam.h:130
asynUser * getUser(void)
Definition: eigerParam.cpp:979
asynPortDriver * getPortDriver(void)
Definition: eigerParam.cpp:951
Definition: eigerParam.h:21
Definition: eigerParam.h:14
Definition: eigerParam.h:15
int valInt
Definition: eigerParam.h:36
Definition: eigerParam.h:17
void setEnumValues(std::vector< std::string > const &values)
Definition: eigerParam.cpp:357
Definition: eigerParam.h:20
EigerParamSet(asynPortDriver *portDriver, RestAPI *api, asynUser *user)
Definition: eigerParam.cpp:935
int fetch(void)
Definition: eigerParam.cpp:687
void setEpsilon(double epsilon)
Definition: eigerParam.cpp:347
#define DEFAULT_TIMEOUT
Definition: restApi.h:8
Definition: eigerParam.h:43
int getIndex(void)
Definition: eigerParam.cpp:352
Definition: NDFileHDF5Layout.h:42
EigerParam * getByName(std::string const &name)
Definition: eigerParam.cpp:961
EigerParam * create(std::string const &asynName, asynParamType asynType, sys_t ss=(sys_t) 0, std::string const &name="")
Definition: eigerParam.cpp:940
int get(bool &value)
Definition: eigerParam.cpp:363
sys_t
Definition: restApi.h:14
EigerParam * getByIndex(int index)
Definition: eigerParam.cpp:970
Definition: eigerParam.h:16
std::map< int, EigerParam * > eiger_asyn_map_t
Definition: eigerParam.h:128