BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
VirtualDeviceManager.h
1 #pragma once
2 
3 #include <queue>
4 #include <string>
5 
6 #include <Poco/SharedPtr.h>
7 #include <Poco/Timestamp.h>
8 #include <Poco/Util/IniFileConfiguration.h>
9 
10 #include "core/DeviceManager.h"
11 #include "core/PollingKeeper.h"
12 #include "vdev/VirtualDevice.h"
13 
14 namespace BeeeOn {
15 
30 public:
32 
33  void setDevicePoller(DevicePoller::Ptr poller);
34 
35  void run() override;
36  void stop() override;
37 
41  void setConfigFile(const std::string &path);
42 
47  void installVirtualDevices();
48 
53  void registerDevice(const VirtualDevice::Ptr virtualDevice);
54 
58  void dispatchNewDevice(VirtualDevice::Ptr device);
59 
64  VirtualDevice::Ptr parseDevice(
65  Poco::AutoPtr<Poco::Util::AbstractConfiguration> cfg);
66 
71  VirtualModule::Ptr parseModule(
72  Poco::AutoPtr<Poco::Util::AbstractConfiguration> cfg,
73  const ModuleID &moduleID);
74 
78  void scheduleAllEntries();
79 
85  void logDeviceParsed(VirtualDevice::Ptr device);
86 
90  void handleRemoteStatus(
91  const DevicePrefix &prefix,
92  const std::set<DeviceID> &devices,
93  const DeviceStatusHandler::DeviceValues &values) override;
94 
95 protected:
96  void handleGeneric(const Command::Ptr cmd, Result::Ptr result) override;
97 
102  void doListenCommand(const GatewayListenCommand::Ptr);
103 
110  void doDeviceAcceptCommand(const DeviceAcceptCommand::Ptr cmd);
111 
117  void doSetValueCommand(const DeviceSetValueCommand::Ptr cmd);
118 
123  void doUnpairCommand(const DeviceUnpairCommand::Ptr cmd);
124 
125 private:
126  std::map<DeviceID, VirtualDevice::Ptr> m_virtualDevicesMap;
127  std::string m_configFile;
128  PollingKeeper m_pollingKeeper;
129  bool m_requestDeviceList;
130  Poco::FastMutex m_lock;
131 };
132 
133 }
void doDeviceAcceptCommand(const DeviceAcceptCommand::Ptr cmd)
void handleRemoteStatus(const DevicePrefix &prefix, const std::set< DeviceID > &devices, const DeviceStatusHandler::DeviceValues &values) override
Reschedule virtual devices after updating the remote status.
void dispatchNewDevice(VirtualDevice::Ptr device)
void registerDevice(const VirtualDevice::Ptr virtualDevice)
void doSetValueCommand(const DeviceSetValueCommand::Ptr cmd)
void doListenCommand(const GatewayListenCommand::Ptr)
VirtualDevice::Ptr parseDevice(Poco::AutoPtr< Poco::Util::AbstractConfiguration > cfg)
void doUnpairCommand(const DeviceUnpairCommand::Ptr cmd)
VirtualModule::Ptr parseModule(Poco::AutoPtr< Poco::Util::AbstractConfiguration > cfg, const ModuleID &moduleID)
PollingKeeper takes care of devices that are being polled. It cancels all polled devices it manages u...
Definition: PollingKeeper.h:17
Definition: ModuleID.h:12
Definition: VirtualDeviceManager.h:29
void handleGeneric(const Command::Ptr cmd, Result::Ptr result) override
Definition: DeviceManager.h:48
void logDeviceParsed(VirtualDevice::Ptr device)
void setConfigFile(const std::string &path)
DevicePrefix prefix() const override
Definition: DeviceManager.cpp:33