ifw-fcf  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
adcConfig.hpp
Go to the documentation of this file.
1 
9 #ifndef FCF_DEVMGR_DEVICE_ADC_CONFIG_HPP
10 #define FCF_DEVMGR_DEVICE_ADC_CONFIG_HPP
11 
12 #include <string>
13 #include <yaml-cpp/yaml.h>
14 #include "fcf/common/iComm.hpp"
15 
21 
22 namespace fcf {
23  namespace devmgr {
24  namespace adc {
25 
26  // Constants for internal mapping
27  // Specifics Adc status values
28  constexpr auto CI_MOTOR_MAP_FILE = "mapMotorFile";
29 
30  constexpr auto CI_AXES = "axes";
31  constexpr auto CI_FOCUS_SIGN = "focus_sign";
32  constexpr auto CI_DIR_SIGN = "dir_sign";
33  constexpr auto CI_STAT_REF = "off_ref";
34  constexpr auto CI_STAT_AUTO = "auto_ref";
35 
36  constexpr auto CI_LATITUDE = "latitude";
37  constexpr auto CI_LONGITUDE = "longitude";
38  constexpr auto CI_TRK_PERIOD = "trk_period";
39  constexpr auto CI_TRK_THRESHOLD = "trk_threshold";
40 
41  constexpr auto CI_PSLOPE = "pslope";
42  constexpr auto CI_POFFSET = "poffset";
43  constexpr auto CI_TSLOPE = "tslope";
44  constexpr auto CI_TOFFSET = "toffset";
45  constexpr auto CI_AFACTOR = "afactor";
46  constexpr auto CI_ZDLIMIT = "zdlimit";
47  constexpr auto CI_MINELEV = "minelev";
48 
49  constexpr auto CI_MOT1_SIGN_OFF = "mot1_signoff";
50  constexpr auto CI_MOT2_SIGN_OFF = "mot2_signoff";
51  constexpr auto CI_MOT1_SIGN_AUTO = "mot1_signauto";
52  constexpr auto CI_MOT2_SIGN_AUTO = "mot2_signauto";
53  constexpr auto CI_MOT1_SIGN_PHI = "mot1_signphi";
54  constexpr auto CI_MOT2_SIGN_PHI = "mot2_signphi";
55  constexpr auto CI_MOT1_REF_OFF = "mot1_refoff";
56  constexpr auto CI_MOT2_REF_OFF = "mot2_refoff";
57  constexpr auto CI_MOT1_REF_AUTO = "mot1_refauto";
58  constexpr auto CI_MOT2_REF_AUTO = "mot2_refauto";
59  constexpr auto CI_MOT1_COFFSET = "mot1_coffset";
60  constexpr auto CI_MOT2_COFFSET = "mot2_coffset";
61  constexpr auto CI_MOT1_POSOFFSET = "mot1_poffset";
62  constexpr auto CI_MOT2_POSOFFSET = "mot2_poffset";
63  constexpr auto CI_MOT1_DROTFACTOR = "mot1_drotfactor";
64  constexpr auto CI_MOT2_DROTFACTOR = "mot2_drotfactor";
65 
66 
67  // Specific Adc RPC
68  constexpr auto RPC_MOVE_ANGLE = "rpcMoveAngle";
69  constexpr auto RPC_START_TRACK = "rpcStartTrack";
70  constexpr auto RPC_STOP_TRACK = "rpcStopTrack";
71 
72 
73  // Specific constant values for Adc device state/substate
74 
75  constexpr int SUBSTATE_RESETTING = 109;
76  constexpr int SUBSTATE_ENABLING = 110;
77 
78  constexpr int SUBSTATE_OP_TRACKING = 220;
79  constexpr int SUBSTATE_OP_PRESETTING = 221;
80 
81  constexpr auto SUBSTATE_RESETTING_STR = "Resetting";
82  constexpr auto SUBSTATE_ENABLING_STR = "Enabling";
83  constexpr auto SUBSTATE_OP_TRACKING_STR = "Tracking";
84  constexpr auto SUBSTATE_OP_PRESETTING_STR = "Presetting";
85 
86 
87 
88  const std::unordered_map<short, std::string> SubstateMap = {
103  };
104 
105  constexpr short TRK_MODE_ENG = 0;
106  constexpr short TRK_MODE_OFF = 1;
107  constexpr short TRK_MODE_AUTO = 2;
108 
109 
110  constexpr auto TRK_MODE_ENG_STR = "eng";
111  constexpr auto TRK_MODE_OFF_STR = "off";
112  constexpr auto TRK_MODE_AUTO_STR = "auto";
113 
114 
115  const std::unordered_map<short, std::string> TrkModeMap = {
119  };
120 
121  constexpr auto CI_STAT_TRACK_MODE = "track_mode";
122  constexpr auto CI_STAT_ALPHA = "alpha";
123  constexpr auto CI_STAT_DELTA = "delta";
124 
125 
126  const std::vector<std::string> cfgMapping = {
127  };
128 
129  const std::vector<std::string> statMapping = {
136  };
137 
138  const std::vector<std::string> rpcMapping = {
147  };
148 
157  {
158 
159  // Enumerations of configuration paramters:
160  // C++ doesn not allow inheritance of enums so we are using the last
161  // enum of the parent class to continue with the enumerations and thus
162  // avoid the collission.
163  enum {
164  CFG_PSLOPE,
165  CFG_POFFSET,
166  CFG_TSLOPE,
167  CFG_TOFFSET,
168  CFG_AFACTOR,
169  CFG_ZDLIMIT,
170  CFG_MINELEV,
171  CFG_MOT1_SIGN_OFF,
172  CFG_MOT2_SIGN_OFF,
173  CFG_MOT1_SIGN_AUTO,
174  CFG_MOT2_SIGN_AUTO,
175  CFG_MOT1_SIGN_PHI,
176  CFG_MOT2_SIGN_PHI,
177  CFG_MOT1_REF_OFF,
178  CFG_MOT2_REF_OFF,
179  CFG_MOT1_REF_AUTO,
180  CFG_MOT2_REF_AUTO,
181  CFG_MOT1_COFFSET,
182  CFG_MOT2_COFFSET,
183  CFG_MOT1_POSOFFSET,
184  CFG_MOT2_POSOFFSET,
185  CFG_MOT1_DROTFACTOR,
186  CFG_MOT2_DROTFACTOR,
187  CFG_LATITUDE,
188  CFG_LONGITUDE,
189  CFG_TRK_PERIOD,
190  CFG_TRK_THRESHOLD,
191  END_ENUM_ADC // WARNING: This should be always last enumerator.
192  };
193 
194 
195  public:
196 
202  AdcConfig(const std::string filename,
203  const std::string name);
204 
208  virtual ~AdcConfig();
209 
218  virtual void ReadConfig();
219 
227  virtual void GetConfig(fcf::common::VectorVariant& params);
228 
229 
238  virtual void GetMotorConfig(fcf::common::VectorVariant& params);
239 
240  virtual void GetMotorConfig(const std::string motor, fcf::common::VectorVariant& params);
241 
242  virtual void SetScaleFactor(const std::string motor, double scale_factor);
243 
244 
245 
255  virtual void GetConfigList(std::vector<std::string>& cfg_list,
256  std::string prefix);
257 
258 
263  virtual std::string GetMotorMapFile();
264 
269  virtual std::string GetMotorType();
270 
275  virtual std::string GetMotorPrefix(const std::string motor);
276 
277  void GetMotorNames(std::vector<std::string>& motor_names);
278 
279  void GetMotorPrefixes(std::vector<std::string>& motor_prefixes);
280 
281  double GetMotorVelocity(const int axis_num);
282 
283  double GetMotorScaleFactor(const int axis_num);
284 
285  double GetMotorScaleFactor(const std::string motor_name);
286 
287  std::string GetMotorName(const std::string nodeid);
288 
289  protected:
290  // All configuration parameters related to the LCS are stored in
291  // dedicated STL maps to make them easilly accessible when downloading
292  // the configuration to the LCS.
297 
299 
300 
301 
303  std::map<std::string, std::unique_ptr<devmgr::motor::MotorConfig>> m_motor_config_map;
304 
307  std::map<std::string, std::string> m_motor_prefix_map;
308 
309  };
310  }
311  }
312 }
313 
314 #endif //FCF_DEVMGR_DEVICE_ADC_CONFIG_H
constexpr auto CI_LATITUDE
Definition: adcConfig.hpp:36
constexpr auto CI_STAT_LOCAL
Definition: deviceConfig.hpp:53
constexpr auto CI_MOT2_COFFSET
Definition: adcConfig.hpp:60
std::string GetMotorName(const std::string nodeid)
Definition: adcConfig.cpp:389
constexpr int SUBSTATE_ENABLING
Definition: adcConfig.hpp:76
devmgr::common::MapCfgBool m_map_cfg_bool
Definition: adcConfig.hpp:293
devmgr::common::MapCfgUInt m_map_cfg_uint
Definition: adcConfig.hpp:295
constexpr auto RPC_INIT
Definition: deviceConfig.hpp:43
constexpr int SUBSTATE_INITIALISING
Definition: deviceConfig.hpp:84
virtual std::string GetMotorMapFile()
Definition: adcConfig.cpp:258
constexpr auto RPC_STOP_TRACK
Definition: adcConfig.hpp:70
constexpr auto SUBSTATE_NOTREADY_STR
Definition: deviceConfig.hpp:87
constexpr auto RPC_MOVE_ANGLE
Definition: adcConfig.hpp:68
virtual void GetMotorConfig(fcf::common::VectorVariant &params)
Obtain the list of ADC motor configuration parameters.
Definition: adcConfig.cpp:191
constexpr auto SUBSTATE_OP_TRACKING_STR
Definition: adcConfig.hpp:83
constexpr auto SUBSTATE_OP_STOPPING_STR
Definition: motorConfig.hpp:125
constexpr auto CI_ZDLIMIT
Definition: adcConfig.hpp:46
const std::vector< std::string > statMapping
Definition: adcConfig.hpp:129
AdcHwErrors header file.
constexpr auto CI_MOT1_REF_AUTO
Definition: adcConfig.hpp:57
constexpr auto CI_STAT_DELTA
Definition: adcConfig.hpp:123
constexpr auto CI_MOT1_COFFSET
Definition: adcConfig.hpp:59
constexpr auto CI_MOT1_SIGN_PHI
Definition: adcConfig.hpp:53
constexpr auto SUBSTATE_OP_DISABLING_STR
Definition: deviceConfig.hpp:95
constexpr int SUBSTATE_OP_STANDSTILL
Definition: motorConfig.hpp:115
constexpr auto CI_FOCUS_SIGN
Definition: adcConfig.hpp:31
constexpr auto CI_MOT1_POSOFFSET
Definition: adcConfig.hpp:61
virtual std::string GetMotorType()
Definition: adcConfig.cpp:277
std::map< std::string, std::unique_ptr< devmgr::motor::MotorConfig > > m_motor_config_map
Maps of ADC axes configuration.
Definition: adcConfig.hpp:303
constexpr auto CI_MOT1_REF_OFF
Definition: adcConfig.hpp:55
constexpr auto CI_MOTOR_MAP_FILE
Definition: adcConfig.hpp:28
int m_num_axis
Definition: adcConfig.hpp:298
virtual std::string GetMotorPrefix(const std::string motor)
Definition: adcConfig.cpp:289
constexpr auto CI_STAT_SUBSTATE
Definition: deviceConfig.hpp:50
constexpr auto RPC_DISABLE
Definition: deviceConfig.hpp:45
constexpr auto CI_STAT_TRACK_MODE
Definition: adcConfig.hpp:121
constexpr auto CI_MINELEV
Definition: adcConfig.hpp:47
constexpr auto CI_AFACTOR
Definition: adcConfig.hpp:45
constexpr int SUBSTATE_OP_DISABLING
Definition: deviceConfig.hpp:92
constexpr auto CI_TSLOPE
Definition: adcConfig.hpp:43
virtual void ReadConfig()
Read the configuration.
Definition: adcConfig.cpp:87
constexpr int SUBSTATE_OP_STOPPING
Definition: motorConfig.hpp:118
constexpr int SUBSTATE_OP_MOVING
Definition: motorConfig.hpp:116
constexpr auto CI_MOT2_POSOFFSET
Definition: adcConfig.hpp:62
constexpr short TRK_MODE_ENG
Definition: adcConfig.hpp:105
const std::unordered_map< short, std::string > TrkModeMap
Definition: adcConfig.hpp:115
constexpr auto CI_STAT_REF
Definition: adcConfig.hpp:33
constexpr auto TRK_MODE_AUTO_STR
Definition: adcConfig.hpp:112
const std::vector< std::string > cfgMapping
Definition: adcConfig.hpp:126
virtual ~AdcConfig()
DeviceConfig destructor.
Definition: adcConfig.cpp:83
constexpr auto SUBSTATE_ENABLING_STR
Definition: adcConfig.hpp:82
virtual void SetScaleFactor(const std::string motor, double scale_factor)
Definition: adcConfig.cpp:317
constexpr auto TRK_MODE_ENG_STR
Definition: adcConfig.hpp:110
constexpr auto CI_PSLOPE
Definition: adcConfig.hpp:41
configSet class header file.
std::map< int, CfgBool > MapCfgBool
Definition: deviceConfig.hpp:112
void GetMotorPrefixes(std::vector< std::string > &motor_prefixes)
Definition: adcConfig.cpp:309
constexpr short TRK_MODE_AUTO
Definition: adcConfig.hpp:107
constexpr auto CI_MOT2_SIGN_OFF
Definition: adcConfig.hpp:50
constexpr int SUBSTATE_ABORTING
Definition: motorConfig.hpp:114
constexpr auto RPC_STOP
Definition: deviceConfig.hpp:46
constexpr short TRK_MODE_OFF
Definition: adcConfig.hpp:106
constexpr auto CI_STAT_STATE
Definition: deviceConfig.hpp:51
constexpr auto SUBSTATE_RESETTING_STR
Definition: adcConfig.hpp:81
constexpr int SUBSTATE_RESETTING
Definition: adcConfig.hpp:75
constexpr auto SUBSTATE_OP_PRESETTING_STR
Definition: adcConfig.hpp:84
constexpr int SUBSTATE_NOTREADY
Definition: deviceConfig.hpp:82
constexpr int SUBSTATE_OP_PRESETTING
Definition: adcConfig.hpp:79
constexpr auto CI_MOT2_REF_OFF
Definition: adcConfig.hpp:56
devmgr::common::MapCfgDouble m_map_cfg_double
Definition: adcConfig.hpp:296
virtual void GetConfig(fcf::common::VectorVariant &params)
Obtain the list of configuration parameters.
Definition: adcConfig.cpp:169
constexpr auto CI_DIR_SIGN
Definition: adcConfig.hpp:32
constexpr auto SUBSTATE_OP_MOVING_STR
Definition: motorConfig.hpp:123
constexpr auto CI_STAT_AUTO
Definition: adcConfig.hpp:34
constexpr auto RPC_START_TRACK
Definition: adcConfig.hpp:69
DataContext class header file.
virtual void GetConfigList(std::vector< std::string > &cfg_list, std::string prefix)
Get configuration list.
Definition: adcConfig.cpp:209
std::map< int, CfgUInt > MapCfgUInt
Definition: deviceConfig.hpp:115
std::map< int, CfgInt > MapCfgInt
Definition: deviceConfig.hpp:114
constexpr auto CI_MOT1_SIGN_AUTO
Definition: adcConfig.hpp:51
constexpr auto SUBSTATE_OP_ERROR_STR
Definition: deviceConfig.hpp:96
const std::unordered_map< short, std::string > SubstateMap
Definition: adcConfig.hpp:88
constexpr auto SUBSTATE_INITIALISING_STR
Definition: deviceConfig.hpp:88
constexpr auto CI_TRK_THRESHOLD
Definition: adcConfig.hpp:39
std::map< int, CfgDouble > MapCfgDouble
Definition: deviceConfig.hpp:116
constexpr auto CI_MOT2_SIGN_PHI
Definition: adcConfig.hpp:54
constexpr auto SUBSTATE_READY_STR
Definition: deviceConfig.hpp:89
constexpr auto CI_TOFFSET
Definition: adcConfig.hpp:44
constexpr auto TRK_MODE_OFF_STR
Definition: adcConfig.hpp:111
constexpr auto CI_MOT1_DROTFACTOR
Definition: adcConfig.hpp:63
constexpr auto CI_MOT2_SIGN_AUTO
Definition: adcConfig.hpp:52
constexpr auto SUBSTATE_OP_STANDSTILL_STR
Definition: motorConfig.hpp:122
constexpr auto CI_STAT_ALPHA
Definition: adcConfig.hpp:122
constexpr auto CI_TRK_PERIOD
Definition: adcConfig.hpp:38
constexpr int SUBSTATE_OP_ERROR
Definition: deviceConfig.hpp:93
const std::vector< std::string > rpcMapping
Definition: adcConfig.hpp:138
constexpr auto RPC_RESET
Definition: deviceConfig.hpp:47
Device Configuration class.
Definition: deviceConfig.hpp:125
constexpr auto CI_MOT2_DROTFACTOR
Definition: adcConfig.hpp:64
constexpr auto CI_POFFSET
Definition: adcConfig.hpp:42
constexpr int SUBSTATE_ERROR
Definition: deviceConfig.hpp:85
MotorConfig class header file.
std::map< std::string, std::string > m_motor_prefix_map
Definition: adcConfig.hpp:307
adc Configuration class
Definition: adcConfig.hpp:156
void GetMotorNames(std::vector< std::string > &motor_names)
Definition: adcConfig.cpp:301
AdcRpcErrors header file.
constexpr auto CI_MOT1_SIGN_OFF
Definition: adcConfig.hpp:49
constexpr auto CI_MOT2_REF_AUTO
Definition: adcConfig.hpp:58
constexpr auto RPC_ENABLE
Definition: deviceConfig.hpp:44
constexpr auto SUBSTATE_ABORTING_STR
Definition: motorConfig.hpp:121
double GetMotorVelocity(const int axis_num)
Definition: adcConfig.cpp:325
constexpr auto SUBSTATE_ERROR_STR
Definition: deviceConfig.hpp:90
AdcConfig(const std::string filename, const std::string name)
DeviceConfig constructor.
Definition: adcConfig.cpp:29
constexpr int SUBSTATE_OP_TRACKING
Definition: adcConfig.hpp:78
constexpr auto CI_AXES
Definition: adcConfig.hpp:30
double GetMotorScaleFactor(const int axis_num)
Definition: adcConfig.cpp:353
constexpr int SUBSTATE_READY
Definition: deviceConfig.hpp:83
constexpr auto CI_LONGITUDE
Definition: adcConfig.hpp:37
devmgr::common::MapCfgInt m_map_cfg_int
Definition: adcConfig.hpp:294