BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
BelkinWemoDevice.h
1 #pragma once
2 
3 #include <list>
4 
5 #include <Poco/Mutex.h>
6 #include <Poco/SharedPtr.h>
7 #include <Poco/Timespan.h>
8 #include <Poco/URI.h>
9 #include <Poco/DOM/Node.h>
10 #include <Poco/DOM/NodeIterator.h>
11 
12 #include "core/PollableDevice.h"
13 #include "model/DeviceID.h"
14 #include "model/ModuleID.h"
15 #include "model/ModuleType.h"
16 #include "model/SensorData.h"
17 #include "util/Loggable.h"
18 
19 namespace BeeeOn {
20 
24 class BelkinWemoDevice : public PollableDevice, protected Loggable {
25 public:
26  typedef Poco::SharedPtr<BelkinWemoDevice> Ptr;
27 
28  BelkinWemoDevice(const DeviceID& id, const RefreshTime &refresh);
29  virtual ~BelkinWemoDevice();
30 
31  DeviceID deviceID() const;
32  DeviceID id() const override;
33 
34  RefreshTime refresh() const override;
35 
36  virtual bool requestModifyState(const ModuleID& moduleID, const double value) = 0;
37  virtual SensorData requestState() = 0;
38  void poll(Distributor::Ptr distributor) override;
39 
40  virtual std::list<ModuleType> moduleTypes() const = 0;
41  virtual std::string name() const = 0;
42  virtual Poco::FastMutex& lock();
43 
50  static Poco::XML::Node* findNode(Poco::XML::NodeIterator& iterator, const std::string& name);
51 
56  static std::list<Poco::XML::Node*> findNodes(Poco::XML::NodeIterator& iterator, const std::string& name);
57 
58 protected:
59  const DeviceID m_deviceId;
60  RefreshTime m_refresh;
61  Poco::FastMutex m_lock;
62 };
63 
64 }
Abstract class representing generic BelkinWemo device.
Definition: BelkinWemoDevice.h:24
RefreshTime represents time of refreshing values from sensors. E.g. sensors are polled periodically o...
Definition: RefreshTime.h:24
Definition: SensorData.h:20
static std::list< Poco::XML::Node * > findNodes(Poco::XML::NodeIterator &iterator, const std::string &name)
Finds all nodes with the given name and returns their values.
Definition: BelkinWemoDevice.cpp:61
void poll(Distributor::Ptr distributor) override
Perform polling for data and ship them via the given distributor.
Definition: BelkinWemoDevice.cpp:81
Definition: ModuleID.h:12
Definition: Loggable.h:19
DeviceID id() const override
Definition: BelkinWemoDevice.cpp:25
static Poco::XML::Node * findNode(Poco::XML::NodeIterator &iterator, const std::string &name)
Finds the first node with the given name and returns it&#39;s value. When the value of node si empty retu...
Definition: BelkinWemoDevice.cpp:40
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
RefreshTime refresh() const override
Regular period telling how often to call the method PollableDevice::poll(). The refresh must contain ...
Definition: BelkinWemoDevice.cpp:30