ifw-fcf  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sensorLcsIf.hpp
Go to the documentation of this file.
1 
10 #ifndef FCF_DEVMGR_DEVICE_SENSOR_LCSIF_HPP
11 #define FCF_DEVMGR_DEVICE_SENSOR_LCSIF_HPP
12 
13 // System headers
14 #include <unordered_map>
15 
16 // Third party headers
17 #include <yaml-cpp/yaml.h>
18 
22 
23 #include <Fcfif.hpp>
24 #include <rad/mal/publisher.hpp>
25 
26 
27 namespace fcf::devmgr::sensor {
28 
33  struct ChannelData {
34  ChannelData();
35  virtual ~ChannelData();
36 
37 
38  void GetValue(bool& value) const;
39  void GetValue(double& value) const;
40  void GetValue(int& value) const;
41 
42 
43  void SetValue(const fcf::common::Variant value);
44  friend std::ostream& operator<<(std::ostream& dest, const ChannelData& obj);
45 
46  protected:
47 
48  fcf::common::Variant m_value;
49  };
50 
61  public:
63  virtual ~SensorControllerData();
64 
65  inline std::string GetErrorText() const;
66  inline virtual std::string GetSubstateStr() const;
67 
68  inline void ClearChannelValues();
69  inline void SetChannelValue(std::string channel,
70  fcf::common::Variant value);
71  inline void GetChannelValue(std::string channel,
72  ChannelData& data);
73 
74 
75  void SetData(const SensorControllerData& data);
76 
77  //friend class SensorLcsIf<TOPIC_TYPE>;
78  protected:
79  std::unordered_map<std::string, ChannelData> m_values;
80  };
81 
82 
96  template<typename TOPIC_TYPE = fcfif::SensorTopicUnion>
98  // enumerations for the Sensor status
99 
100  enum {
101  STAT_LOCAL = 1,
102  STAT_ERROR = 2,
103  STAT_STATE = 3,
104  STAT_SUBSTATE = 4,
105  STAT_CHANNEL = 5,
106  };
107 
108  public:
116  SensorLcsIf(std::shared_ptr<fcf::devmgr::common::IDeviceConfig> config,
117  fcf::devmgr::common::DataContext& data_ctx, bool initialise = true);
118 
122  virtual ~SensorLcsIf() {};
123 
128  virtual bool IsReady();
129 
130  virtual bool IsNotReady();
131 
136  virtual bool IsOperational();
137 
142  bool IsHwFailure();
143 
153  virtual void ReadStatus(SensorControllerData& status);
154 
164  void StartMonitoring();
165 
173  void StopMonitoring();
174 
186  void Listener(fcf::common::VectorVariant& params);
187 
193  virtual std::string GetRpcError(const short error_code) const;
194 
195 
196  private:
197 
205  void PublishState(const fcf::common::Variant& value);
206 
214  void PublishSubstate(const fcf::common::Variant& value);
215 
216  void PublishError(const fcf::common::Variant& value);
217 
218  void PublishChannel(const std::string channel,
219  const fcf::common::Variant& value);
220 
221 
222  protected:
223 
224 
227  std::unordered_map<std::string, std::string> m_channels_map;
228  std::unique_ptr<rad::cii::Publisher<TOPIC_TYPE>> m_publisher;
229 
230  private:
231 
232 
233 
234  };
235 }
236 
237 #include "sensorLcsIf.ipp"
238 
239 #endif //FCF_DEVMGR_DEVICE_SENSOR_LCSIF_HPP
void SetValue(const fcf::common::Variant value)
void Listener(fcf::common::VectorVariant &params)
Callback to manage changes on the monitored items.
bool IsHwFailure()
Check if Sensor is in hardware error.
void SetData(const SensorControllerData &data)
Definition: sensorLcsIf.cpp:36
Sensor Local Control System (LCS) Interface (IF) class.
Definition: sensorLcsIf.hpp:97
SensorConfig class header file.
void StopMonitoring()
Stop monitoring of controller attributes.
virtual std::string GetSubstateStr() const
The DeviceControllerData struct.
Definition: deviceLcsIf.hpp:31
virtual ~ChannelData()
Definition: sensorLcsIf.cpp:21
friend std::ostream & operator<<(std::ostream &dest, const ChannelData &obj)
Definition: sensorLcsIf.cpp:24
virtual bool IsReady()
Check if controller is in Standby/Ready state.
void GetChannelValue(std::string channel, ChannelData &data)
void SetChannelValue(std::string channel, fcf::common::Variant value)
SensorLcsIf(std::shared_ptr< fcf::devmgr::common::IDeviceConfig > config, fcf::devmgr::common::DataContext &data_ctx, bool initialise=true)
sensorLcsIf constructor.
virtual void ReadStatus(SensorControllerData &status)
Read status from the controller.
void GetValue(bool &value) const
virtual std::string GetRpcError(const short error_code) const
virtual bool IsOperational()
Check if controller is in Operational.
void StartMonitoring()
Start monitoring of controller attributes.
The sensorControllerData struct.
Definition: sensorLcsIf.hpp:60
ChannelData()
Definition: sensorLcsIf.cpp:18
std::unordered_map< std::string, ChannelData > m_values
Definition: sensorLcsIf.hpp:79
fcf::common::Variant m_value
Definition: sensorLcsIf.hpp:48
DataContext class header file.
Definition: dataContext.hpp:81
std::unique_ptr< rad::cii::Publisher< TOPIC_TYPE > > m_publisher
Definition: sensorLcsIf.hpp:228
SensorControllerData()
Definition: sensorLcsIf.cpp:29
deviceLcsIf class header file.
virtual ~SensorLcsIf()
Default destructor.
Definition: sensorLcsIf.hpp:122
std::unordered_map< std::string, std::string > m_channels_map
Definition: sensorLcsIf.hpp:227
virtual ~SensorControllerData()
Definition: sensorLcsIf.cpp:33
The ChannelData struct.
Definition: sensorLcsIf.hpp:33
virtual bool IsNotReady()
Check if controller is in Standby/NotReady state.
Definition: deviceLcsIf.hpp:72