BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
GenericZWaveMapperRegistry.h
1 #pragma once
2 
3 #include <iosfwd>
4 #include <map>
5 
6 #include "model/ModuleID.h"
7 #include "model/ModuleType.h"
8 #include "util/Loggable.h"
9 #include "zwave/ZWaveMapperRegistry.h"
10 
11 namespace BeeeOn {
12 
27  public ZWaveMapperRegistry,
28  Loggable {
29 public:
31  public:
32  typedef Poco::SharedPtr<GenericMapper> Ptr;
33 
38  static uint8_t ID_MANGLE_BITS;
39 
40  GenericMapper(const ZWaveNode::Identity &id, const std::string &product);
41 
46  DeviceID buildID() const override;
47 
52  std::string product() const override;
53 
57  std::list<ModuleType> types() const override;
58  SensorValue convert(const ZWaveNode::Value &value) const override;
59  ZWaveNode::Value convert(const ModuleID &id, double value) const override;
60 
66  void mapType(
67  const ZWaveNode::CommandClass &cc,
68  const ModuleType &type);
69 
70  protected:
75  void cannotConvert(const ZWaveNode::Value &value) const;
76 
77  private:
78  std::map<ZWaveNode::CommandClass, ModuleID> m_mapping;
79  std::map<ModuleID, ModuleType> m_modules;
80  };
81 
83 
87  void loadTypesMapping(const std::string &file);
88  void loadTypesMapping(std::istream &in);
89 
94  Mapper::Ptr resolve(const ZWaveNode &node) override;
95 
96 private:
100  std::map<std::pair<uint8_t, uint8_t>, ModuleType> m_typesMapping;
101 
111  std::map<std::pair<uint8_t, uint8_t>, unsigned int> m_typesOrder;
112 };
113 
114 }
ZWaveMapperRegistry is mostly intended to map Z-Wave specific data type hierarchy to BeeeOn ModuleTyp...
Definition: ZWaveMapperRegistry.h:22
DeviceID buildID() const override
Definition: GenericZWaveMapperRegistry.cpp:38
Mapper::Ptr resolve(const ZWaveNode &node) override
Definition: GenericZWaveMapperRegistry.cpp:296
Command class representation of a Z-Wave value. We support only a subset of command classes that are ...
Definition: ZWaveNode.h:48
static uint8_t ID_MANGLE_BITS
Mangle bits to be injected into device ID of Z-Wave devices that are using the GenericMapper.
Definition: GenericZWaveMapperRegistry.h:38
SensorValue convert(const ZWaveNode::Value &value) const override
Definition: GenericZWaveMapperRegistry.cpp:80
Value coming from the Z-Wave network. It holds some data (usually sensor data) and metadata to identi...
Definition: ZWaveNode.h:102
void loadTypesMapping(const std::string &file)
Load XML file with the types mapping between Z-Wave and BeeeOn.
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
void mapType(const ZWaveNode::CommandClass &cc, const ModuleType &type)
Record the given association between the given Z-Wave command class and BeeeOn ModuleType. When calling this method mutiple times, the order corresponds to an increasing ModuleID.
Definition: GenericZWaveMapperRegistry.cpp:48
Certain Z-Wave nodes can be mapped to the BeeeOn system generically. This allows to support any node ...
Definition: GenericZWaveMapperRegistry.h:26
Definition: GenericZWaveMapperRegistry.h:30
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
std::string product() const override
Definition: GenericZWaveMapperRegistry.cpp:43
Definition: ModuleType.h:18
Definition: Loggable.h:19
void cannotConvert(const ZWaveNode::Value &value) const
Throw an exception when the given value cannot be converted into the BeeeOn representation.
Definition: GenericZWaveMapperRegistry.cpp:73
Definition: DeviceID.h:17
std::list< ModuleType > types() const override
Definition: GenericZWaveMapperRegistry.cpp:63
Identity of a Z-Wave node that can be used separately without any instance of the ZWaveNode class...
Definition: ZWaveNode.h:28