BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
PhilipsHueBulb.h
1 #pragma once
2 
3 #include <list>
4 #include <string>
5 
6 #include <Poco/Mutex.h>
7 #include <Poco/SharedPtr.h>
8 
9 #include "core/PollableDevice.h"
10 #include "model/DeviceID.h"
11 #include "model/ModuleID.h"
12 #include "model/ModuleType.h"
13 #include "model/SensorData.h"
14 #include "philips/PhilipsHueBulbInfo.h"
15 #include "philips/PhilipsHueBridge.h"
16 #include "util/Loggable.h"
17 
18 namespace BeeeOn {
19 
23 class PhilipsHueBulb : public PollableDevice, protected Loggable {
24 public:
25  typedef Poco::SharedPtr<PhilipsHueBulb> Ptr;
26 
27  static const double MAX_DIM;
28 
34  const uint32_t ordinalNumber,
35  const PhilipsHueBridge::BulbID bulbId,
36  const PhilipsHueBridge::Ptr bridge,
37  const RefreshTime &refresh);
38  ~PhilipsHueBulb();
39 
40  virtual bool requestModifyState(const ModuleID& moduleID, const double value) = 0;
41  virtual SensorData requestState() = 0;
42 
43  DeviceID id() const override;
44  RefreshTime refresh() const override;
45  virtual std::list<ModuleType> moduleTypes() const = 0;
46  virtual std::string name() const = 0;
47  Poco::FastMutex& lock();
48 
49  PhilipsHueBridge::Ptr bridge();
50  PhilipsHueBulbInfo info();
51 
52  void poll(Distributor::Ptr distributor) override;
53 
54 protected:
55  int dimToPercentage(const double value);
56  int dimFromPercentage(const double percents);
57 
58 protected:
59  const DeviceID m_deviceID;
60  uint32_t m_ordinalNumber;
61  PhilipsHueBridge::Ptr m_bridge;
62  RefreshTime m_refresh;
63 };
64 
65 }
RefreshTime represents time of refreshing values from sensors. E.g. sensors are polled periodically o...
Definition: RefreshTime.h:24
Definition: SensorData.h:20
void poll(Distributor::Ptr distributor) override
Perform polling for data and ship them via the given distributor.
Definition: PhilipsHueBulb.cpp:63
RefreshTime refresh() const override
Regular period telling how often to call the method PollableDevice::poll(). The refresh must contain ...
Definition: PhilipsHueBulb.cpp:42
Definition: ModuleID.h:12
Definition: Loggable.h:19
DeviceID id() const override
Definition: PhilipsHueBulb.cpp:37
Abstract class representing generic Philips Hue bulb.
Definition: PhilipsHueBulb.h:23
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
Definition: PhilipsHueBulbInfo.h:11
PhilipsHueBulb(const uint32_t ordinalNumber, const PhilipsHueBridge::BulbID bulbId, const PhilipsHueBridge::Ptr bridge, const RefreshTime &refresh)
The DeviceID is created based on a bulb&#39;s 64-bit identifier, where DevicePrefix is given on 8th byte...
Definition: PhilipsHueBulb.cpp:14