ifw-fcf  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
device.hpp
Go to the documentation of this file.
1 
9 #ifndef FCF_DEVMGR_COMMON_DEVICE_HPP
10 #define FCF_DEVMGR_COMMON_DEVICE_HPP
11 
12 #include <fcf/common/dispatcher.hpp>
17 
18 namespace fcf {
19 namespace devmgr {
20  namespace common {
21 
22  class DeviceConfig;
23  class DeviceLcsIf;
30  class Device : public IDevice {
31 
32  public:
39  Device(const std::string filename,
40  const std::string name,
41  DataContext& data_ctx);
42 
46  virtual ~Device();
47 
53  virtual bool IsNotReady() const override;
59  virtual bool IsReady() const override;
60 
66  virtual bool IsOperational() const override;
67 
73  virtual void CheckHwFailure() const override;
74 
80  virtual bool IsDisabling() const override;
81 
87  virtual void Init() override;
88 
94  virtual void Enable() override;
95 
101  virtual void Disable() override;
102 
108  virtual void Stop() override;
109 
115  virtual void Reset() override;
116 
117 
118 
119  void Status(DeviceControllerData* data, std::string& buffer);
120 
131  virtual void Status(const std::string prefix,
132  const dit::did::Did& dictionary,
133  std::shared_ptr<CCfits::FITS>& fits_handle);
134 
135 
143  virtual void Simulate(rad::AnyEvent const& last_event) override;
144 
152  virtual void StopSim(rad::AnyEvent const& last_event) override;
153 
161  virtual void Ignore(rad::AnyEvent const& last_event) override;
162 
170  virtual void StopIgn(rad::AnyEvent const& last_event) override;
171 
179  virtual void HwReset(rad::AnyEvent const& last_event) override;
180 
188  virtual void HwInit(rad::AnyEvent const& last_event) override;
189 
197  virtual void HwEnable(rad::AnyEvent const& last_event) override;
198 
206  virtual void HwDisable(rad::AnyEvent const& last_event) override;
207 
211  virtual void StartMonitoring() override;
212 
216  virtual void StopMonitoring() override;
217 
222  virtual std::string GetName() const override;
223 
224 
225  protected:
226 
233  bool IsMsgForMe(const std::string& id) const;
234 
240  void UpdateDb(std::vector<std::string> attr_vector);
241 
246  void SetIgnore(bool flag);
247 
252  void SetSimulation(bool flag);
253 
259  void GetPrefix(const std::vector<std::string> prefix_list, std::string& prefix);
260 
268  bool CheckNameParam(const std::any& payload);
269 
270 
271  protected:
272  std::string m_filename;
273  std::string m_name;
275 
277  fcf::common::Dispatcher<> m_failure;
279  fcf::common::Dispatcher<> m_normal;
280 
282  std::shared_ptr<DeviceConfig> m_config;
283 
285  std::shared_ptr<DeviceLcsIf> m_lcs_if;
286 
287  };
288 
289  }
290  }
291 }
292 
293 
294 #endif //FCF_DEVMGR_COMMON_DEVICE_HPP
void GetPrefix(const std::vector< std::string > prefix_list, std::string &prefix)
Get prefix for writing attributes to the DB.
Definition: device.cpp:686
virtual void HwInit(rad::AnyEvent const &last_event) override
Executes a hardware init command.
Definition: device.cpp:459
void SetIgnore(bool flag)
SetIgnore.
Definition: device.cpp:646
virtual void Reset() override
Executes a Reset command.
Definition: device.cpp:116
Device(const std::string filename, const std::string name, DataContext &data_ctx)
Device abstract class constructor.
Definition: device.cpp:31
The DeviceControllerData struct.
Definition: deviceLcsIf.hpp:31
virtual bool IsReady() const override
Check if device is Standby/Ready.
Definition: device.cpp:547
virtual void Init() override
Executes a Init command.
Definition: device.cpp:44
Definition: iDevice.hpp:39
void Status(DeviceControllerData *data, std::string &buffer)
Definition: device.cpp:150
virtual void Ignore(rad::AnyEvent const &last_event) override
Executes a Ignore.
Definition: device.cpp:345
virtual std::string GetName() const override
Get device id.
Definition: device.cpp:699
virtual void StopIgn(rad::AnyEvent const &last_event) override
Executes a StopIgn.
Definition: device.cpp:386
Device class header file.
virtual void Enable() override
Executes a Enable command.
Definition: device.cpp:67
virtual bool IsDisabling() const override
Check if device is disablig.
Definition: device.cpp:606
std::shared_ptr< DeviceLcsIf > m_lcs_if
Local Control System Interface.
Definition: device.hpp:285
fcf::common::Dispatcher m_normal
Dispatcher for managing positive events.
Definition: device.hpp:279
virtual void HwEnable(rad::AnyEvent const &last_event) override
Executes a hardware enable command.
Definition: device.cpp:482
virtual ~Device()
Default destructor.
Definition: device.cpp:39
virtual void HwDisable(rad::AnyEvent const &last_event) override
Executes a hardware disable command.
Definition: device.cpp:505
virtual bool IsOperational() const override
Check if device is Operational.
Definition: device.cpp:566
virtual void CheckHwFailure() const override
Check if device is in failure state.
Definition: device.cpp:584
Definition: device.hpp:30
void SetSimulation(bool flag)
SetSimulation.
Definition: device.cpp:666
std::string m_name
device ID.
Definition: device.hpp:273
DataContext & m_data_ctx
reference to the data context object.
Definition: device.hpp:274
virtual void Disable() override
Executes a Disable command.
Definition: device.cpp:85
virtual void HwReset(rad::AnyEvent const &last_event) override
Executes a hardware reset command.
Definition: device.cpp:436
bool CheckNameParam(const std::any &payload)
Determine whether paramater is included (device name).
Definition: device.cpp:730
virtual void StopMonitoring() override
Stop device monitoring.
Definition: device.cpp:717
DataContext class header file.
std::shared_ptr< DeviceConfig > m_config
Pointer to configuration object.
Definition: device.hpp:282
virtual void StopSim(rad::AnyEvent const &last_event) override
Executes a StopSim.
Definition: device.cpp:242
Definition: dataContext.hpp:81
fcf::common::Dispatcher m_failure
Dispatcher for managing failures.
Definition: device.hpp:277
deviceLcsIf class header file.
virtual bool IsNotReady() const override
Check if device is Standby/NotReady.
Definition: device.cpp:528
std::string m_filename
device configuration filename.
Definition: device.hpp:272
bool IsMsgForMe(const std::string &id) const
Check if received message id is addressed to me.
Definition: device.cpp:624
virtual void Stop() override
Executes a Stop command.
Definition: device.cpp:101
void UpdateDb(std::vector< std::string > attr_vector)
Update device database.
Definition: device.cpp:636
virtual void Simulate(rad::AnyEvent const &last_event) override
Executes a Simulat.
Definition: device.cpp:185
DeviceConfig class header file.
virtual void StartMonitoring() override
Start device monitoring via OPCUA subscriptions.
Definition: device.cpp:704