knx
ETS configurable knx-stack
group_object.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <stddef.h>
4 #include <stdint.h>
5 #include "knx_types.h"
6 #include "dptconvert.h"
7 
9 
10 enum ComFlag
11 {
12  Updated = 0,
16  Ok = 4,
17  Error = 5,
18  Uninitialized = 6
19 };
20 
21 class GroupObject;
22 
23 #ifndef HAS_FUNCTIONAL
24 # if defined(__linux__) || defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_STM32) || defined (ARDUINO_ARCH_SAMD) || defined (ARDUINO_ARCH_RP2040)
25 # define HAS_FUNCTIONAL 1
26 # else
27 # define HAS_FUNCTIONAL 0
28 # endif
29 #endif
30 
31 #if HAS_FUNCTIONAL
32 #include <functional>
33 typedef std::function<void(GroupObject&)> GroupObjectUpdatedHandler;
34 #else
35 typedef void (*GroupObjectUpdatedHandler)(GroupObject& go);
36 #endif
37 
42 {
43  friend class GroupObjectTableObject;
44 
45  public:
49  GroupObject();
53  GroupObject(const GroupObject& other);
57  virtual ~GroupObject();
58  // config flags from ETS
62  bool responseUpdateEnable();
66  bool transmitEnable();
70  bool valueReadOnInit();
74  bool writeEnable();
78  bool readEnable();
82  bool communicationEnable();
83 
88 
92  ComFlag commFlag();
97  void commFlag(ComFlag value);
98 
108  void requestObjectRead();
115  void objectWritten();
116 
121  size_t valueSize();
126  size_t sizeInTelegram();
131  uint8_t* valueRef();
136  uint16_t asap();
137 
138 #ifndef SMALL_GROUPOBJECT
142  void callback(GroupObjectUpdatedHandler handler);
147 #endif
152  KNXValue value(const Dpt& type);
160  void value(const KNXValue& value, const Dpt& type);
168  void valueNoSend(const KNXValue& value, const Dpt& type);
178  bool tryValue(KNXValue& value, const Dpt& type);
179 
180 #ifndef SMALL_GROUPOBJECT
185  KNXValue value();
192  void value(const KNXValue& value);
199  void valueNoSend(const KNXValue& value);
208  bool tryValue(KNXValue& value);
209 
213  Dpt dataPointType();
217  void dataPointType(Dpt value);
218 #else
224  static GroupObjectUpdatedHandler classCallback();
225  static void classCallback(GroupObjectUpdatedHandler handler);
226  static void processClassCallback(GroupObject& ko);
227 #endif
228 
229  private:
230  // class members
231  static GroupObjectTableObject* _table;
232 #ifdef SMALL_GROUPOBJECT
233  static GroupObjectUpdatedHandler _updateHandlerStatic;
234 #endif
235 
236  size_t asapValueSize(uint8_t code);
237  size_t goSize();
238  uint16_t _asap = 0;
239  ComFlag _commFlag = Uninitialized;
240  uint8_t* _data = 0;
241  uint8_t _dataLength = 0;
242 #ifndef SMALL_GROUPOBJECT
243  GroupObjectUpdatedHandler _updateHandler;
244  Dpt _datapointType;
245 #endif
246 };
Definition: dpt.h:364
This class represents a single group object.
Definition: group_object.h:42
bool writeEnable()
Check if the write flag (W) was set.
GroupObjectUpdatedHandler callback()
returns the registered callback
uint16_t asap()
returns the Application Service Access Point of the group object.
bool responseUpdateEnable()
Check if the update flag (U) was set.
virtual ~GroupObject()
The destructor.
size_t sizeInTelegram()
returns the size of the group object in Byte as it is in a telegram.
ComFlag commFlag()
Return the current state of the group object.
KNXValue value()
return the current value of the group object.
bool transmitEnable()
Check if the transmit flag (T) was set.
GroupObject()
The constructor.
void objectWritten()
Mark a communication object as written.
uint8_t * valueRef()
returns the pointer to the value of the group object.
void requestObjectRead()
Request the read of a communication object.
Priority priority()
Get the priority of the group object.
bool valueReadOnInit()
Check if the initialisation flag (I) was set.
bool communicationEnable()
Check if the communication flag (C) was set.
void valueNoSend(const KNXValue &value, const Dpt &type)
set the current value of the group object.
bool tryValue(KNXValue &value, const Dpt &type)
set the current value of the group object.
size_t valueSize()
returns the size of the group object in Byte.
Dpt dataPointType()
returns the currently configured datapoint type.
bool readEnable()
Check if the read flag (R) was set.
ComFlag
Definition: group_object.h:11
@ Ok
read or write request were send successfully
Definition: group_object.h:16
@ ReadRequest
Read was requested but was not processed.
Definition: group_object.h:13
@ Updated
Group object was updated.
Definition: group_object.h:12
@ Uninitialized
uninitialized Group Object, its value is not valid
Definition: group_object.h:18
@ Error
there was an error on processing a request
Definition: group_object.h:17
@ Transmitting
Group Object is processed a the moment (read or write)
Definition: group_object.h:15
@ WriteRequest
Write was requested but was not processed.
Definition: group_object.h:14
std::function< void(GroupObject &)> GroupObjectUpdatedHandler
Definition: group_object.h:33
Priority
Definition: knx_types.h:10