BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
DeviceDescription.h
1 #pragma once
2 
3 #include <list>
4 #include <string>
5 
6 #include <Poco/Nullable.h>
7 #include <Poco/Timespan.h>
8 #include <Poco/Net/IPAddress.h>
9 
10 #include "model/DeviceID.h"
11 #include "model/ModuleType.h"
12 #include "model/RefreshTime.h"
13 #include "net/MACAddress.h"
14 
15 namespace BeeeOn {
16 
22 public:
23  class Builder {
24  public:
25  Builder();
26 
27  Builder &id(const DeviceID &id);
28  Builder &type(
29  const std::string &vendor,
30  const std::string &name);
31 
32  template <typename Container>
33  Builder &modules(const Container &types)
34  {
35  m_modules.clear();
36 
37  for (const auto type : types)
38  m_modules.emplace_back(type);
39 
40  return *this;
41  }
42 
43  Builder &refreshTime(const Poco::Timespan &time);
44  Builder &disabledRefreshTime();
45  Builder &noRefreshTime();
46 
47  Builder &name(const std::string &name);
48  Builder &firmware(const std::string &firmware);
49  Builder &ipAddress(const Poco::Net::IPAddress &address);
50  Builder &macAddress(const MACAddress &mac);
51  Builder &serialNumber(const uint64_t serial);
52 
53  DeviceDescription build() const;
54 
55  private:
56  Poco::Nullable<DeviceID> m_id;
57  Poco::Nullable<std::string> m_vendor;
58  Poco::Nullable<std::string> m_product;
59  std::list<ModuleType> m_modules;
60  RefreshTime m_refreshTime;
61  std::string m_name;
62  std::string m_firmware;
63  Poco::Nullable<Poco::Net::IPAddress> m_ipAddress;
64  Poco::Nullable<MACAddress> m_macAddress;
65  Poco::Nullable<uint64_t> m_serialNumber;
66  };
67 
69 
70  void setID(const DeviceID &id);
71  DeviceID id() const;
72 
73  void setVendor(const std::string &vendor);
74  std::string vendor() const;
75 
76  void setProductName(const std::string &name);
77  std::string productName() const;
78 
79  void setDataTypes(const std::list<ModuleType> &types);
80  std::list<ModuleType> dataTypes() const;
81 
82  void setRefreshTime(const RefreshTime &time);
83 
94  RefreshTime refreshTime() const;
95 
96  void setName(const std::string &name);
97  std::string name() const;
98 
99  void setFirmware(const std::string &firmware);
100  std::string firmware() const;
101 
102  void setIPAddress(const Poco::Net::IPAddress &ipAddress);
103  Poco::Nullable<Poco::Net::IPAddress> ipAddress() const;
104 
105  void setMACAddress(const MACAddress &macAddress);
106  Poco::Nullable<MACAddress> macAddress() const;
107 
108  void setSerialNumber(uint64_t serial);
109  Poco::Nullable<uint64_t> serialNumber() const;
110 
111  std::string toString() const;
112  std::string toPrettyString() const;
113 
114 private:
115  static std::string normalizeName(const std::string& bytes);
116 
117 private:
118  DeviceID m_deviceID;
119  std::string m_vendor;
120  std::string m_productName;
121  std::list<ModuleType> m_dataTypes;
122  RefreshTime m_refreshTime;
123  std::string m_name;
124  std::string m_firmware;
125  Poco::Nullable<Poco::Net::IPAddress> m_ipAddress;
126  Poco::Nullable<MACAddress> m_macAddress;
127  Poco::Nullable<uint64_t> m_serialNumber;
128 };
129 
130 }
RefreshTime represents time of refreshing values from sensors. E.g. sensors are polled periodically o...
Definition: RefreshTime.h:24
Definition: MACAddress.h:8
RefreshTime refreshTime() const
Definition: DeviceDescription.cpp:181
Definition: DeviceID.h:17
The class wraps information about a device&#39;s type. It describes its properties and provided sensor ty...
Definition: DeviceDescription.h:21
Definition: DeviceDescription.h:23