ifw-fcf  4.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 
116  {
117  public:
118  enum {
132  STAT_MODE = 14,
148  };
149 
150  public:
159  MotorLcsIf(std::shared_ptr<fcf::devmgr::common::IDeviceConfig> config,
161 
165  virtual ~MotorLcsIf() {};
166 
173  void MoveAbs(double position);
174 
182  void MoveEncAbs(int encoders);
183 
190  void MoveRel(double position);
191 
199  void MoveEncRel(int encoders);
200 
208  void MoveByName(std::string namedpos);
209 
217  void MoveVel(double velocity);
218 
223  virtual bool IsDisabling();
224 
229  bool IsMoving() const;
230 
235  bool IsStandstill() const;
236 
241  bool IsInPosition() const;
242 
252  virtual void ReadStatus(MotorControllerData& status);
253 
265  void Listener(fcf::common::VectorVariant& params);
266 
272  virtual std::string GetRpcError(const short error_code) const;
273 
274 
275  protected:
276 
285  void StorePosition(const fcf::common::Variant& value,
286  int attribute);
287 
288  private:
289  void MovePos(double position, double velocity, std::string move_type=RPC_MOVE_ABS);
290 
291  protected:
292 
293  //std::unique_ptr<rad::cii::Publisher<fcfif::MotorPositionTopic>> m_motor_publisher;
294  //std::unique_ptr<rad::cii::Publisher<TOPIC_TYPE>> m_publisher;
295 
296  double m_mot_actual_pos {0.0};
297  double m_mot_actual_enc {0.0};
298  std::string m_mot_actual_name {""};
299  double m_mot_target_pos {};
300  double m_mot_pos_error {};
301  double m_mot_actual_vel {};
302  double m_mot_scale {1.0};
303  bool m_mot_initialised {false};
306  int m_mot_mode {};
309  bool m_mot_axis_ready {false};
310  bool m_mot_axis_enable {false};
311  bool m_mot_axis_brake {false};
312  bool m_mot_axis_lock {false};
313  bool m_mot_axis_inpos {false};
314  bool m_mot_signal_lstop {false};
315  bool m_mot_signal_lhw {false};
316  bool m_mot_signal_ref {false};
317  bool m_mot_signal_index {false};
318  bool m_mot_signal_uhw {false};
319  bool m_mot_signal_ustop {false};
320 
321  private:
322  log4cplus::Logger m_logger;
323 
324 
325  };
326 
327 }
328 
329 #include "motorLcsIf.ipp"
330 
331 #endif //FCF_DEVMGR_DEVICE_MOTOR_IF_HPP
fcf::devmgr::motor::MotorLcsIf::m_mot_actual_enc
double m_mot_actual_enc
Definition: motorLcsIf.hpp:297
fcf::devmgr::motor::MotorControllerData::SetEnableFlag
void SetEnableFlag(bool flag)
fcf::devmgr::motor::MotorControllerData::GetInfoData2
short GetInfoData2() const
fcf::devmgr::motor::MotorLcsIf::m_mot_axis_ready
bool m_mot_axis_ready
Definition: motorLcsIf.hpp:309
fcf::devmgr::motor::MotorLcsIf::m_mot_pos_error
double m_mot_pos_error
Definition: motorLcsIf.hpp:300
fcf::devmgr::motor::MotorLcsIf::STAT_AXIS_LOCK
@ STAT_AXIS_LOCK
Definition: motorLcsIf.hpp:131
fcf::devmgr::motor::MotorLcsIf::STAT_POS_ERROR
@ STAT_POS_ERROR
Definition: motorLcsIf.hpp:126
fcf::devmgr::motor::MotorLcsIf::MoveVel
void MoveVel(double velocity)
Executes the MoveVel RPC.
Definition: motorLcsIf.cpp:197
dataContext.hpp
DataContext class header file.
fcf::devmgr::motor::MotorLcsIf::IsMoving
bool IsMoving() const
Check if motor is moving.
Definition: motorLcsIf.cpp:230
fcf::devmgr::motor::MotorLcsIf::MoveByName
void MoveByName(std::string namedpos)
Executes the MovePos RPC.
Definition: motorLcsIf.cpp:134
fcf::devmgr::motor::MotorControllerData::SetMode
void SetMode(int mode)
fcf::devmgr::motor::MotorLcsIf::STAT_INIT_STEP
@ STAT_INIT_STEP
Definition: motorLcsIf.hpp:138
fcf::devmgr::motor
Definition: motor.hpp:20
fcf::devmgr::motor::MotorLcsIf::m_mot_actual_name
std::string m_mot_actual_name
Definition: motorLcsIf.hpp:298
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::m_mot_actual_pos
double m_mot_actual_pos
Definition: motorLcsIf.hpp:296
fcf::devmgr::motor::MotorLcsIf::STAT_STATE
@ STAT_STATE
Definition: motorLcsIf.hpp:122
fcf::devmgr::motor::MotorLcsIf::STAT_AXIS_INFO1
@ STAT_AXIS_INFO1
Definition: motorLcsIf.hpp:135
fcf::devmgr::motor::MotorLcsIf::m_mot_mode
int m_mot_mode
Definition: motorLcsIf.hpp:306
fcf::devmgr::motor::MotorControllerData::SetScaleFactor
void SetScaleFactor(double scale)
fcf::devmgr::motor::MotorLcsIf::IsDisabling
virtual bool IsDisabling()
Check if controller is disabling the motor.
Definition: motorLcsIf.cpp:189
fcf::devmgr::motor::MotorLcsIf::STAT_TARGET_VEL
@ STAT_TARGET_VEL
Definition: motorLcsIf.hpp:128
fcf::devmgr::motor::MotorLcsIf::ReadStatus
virtual void ReadStatus(MotorControllerData &status)
Read status from the controller.
Definition: motorLcsIf.cpp:268
fcf::devmgr::motor::MotorControllerData::m_brake
bool m_brake
Definition: motorLcsIf.hpp:91
fcf::devmgr::motor::MotorLcsIf::m_mot_axis_info2
short m_mot_axis_info2
Definition: motorLcsIf.hpp:308
fcf::devmgr::motor::MotorControllerData::m_ready
bool m_ready
Definition: motorLcsIf.hpp:95
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::m_mot_axis_inpos
bool m_mot_axis_inpos
Definition: motorLcsIf.hpp:313
fcf::devmgr::motor::MotorControllerData::m_actual_pos
double m_actual_pos
Definition: motorLcsIf.hpp:86
fcf::devmgr::motor::MotorLcsIf::STAT_MODE
@ STAT_MODE
Definition: motorLcsIf.hpp:132
fcf::devmgr::motor::MotorLcsIf::IsInPosition
bool IsInPosition() const
Check if motor is in position.
Definition: motorLcsIf.cpp:255
fcf::devmgr::motor::MotorControllerData::GetSubstateStr
virtual std::string GetSubstateStr() const
fcf::devmgr::motor::MotorLcsIf::STAT_SIGNAL_LHW
@ STAT_SIGNAL_LHW
Definition: motorLcsIf.hpp:141
fcf::devmgr::motor::MotorLcsIf::MoveRel
void MoveRel(double position)
Executes the MoveRel RPC.
Definition: motorLcsIf.cpp:95
fcf::devmgr::motor::MotorLcsIf::STAT_SIGNAL_LSTOP
@ STAT_SIGNAL_LSTOP
Definition: motorLcsIf.hpp:140
fcf::devmgr::motor::MotorLcsIf::STAT_SIGNAL_REF
@ STAT_SIGNAL_REF
Definition: motorLcsIf.hpp:142
fcf::devmgr::motor::MotorControllerData::m_locked
bool m_locked
Definition: motorLcsIf.hpp:93
fcf::devmgr::motor::MotorLcsIf::m_mot_actual_vel
double m_mot_actual_vel
Definition: motorLcsIf.hpp:301
fcf::devmgr::motor::MotorLcsIf::m_mot_initialised
bool m_mot_initialised
Definition: motorLcsIf.hpp:303
fcf::devmgr::motor::MotorLcsIf::STAT_SIGNAL_USTOP
@ STAT_SIGNAL_USTOP
Definition: motorLcsIf.hpp:145
fcf::devmgr::motor::MotorControllerData::GetLockFlag
bool GetLockFlag() const
fcf::devmgr::motor::Signal
Signal
Definition: motorConfig.hpp:176
fcf::devmgr::motor::MotorLcsIf::STAT_INIT_ACTION
@ STAT_INIT_ACTION
Definition: motorLcsIf.hpp:139
fcf::devmgr::motor::MotorLcsIf::MotorLcsIf
MotorLcsIf(std::shared_ptr< fcf::devmgr::common::IDeviceConfig > config, fcf::devmgr::common::DataContext &data_ctx)
MotorLcsIf constructor.
Definition: motorLcsIf.cpp:35
fcf::devmgr::motor::MotorControllerData::SetTargetPos
void SetTargetPos(double position)
fcf::devmgr::motor::MotorControllerData::GetInPositionFlag
bool GetInPositionFlag() const
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_ERROR
@ STAT_ERROR
Definition: motorLcsIf.hpp:120
fcf::devmgr::motor::MotorControllerData::SetInPositionFlag
void SetInPositionFlag(bool flag)
fcf::devmgr::motor::MotorLcsIf::STAT_AXIS_ENABLE
@ STAT_AXIS_ENABLE
Definition: motorLcsIf.hpp:130
fcf::devmgr::motor::MotorControllerData::m_signals
std::vector< bool > m_signals
Definition: motorLcsIf.hpp:99
fcf::devmgr::motor::MotorLcsIf::STAT_ACTUAL_POS
@ STAT_ACTUAL_POS
Definition: motorLcsIf.hpp:124
fcf::devmgr::motor::MotorLcsIf::STAT_ACTUAL_VEL
@ STAT_ACTUAL_VEL
Definition: motorLcsIf.hpp:127
fcf::devmgr::motor::MotorLcsIf::STAT_AXIS_INFO2
@ STAT_AXIS_INFO2
Definition: motorLcsIf.hpp:136
fcf::devmgr::motor::MotorControllerData::MotorControllerData
MotorControllerData()
Definition: motorLcsIf.cpp:4
deviceLcsIf.hpp
deviceLcsIf class header file.
fcf::devmgr::motor::MotorLcsIf::~MotorLcsIf
virtual ~MotorLcsIf()
Default destructor.
Definition: motorLcsIf.hpp:165
fcf::devmgr::motor::MotorControllerData::SetActualPos
void SetActualPos(double position)
fcf::devmgr::motor::MotorLcsIf::m_mot_axis_enable
bool m_mot_axis_enable
Definition: motorLcsIf.hpp:310
fcf::devmgr::motor::MotorLcsIf::STAT_MOTOR_END
@ STAT_MOTOR_END
Definition: motorLcsIf.hpp:147
fcf::devmgr::motor::MotorLcsIf::Listener
void Listener(fcf::common::VectorVariant &params)
Callback to manage changes on the monitored items.
Definition: motorLcsIf.cpp:286
fcf::devmgr::motor::MotorLcsIf::STAT_AXIS_INPOS
@ STAT_AXIS_INPOS
Definition: motorLcsIf.hpp:134
fcf::devmgr::motor::MotorLcsIf::m_mot_axis_lock
bool m_mot_axis_lock
Definition: motorLcsIf.hpp:312
fcf::devmgr::motor::MotorLcsIf::StorePosition
void StorePosition(const fcf::common::Variant &value, int attribute)
Store Position.
Definition: motorLcsIf.cpp:510
fcf::devmgr::motor::MotorControllerData::m_mode
int m_mode
Definition: motorLcsIf.hpp:94
fcf::devmgr::motor::MotorLcsIf::STAT_SIGNAL_UHW
@ STAT_SIGNAL_UHW
Definition: motorLcsIf.hpp:144
fcf::devmgr::motor::MotorLcsIf::STAT_HW_STATUS
@ STAT_HW_STATUS
Definition: motorLcsIf.hpp:121
fcf::devmgr::common::DataContext
Definition: dataContext.hpp:90
fcf::devmgr::motor::MotorLcsIf::MoveEncAbs
void MoveEncAbs(int encoders)
Executes the MoveAbs RPC.
Definition: motorLcsIf.cpp:108
fcf::devmgr::motor::MotorLcsIf::m_mot_axis_info1
short m_mot_axis_info1
Definition: motorLcsIf.hpp:307
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::common::DeviceLcsIf
Definition: deviceLcsIf.hpp:77
fcf::devmgr::motor::MotorLcsIf::m_mot_init_action
int m_mot_init_action
Definition: motorLcsIf.hpp:305
fcf::devmgr::motor::MotorLcsIf::m_mot_signal_ref
bool m_mot_signal_ref
Definition: motorLcsIf.hpp:316
fcf::devmgr::motor::MotorControllerData::SetReadyFlag
void SetReadyFlag(bool flag)
fcf::devmgr::motor::MotorControllerData::SetPosError
void SetPosError(double pos_error)
fcf::devmgr::motor::MotorControllerData::SetInfoData1
void SetInfoData1(short info)
fcf::devmgr::motor::MotorControllerData::m_pos_error
double m_pos_error
Definition: motorLcsIf.hpp:87
fcf::devmgr::motor::MotorControllerData::GetActualPos
double GetActualPos() const
fcf::devmgr::motor::MotorControllerData::~MotorControllerData
virtual ~MotorControllerData()
Definition: motorLcsIf.cpp:26
fcf::devmgr::motor::MotorLcsIf::m_mot_signal_ustop
bool m_mot_signal_ustop
Definition: motorLcsIf.hpp:319
fcf::devmgr::motor::RPC_MOVE_ABS
constexpr auto RPC_MOVE_ABS
Definition: motorConfig.hpp:113
fcf::devmgr::motor::MotorLcsIf::m_mot_signal_index
bool m_mot_signal_index
Definition: motorLcsIf.hpp:317
fcf::devmgr::motor::MotorControllerData::GetTargetVel
double GetTargetVel() const
fcf::devmgr::motor::MotorControllerData::SetBrakeFlag
void SetBrakeFlag(bool flag)
fcf::devmgr::motor::MotorLcsIf::STAT_SUBSTATE
@ STAT_SUBSTATE
Definition: motorLcsIf.hpp:123
fcf::devmgr::motor::MotorControllerData::m_scale_factor
double m_scale_factor
Definition: motorLcsIf.hpp:90
fcf::devmgr::motor::MotorLcsIf::GetRpcError
virtual std::string GetRpcError(const short error_code) const
Definition: motorLcsIf.cpp:477
fcf::devmgr::motor::MotorControllerData::GetEnableFlag
bool GetEnableFlag() const
fcf::devmgr::motor::MotorLcsIf::STAT_LOCAL
@ STAT_LOCAL
Definition: motorLcsIf.hpp:119
fcf::devmgr::motor::MotorLcsIf::m_mot_scale
double m_mot_scale
Definition: motorLcsIf.hpp:302
fcf::devmgr::motor::MotorLcsIf::IsStandstill
bool IsStandstill() const
Check if motor is on.
Definition: motorLcsIf.cpp:245
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_SIGNAL_INDEX
@ STAT_SIGNAL_INDEX
Definition: motorLcsIf.hpp:143
fcf::devmgr::motor::MotorLcsIf::MoveAbs
void MoveAbs(double position)
Executes the MoveAbs RPC.
Definition: motorLcsIf.cpp:82
fcf::devmgr::motor::MotorControllerData::GetReadyFlag
bool GetReadyFlag() const
fcf::devmgr::motor::MotorLcsIf::m_mot_signal_lstop
bool m_mot_signal_lstop
Definition: motorLcsIf.hpp:314
fcf::devmgr::motor::MotorLcsIf::m_mot_signal_lhw
bool m_mot_signal_lhw
Definition: motorLcsIf.hpp:315
fcf::devmgr::motor::MotorLcsIf::STAT_SCALE_FACTOR
@ STAT_SCALE_FACTOR
Definition: motorLcsIf.hpp:146
fcf::devmgr::motor::MotorControllerData::GetScaleFactor
double GetScaleFactor() const
fcf::devmgr::motor::MotorLcsIf::MoveEncRel
void MoveEncRel(int encoders)
Executes the MoveRel RPC.
Definition: motorLcsIf.cpp:121
fcf::devmgr::motor::MotorLcsIf::STAT_INITIALISED
@ STAT_INITIALISED
Definition: motorLcsIf.hpp:137
fcf::devmgr::motor::MotorLcsIf::m_mot_signal_uhw
bool m_mot_signal_uhw
Definition: motorLcsIf.hpp:318
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::common::DeviceControllerData
The DeviceControllerData struct.
Definition: deviceLcsIf.hpp:36
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::m_mot_target_pos
double m_mot_target_pos
Definition: motorLcsIf.hpp:299
fcf::devmgr::motor::MotorLcsIf::STAT_AXIS_READY
@ STAT_AXIS_READY
Definition: motorLcsIf.hpp:133
motorConfig.hpp
MotorConfig class header file.
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::MotorControllerData::GetTargetPos
double GetTargetPos() const
fcf::devmgr::motor::MotorLcsIf::m_mot_init_step
int m_mot_init_step
Definition: motorLcsIf.hpp:304
fcf::devmgr::motor::MotorLcsIf::STAT_AXIS_BRAKE
@ STAT_AXIS_BRAKE
Definition: motorLcsIf.hpp:129
fcf::devmgr::motor::MotorLcsIf::m_mot_axis_brake
bool m_mot_axis_brake
Definition: motorLcsIf.hpp:311
fcf::devmgr::motor::MotorLcsIf::STAT_TARGET_POS
@ STAT_TARGET_POS
Definition: motorLcsIf.hpp:125
fcf::devmgr::motor::MotorLcsIf
Motor Local Control System (LCS) Interface (IF) class.
Definition: motorLcsIf.hpp:116
fcf::devmgr::motor::MotorControllerData
The MotorControllerData struct.
Definition: motorLcsIf.hpp:34