libhomegear-base  0.7
Base library for Homegear and Homegear family modules.
HomegearDevice.h
Go to the documentation of this file.
1 /* Copyright 2013-2019 Homegear GmbH
2  *
3  * libhomegear-base is free software: you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public License as
5  * published by the Free Software Foundation, either version 3 of the
6  * License, or (at your option) any later version.
7  *
8  * libhomegear-base is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with libhomegear-base. If not, see
15  * <http://www.gnu.org/licenses/>.
16  *
17  * In addition, as a special exception, the copyright holders give
18  * permission to link the code of portions of this program with the
19  * OpenSSL library under certain conditions as described in each
20  * individual source file, and distribute linked combinations
21  * including the two.
22  * You must obey the GNU Lesser General Public License in all respects
23  * for all of the code used other than OpenSSL. If you modify
24  * file(s) with this exception, you may extend this exception to your
25  * version of the file(s), but you are not obligated to do so. If you
26  * do not wish to do so, delete this exception statement from your
27  * version. If you delete this exception statement from all source
28  * files in the program, then also delete it here.
29 */
30 
31 #ifndef HOMEGEARDEVICE_H_
32 #define HOMEGEARDEVICE_H_
33 
34 #include "DevicePacket.h"
35 #include "SupportedDevice.h"
36 #include "RunProgram.h"
37 #include "Function.h"
38 
39 namespace BaseLib
40 {
41 namespace DeviceDescription
42 {
43 
45 
49 typedef std::shared_ptr<HomegearDevice> PHomegearDevice;
50 
55 {
56 public:
57  struct ReceiveModes
58  {
59  enum Enum { none = 0, always = 1, wakeOnRadio = 2, config = 4, wakeUp = 8, lazyConfig = 16, wakeUp2 = 32 };
60  };
61 
62  explicit HomegearDevice(BaseLib::SharedObjects* baseLib);
64  HomegearDevice(BaseLib::SharedObjects* baseLib, std::string xmlFilename, bool& oldFormat);
65  HomegearDevice(BaseLib::SharedObjects* baseLib, std::string xmlFilename, std::vector<char>& xml);
66  virtual ~HomegearDevice();
67 
68  bool loaded() const { return _loaded; }
69 
70  // {{{ Shortcuts
73  // }}}
74 
75  // {{{ Attributes
76  int32_t version = 0;
77  // }}}
78 
79  // {{{ Properties
81  bool encryption = false;
82  uint32_t timeout = 0;
83  uint32_t memorySize = 0;
84  uint32_t memorySize2 = 0;
85  bool visible = true;
86  bool deletable = true;
87  bool internal = false;
88  bool needsTime = false;
89  bool hasBattery = false;
90  uint32_t addressSize = 0;
91  std::string pairingMethod;
92  std::string interface;
93  // }}}
94 
95  // {{{ Elements
105  PHomegearDevice group;
106  // }}}
107 
108  // {{{ Helpers
109  void setPath(std::string& value);
110  std::string getPath();
111  void setFilename(std::string& value);
112  std::string getFilename();
113  int32_t getDynamicChannelCount();
114  void setDynamicChannelCount(int32_t value);
115  PSupportedDevice getType(uint64_t typeNumber);
116  PSupportedDevice getType(uint64_t typeNumber, int32_t firmwareVersion);
117  void save(std::string& filename);
118  // }}}
119 protected:
121  bool _loaded = false;
122 
123  // {{{ Helpers
124  std::string _path;
125  std::string _filename;
126  int32_t _dynamicChannelCount = -1;
127  // }}}
128 
129  void load(std::string xmlFilename, bool& oldFormat);
130  void load(std::string xmlFilename, std::vector<char>& xml);
131  void postProcessFunction(PFunction& function, std::map<std::string, PConfigParameters>& configParameters, std::map<std::string, PVariables>& variables, std::map<std::string, PLinkParameters>& linkParameters);
132  void parseXML(xml_node* node);
133  void postLoad();
134 
135  // {{{ Helpers
136  void saveDevice(xml_document* doc, xml_node* parentNode, HomegearDevice* device);
137  void saveFunction(xml_document* doc, xml_node* parentNode, PFunction& function, std::map<std::string, PConfigParameters>& configParameters, std::map<std::string, PVariables>& variables, std::map<std::string, PLinkParameters>& linkParameters);
138  void saveParameter(xml_document* doc, xml_node* parentNode, PParameter& parameter);
139  void saveScenario(xml_document* doc, xml_node* parentNode, PScenario& scenario);
140  void saveParameterPacket(xml_document* doc, xml_node* parentNode, std::shared_ptr<Parameter::Packet>& packet);
141  // }}}
142 };
143 }
144 }
145 
146 #endif
BaseLib::SharedObjects * _bl
Definition: HomegearDevice.h:120
void saveScenario(xml_document *doc, xml_node *parentNode, PScenario &scenario)
Definition: HomegearDevice.cpp:2062
bool _loaded
Definition: HomegearDevice.h:121
bool hasBattery
Definition: HomegearDevice.h:89
void postProcessFunction(PFunction &function, std::map< std::string, PConfigParameters > &configParameters, std::map< std::string, PVariables > &variables, std::map< std::string, PLinkParameters > &linkParameters)
Definition: HomegearDevice.cpp:2375
Class defining a Homegear device.
Definition: HomegearDevice.h:54
bool deletable
Definition: HomegearDevice.h:86
std::string _filename
Definition: HomegearDevice.h:125
bool loaded() const
Definition: HomegearDevice.h:68
This is the base library main class.
Definition: BaseLib.h:95
std::map< uint32_t, PFunction > Functions
Definition: Function.h:47
PRunProgram runProgram
Definition: HomegearDevice.h:97
std::shared_ptr< HomegearDevice > PHomegearDevice
Helper type for HomegearDevice pointers.
Definition: HomegearDevice.h:44
std::string pairingMethod
Definition: HomegearDevice.h:91
int32_t dynamicChannelCountIndex
Definition: HomegearDevice.h:71
int32_t getDynamicChannelCount()
Definition: HomegearDevice.cpp:55
PacketsByFunction packetsByFunction1
Definition: HomegearDevice.h:102
Functions functions
Definition: HomegearDevice.h:98
std::shared_ptr< RunProgram > PRunProgram
Definition: RunProgram.h:50
std::string getFilename()
Definition: HomegearDevice.cpp:51
Definition: BaseLib.cpp:34
std::multimap< std::string, PPacket > PacketsByFunction
Helper type to store packets sorted by function.
Definition: DevicePacket.h:73
std::multimap< uint32_t, PPacket > PacketsByMessageType
Helper type to store packets by integer message type.
Definition: DevicePacket.h:63
HomegearDevice(BaseLib::SharedObjects *baseLib)
Definition: HomegearDevice.cpp:95
std::map< int32_t, std::map< std::string, PPacket > > ValueRequestPackets
Helper type to store packets used to request values from devices.
Definition: DevicePacket.h:78
void saveFunction(xml_document *doc, xml_node *parentNode, PFunction &function, std::map< std::string, PConfigParameters > &configParameters, std::map< std::string, PVariables > &variables, std::map< std::string, PLinkParameters > &linkParameters)
Definition: HomegearDevice.cpp:2083
uint32_t memorySize2
Definition: HomegearDevice.h:84
std::string _path
Definition: HomegearDevice.h:124
PacketsByMessageType packetsByMessageType
Definition: HomegearDevice.h:100
void saveDevice(xml_document *doc, xml_node *parentNode, HomegearDevice *device)
Definition: HomegearDevice.cpp:278
ReceiveModes::Enum receiveModes
Definition: HomegearDevice.h:80
void parseXML(xml_node *node)
Definition: HomegearDevice.cpp:2257
PVariable value
Definition: UiElements.h:217
std::shared_ptr< Variable > PVariable
Definition: PhysicalInterfaceSettings.h:41
PSupportedDevice getType(uint64_t typeNumber)
Definition: HomegearDevice.cpp:2435
std::vector< PSupportedDevice > SupportedDevices
Definition: SupportedDevice.h:54
std::string interface
Definition: HomegearDevice.h:92
PacketsByFunction packetsByFunction2
Definition: HomegearDevice.h:103
std::map< std::string, PPacket > PacketsById
Helper type to store packets sorted by packet ID.
Definition: DevicePacket.h:68
uint32_t addressSize
Definition: HomegearDevice.h:90
void setFilename(std::string &value)
Definition: HomegearDevice.cpp:47
virtual ~HomegearDevice()
Definition: HomegearDevice.cpp:128
int32_t _dynamicChannelCount
Definition: HomegearDevice.h:126
std::shared_ptr< Scenario > PScenario
Definition: Scenario.h:53
bool encryption
Definition: HomegearDevice.h:81
std::shared_ptr< Function > PFunction
Definition: Function.h:46
void load(std::string xmlFilename, bool &oldFormat)
Definition: HomegearDevice.cpp:162
void postLoad()
Definition: HomegearDevice.cpp:202
uint32_t memorySize
Definition: HomegearDevice.h:83
PacketsById packetsById
Definition: HomegearDevice.h:101
void setPath(std::string &value)
Definition: HomegearDevice.cpp:39
void save(std::string &filename)
Definition: HomegearDevice.cpp:247
SupportedDevices supportedDevices
Definition: HomegearDevice.h:96
void setDynamicChannelCount(int32_t value)
Definition: HomegearDevice.cpp:59
This class represents root of the DOM hierarchy.
Definition: rapidxml.h:729
Class representing a node of XML document.
Definition: rapidxml.h:539
int32_t version
Definition: HomegearDevice.h:76
PVariable metadata
Definition: HomegearDevice.h:99
std::shared_ptr< Parameter > PParameter
Definition: Parameter.h:55
double dynamicChannelCountSize
Definition: HomegearDevice.h:72
bool visible
Definition: HomegearDevice.h:85
void saveParameter(xml_document *doc, xml_node *parentNode, PParameter &parameter)
Definition: HomegearDevice.cpp:999
std::string getPath()
Definition: HomegearDevice.cpp:43
std::shared_ptr< SupportedDevice > PSupportedDevice
Definition: SupportedDevice.h:51
uint32_t timeout
Definition: HomegearDevice.h:82
PHomegearDevice group
Definition: HomegearDevice.h:105
ValueRequestPackets valueRequestPackets
Definition: HomegearDevice.h:104
bool needsTime
Definition: HomegearDevice.h:88
void saveParameterPacket(xml_document *doc, xml_node *parentNode, std::shared_ptr< Parameter::Packet > &packet)
Definition: HomegearDevice.cpp:1999