mirror of
https://github.com/thelsing/knx.git
synced 2025-08-13 13:46:20 +02:00
Merge 9ee6e11ca5
into 5048de6c75
This commit is contained in:
commit
21bd4e3812
@ -485,6 +485,18 @@ namespace Knx
|
|||||||
ComFlag _commFlag : 7;
|
ComFlag _commFlag : 7;
|
||||||
uint8_t* _data = 0;
|
uint8_t* _data = 0;
|
||||||
uint8_t _dataLength = 0;
|
uint8_t _dataLength = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the current value of the group object and show success.
|
||||||
|
* @param value the value the group object is set to
|
||||||
|
* @param type the datapoint type used for the conversion.
|
||||||
|
*
|
||||||
|
* The parameters must fit the group object. Otherwise it will stay unchanged.
|
||||||
|
*
|
||||||
|
* @returns true if the value of the group object was updated after successful conversion.
|
||||||
|
*/
|
||||||
|
template<class DPT> bool _valueNoSend(const DPT& value);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bool operator==(const GroupObject& lhs, const GroupObject& rhs);
|
bool operator==(const GroupObject& lhs, const GroupObject& rhs);
|
||||||
@ -492,9 +504,12 @@ namespace Knx
|
|||||||
template <class DPT>
|
template <class DPT>
|
||||||
void GroupObject::value(const DPT& value)
|
void GroupObject::value(const DPT& value)
|
||||||
{
|
{
|
||||||
valueNoSend(value);
|
if (_valueNoSend(value))
|
||||||
|
{
|
||||||
|
// write on successful conversion/setting value only
|
||||||
objectWritten();
|
objectWritten();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template <class DPT>
|
template <class DPT>
|
||||||
DPT GroupObject::value()
|
DPT GroupObject::value()
|
||||||
@ -519,14 +534,24 @@ namespace Knx
|
|||||||
|
|
||||||
template <class DPT>
|
template <class DPT>
|
||||||
void GroupObject::valueNoSend(const DPT& value)
|
void GroupObject::valueNoSend(const DPT& value)
|
||||||
|
{
|
||||||
|
// ignore actual updating TODO check replacing valueNoSend with _valueNoSend
|
||||||
|
_valueNoSend(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class DPT> bool GroupObject::_valueNoSend(const KNXValue& value)
|
||||||
{
|
{
|
||||||
if (value.size() != sizeCode())
|
if (value.size() != sizeCode())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_uninitialized)
|
const bool encodingDone = true; // TODO FIXME for devel! value.encode needs success indicator
|
||||||
|
value.encode(_data);
|
||||||
|
|
||||||
|
// initialize on succesful conversion only
|
||||||
|
if (encodingDone && _uninitialized)
|
||||||
commFlag(Ok);
|
commFlag(Ok);
|
||||||
|
|
||||||
value.encode(_data);
|
return encodingDone;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class DPT>
|
template <class DPT>
|
||||||
@ -538,15 +563,22 @@ namespace Knx
|
|||||||
if (_uninitialized)
|
if (_uninitialized)
|
||||||
{
|
{
|
||||||
// always set first value
|
// always set first value
|
||||||
this->valueNoSend(value);
|
return _valueNoSend(value);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// convert new value to given dtp
|
// convert new value to given DPT
|
||||||
uint8_t newData[_dataLength];
|
uint8_t newData[_dataLength];
|
||||||
memset(newData, 0, _dataLength);
|
memset(newData, 0, _dataLength);
|
||||||
|
|
||||||
|
const bool encodingDone = true; // TODO FIXME for devel! value.encode needs success indicator
|
||||||
value.encode(newData);
|
value.encode(newData);
|
||||||
|
if (!encodingDone)
|
||||||
|
{
|
||||||
|
// value conversion to DPT failed
|
||||||
|
// do NOT update the value of the KO!
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// check for change in converted value / update value on change only
|
// check for change in converted value / update value on change only
|
||||||
const bool dataChanged = memcmp(_data, newData, _dataLength);
|
const bool dataChanged = memcmp(_data, newData, _dataLength);
|
||||||
|
Loading…
Reference in New Issue
Block a user