ifw-fcf  4.0.0
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 
16 #include <utils/bat/logger.hpp>
22 
23 namespace fcf::devmgr::adc {
24 
25 
26  constexpr auto LOGGER_NAME = "adc";
27  // Constants for internal mapping
28  // Specifics Adc status values
29  constexpr auto CI_MOTOR_MAP_FILE = "mapMotorFile";
30 
31  constexpr auto CI_AXES = "motors";
32  constexpr auto CI_FOCUS_SIGN = "focus_sign";
33  constexpr auto CI_DIR_SIGN = "dir_sign";
34  constexpr auto CI_STAT_REF = "off_ref";
35  constexpr auto CI_STAT_AUTO = "auto_ref";
36 
37  constexpr auto CI_LATITUDE = "latitude";
38  constexpr auto CI_LONGITUDE = "longitude";
39  constexpr auto CI_TRK_PERIOD = "trk_period";
40  constexpr auto CI_TRK_THRESHOLD = "trk_threshold";
41 
42  constexpr auto CI_PSLOPE = "pslope";
43  constexpr auto CI_POFFSET = "poffset";
44  constexpr auto CI_TSLOPE = "tslope";
45  constexpr auto CI_TOFFSET = "toffset";
46  constexpr auto CI_AFACTOR = "afactor";
47  constexpr auto CI_ZDLIMIT = "zdlimit";
48  constexpr auto CI_MINELEV = "minelev";
49 
50  constexpr auto CI_MOT1_SIGN_OFF = "mot1_signoff";
51  constexpr auto CI_MOT2_SIGN_OFF = "mot2_signoff";
52  constexpr auto CI_MOT1_SIGN_AUTO = "mot1_signauto";
53  constexpr auto CI_MOT2_SIGN_AUTO = "mot2_signauto";
54  constexpr auto CI_MOT1_SIGN_PHI = "mot1_signphi";
55  constexpr auto CI_MOT2_SIGN_PHI = "mot2_signphi";
56  constexpr auto CI_MOT1_REF_OFF = "mot1_refoff";
57  constexpr auto CI_MOT2_REF_OFF = "mot2_refoff";
58  constexpr auto CI_MOT1_REF_AUTO = "mot1_refauto";
59  constexpr auto CI_MOT2_REF_AUTO = "mot2_refauto";
60  constexpr auto CI_MOT1_COFFSET = "mot1_coffset";
61  constexpr auto CI_MOT2_COFFSET = "mot2_coffset";
62  constexpr auto CI_MOT1_POSOFFSET = "mot1_poffset";
63  constexpr auto CI_MOT2_POSOFFSET = "mot2_poffset";
64  constexpr auto CI_MOT1_DROTFACTOR = "mot1_drotfactor";
65  constexpr auto CI_MOT2_DROTFACTOR = "mot2_drotfactor";
66 
67 
68  // Specific Adc RPC
69  constexpr auto RPC_MOVE_ANGLE = "rpcMoveAngle";
70  constexpr auto RPC_START_TRACK = "rpcStartTrack";
71  constexpr auto RPC_STOP_TRACK = "rpcStopTrack";
72 
73 
74  // Specific constant values for Adc device state/substate
75 
76  constexpr int SUBSTATE_RESETTING = 109;
77  constexpr int SUBSTATE_ENABLING = 110;
78 
79  constexpr int SUBSTATE_OP_TRACKING = 220;
80  constexpr int SUBSTATE_OP_PRESETTING = 221;
81 
82  constexpr auto SUBSTATE_RESETTING_STR = "Resetting";
83  constexpr auto SUBSTATE_ENABLING_STR = "Enabling";
84  constexpr auto SUBSTATE_OP_TRACKING_STR = "Tracking";
85  constexpr auto SUBSTATE_OP_PRESETTING_STR = "Presetting";
86 
87 
88 
89  const std::unordered_map<short, std::string> SubstateMap = {
104  };
105 
106  constexpr short TRK_MODE_ENG = 0;
107  constexpr short TRK_MODE_OFF = 1;
108  constexpr short TRK_MODE_AUTO = 2;
109 
110 
111  constexpr auto TRK_MODE_ENG_STR = "eng";
112  constexpr auto TRK_MODE_OFF_STR = "off";
113  constexpr auto TRK_MODE_AUTO_STR = "auto";
114 
115 
116  const std::unordered_map<short, std::string> TrkModeMap = {
120  };
121 
122  constexpr auto CI_STAT_TRACK_MODE = "track_mode";
123  constexpr auto CI_STAT_ALPHA = "alpha";
124  constexpr auto CI_STAT_DELTA = "delta";
125 
126 
127 
128 
137  {
138 
139  // Enumerations of configuration paramters:
140  // C++ doesn not allow inheritance of enums so we are using the last
141  // enum of the parent class to continue with the enumerations and thus
142  // avoid the collission.
143  enum {
144  CFG_PSLOPE,
145  CFG_POFFSET,
146  CFG_TSLOPE,
147  CFG_TOFFSET,
148  CFG_AFACTOR,
149  CFG_ZDLIMIT,
150  CFG_MINELEV,
151  CFG_MOT1_SIGN_OFF,
152  CFG_MOT2_SIGN_OFF,
153  CFG_MOT1_SIGN_AUTO,
154  CFG_MOT2_SIGN_AUTO,
155  CFG_MOT1_SIGN_PHI,
156  CFG_MOT2_SIGN_PHI,
157  CFG_MOT1_REF_OFF,
158  CFG_MOT2_REF_OFF,
159  CFG_MOT1_REF_AUTO,
160  CFG_MOT2_REF_AUTO,
161  CFG_MOT1_COFFSET,
162  CFG_MOT2_COFFSET,
163  CFG_MOT1_POSOFFSET,
164  CFG_MOT2_POSOFFSET,
165  CFG_MOT1_DROTFACTOR,
166  CFG_MOT2_DROTFACTOR,
167  CFG_LATITUDE,
168  CFG_LONGITUDE,
169  CFG_TRK_PERIOD,
170  CFG_TRK_THRESHOLD,
171  END_ENUM_ADC // WARNING: This should be always last enumerator.
172  };
173 
174 
175  public:
176 
182  AdcConfig(const std::string filename,
183  const std::string name);
184 
189  AdcConfig(const std::string name);
190 
194  virtual ~AdcConfig() = default;
195 
199  void Init();
200 
208  virtual void GetConfig(fcf::common::VectorVariant& params) const override;
209 
210 
219  virtual void GetMotorConfig(fcf::common::VectorVariant& params) const;
220 
221  virtual void GetMotorConfig(const std::string motor, fcf::common::VectorVariant& params) const;
222 
223  virtual void SetScaleFactor(const std::string motor, double scale_factor);
224 
225 
230  double GetNpTolerance() const;
231 
241  virtual void GetConfigList(utils::bat::DbVector& cfg_list,
242  std::string prefix) const override;
243 
244 
249  virtual std::string GetMotorMapFile() const;
250 
255  virtual std::string GetMotorType() const;
256 
261  std::string GetMotorPrefix(const int& index) const;
262  std::string GetMotorPrefix(const std::string& motor) const;
263  std::string GetMotorName(const int& index) const;
264 
265  void GetMotorNames(std::vector<std::string>& motor_names) const;
266 
267  void GetMotorPrefixes(std::vector<std::string>& motor_prefixes) const;
268 
269  double GetMotorVelocity(const int axis_num) const;
270 
271  double GetMotorScaleFactor(const int axis_num) const;
272 
273  double GetMotorScaleFactor(const std::string motor_name) const;
274 
275  std::string GetMotorName(const std::string nodeid) const;
276 
277  protected:
278 
279 
281 
282 
283 
285  std::map<std::string, std::unique_ptr<fcf::devmgr::motor::MotorConfig>> m_motor_config_map;
286 
289  std::map<std::string, std::string> m_motor_prefix_map;
290 
291  private:
292  log4cplus::Logger m_logger;
293  };
294 
295 } //namespace
296 
297 #endif //FCF_DEVMGR_DEVICE_ADC_CONFIG_H
fcf::devmgr::motor::SUBSTATE_OP_MOVING_STR
constexpr auto SUBSTATE_OP_MOVING_STR
Definition: motorConfig.hpp:126
fcf::devmgr::adc::CI_MOT2_SIGN_AUTO
constexpr auto CI_MOT2_SIGN_AUTO
Definition: adcConfig.hpp:53
fcf::devmgr::adc::CI_MOT1_SIGN_PHI
constexpr auto CI_MOT1_SIGN_PHI
Definition: adcConfig.hpp:54
fcf::devmgr::adc::SUBSTATE_OP_PRESETTING
constexpr int SUBSTATE_OP_PRESETTING
Definition: adcConfig.hpp:80
dataContext.hpp
DataContext class header file.
fcf::devmgr::adc::AdcConfig::m_motor_prefix_map
std::map< std::string, std::string > m_motor_prefix_map
Definition: adcConfig.hpp:289
fcf::devmgr::adc::CI_MINELEV
constexpr auto CI_MINELEV
Definition: adcConfig.hpp:48
fcf::devmgr::adc::CI_MOT1_REF_OFF
constexpr auto CI_MOT1_REF_OFF
Definition: adcConfig.hpp:56
fcf::devmgr::adc::AdcConfig
adc Configuration class
Definition: adcConfig.hpp:137
fcf::devmgr::adc::AdcConfig::~AdcConfig
virtual ~AdcConfig()=default
DeviceConfig destructor.
fcf::devmgr::adc::AdcConfig::GetNpTolerance
double GetNpTolerance() const
Get named position tolerance.
Definition: adcConfig.cpp:304
fcf::devmgr::adc::AdcConfig::GetConfigList
virtual void GetConfigList(utils::bat::DbVector &cfg_list, std::string prefix) const override
Get configuration list.
Definition: adcConfig.cpp:120
fcf::devmgr::adc::AdcConfig::GetMotorConfig
virtual void GetMotorConfig(fcf::common::VectorVariant &params) const
Obtain the list of ADC motor configuration parameters.
Definition: adcConfig.cpp:103
fcf::devmgr::adc::CI_MOT2_COFFSET
constexpr auto CI_MOT2_COFFSET
Definition: adcConfig.hpp:61
fcf::devmgr::adc::AdcConfig::m_motor_config_map
std::map< std::string, std::unique_ptr< fcf::devmgr::motor::MotorConfig > > m_motor_config_map
Maps of ADC axes configuration.
Definition: adcConfig.hpp:285
fcf::devmgr::adc::CI_ZDLIMIT
constexpr auto CI_ZDLIMIT
Definition: adcConfig.hpp:47
fcf::devmgr::adc::AdcConfig::GetMotorNames
void GetMotorNames(std::vector< std::string > &motor_names) const
Definition: adcConfig.cpp:207
fcf::devmgr::common::SUBSTATE_OP_DISABLING_STR
constexpr auto SUBSTATE_OP_DISABLING_STR
Definition: deviceConfig.hpp:107
fcf::devmgr::adc::CI_MOT2_SIGN_PHI
constexpr auto CI_MOT2_SIGN_PHI
Definition: adcConfig.hpp:55
fcf::devmgr::adc::CI_TRK_PERIOD
constexpr auto CI_TRK_PERIOD
Definition: adcConfig.hpp:39
fcf::devmgr::adc::AdcConfig::GetMotorName
std::string GetMotorName(const int &index) const
Definition: adcConfig.cpp:196
fcf::devmgr::motor::SUBSTATE_OP_MOVING
constexpr int SUBSTATE_OP_MOVING
Definition: motorConfig.hpp:119
fcf::devmgr::adc::CI_MOT2_REF_OFF
constexpr auto CI_MOT2_REF_OFF
Definition: adcConfig.hpp:57
fcf::devmgr::adc::AdcConfig::GetMotorPrefixes
void GetMotorPrefixes(std::vector< std::string > &motor_prefixes) const
Definition: adcConfig.cpp:214
fcf::devmgr::adc::LOGGER_NAME
constexpr auto LOGGER_NAME
Definition: adcConfig.hpp:26
fcf::devmgr::adc::CI_STAT_AUTO
constexpr auto CI_STAT_AUTO
Definition: adcConfig.hpp:35
fcf::devmgr::adc::CI_MOT2_DROTFACTOR
constexpr auto CI_MOT2_DROTFACTOR
Definition: adcConfig.hpp:65
fcf::devmgr::adc::AdcConfig::GetMotorType
virtual std::string GetMotorType() const
Definition: adcConfig.cpp:154
fcf::devmgr::adc::AdcConfig::AdcConfig
AdcConfig(const std::string filename, const std::string name)
DeviceConfig constructor.
Definition: adcConfig.cpp:29
fcf::devmgr::adc::AdcConfig::GetConfig
virtual void GetConfig(fcf::common::VectorVariant &params) const override
Obtain the list of configuration parameters.
Definition: adcConfig.cpp:92
fcf::devmgr::motor::SUBSTATE_ABORTING
constexpr int SUBSTATE_ABORTING
Definition: motorConfig.hpp:117
fcf::devmgr::adc::TrkModeMap
const std::unordered_map< short, std::string > TrkModeMap
Definition: adcConfig.hpp:116
fcf::devmgr::adc::CI_TSLOPE
constexpr auto CI_TSLOPE
Definition: adcConfig.hpp:44
fcf::devmgr::adc::CI_STAT_REF
constexpr auto CI_STAT_REF
Definition: adcConfig.hpp:34
fcf::devmgr::adc::SUBSTATE_RESETTING_STR
constexpr auto SUBSTATE_RESETTING_STR
Definition: adcConfig.hpp:82
fcf::devmgr::adc::CI_PSLOPE
constexpr auto CI_PSLOPE
Definition: adcConfig.hpp:42
fcf::devmgr::adc::CI_MOT1_SIGN_AUTO
constexpr auto CI_MOT1_SIGN_AUTO
Definition: adcConfig.hpp:52
fcf::devmgr::adc::SUBSTATE_OP_PRESETTING_STR
constexpr auto SUBSTATE_OP_PRESETTING_STR
Definition: adcConfig.hpp:85
fcf::devmgr::motor::SUBSTATE_OP_STANDSTILL_STR
constexpr auto SUBSTATE_OP_STANDSTILL_STR
Definition: motorConfig.hpp:125
fcf::devmgr::adc::CI_AXES
constexpr auto CI_AXES
Definition: adcConfig.hpp:31
fcf::devmgr::adc::CI_STAT_TRACK_MODE
constexpr auto CI_STAT_TRACK_MODE
Definition: adcConfig.hpp:122
fcf::devmgr::common::SUBSTATE_OP_DISABLING
constexpr int SUBSTATE_OP_DISABLING
Definition: deviceConfig.hpp:104
fcf::devmgr::adc::SUBSTATE_ENABLING
constexpr int SUBSTATE_ENABLING
Definition: adcConfig.hpp:77
fcf::devmgr::adc::CI_MOT2_SIGN_OFF
constexpr auto CI_MOT2_SIGN_OFF
Definition: adcConfig.hpp:51
fcf::devmgr::adc
Definition: adc.cpp:20
fcf::devmgr::adc::TRK_MODE_ENG
constexpr short TRK_MODE_ENG
Definition: adcConfig.hpp:106
fcf::devmgr::adc::CI_TRK_THRESHOLD
constexpr auto CI_TRK_THRESHOLD
Definition: adcConfig.hpp:40
fcf::devmgr::adc::CI_LONGITUDE
constexpr auto CI_LONGITUDE
Definition: adcConfig.hpp:38
fcf::devmgr::common::SUBSTATE_NOTREADY_STR
constexpr auto SUBSTATE_NOTREADY_STR
Definition: deviceConfig.hpp:99
configSet.hpp
configSet class header file.
fcf::devmgr::adc::CI_MOT1_POSOFFSET
constexpr auto CI_MOT1_POSOFFSET
Definition: adcConfig.hpp:62
fcf::devmgr::common::SUBSTATE_INITIALISING_STR
constexpr auto SUBSTATE_INITIALISING_STR
Definition: deviceConfig.hpp:100
fcf::devmgr::adc::CI_MOT1_SIGN_OFF
constexpr auto CI_MOT1_SIGN_OFF
Definition: adcConfig.hpp:50
fcf::devmgr::adc::CI_MOT2_POSOFFSET
constexpr auto CI_MOT2_POSOFFSET
Definition: adcConfig.hpp:63
fcf::devmgr::adc::TRK_MODE_OFF_STR
constexpr auto TRK_MODE_OFF_STR
Definition: adcConfig.hpp:112
fcf::devmgr::adc::CI_MOT1_DROTFACTOR
constexpr auto CI_MOT1_DROTFACTOR
Definition: adcConfig.hpp:64
fcf::devmgr::common::SUBSTATE_NOTREADY
constexpr int SUBSTATE_NOTREADY
Definition: deviceConfig.hpp:94
fcf::devmgr::adc::CI_STAT_DELTA
constexpr auto CI_STAT_DELTA
Definition: adcConfig.hpp:124
fcf::devmgr::common::SUBSTATE_INITIALISING
constexpr int SUBSTATE_INITIALISING
Definition: deviceConfig.hpp:96
fcf::devmgr::adc::CI_MOT1_COFFSET
constexpr auto CI_MOT1_COFFSET
Definition: adcConfig.hpp:60
fcf::devmgr::adc::SUBSTATE_OP_TRACKING_STR
constexpr auto SUBSTATE_OP_TRACKING_STR
Definition: adcConfig.hpp:84
fcf::devmgr::adc::RPC_STOP_TRACK
constexpr auto RPC_STOP_TRACK
Definition: adcConfig.hpp:71
fcf::devmgr::adc::TRK_MODE_AUTO_STR
constexpr auto TRK_MODE_AUTO_STR
Definition: adcConfig.hpp:113
fcf::devmgr::common::SUBSTATE_OP_ERROR
constexpr int SUBSTATE_OP_ERROR
Definition: deviceConfig.hpp:105
fcf::devmgr::adc::SUBSTATE_RESETTING
constexpr int SUBSTATE_RESETTING
Definition: adcConfig.hpp:76
fcf::devmgr::adc::CI_AFACTOR
constexpr auto CI_AFACTOR
Definition: adcConfig.hpp:46
fcf::devmgr::common::SUBSTATE_OP_ERROR_STR
constexpr auto SUBSTATE_OP_ERROR_STR
Definition: deviceConfig.hpp:108
fcf::devmgr::adc::CI_FOCUS_SIGN
constexpr auto CI_FOCUS_SIGN
Definition: adcConfig.hpp:32
fcf::devmgr::adc::TRK_MODE_AUTO
constexpr short TRK_MODE_AUTO
Definition: adcConfig.hpp:108
fcf::devmgr::adc::CI_TOFFSET
constexpr auto CI_TOFFSET
Definition: adcConfig.hpp:45
fcf::devmgr::adc::SubstateMap
const std::unordered_map< short, std::string > SubstateMap
Definition: adcConfig.hpp:89
fcf::devmgr::adc::CI_MOT1_REF_AUTO
constexpr auto CI_MOT1_REF_AUTO
Definition: adcConfig.hpp:58
fcf::devmgr::common::SUBSTATE_ERROR
constexpr int SUBSTATE_ERROR
Definition: deviceConfig.hpp:97
fcf::devmgr::adc::CI_LATITUDE
constexpr auto CI_LATITUDE
Definition: adcConfig.hpp:37
fcf::devmgr::adc::SUBSTATE_OP_TRACKING
constexpr int SUBSTATE_OP_TRACKING
Definition: adcConfig.hpp:79
fcf::devmgr::adc::TRK_MODE_ENG_STR
constexpr auto TRK_MODE_ENG_STR
Definition: adcConfig.hpp:111
fcf::devmgr::motor::SUBSTATE_ABORTING_STR
constexpr auto SUBSTATE_ABORTING_STR
Definition: motorConfig.hpp:124
fcf::devmgr::adc::AdcConfig::Init
void Init()
Define configuration parameters for adc device.
Definition: adcConfig.cpp:48
fcf::devmgr::common::DeviceConfig
Device Configuration class.
Definition: deviceConfig.hpp:123
fcf::devmgr::adc::TRK_MODE_OFF
constexpr short TRK_MODE_OFF
Definition: adcConfig.hpp:107
fcf::devmgr::adc::AdcConfig::GetMotorScaleFactor
double GetMotorScaleFactor(const int axis_num) const
Definition: adcConfig.cpp:258
fcf::devmgr::adc::AdcConfig::SetScaleFactor
virtual void SetScaleFactor(const std::string motor, double scale_factor)
Definition: adcConfig.cpp:221
fcf::devmgr::adc::AdcConfig::GetMotorPrefix
std::string GetMotorPrefix(const int &index) const
Definition: adcConfig.cpp:165
fcf::devmgr::adc::AdcConfig::GetMotorVelocity
double GetMotorVelocity(const int axis_num) const
Definition: adcConfig.cpp:229
fcf::devmgr::adc::CI_POFFSET
constexpr auto CI_POFFSET
Definition: adcConfig.hpp:43
fcf::devmgr::common::SUBSTATE_READY_STR
constexpr auto SUBSTATE_READY_STR
Definition: deviceConfig.hpp:101
adcHwErrors.hpp
AdcHwErrors header file.
fcf::devmgr::common::SUBSTATE_READY
constexpr int SUBSTATE_READY
Definition: deviceConfig.hpp:95
adcRpcErrors.hpp
AdcRpcErrors header file.
fcf::devmgr::adc::SUBSTATE_ENABLING_STR
constexpr auto SUBSTATE_ENABLING_STR
Definition: adcConfig.hpp:83
fcf::devmgr::adc::AdcConfig::m_num_axis
int m_num_axis
Definition: adcConfig.hpp:280
fcf::devmgr::motor::SUBSTATE_OP_STOPPING
constexpr int SUBSTATE_OP_STOPPING
Definition: motorConfig.hpp:121
fcf::devmgr::motor::SUBSTATE_OP_STOPPING_STR
constexpr auto SUBSTATE_OP_STOPPING_STR
Definition: motorConfig.hpp:128
fcf::devmgr::common::SUBSTATE_ERROR_STR
constexpr auto SUBSTATE_ERROR_STR
Definition: deviceConfig.hpp:102
fcf::devmgr::adc::CI_MOTOR_MAP_FILE
constexpr auto CI_MOTOR_MAP_FILE
Definition: adcConfig.hpp:29
fcf::devmgr::adc::CI_STAT_ALPHA
constexpr auto CI_STAT_ALPHA
Definition: adcConfig.hpp:123
motorConfig.hpp
MotorConfig class header file.
fcf::devmgr::adc::AdcConfig::GetMotorMapFile
virtual std::string GetMotorMapFile() const
Definition: adcConfig.cpp:136
fcf::devmgr::adc::RPC_MOVE_ANGLE
constexpr auto RPC_MOVE_ANGLE
Definition: adcConfig.hpp:69
fcf::devmgr::adc::CI_DIR_SIGN
constexpr auto CI_DIR_SIGN
Definition: adcConfig.hpp:33
fcf::devmgr::motor::SUBSTATE_OP_STANDSTILL
constexpr int SUBSTATE_OP_STANDSTILL
Definition: motorConfig.hpp:118
fcf::devmgr::adc::RPC_START_TRACK
constexpr auto RPC_START_TRACK
Definition: adcConfig.hpp:70
fcf::devmgr::adc::CI_MOT2_REF_AUTO
constexpr auto CI_MOT2_REF_AUTO
Definition: adcConfig.hpp:59