areaDetector  3-14
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 
146  asynPortDriver *getPortDriver (void);
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
Definition: eigerParam.h:44
EigerParam(EigerParamSet *set, std::string const &asynName, asynParamType asynType, sys_t ss=(sys_t) 0, std::string const &name="")
Definition: eigerParam.cpp:307
int fetch(void)
Definition: eigerParam.cpp:699
int get(bool &value)
Definition: eigerParam.cpp:365
void setEnumValues(std::vector< std::string > const &values)
Definition: eigerParam.cpp:359
int getIndex(void)
Definition: eigerParam.cpp:354
int put(bool value, int timeout=DEFAULT_TIMEOUT)
Definition: eigerParam.cpp:759
void setEpsilon(double epsilon)
Definition: eigerParam.cpp:349
Definition: eigerParam.h:131
EigerParam * getByIndex(int index)
Definition: eigerParam.cpp:982
int fetchParams(std::vector< std::string > const &params)
Definition: eigerParam.cpp:1007
RestAPI * getApi(void)
Definition: eigerParam.cpp:968
int fetchAll(void)
Definition: eigerParam.cpp:996
EigerParam * create(std::string const &asynName, asynParamType asynType, sys_t ss=(sys_t) 0, std::string const &name="")
Definition: eigerParam.cpp:952
EigerParamSet(asynPortDriver *portDriver, RestAPI *api, asynUser *user)
Definition: eigerParam.cpp:947
asynPortDriver * getPortDriver(void)
Definition: eigerParam.cpp:963
EigerParam * getByName(std::string const &name)
Definition: eigerParam.cpp:973
asynUser * getUser(void)
Definition: eigerParam.cpp:991
Definition: restApi.h:45
std::map< std::string, EigerParam * > eiger_param_map_t
Definition: eigerParam.h:127
eiger_access_mode_t
Definition: eigerParam.h:25
@ EIGER_ACC_RW
Definition: eigerParam.h:27
@ EIGER_ACC_WO
Definition: eigerParam.h:28
@ EIGER_ACC_RO
Definition: eigerParam.h:26
std::map< int, EigerParam * > eiger_asyn_map_t
Definition: eigerParam.h:128
eiger_param_type_t
Definition: eigerParam.h:13
@ EIGER_P_UNINIT
Definition: eigerParam.h:14
@ EIGER_P_ENUM
Definition: eigerParam.h:20
@ EIGER_P_INT
Definition: eigerParam.h:16
@ EIGER_P_COMMAND
Definition: eigerParam.h:21
@ EIGER_P_BOOL
Definition: eigerParam.h:15
@ EIGER_P_UINT
Definition: eigerParam.h:17
@ EIGER_P_DOUBLE
Definition: eigerParam.h:18
@ EIGER_P_STRING
Definition: eigerParam.h:19
@ string
Definition: NDFileHDF5Layout.h:44
name
Definition: makeDbAndEdl.py:232
list value
Definition: makeDbAndEdl.py:234
sys_t
Definition: restApi.h:20
#define DEFAULT_TIMEOUT
Definition: restApi.h:8
Definition: eigerParam.h:32
double valDouble
Definition: eigerParam.h:37
int valInt
Definition: eigerParam.h:36
bool exists
Definition: eigerParam.h:33