libhomegear-base  0.7
Base library for Homegear and Homegear family modules.
DevicePacket.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 DEVICEPACKET_H_
32 #define DEVICEPACKET_H_
33 
34 #include "JsonPayload.h"
35 #include "BinaryPayload.h"
36 #include "HttpPayload.h"
37 #include "Parameter.h"
38 #include "DevicePacketResponse.h"
39 
40 #include <string>
41 #include <memory>
42 #include <vector>
43 #include <map>
44 
45 namespace BaseLib
46 {
47 
48 class SharedObjects;
49 
50 namespace DeviceDescription
51 {
52 
53 class Packet;
54 
58 typedef std::shared_ptr<Packet> PPacket;
59 
63 typedef std::multimap<uint32_t, PPacket> PacketsByMessageType;
64 
68 typedef std::map<std::string, PPacket> PacketsById;
69 
73 typedef std::multimap<std::string, PPacket> PacketsByFunction;
74 
78 typedef std::map<int32_t, std::map<std::string, PPacket>> ValueRequestPackets;
79 
83 class Packet
84 {
85 public:
86  struct Direction
87  {
88  enum Enum { none = 0, toCentral = 1, fromCentral = 2 };
89  };
90 
92  Packet(BaseLib::SharedObjects* baseLib, xml_node* node);
93  virtual ~Packet() {}
94 
95  //Attributes
96  std::string id;
97 
98  //Elements
99  Direction::Enum direction = Direction::Enum::none;
100  int32_t length = -1;
101  int32_t type = -1;
102  int32_t subtype = -1;
103  int32_t subtypeIndex = -1;
104  double subtypeSize = -1;
105  std::string function1;
106  std::string function2;
107  std::string metaString1;
108  std::string metaString2;
109  int32_t responseType = -1;
110  int32_t responseSubtype = -1;
111  std::string responseTypeId;
112  std::vector<PDevicePacketResponse> responses;
113  int32_t channel = -1;
114  int32_t channelIndex = -1;
115  int32_t channelIndexOffset = 0;
116  double channelSize = 1;
117  bool doubleSend = false;
118  int32_t splitAfter = -1;
119  bool repeat = true;
120  int32_t maxPackets = -1;
124 
125  //Helpers
126  std::vector<PParameter> associatedVariables;
127 protected:
129 };
130 }
131 }
132 
133 #endif
int32_t responseType
Definition: DevicePacket.h:109
BinaryPayloads binaryPayloads
Definition: DevicePacket.h:122
std::string function1
Definition: DevicePacket.h:105
BaseLib::SharedObjects * _bl
Definition: DevicePacket.h:128
std::string metaString1
Definition: DevicePacket.h:107
bool repeat
Definition: DevicePacket.h:119
This is the base library main class.
Definition: BaseLib.h:95
std::string function2
Definition: DevicePacket.h:106
int32_t maxPackets
Definition: DevicePacket.h:120
std::shared_ptr< Packet > PPacket
Helper type for Packet pointers.
Definition: DevicePacket.h:53
Definition: BaseLib.cpp:34
JsonPayloads jsonPayloads
Definition: DevicePacket.h:121
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
std::vector< PHttpPayload > HttpPayloads
Helper type for HttpPayload pointer arrays.
Definition: HttpPayload.h:63
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
Direction::Enum direction
Definition: DevicePacket.h:99
int32_t length
Definition: DevicePacket.h:100
std::string metaString2
Definition: DevicePacket.h:108
std::vector< PJsonPayload > JsonPayloads
Helper type for JsonPayload pointer arrays.
Definition: JsonPayload.h:63
double subtypeSize
Definition: DevicePacket.h:104
int32_t type
Definition: DevicePacket.h:101
HttpPayloads httpPayloads
Definition: DevicePacket.h:123
std::map< std::string, PPacket > PacketsById
Helper type to store packets sorted by packet ID.
Definition: DevicePacket.h:68
int32_t channelIndexOffset
Definition: DevicePacket.h:115
Class defining a physical packet.
Definition: DevicePacket.h:83
virtual ~Packet()
Definition: DevicePacket.h:93
Packet(BaseLib::SharedObjects *baseLib)
Definition: DevicePacket.cpp:39
std::string responseTypeId
Definition: DevicePacket.h:111
std::vector< PParameter > associatedVariables
Definition: DevicePacket.h:126
int32_t channel
Definition: DevicePacket.h:113
int32_t subtype
Definition: DevicePacket.h:102
int32_t splitAfter
Definition: DevicePacket.h:118
double channelSize
Definition: DevicePacket.h:116
int32_t subtypeIndex
Definition: DevicePacket.h:103
std::vector< PBinaryPayload > BinaryPayloads
Helper type for arrays of BinaryPayload pointers.
Definition: BinaryPayload.h:63
int32_t responseSubtype
Definition: DevicePacket.h:110
Class representing a node of XML document.
Definition: rapidxml.h:539
int32_t channelIndex
Definition: DevicePacket.h:114
std::string id
Definition: DevicePacket.h:96
std::vector< PDevicePacketResponse > responses
Definition: DevicePacket.h:112
bool doubleSend
Definition: DevicePacket.h:117