BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
ZWaveMapperRegistry.h
1 #pragma once
2 
3 #include <list>
4 #include <string>
5 
6 #include <Poco/Nullable.h>
7 #include <Poco/SharedPtr.h>
8 
9 #include "model/DeviceID.h"
10 #include "model/ModuleType.h"
11 #include "model/SensorValue.h"
12 #include "zwave/ZWaveNode.h"
13 
14 namespace BeeeOn {
15 
23 public:
24  typedef Poco::SharedPtr<ZWaveMapperRegistry> Ptr;
25 
31  class Mapper {
32  public:
33  typedef Poco::SharedPtr<Mapper> Ptr;
34 
35  Mapper(const ZWaveNode::Identity &id, const std::string &product);
36  virtual ~Mapper();
37 
47  virtual DeviceID buildID() const;
48 
52  virtual std::string product() const;
53 
57  virtual std::list<ModuleType> types() const = 0;
58 
62  Poco::Nullable<ModuleType> findType(const ModuleID &id) const;
63 
67  virtual SensorValue convert(const ZWaveNode::Value &value) const = 0;
68 
76  virtual ZWaveNode::Value convert(const ModuleID &id, double value) const;
77 
78  protected:
79  static DeviceID mangleID(const DeviceID &id, uint8_t bits);
80  ZWaveNode::Identity identity() const;
81 
82  private:
83  ZWaveNode::Identity m_identity;
84  std::string m_product;
85  };
86 
87  virtual ~ZWaveMapperRegistry();
88 
92  virtual Mapper::Ptr resolve(const ZWaveNode &node) = 0;
93 };
94 
95 }
ZWaveMapperRegistry is mostly intended to map Z-Wave specific data type hierarchy to BeeeOn ModuleTyp...
Definition: ZWaveMapperRegistry.h:22
virtual std::string product() const
Definition: ZWaveMapperRegistry.cpp:30
Poco::Nullable< ModuleType > findType(const ModuleID &id) const
Find module type by ID.
Definition: ZWaveMapperRegistry.cpp:35
virtual std::list< ModuleType > types() const =0
Value coming from the Z-Wave network. It holds some data (usually sensor data) and metadata to identi...
Definition: ZWaveNode.h:102
Definition: SensorValue.h:14
Map the ZWaveNode-specific data to the BeeeOn-specific ones. It is assumed that the ZWaveNode instanc...
Definition: ZWaveMapperRegistry.h:31
virtual Mapper::Ptr resolve(const ZWaveNode &node)=0
Try to resolve a Mapper implementation suitable for the given Z-Wave node.
Definition: ModuleID.h:12
ZWaveNode represents information from the Z-Wave network about a particular node. Each Z-Wave node is...
Definition: ZWaveNode.h:22
virtual DeviceID buildID() const
The mapper can sometimes need to mangle a device ID for a Z-Wave node. This is possible by overriding...
Definition: ZWaveMapperRegistry.cpp:19
virtual SensorValue convert(const ZWaveNode::Value &value) const =0
Definition: DeviceID.h:17
Identity of a Z-Wave node that can be used separately without any instance of the ZWaveNode class...
Definition: ZWaveNode.h:28