mirror of
https://github.com/thelsing/knx.git
synced 2025-08-26 13:51:28 +02:00
- added SMALL_GROUPOBJECT
This commit is contained in:
parent
d7e5291387
commit
cb19647673
@ -114,9 +114,13 @@ void BauSystemBDevice::updateGroupObject(GroupObject & go, uint8_t * data, uint8
|
|||||||
memcpy(goData, data, length);
|
memcpy(goData, data, length);
|
||||||
|
|
||||||
go.commFlag(Updated);
|
go.commFlag(Updated);
|
||||||
|
#ifdef SMALL_GROUPOBJECT
|
||||||
|
GroupObject::processClassCallback(go);
|
||||||
|
#else
|
||||||
GroupObjectUpdatedHandler handler = go.callback();
|
GroupObjectUpdatedHandler handler = go.callback();
|
||||||
if (handler)
|
if (handler)
|
||||||
handler(go);
|
handler(go);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BauSystemBDevice::configured()
|
bool BauSystemBDevice::configured()
|
||||||
|
@ -4,23 +4,30 @@
|
|||||||
#include "datapoint_types.h"
|
#include "datapoint_types.h"
|
||||||
#include "group_object_table_object.h"
|
#include "group_object_table_object.h"
|
||||||
|
|
||||||
|
#ifdef SMALL_GROUPOBJECT
|
||||||
|
GroupObjectUpdatedHandler GroupObject::_updateHandlerStatic = 0;
|
||||||
|
#endif
|
||||||
|
GroupObjectTableObject* GroupObject::_table = 0;
|
||||||
|
|
||||||
GroupObject::GroupObject()
|
GroupObject::GroupObject()
|
||||||
{
|
{
|
||||||
_data = 0;
|
_data = 0;
|
||||||
_commFlag = Ok;
|
_commFlag = Ok;
|
||||||
_table = 0;
|
|
||||||
_dataLength = 0;
|
_dataLength = 0;
|
||||||
|
#ifndef SMALL_GROUPOBJECT
|
||||||
_updateHandler = 0;
|
_updateHandler = 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
GroupObject::GroupObject(const GroupObject& other)
|
GroupObject::GroupObject(const GroupObject& other)
|
||||||
{
|
{
|
||||||
_data = new uint8_t[other._dataLength];
|
_data = new uint8_t[other._dataLength];
|
||||||
_commFlag = other._commFlag;
|
_commFlag = other._commFlag;
|
||||||
_table = other._table;
|
|
||||||
_dataLength = other._dataLength;
|
_dataLength = other._dataLength;
|
||||||
_asap = other._asap;
|
_asap = other._asap;
|
||||||
|
#ifndef SMALL_GROUPOBJECT
|
||||||
_updateHandler = other._updateHandler;
|
_updateHandler = other._updateHandler;
|
||||||
|
#endif
|
||||||
memcpy(_data, other._data, _dataLength);
|
memcpy(_data, other._data, _dataLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,6 +182,24 @@ size_t GroupObject::sizeInTelegram()
|
|||||||
return asapValueSize(code);
|
return asapValueSize(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef SMALL_GROUPOBJECT
|
||||||
|
GroupObjectUpdatedHandler GroupObject::classCallback()
|
||||||
|
{
|
||||||
|
return _updateHandlerStatic;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GroupObject::classCallback(GroupObjectUpdatedHandler handler)
|
||||||
|
{
|
||||||
|
_updateHandlerStatic = handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GroupObject::processClassCallback(GroupObject& ko)
|
||||||
|
{
|
||||||
|
if (_updateHandlerStatic != 0)
|
||||||
|
_updateHandlerStatic(ko);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
void GroupObject::callback(GroupObjectUpdatedHandler handler)
|
void GroupObject::callback(GroupObjectUpdatedHandler handler)
|
||||||
{
|
{
|
||||||
_updateHandler = handler;
|
_updateHandler = handler;
|
||||||
@ -185,6 +210,7 @@ GroupObjectUpdatedHandler GroupObject::callback()
|
|||||||
{
|
{
|
||||||
return _updateHandler;
|
return _updateHandler;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void GroupObject::value(const KNXValue& value, const Dpt& type)
|
void GroupObject::value(const KNXValue& value, const Dpt& type)
|
||||||
{
|
{
|
||||||
@ -205,7 +231,7 @@ bool GroupObject::tryValue(KNXValue& value, const Dpt& type)
|
|||||||
return KNX_Decode_Value(_data, _dataLength, type, value);
|
return KNX_Decode_Value(_data, _dataLength, type, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef SMALL_GROUPOBJECT
|
||||||
void GroupObject::dataPointType(Dpt value)
|
void GroupObject::dataPointType(Dpt value)
|
||||||
{
|
{
|
||||||
_datapointType = value;
|
_datapointType = value;
|
||||||
@ -240,7 +266,7 @@ void GroupObject::valueNoSend(const KNXValue& value)
|
|||||||
{
|
{
|
||||||
valueNoSend(value, _datapointType);
|
valueNoSend(value, _datapointType);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void GroupObject::valueNoSend(const KNXValue& value, const Dpt& type)
|
void GroupObject::valueNoSend(const KNXValue& value, const Dpt& type)
|
||||||
{
|
{
|
||||||
|
@ -133,6 +133,8 @@ class GroupObject
|
|||||||
* (in german "KO-Nr")
|
* (in german "KO-Nr")
|
||||||
*/
|
*/
|
||||||
uint16_t asap();
|
uint16_t asap();
|
||||||
|
|
||||||
|
#ifndef SMALL_GROUPOBJECT
|
||||||
/**
|
/**
|
||||||
* register a callback for this group object. The registered callback will be called if the group object was changed from the bus.
|
* register a callback for this group object. The registered callback will be called if the group object was changed from the bus.
|
||||||
*/
|
*/
|
||||||
@ -141,16 +143,12 @@ class GroupObject
|
|||||||
* returns the registered callback
|
* returns the registered callback
|
||||||
*/
|
*/
|
||||||
GroupObjectUpdatedHandler callback();
|
GroupObjectUpdatedHandler callback();
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* return the current value of the group object.
|
* return the current value of the group object.
|
||||||
* @param type the datapoint type used for the conversion. If this doesn't fit to the group object the returned value is invalid.
|
* @param type the datapoint type used for the conversion. If this doesn't fit to the group object the returned value is invalid.
|
||||||
*/
|
*/
|
||||||
KNXValue value(const Dpt& type);
|
KNXValue value(const Dpt& type);
|
||||||
/**
|
|
||||||
* return the current value of the group object. The datapoint type must be set with dataPointType(). Otherwise the returned
|
|
||||||
* value is invalid.
|
|
||||||
*/
|
|
||||||
KNXValue value();
|
|
||||||
/**
|
/**
|
||||||
* set the current value of the group object and changes the state of the group object to ::WriteRequest.
|
* set the current value of the group object and changes the state of the group object to ::WriteRequest.
|
||||||
* @param value the value the group object is set to
|
* @param value the value the group object is set to
|
||||||
@ -159,13 +157,6 @@ class GroupObject
|
|||||||
* The parameters must fit the group object. Otherwise it will stay unchanged.
|
* The parameters must fit the group object. Otherwise it will stay unchanged.
|
||||||
*/
|
*/
|
||||||
void value(const KNXValue& value, const Dpt& type);
|
void value(const KNXValue& value, const Dpt& type);
|
||||||
/**
|
|
||||||
* set the current value of the group object and changes the state of the group object to ::WriteRequest.
|
|
||||||
* @param value the value the group object is set to
|
|
||||||
*
|
|
||||||
* The parameters must fit the group object and dhe datapoint type must be set with dataPointType(). Otherwise it will stay unchanged.
|
|
||||||
*/
|
|
||||||
void value(const KNXValue& value);
|
|
||||||
/**
|
/**
|
||||||
* set the current value of the group object.
|
* set the current value of the group object.
|
||||||
* @param value the value the group object is set to
|
* @param value the value the group object is set to
|
||||||
@ -174,13 +165,6 @@ class GroupObject
|
|||||||
* The parameters must fit the group object. Otherwise it will stay unchanged.
|
* The parameters must fit the group object. Otherwise it will stay unchanged.
|
||||||
*/
|
*/
|
||||||
void valueNoSend(const KNXValue& value, const Dpt& type);
|
void valueNoSend(const KNXValue& value, const Dpt& type);
|
||||||
/**
|
|
||||||
* set the current value of the group object.
|
|
||||||
* @param value the value the group object is set to
|
|
||||||
*
|
|
||||||
* The parameters must fit the group object and dhe datapoint type must be set with dataPointType(). Otherwise it will stay unchanged.
|
|
||||||
*/
|
|
||||||
void valueNoSend(const KNXValue& value);
|
|
||||||
/**
|
/**
|
||||||
* set the current value of the group object.
|
* set the current value of the group object.
|
||||||
* @param value the value the group object is set to
|
* @param value the value the group object is set to
|
||||||
@ -191,6 +175,27 @@ class GroupObject
|
|||||||
* @returns true if the value of the group object was changed successfully.
|
* @returns true if the value of the group object was changed successfully.
|
||||||
*/
|
*/
|
||||||
bool tryValue(KNXValue& value, const Dpt& type);
|
bool tryValue(KNXValue& value, const Dpt& type);
|
||||||
|
|
||||||
|
#ifndef SMALL_GROUPOBJECT
|
||||||
|
/**
|
||||||
|
* return the current value of the group object. The datapoint type must be set with dataPointType(). Otherwise the returned
|
||||||
|
* value is invalid.
|
||||||
|
*/
|
||||||
|
KNXValue value();
|
||||||
|
/**
|
||||||
|
* set the current value of the group object and changes the state of the group object to ::WriteRequest.
|
||||||
|
* @param value the value the group object is set to
|
||||||
|
*
|
||||||
|
* The parameters must fit the group object and dhe datapoint type must be set with dataPointType(). Otherwise it will stay unchanged.
|
||||||
|
*/
|
||||||
|
void value(const KNXValue& value);
|
||||||
|
/**
|
||||||
|
* set the current value of the group object.
|
||||||
|
* @param value the value the group object is set to
|
||||||
|
*
|
||||||
|
* The parameters must fit the group object and dhe datapoint type must be set with dataPointType(). Otherwise it will stay unchanged.
|
||||||
|
*/
|
||||||
|
void valueNoSend(const KNXValue& value);
|
||||||
/**
|
/**
|
||||||
* set the current value of the group object.
|
* set the current value of the group object.
|
||||||
* @param value the value the group object is set to
|
* @param value the value the group object is set to
|
||||||
@ -209,15 +214,32 @@ class GroupObject
|
|||||||
* sets the datapoint type of the group object.
|
* sets the datapoint type of the group object.
|
||||||
*/
|
*/
|
||||||
void dataPointType(Dpt value);
|
void dataPointType(Dpt value);
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* Alternative callback processing: register one global callback for all group object.
|
||||||
|
* The registered callback will be called if any group object was changed from the bus.
|
||||||
|
* The callback method has to dispatch to the correct handler for this group object.
|
||||||
|
*/
|
||||||
|
static GroupObjectUpdatedHandler classCallback();
|
||||||
|
static void classCallback(GroupObjectUpdatedHandler handler);
|
||||||
|
static void processClassCallback(GroupObject& ko);
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// class members
|
||||||
|
static GroupObjectTableObject* _table;
|
||||||
|
#ifdef SMALL_GROUPOBJECT
|
||||||
|
static GroupObjectUpdatedHandler _updateHandlerStatic;
|
||||||
|
#endif
|
||||||
|
|
||||||
size_t asapValueSize(uint8_t code);
|
size_t asapValueSize(uint8_t code);
|
||||||
GroupObjectUpdatedHandler _updateHandler;
|
|
||||||
size_t goSize();
|
size_t goSize();
|
||||||
uint16_t _asap = 0;
|
uint16_t _asap = 0;
|
||||||
ComFlag _commFlag = Ok;
|
ComFlag _commFlag = Ok;
|
||||||
uint8_t* _data = 0;
|
uint8_t* _data = 0;
|
||||||
uint8_t _dataLength = 0;
|
uint8_t _dataLength = 0;
|
||||||
GroupObjectTableObject* _table = 0;
|
#ifndef SMALL_GROUPOBJECT
|
||||||
|
GroupObjectUpdatedHandler _updateHandler;
|
||||||
Dpt _datapointType;
|
Dpt _datapointType;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user