mirror of
https://github.com/thelsing/knx.git
synced 2025-01-02 00:06:43 +01:00
New implementation of Uninitialized state for group object
- old implementation is still there for compatibility reasons - new implementation reflects the case "uninitialized while transmitting" - Just states "Updated", "WriteRequest" and "Ok" remove uninitialized state
This commit is contained in:
parent
57b5b05ce1
commit
e43325e42b
@ -12,7 +12,8 @@ GroupObjectTableObject* GroupObject::_table = 0;
|
|||||||
GroupObject::GroupObject()
|
GroupObject::GroupObject()
|
||||||
{
|
{
|
||||||
_data = 0;
|
_data = 0;
|
||||||
_commFlag = Uninitialized;
|
_commFlagEx.uninitialized = true;
|
||||||
|
_commFlagEx.commFlag = Uninitialized;
|
||||||
_dataLength = 0;
|
_dataLength = 0;
|
||||||
#ifndef SMALL_GROUPOBJECT
|
#ifndef SMALL_GROUPOBJECT
|
||||||
_updateHandler = 0;
|
_updateHandler = 0;
|
||||||
@ -22,7 +23,7 @@ GroupObject::GroupObject()
|
|||||||
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;
|
_commFlagEx = other._commFlagEx;
|
||||||
_dataLength = other._dataLength;
|
_dataLength = other._dataLength;
|
||||||
_asap = other._asap;
|
_asap = other._asap;
|
||||||
#ifndef SMALL_GROUPOBJECT
|
#ifndef SMALL_GROUPOBJECT
|
||||||
@ -75,7 +76,7 @@ bool GroupObject::readEnable()
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// we forbid reading of new (uninitialized) go
|
// we forbid reading of new (uninitialized) go
|
||||||
if (_commFlag == Uninitialized)
|
if (_commFlagEx.uninitialized)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return bitRead(ntohs(_table->_tableData[_asap]), 11) > 0;
|
return bitRead(ntohs(_table->_tableData[_asap]), 11) > 0;
|
||||||
@ -157,22 +158,29 @@ size_t GroupObject::asapValueSize(uint8_t code)
|
|||||||
|
|
||||||
ComFlag GroupObject::commFlag()
|
ComFlag GroupObject::commFlag()
|
||||||
{
|
{
|
||||||
return _commFlag;
|
return _commFlagEx.commFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupObject::commFlag(ComFlag value)
|
void GroupObject::commFlag(ComFlag value)
|
||||||
{
|
{
|
||||||
_commFlag = value;
|
_commFlagEx.commFlag = value;
|
||||||
|
if (value == WriteRequest || value == Updated || value == Ok)
|
||||||
|
_commFlagEx.uninitialized = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GroupObject::initialized()
|
||||||
|
{
|
||||||
|
return !_commFlagEx.uninitialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupObject::requestObjectRead()
|
void GroupObject::requestObjectRead()
|
||||||
{
|
{
|
||||||
_commFlag = ReadRequest;
|
_commFlagEx.commFlag = ReadRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupObject::objectWritten()
|
void GroupObject::objectWritten()
|
||||||
{
|
{
|
||||||
_commFlag = WriteRequest;
|
_commFlagEx.commFlag = WriteRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t GroupObject::valueSize()
|
size_t GroupObject::valueSize()
|
||||||
@ -274,8 +282,11 @@ void GroupObject::valueNoSend(const KNXValue& value)
|
|||||||
|
|
||||||
void GroupObject::valueNoSend(const KNXValue& value, const Dpt& type)
|
void GroupObject::valueNoSend(const KNXValue& value, const Dpt& type)
|
||||||
{
|
{
|
||||||
if (_commFlag == Uninitialized)
|
if (_commFlagEx.uninitialized)
|
||||||
_commFlag = Ok;
|
{
|
||||||
|
_commFlagEx.commFlag = Ok;
|
||||||
|
_commFlagEx.uninitialized = false;
|
||||||
|
}
|
||||||
|
|
||||||
KNX_Encode_Value(value, _data, _dataLength, type);
|
KNX_Encode_Value(value, _data, _dataLength, type);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
class GroupObjectTableObject;
|
class GroupObjectTableObject;
|
||||||
|
|
||||||
enum ComFlag
|
enum ComFlag : uint8_t
|
||||||
{
|
{
|
||||||
Updated = 0, //!< Group object was updated
|
Updated = 0, //!< Group object was updated
|
||||||
ReadRequest = 1, //!< Read was requested but was not processed
|
ReadRequest = 1, //!< Read was requested but was not processed
|
||||||
@ -18,6 +18,16 @@ enum ComFlag
|
|||||||
Uninitialized = 6 //!< uninitialized Group Object, its value is not valid
|
Uninitialized = 6 //!< uninitialized Group Object, its value is not valid
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// extended ComFlag: Uninitialized it not handled correctly as ComFlag
|
||||||
|
// it might be in state Transmitting during a ReadRequest on startup while value is still not valid
|
||||||
|
// we use MSB to store Uninitialized and keep the size of GroupObject the same saving memory ressources
|
||||||
|
// the old Uninitialized handling is still there for compatibility reasons.
|
||||||
|
struct ComFlagEx
|
||||||
|
{
|
||||||
|
bool uninitialized : 1;
|
||||||
|
ComFlag commFlag : 7;
|
||||||
|
};
|
||||||
|
|
||||||
class GroupObject;
|
class GroupObject;
|
||||||
|
|
||||||
#ifndef HAS_FUNCTIONAL
|
#ifndef HAS_FUNCTIONAL
|
||||||
@ -96,6 +106,11 @@ class GroupObject
|
|||||||
*/
|
*/
|
||||||
void commFlag(ComFlag value);
|
void commFlag(ComFlag value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the group object contains a valid value assigned from bus or from application program
|
||||||
|
*/
|
||||||
|
bool initialized();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request the read of a communication object. Calling this function triggers the
|
* Request the read of a communication object. Calling this function triggers the
|
||||||
* sending of a read-group-value telegram, to read the value of the communication
|
* sending of a read-group-value telegram, to read the value of the communication
|
||||||
@ -249,7 +264,7 @@ class GroupObject
|
|||||||
size_t asapValueSize(uint8_t code);
|
size_t asapValueSize(uint8_t code);
|
||||||
size_t goSize();
|
size_t goSize();
|
||||||
uint16_t _asap = 0;
|
uint16_t _asap = 0;
|
||||||
ComFlag _commFlag = Uninitialized;
|
ComFlagEx _commFlagEx;
|
||||||
uint8_t* _data = 0;
|
uint8_t* _data = 0;
|
||||||
uint8_t _dataLength = 0;
|
uint8_t _dataLength = 0;
|
||||||
#ifndef SMALL_GROUPOBJECT
|
#ifndef SMALL_GROUPOBJECT
|
||||||
|
Loading…
Reference in New Issue
Block a user