ifw-fcf  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
adcLcsIf.hpp
Go to the documentation of this file.
1 
9 #ifndef FCF_DEVMGR_DEVICE_ADC_IF_HPP
10 #define FCF_DEVMGR_DEVICE_ADC_IF_HPP
11 
12 #include <unordered_map>
13 
14 #include <yaml-cpp/yaml.h>
18 
19 namespace fcf::devmgr::adc {
20 
29  public:
31  virtual ~AdcControllerData();
32 
33  void SetData(const AdcControllerData& data);
34 
35  inline virtual std::string GetErrorText() const;
36  inline virtual std::string GetSubstateStr() const;
37 
38  inline short GetTrackingMode() const;
39  inline void SetTrackingMode(short mode);
40 
41  inline double GetAlpha() const;
42  inline void SetAlpha(double alpha);
43 
44  inline double GetDelta() const;
45  inline void SetDelta(double delta);
46 
47  inline devmgr::motor::MotorControllerData& GetMotor(std::string motor);
48 
49  inline void ClearMotors();
50 
51  inline void AddMotor(const std::string motor,
52  const devmgr::motor::MotorControllerData motor_data);
53 
54  inline void GetMotorNames(std::vector<std::string>& motor_vector);
55 
56  protected:
58  double m_alpha;
59  double m_delta;
60 
61  std::map<std::string, fcf::devmgr::motor::MotorControllerData> m_motors;
62  };
63 
64 
65 
79  template<typename TOPIC_TYPE = fcfif::AdcTopicUnion>
81 
82  // enumerations for Adc status
83  enum {
84  STAT_LOCAL = 100,
85  STAT_ERROR = 101,
86  STAT_STATE = 102,
87  STAT_SUBSTATE = 103,
88  STAT_TRACK_MODE = 104,
89  STAT_ALPHA = 105,
90  STAT_DELTA = 106
91  };
92 
93  public:
99  AdcLcsIf(std::shared_ptr<AdcConfig> config,
101 
105  virtual ~AdcLcsIf() {};
106 
112  virtual void Init();
113 
120  void MoveAbs(int axis_id, double position, double velocity);
121 
128  void MoveRel(int axis_id, double position, double velocity);
129 
139  void MoveVel(int axis_id, double velocity);
140 
145  bool IsMoving();
146 
151  bool IsStandstill();
152 
157  bool IsTracking();
158 
164  void ReadConfig();
165 
166  std::string GetMotorMapValue(std::string motor, std::string category, std::string key);
167 
173  void MoveAngle(double angle);
174 
180  void StartTrack(double angle);
181 
185  void StopTrack();
186 
195  virtual void ReadStatus(AdcControllerData& status);
196 
197  void StartTrackMonitoring();
198 
206  void StopMonitoring();
207 
208  void StopTrackMonitoring();
209 
221  void Listener(fcf::common::VectorVariant& params);
222 
228  virtual std::string GetRpcError(const short error_code) const;
229 
230  protected:
231 
236  void LoadConfig();
237 
238  private:
239 
251  void StoreAttribute(const std::string key,
252  const fcf::common::Variant& value,
253  bool publish,
254  int attribute);
255 
263  void PublishPosition(const std::string nodeid_prefix,
264  const fcf::common::Variant& value,
265  int attribute);
266 
267  void MovePos(int axis_id, double position, double velocity,
268  std::string move_type=devmgr::motor::RPC_MOVE_ABS);
269 
270  protected:
272  std::vector<std::string> m_monitor_track_vector;
273 
274  std::unordered_map<std::string,
275  std::unique_ptr<rad::cii::Publisher<fcfif::MotorPositionTopic>>> m_motor_publisher_map;
276  std::unique_ptr<rad::cii::Publisher<TOPIC_TYPE>> m_publisher;
277 
278  private:
279 
280  // This is private reference of configuration object to avoid
281  // casting the base one. It is used only for non virtual methods.
282  std::shared_ptr<AdcConfig> m_own_config;
283 
287  YAML::Node m_motor_map_node;
288  };
289 
290 }
291 
292 #include "adcLcsIf.ipp"
293 
294 #endif //FCF_DEVMGR_DEVICE_ADC_IF_HPP
void Listener(fcf::common::VectorVariant &params)
Callback to manage changes on the monitored items.
void LoadConfig()
Load the YAML configuration.
ShutterLcsIf class header file.
void SetData(const AdcControllerData &data)
Definition: adcLcsIf.cpp:30
std::unordered_map< std::string, std::unique_ptr< rad::cii::Publisher< fcfif::MotorPositionTopic > > > m_motor_publisher_map
Definition: adcLcsIf.hpp:275
The DeviceControllerData struct.
Definition: deviceLcsIf.hpp:31
void StopTrack()
StopTrack.
virtual std::string GetSubstateStr() const
AdcControllerData()
Definition: adcLcsIf.cpp:18
AdcConfig class header file.
short m_tracking_mode
Definition: adcLcsIf.hpp:57
std::map< std::string, fcf::devmgr::motor::MotorControllerData > m_motors
Definition: adcLcsIf.hpp:61
virtual void ReadStatus(AdcControllerData &status)
Read status from the controller.
void AddMotor(const std::string motor, const devmgr::motor::MotorControllerData motor_data)
void ReadConfig()
Read the configuration.
void MoveAbs(int axis_id, double position, double velocity)
Executes the MoveAbs RPC.
void MoveVel(int axis_id, double velocity)
Executes the MoveVel RPC.
bool IsMoving()
Check if motor is moving.
bool IsStandstill()
Check if motor is on.
std::vector< std::string > m_monitor_track_vector
Special monitor vector of attributes to be monitored only in tracking mode.
Definition: adcLcsIf.hpp:272
constexpr auto RPC_MOVE_ABS
Definition: motorConfig.hpp:110
void GetMotorNames(std::vector< std::string > &motor_vector)
virtual std::string GetErrorText() const
virtual ~AdcLcsIf()
Default destructor.
Definition: adcLcsIf.hpp:105
Adc Local Control System (LCS) Interface (IF) class.
Definition: adcLcsIf.hpp:80
DataContext class header file.
The MotorControllerData struct.
Definition: motorLcsIf.hpp:34
virtual ~AdcControllerData()
Definition: adcLcsIf.cpp:27
void MoveRel(int axis_id, double position, double velocity)
Executes the MoveRel RPC.
void MoveAngle(double angle)
Move adc to a position angle.
Definition: dataContext.hpp:81
double m_delta
Definition: adcLcsIf.hpp:59
void StopMonitoring()
Stop monitoring of controller attributes.
devmgr::motor::MotorControllerData & GetMotor(std::string motor)
std::unique_ptr< rad::cii::Publisher< TOPIC_TYPE > > m_publisher
Definition: adcLcsIf.hpp:276
bool IsTracking()
Check if adc is tracking.
AdcLcsIf(std::shared_ptr< AdcConfig > config, fcf::devmgr::common::DataContext &data_ctx)
adcLcsIf constructor.
virtual void Init()
Executes the Init RPC.
std::string GetMotorMapValue(std::string motor, std::string category, std::string key)
virtual std::string GetRpcError(const short error_code) const
Definition: deviceLcsIf.hpp:72
double m_alpha
Definition: adcLcsIf.hpp:58
void StartTrack(double angle)
Start ADC tracking.
The adcControllerData struct.
Definition: adcLcsIf.hpp:28