ifw-fcf  3.0.0
motorLcsIf.hpp
Go to the documentation of this file.
1 
9 #ifndef FCF_DEVMGR_DEVICE_MOTOR_IF_HPP
10 #define FCF_DEVMGR_DEVICE_MOTOR_IF_HPP
11 
12 // System headers
13 #include <unordered_map>
14 
15 // Third party headers
16 #include <yaml-cpp/yaml.h>
17 
21 
22 #include <Fcfif.hpp>
23 #include <rad/mal/publisher.hpp>
24 
25 namespace fcf::devmgr::motor {
26 
35  public:
37  virtual ~MotorControllerData();
38 
39  inline double GetActualPos() const;
40  inline void SetActualPos(double position);
41  inline double GetPosError() const;
42  inline void SetPosError(double pos_error);
43  inline double GetActualVel() const;
44  inline void SetActualVel(double velocity);
45  inline double GetTargetPos() const;
46  inline void SetTargetPos(double position);
47  inline double GetTargetVel() const;
48  inline void SetTargetVel(double velocity);
49  inline double GetScaleFactor() const;
50  inline void SetScaleFactor(double scale);
51 
52  inline bool GetBrakeFlag() const;
53  inline void SetBrakeFlag(bool flag);
54 
55  inline bool GetEnableFlag() const;
56  inline void SetEnableFlag(bool flag);
57 
58  inline bool GetLockFlag() const;
59  inline void SetLockFlag(bool flag);
60 
61  inline int GetMode() const;
62  inline void SetMode(int mode);
63 
64  inline bool GetReadyFlag() const;
65  inline void SetReadyFlag(bool flag);
66 
67  inline bool GetInPositionFlag() const;
68  inline void SetInPositionFlag(bool flag);
69 
70  inline short GetInfoData1() const;
71  inline void SetInfoData1(short info);
72 
73  inline short GetInfoData2() const;
74  inline void SetInfoData2(short info);
75 
76  inline bool GetSignalFlag(Signal signal) const;
77  inline void SetSignalFlag(Signal signal, bool flag);
78 
79  inline virtual std::string GetErrorText() const;
80  inline virtual std::string GetSubstateStr() const;
81 
82  void SetData(const MotorControllerData& data);
83 
84  protected:
85  double m_target_pos {};
86  double m_actual_pos {};
87  double m_pos_error {};
88  double m_actual_vel {};
89  double m_target_vel {};
90  double m_scale_factor {1};
91  bool m_brake {false};
92  bool m_enabled {false};
93  bool m_locked {false};
94  int m_mode {};
95  bool m_ready {false};
96  bool m_in_position {false};
97  int m_info_data1 {};
98  int m_info_data2 {};
99  std::vector<bool> m_signals;
100  };
101 
115  template<typename TOPIC_TYPE>
117  {
118  public:
119  enum {
133  STAT_MODE = 14,
149  };
150 
151  public:
159  MotorLcsIf(std::shared_ptr<fcf::devmgr::common::IDeviceConfig> config,
160  fcf::devmgr::common::DataContext& data_ctx, bool initialise = true);
161 
165  virtual ~MotorLcsIf() {};
166 
173  void MoveAbs(double position, double velocity);
174 
181  void MoveRel(double position, double velocity);
182 
190  void MoveVel(double velocity);
191 
196  virtual bool IsDisabling();
197 
202  bool IsMoving();
203 
208  bool IsStandstill();
209 
219  virtual void ReadStatus(MotorControllerData& status,
220  bool force_read = true);
221 
233  void Listener(fcf::common::VectorVariant& params);
234 
240  virtual std::string GetRpcError(const short error_code) const;
241 
242 
243  protected:
244 
256  void StoreAttribute(const std::string key,
257  const fcf::common::Variant& value,
258  bool publish,
259  int attribute);
260 
269  void PublishPosition(const fcf::common::Variant& value,
270  int attribute);
271 
272  private:
273  void MovePos(double position, double velocity, std::string move_type=RPC_MOVE_ABS);
274 
275  protected:
276 
277  std::unique_ptr<rad::cii::Publisher<fcfif::MotorPositionTopic>> m_motor_publisher;
278  std::unique_ptr<rad::cii::Publisher<TOPIC_TYPE>> m_publisher;
279 
280  double m_mot_actual_pos {};
281  double m_mot_target_pos {};
282  double m_mot_pos_error {};
283  double m_mot_actual_vel {};
284  double m_mot_scale {1.0};
285  bool m_mot_initialised {false};
288  int m_mot_mode {};
291  bool m_mot_axis_ready {false};
292  bool m_mot_axis_enable {false};
293  bool m_mot_axis_brake {false};
294  bool m_mot_axis_lock {false};
295  bool m_mot_axis_inpos {false};
296  bool m_mot_signal_lstop {false};
297  bool m_mot_signal_lhw {false};
298  bool m_mot_signal_ref {false};
299  bool m_mot_signal_index {false};
300  bool m_mot_signal_uhw {false};
301  bool m_mot_signal_ustop {false};
302 
303  private:
305  static std::timed_mutex m_mutex;
306 
307 
308 
309 
310  };
311 
312 }
313 
314 #include "motorLcsIf.ipp"
315 
316 #endif //FCF_DEVMGR_DEVICE_MOTOR_IF_HPP
fcf::devmgr::motor::MotorControllerData::SetEnableFlag
void SetEnableFlag(bool flag)
fcf::devmgr::motor::MotorControllerData::GetInfoData2
short GetInfoData2() const
fcf::devmgr::motor::MotorLcsIf::PublishPosition
void PublishPosition(const fcf::common::Variant &value, int attribute)
Publish Position.
fcf::devmgr::motor::MotorLcsIf::m_mot_initialised
bool m_mot_initialised
Definition: motorLcsIf.hpp:285
fcf::devmgr::motor::MotorLcsIf::m_mot_signal_lhw
bool m_mot_signal_lhw
Definition: motorLcsIf.hpp:297
dataContext.hpp
DataContext class header file.
fcf::devmgr::motor::MotorLcsIf::STAT_MOTOR_END
@ STAT_MOTOR_END
Definition: motorLcsIf.hpp:148
fcf::devmgr::motor::MotorLcsIf::STAT_AXIS_INFO2
@ STAT_AXIS_INFO2
Definition: motorLcsIf.hpp:137
fcf::devmgr::motor::MotorControllerData::SetMode
void SetMode(int mode)
fcf::devmgr::motor::MotorLcsIf::IsMoving
bool IsMoving()
Check if motor is moving.
fcf::devmgr::motor
Definition: motor.hpp:20
fcf::devmgr::motor::MotorLcsIf::m_mot_signal_ustop
bool m_mot_signal_ustop
Definition: motorLcsIf.hpp:301
fcf::devmgr::motor::MotorLcsIf::STAT_POS_ERROR
@ STAT_POS_ERROR
Definition: motorLcsIf.hpp:127
fcf::devmgr::motor::MotorControllerData::SetTargetVel
void SetTargetVel(double velocity)
fcf::devmgr::motor::MotorControllerData::SetLockFlag
void SetLockFlag(bool flag)
fcf::devmgr::motor::MotorControllerData::GetInfoData1
short GetInfoData1() const
fcf::devmgr::motor::MotorLcsIf::GetRpcError
virtual std::string GetRpcError(const short error_code) const
fcf::devmgr::motor::MotorLcsIf::m_motor_publisher
std::unique_ptr< rad::cii::Publisher< fcfif::MotorPositionTopic > > m_motor_publisher
Definition: motorLcsIf.hpp:277
fcf::devmgr::motor::MotorControllerData::SetScaleFactor
void SetScaleFactor(double scale)
fcf::devmgr::motor::MotorLcsIf::STAT_TARGET_POS
@ STAT_TARGET_POS
Definition: motorLcsIf.hpp:126
fcf::devmgr::motor::MotorLcsIf::STAT_STATE
@ STAT_STATE
Definition: motorLcsIf.hpp:123
fcf::devmgr::motor::MotorLcsIf::m_mot_scale
double m_mot_scale
Definition: motorLcsIf.hpp:284
fcf::devmgr::motor::MotorControllerData::m_brake
bool m_brake
Definition: motorLcsIf.hpp:91
fcf::devmgr::motor::MotorLcsIf::STAT_SCALE_FACTOR
@ STAT_SCALE_FACTOR
Definition: motorLcsIf.hpp:147
fcf::devmgr::motor::MotorControllerData::m_ready
bool m_ready
Definition: motorLcsIf.hpp:95
fcf::devmgr::motor::MotorLcsIf::m_mot_axis_info1
short m_mot_axis_info1
Definition: motorLcsIf.hpp:289
fcf::devmgr::motor::MotorControllerData::GetErrorText
virtual std::string GetErrorText() const
fcf::devmgr::motor::MotorControllerData::GetActualVel
double GetActualVel() const
fcf::devmgr::motor::MotorControllerData::GetSignalFlag
bool GetSignalFlag(Signal signal) const
fcf::devmgr::motor::MotorControllerData::GetMode
int GetMode() const
fcf::devmgr::motor::MotorLcsIf::STAT_SUBSTATE
@ STAT_SUBSTATE
Definition: motorLcsIf.hpp:124
fcf::devmgr::motor::MotorControllerData::m_actual_pos
double m_actual_pos
Definition: motorLcsIf.hpp:86
fcf::devmgr::motor::MotorControllerData::GetSubstateStr
virtual std::string GetSubstateStr() const
fcf::devmgr::motor::MotorLcsIf::m_mot_axis_inpos
bool m_mot_axis_inpos
Definition: motorLcsIf.hpp:295
fcf::devmgr::motor::MotorLcsIf::STAT_MODE
@ STAT_MODE
Definition: motorLcsIf.hpp:133
fcf::devmgr::motor::MotorLcsIf::Listener
void Listener(fcf::common::VectorVariant &params)
Callback to manage changes on the monitored items.
fcf::devmgr::motor::MotorLcsIf::m_mot_init_step
int m_mot_init_step
Definition: motorLcsIf.hpp:286
fcf::devmgr::motor::MotorLcsIf::STAT_SIGNAL_REF
@ STAT_SIGNAL_REF
Definition: motorLcsIf.hpp:143
fcf::devmgr::motor::MotorLcsIf::STAT_ERROR
@ STAT_ERROR
Definition: motorLcsIf.hpp:121
fcf::devmgr::motor::MotorControllerData::m_locked
bool m_locked
Definition: motorLcsIf.hpp:93
fcf::devmgr::motor::MotorLcsIf::STAT_SIGNAL_LHW
@ STAT_SIGNAL_LHW
Definition: motorLcsIf.hpp:142
fcf::devmgr::motor::MotorLcsIf::m_mot_axis_ready
bool m_mot_axis_ready
Definition: motorLcsIf.hpp:291
fcf::devmgr::motor::MotorLcsIf::STAT_AXIS_ENABLE
@ STAT_AXIS_ENABLE
Definition: motorLcsIf.hpp:131
fcf::devmgr::motor::MotorControllerData::GetLockFlag
bool GetLockFlag() const
fcf::devmgr::motor::Signal
Signal
Definition: motorConfig.hpp:173
fcf::devmgr::motor::MotorLcsIf::IsStandstill
bool IsStandstill()
Check if motor is on.
fcf::devmgr::motor::MotorLcsIf::STAT_LOCAL
@ STAT_LOCAL
Definition: motorLcsIf.hpp:120
fcf::devmgr::motor::MotorControllerData::SetTargetPos
void SetTargetPos(double position)
fcf::devmgr::motor::MotorControllerData::GetInPositionFlag
bool GetInPositionFlag() const
fcf::devmgr::motor::MotorLcsIf::IsDisabling
virtual bool IsDisabling()
Check if controller is disabling the motor.
fcf::devmgr::motor::MotorControllerData::GetPosError
double GetPosError() const
fcf::devmgr::motor::MotorControllerData::GetBrakeFlag
bool GetBrakeFlag() const
fcf::devmgr::motor::MotorControllerData::m_info_data2
int m_info_data2
Definition: motorLcsIf.hpp:98
fcf::devmgr::motor::MotorLcsIf::STAT_INITIALISED
@ STAT_INITIALISED
Definition: motorLcsIf.hpp:138
fcf::devmgr::motor::MotorControllerData::SetInPositionFlag
void SetInPositionFlag(bool flag)
fcf::devmgr::motor::MotorLcsIf::ReadStatus
virtual void ReadStatus(MotorControllerData &status, bool force_read=true)
Read status from the controller.
fcf::devmgr::motor::MotorLcsIf::STAT_SIGNAL_LSTOP
@ STAT_SIGNAL_LSTOP
Definition: motorLcsIf.hpp:141
fcf::devmgr::motor::MotorControllerData::m_signals
std::vector< bool > m_signals
Definition: motorLcsIf.hpp:99
fcf::devmgr::motor::MotorControllerData::MotorControllerData
MotorControllerData()
Definition: motorLcsIf.cpp:4
deviceLcsIf.hpp
deviceLcsIf class header file.
fcf::devmgr::motor::MotorControllerData::SetActualPos
void SetActualPos(double position)
fcf::devmgr::motor::MotorLcsIf::m_mot_mode
int m_mot_mode
Definition: motorLcsIf.hpp:288
fcf::devmgr::motor::MotorLcsIf::m_mot_axis_brake
bool m_mot_axis_brake
Definition: motorLcsIf.hpp:293
fcf::devmgr::motor::MotorLcsIf::MoveVel
void MoveVel(double velocity)
Executes the MoveVel RPC.
fcf::devmgr::motor::MotorLcsIf::m_mot_pos_error
double m_mot_pos_error
Definition: motorLcsIf.hpp:282
fcf::devmgr::motor::MotorControllerData::m_mode
int m_mode
Definition: motorLcsIf.hpp:94
fcf::devmgr::motor::MotorLcsIf::STAT_AXIS_BRAKE
@ STAT_AXIS_BRAKE
Definition: motorLcsIf.hpp:130
fcf::devmgr::common::DataContext
Definition: dataContext.hpp:92
fcf::devmgr::motor::MotorControllerData::m_in_position
bool m_in_position
Definition: motorLcsIf.hpp:96
fcf::devmgr::motor::MotorControllerData::m_target_pos
double m_target_pos
Definition: motorLcsIf.hpp:85
fcf::devmgr::motor::MotorLcsIf::m_mot_axis_info2
short m_mot_axis_info2
Definition: motorLcsIf.hpp:290
fcf::devmgr::common::DeviceLcsIf
Definition: deviceLcsIf.hpp:75
fcf::devmgr::motor::MotorLcsIf::STAT_HW_STATUS
@ STAT_HW_STATUS
Definition: motorLcsIf.hpp:122
fcf::devmgr::motor::MotorControllerData::SetReadyFlag
void SetReadyFlag(bool flag)
fcf::devmgr::motor::MotorLcsIf::m_mot_target_pos
double m_mot_target_pos
Definition: motorLcsIf.hpp:281
fcf::devmgr::motor::MotorLcsIf::m_mot_init_action
int m_mot_init_action
Definition: motorLcsIf.hpp:287
fcf::devmgr::motor::MotorLcsIf::STAT_INIT_ACTION
@ STAT_INIT_ACTION
Definition: motorLcsIf.hpp:140
fcf::devmgr::motor::MotorControllerData::SetPosError
void SetPosError(double pos_error)
fcf::devmgr::motor::MotorControllerData::SetInfoData1
void SetInfoData1(short info)
fcf::devmgr::motor::MotorLcsIf::m_mot_signal_uhw
bool m_mot_signal_uhw
Definition: motorLcsIf.hpp:300
fcf::devmgr::motor::MotorControllerData::m_pos_error
double m_pos_error
Definition: motorLcsIf.hpp:87
fcf::devmgr::motor::MotorLcsIf::m_mot_actual_pos
double m_mot_actual_pos
Definition: motorLcsIf.hpp:280
fcf::devmgr::motor::MotorControllerData::GetActualPos
double GetActualPos() const
fcf::devmgr::motor::MotorControllerData::~MotorControllerData
virtual ~MotorControllerData()
Definition: motorLcsIf.cpp:26
fcf::devmgr::motor::RPC_MOVE_ABS
constexpr auto RPC_MOVE_ABS
Definition: motorConfig.hpp:110
fcf::devmgr::motor::MotorLcsIf::MoveAbs
void MoveAbs(double position, double velocity)
Executes the MoveAbs RPC.
fcf::devmgr::motor::MotorLcsIf::STAT_AXIS_INPOS
@ STAT_AXIS_INPOS
Definition: motorLcsIf.hpp:135
fcf::devmgr::motor::MotorControllerData::GetTargetVel
double GetTargetVel() const
fcf::devmgr::motor::MotorControllerData::SetBrakeFlag
void SetBrakeFlag(bool flag)
fcf::devmgr::motor::MotorLcsIf::~MotorLcsIf
virtual ~MotorLcsIf()
Default destructor.
Definition: motorLcsIf.hpp:165
fcf::devmgr::motor::MotorLcsIf::STAT_AXIS_READY
@ STAT_AXIS_READY
Definition: motorLcsIf.hpp:134
fcf::devmgr::motor::MotorControllerData::m_scale_factor
double m_scale_factor
Definition: motorLcsIf.hpp:90
fcf::devmgr::motor::MotorLcsIf::m_mot_signal_ref
bool m_mot_signal_ref
Definition: motorLcsIf.hpp:298
fcf::devmgr::motor::MotorControllerData::GetEnableFlag
bool GetEnableFlag() const
fcf::devmgr::motor::MotorLcsIf::m_publisher
std::unique_ptr< rad::cii::Publisher< TOPIC_TYPE > > m_publisher
Definition: motorLcsIf.hpp:278
fcf::devmgr::motor::MotorLcsIf::StoreAttribute
void StoreAttribute(const std::string key, const fcf::common::Variant &value, bool publish, int attribute)
Store the updated into the DB.
fcf::devmgr::motor::MotorControllerData::SetActualVel
void SetActualVel(double velocity)
fcf::devmgr::motor::MotorControllerData::SetSignalFlag
void SetSignalFlag(Signal signal, bool flag)
fcf::devmgr::motor::MotorLcsIf::STAT_TARGET_VEL
@ STAT_TARGET_VEL
Definition: motorLcsIf.hpp:129
fcf::devmgr::motor::MotorControllerData::GetReadyFlag
bool GetReadyFlag() const
fcf::devmgr::motor::MotorLcsIf::m_mot_signal_lstop
bool m_mot_signal_lstop
Definition: motorLcsIf.hpp:296
fcf::devmgr::motor::MotorLcsIf::STAT_ACTUAL_POS
@ STAT_ACTUAL_POS
Definition: motorLcsIf.hpp:125
fcf::devmgr::motor::MotorLcsIf::STAT_SIGNAL_UHW
@ STAT_SIGNAL_UHW
Definition: motorLcsIf.hpp:145
fcf::devmgr::motor::MotorLcsIf::STAT_ACTUAL_VEL
@ STAT_ACTUAL_VEL
Definition: motorLcsIf.hpp:128
fcf::devmgr::motor::MotorControllerData::GetScaleFactor
double GetScaleFactor() const
fcf::devmgr::motor::MotorLcsIf::MoveRel
void MoveRel(double position, double velocity)
Executes the MoveRel RPC.
fcf::devmgr::motor::MotorLcsIf::m_mot_actual_vel
double m_mot_actual_vel
Definition: motorLcsIf.hpp:283
fcf::devmgr::motor::MotorControllerData::m_info_data1
int m_info_data1
Definition: motorLcsIf.hpp:97
fcf::devmgr::motor::MotorControllerData::SetInfoData2
void SetInfoData2(short info)
fcf::devmgr::motor::MotorLcsIf::m_mot_axis_lock
bool m_mot_axis_lock
Definition: motorLcsIf.hpp:294
fcf::devmgr::common::DeviceControllerData
The DeviceControllerData struct.
Definition: deviceLcsIf.hpp:34
fcf::devmgr::motor::MotorControllerData::m_target_vel
double m_target_vel
Definition: motorLcsIf.hpp:89
fcf::devmgr::motor::MotorControllerData::m_enabled
bool m_enabled
Definition: motorLcsIf.hpp:92
fcf::devmgr::motor::MotorLcsIf::STAT_AXIS_LOCK
@ STAT_AXIS_LOCK
Definition: motorLcsIf.hpp:132
fcf::devmgr::motor::MotorLcsIf::STAT_INIT_STEP
@ STAT_INIT_STEP
Definition: motorLcsIf.hpp:139
motorConfig.hpp
MotorConfig class header file.
fcf::devmgr::motor::MotorLcsIf::m_mot_axis_enable
bool m_mot_axis_enable
Definition: motorLcsIf.hpp:292
fcf::devmgr::motor::MotorControllerData::m_actual_vel
double m_actual_vel
Definition: motorLcsIf.hpp:88
fcf::devmgr::motor::MotorControllerData::SetData
void SetData(const MotorControllerData &data)
Definition: motorLcsIf.cpp:29
fcf::devmgr::motor::MotorLcsIf::MotorLcsIf
MotorLcsIf(std::shared_ptr< fcf::devmgr::common::IDeviceConfig > config, fcf::devmgr::common::DataContext &data_ctx, bool initialise=true)
MotorLcsIf constructor.
fcf::devmgr::motor::MotorControllerData::GetTargetPos
double GetTargetPos() const
fcf::devmgr::motor::MotorLcsIf::STAT_AXIS_INFO1
@ STAT_AXIS_INFO1
Definition: motorLcsIf.hpp:136
fcf::devmgr::motor::MotorLcsIf
Motor Local Control System (LCS) Interface (IF) class.
Definition: motorLcsIf.hpp:117
fcf::devmgr::motor::MotorLcsIf::m_mot_signal_index
bool m_mot_signal_index
Definition: motorLcsIf.hpp:299
fcf::devmgr::motor::MotorLcsIf::STAT_SIGNAL_INDEX
@ STAT_SIGNAL_INDEX
Definition: motorLcsIf.hpp:144
fcf::devmgr::motor::MotorLcsIf::STAT_SIGNAL_USTOP
@ STAT_SIGNAL_USTOP
Definition: motorLcsIf.hpp:146
fcf::devmgr::motor::MotorControllerData
The MotorControllerData struct.
Definition: motorLcsIf.hpp:34