BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
VirtualDevice.h
1 #pragma once
2 
3 #include <list>
4 
5 #include <Poco/Event.h>
6 #include <Poco/SharedPtr.h>
7 #include <Poco/Timespan.h>
8 
9 #include "core/PollableDevice.h"
10 #include "core/Result.h"
11 #include "model/DeviceID.h"
12 #include "model/ModuleID.h"
13 #include "model/ModuleType.h"
14 #include "model/RefreshTime.h"
15 #include "model/SensorData.h"
16 #include "vdev/VirtualModule.h"
17 
18 namespace BeeeOn {
19 
20 class VirtualDevice : public PollableDevice {
21 public:
22  typedef Poco::SharedPtr<VirtualDevice> Ptr;
23 
24  VirtualDevice();
25  ~VirtualDevice();
26 
27  void setID(const DeviceID &deviceId);
28  DeviceID id() const override;
29 
30  void setVendorName(const std::string &vendorName);
31  std::string vendorName() const;
32 
33  void setProductName(const std::string &productName);
34  std::string productName() const;
35 
36  std::list<VirtualModule::Ptr> modules() const;
37  void addModule(const VirtualModule::Ptr virtualModule);
38  std::list<ModuleType> moduleTypes() const;
39 
40  void setRefresh(const RefreshTime &refresh);
41  RefreshTime refresh() const override;
42 
43  bool modifyValue(
44  const ModuleID &moduleID, double value);
45  SensorData generate();
46 
47  void poll(Distributor::Ptr distributor) override;
48 
49 private:
50  RefreshTime m_refresh;
51  std::string m_vendorName;
52  std::string m_productName;
53  std::list<VirtualModule::Ptr> m_modules;
54  DeviceID m_deviceID;
55 };
56 
57 }
RefreshTime represents time of refreshing values from sensors. E.g. sensors are polled periodically o...
Definition: RefreshTime.h:24
Definition: SensorData.h:20
Definition: ModuleID.h:12
DeviceID id() const override
Definition: VirtualDevice.cpp:20
void poll(Distributor::Ptr distributor) override
Perform polling for data and ship them via the given distributor.
Definition: VirtualDevice.cpp:108
RefreshTime refresh() const override
Regular period telling how often to call the method PollableDevice::poll(). The refresh must contain ...
Definition: VirtualDevice.cpp:69
Definition: VirtualDevice.h:20
Definition: DeviceID.h:17
PollableDevice is a device that is necessary to poll regularly for data. The polling can take some ti...
Definition: PollableDevice.h:18