BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
PressureSensorManager.h
1 #pragma once
2 
3 #include <list>
4 #include <string>
5 
6 #include <Poco/SharedPtr.h>
7 #include <Poco/Timespan.h>
8 
9 #include "commands/DeviceAcceptCommand.h"
10 #include "commands/DeviceUnpairCommand.h"
11 #include "commands/GatewayListenCommand.h"
12 #include "core/DeviceManager.h"
13 #include "model/DeviceID.h"
14 #include "model/ModuleType.h"
15 #include "model/RefreshTime.h"
16 
17 namespace BeeeOn {
18 
32 public:
33 
36 
37  void run() override;
38  void stop() override;
39 
40  void setRefresh(const Poco::Timespan &refresh);
41 
47  void setPath(const std::string &path);
48  void setVendor(const std::string &vendor);
49 
54  void setUnit(const std::string &unit);
55 
59  void handleRemoteStatus(
60  const DevicePrefix &prefix,
61  const std::set<DeviceID> &devices,
62  const DeviceStatusHandler::DeviceValues &values) override;
63 
64 protected:
65  void handleAccept(const DeviceAcceptCommand::Ptr cmd) override;
66  AsyncWork<>::Ptr startDiscovery(const Poco::Timespan &timeout) override;
68  const DeviceID &id,
69  const Poco::Timespan &timeout) override;
70 
71 private:
75  void shipValue();
76  DeviceID pairedID();
77 
82  DeviceID buildID(const std::string &path);
83 
88  double convertToHPA(const double value);
89 
90 private:
91  RefreshTime m_refresh;
92  std::string m_vendor;
93  std::string m_path;
94  std::string m_unit;
95 };
96 
97 }
RefreshTime represents time of refreshing values from sensors. E.g. sensors are polled periodically o...
Definition: RefreshTime.h:24
Definition: PressureSensorManager.h:31
void stop() override
Definition: PressureSensorManager.cpp:75
AsyncWork is an interface allowing to wait until an asynchronous operation finishes. It is also possible to force-stop it by calling cancel().
Definition: AsyncWork.h:21
void handleRemoteStatus(const DevicePrefix &prefix, const std::set< DeviceID > &devices, const DeviceStatusHandler::DeviceValues &values) override
Wake-up the main thread when received new status.
Definition: PressureSensorManager.cpp:80
AsyncWork< std::set< DeviceID > >::Ptr startUnpair(const DeviceID &id, const Poco::Timespan &timeout) override
Starts device unpair process in a technology-specific way. This method is always called inside a crit...
Definition: PressureSensorManager.cpp:121
AsyncWork::Ptr startDiscovery(const Poco::Timespan &timeout) override
Starts device discovery process in a technology-specific way. This method is always called inside a c...
Definition: PressureSensorManager.cpp:89
void handleAccept(const DeviceAcceptCommand::Ptr cmd) override
Generic handler of the DeviceAcceptCommand. It might be helpful to override this method in case we ne...
Definition: PressureSensorManager.cpp:105
Definition: DeviceManager.h:48
Definition: DeviceID.h:17
void setPath(const std::string &path)
sets the Path to Air Pressure Sensor device entry output file. Reading from this file invoke measurin...
Definition: PressureSensorManager.cpp:153
void setUnit(const std::string &unit)
sets the expected unit, conversion of this unit needs to be made before shipping measured value...
Definition: PressureSensorManager.cpp:163
DevicePrefix prefix() const override
Definition: DeviceManager.cpp:33