mirror of
https://github.com/thelsing/knx.git
synced 2025-01-02 00:06:43 +01:00
document AddressTableObject
This commit is contained in:
parent
9a811b1458
commit
ae9baa7702
@ -6,6 +6,14 @@
|
|||||||
note = "v01.01.02"
|
note = "v01.01.02"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@manual{knx:3/5/1,
|
||||||
|
organization = "KNX Association",
|
||||||
|
title = "KNX System Specifications Chapter 3/5/1 Resources",
|
||||||
|
year = 2013,
|
||||||
|
month = 12,
|
||||||
|
note = "v01.09.03"
|
||||||
|
}
|
||||||
|
|
||||||
@manual{knx:3/7/3,
|
@manual{knx:3/7/3,
|
||||||
organization = "KNX Association",
|
organization = "KNX Association",
|
||||||
title = "KNX System Specifications Chapter 3/7/3 Standardized Identifier Tables",
|
title = "KNX System Specifications Chapter 3/7/3 Standardized Identifier Tables",
|
||||||
|
@ -32,7 +32,7 @@ uint16_t AddressTableObject::entryCount()
|
|||||||
return ntohs(_groupAddresses[0]);
|
return ntohs(_groupAddresses[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t AddressTableObject::getGa(uint16_t tsap)
|
uint16_t AddressTableObject::getGroupAddress(uint16_t tsap)
|
||||||
{
|
{
|
||||||
if (loadState() != LS_LOADED || tsap > entryCount() )
|
if (loadState() != LS_LOADED || tsap > entryCount() )
|
||||||
return 0;
|
return 0;
|
||||||
@ -46,7 +46,7 @@ uint16_t AddressTableObject::getTsap(uint16_t addr)
|
|||||||
for (uint16_t i = 1; i <= size; i++)
|
for (uint16_t i = 1; i <= size; i++)
|
||||||
if (ntohs(_groupAddresses[i]) == addr)
|
if (ntohs(_groupAddresses[i]) == addr)
|
||||||
return i;
|
return i;
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma region SaveRestore
|
#pragma region SaveRestore
|
||||||
@ -60,7 +60,7 @@ uint8_t* AddressTableObject::restore(uint8_t* buffer)
|
|||||||
{
|
{
|
||||||
buffer = TableObject::restore(buffer);
|
buffer = TableObject::restore(buffer);
|
||||||
|
|
||||||
_groupAddresses = (uint16_t*)_data;
|
_groupAddresses = (uint16_t*)data();
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
@ -82,7 +82,7 @@ void AddressTableObject::beforeStateChange(LoadState& newState)
|
|||||||
if (newState != LS_LOADED)
|
if (newState != LS_LOADED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_groupAddresses = (uint16_t*)_data;
|
_groupAddresses = (uint16_t*)data();
|
||||||
}
|
}
|
||||||
|
|
||||||
static PropertyDescription _propertyDescriptions[] =
|
static PropertyDescription _propertyDescriptions[] =
|
||||||
|
@ -1,18 +1,53 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "table_object.h"
|
#include "table_object.h"
|
||||||
|
/**
|
||||||
|
* @brief This class represents the group address table. It provides a mapping between tranport layer
|
||||||
|
* service access points (TSAP) and group addresses. The TSAP can be imagined as an index to the array
|
||||||
|
* of group adresses.
|
||||||
|
*
|
||||||
|
* See section 4.10 of @cite knx:3/5/1 for further details.
|
||||||
|
* It implements realisation type 7 (see section 4.10.7 of @cite knx:3/5/1).
|
||||||
|
*/
|
||||||
class AddressTableObject: public TableObject
|
class AddressTableObject: public TableObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* @brief The contructor.
|
||||||
|
* @param platform This parameter is only passed to the custructor of TableObject an not used by this class.
|
||||||
|
*/
|
||||||
AddressTableObject(Platform& platform);
|
AddressTableObject(Platform& platform);
|
||||||
void readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t *data);
|
void readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t *data);
|
||||||
|
uint8_t *save(uint8_t *buffer);
|
||||||
|
uint8_t *restore(uint8_t *buffer);
|
||||||
|
/**
|
||||||
|
* @brief returns the number of group addresses of the object.
|
||||||
|
*/
|
||||||
uint16_t entryCount();
|
uint16_t entryCount();
|
||||||
uint16_t getGa(uint16_t tsap);
|
/**
|
||||||
uint16_t getTsap(uint16_t ga);
|
* @brief Get the group address mapped to a TSAP.
|
||||||
uint8_t* save(uint8_t* buffer);
|
*
|
||||||
uint8_t* restore(uint8_t* buffer);
|
* @param tsap The TSAP of which to get the group address for.
|
||||||
bool contains(uint16_t addr);
|
*
|
||||||
|
* @return the groupAddress if found or zero if no group address was found.
|
||||||
|
*/
|
||||||
|
uint16_t getGroupAddress(uint16_t tsap);
|
||||||
|
/**
|
||||||
|
* @brief Get the TSAP mapped to a group address.
|
||||||
|
*
|
||||||
|
* @param groupAddress the group address of whicht to get the TSAP for.
|
||||||
|
*
|
||||||
|
* @return the TSAP if found or zero if no tsap was found.
|
||||||
|
*/
|
||||||
|
uint16_t getTsap(uint16_t groupAddress);
|
||||||
|
/**
|
||||||
|
* @brief Check if the address table contains a group address.
|
||||||
|
*
|
||||||
|
* @param groupAddress the group address to check
|
||||||
|
*
|
||||||
|
* @return true if the address table contains the group address, false otherwise
|
||||||
|
*/
|
||||||
|
bool contains(uint16_t groupAddress);
|
||||||
protected:
|
protected:
|
||||||
virtual void beforeStateChange(LoadState& newState);
|
virtual void beforeStateChange(LoadState& newState);
|
||||||
uint8_t propertyCount();
|
uint8_t propertyCount();
|
||||||
|
@ -56,22 +56,22 @@ uint8_t ApplicationProgramObject::propertySize(PropertyID id)
|
|||||||
|
|
||||||
uint8_t * ApplicationProgramObject::data(uint32_t addr)
|
uint8_t * ApplicationProgramObject::data(uint32_t addr)
|
||||||
{
|
{
|
||||||
return _data + addr;
|
return TableObject::data() + addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t ApplicationProgramObject::getByte(uint32_t addr)
|
uint8_t ApplicationProgramObject::getByte(uint32_t addr)
|
||||||
{
|
{
|
||||||
return *(_data + addr);
|
return *(TableObject::data() + addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t ApplicationProgramObject::getWord(uint32_t addr)
|
uint16_t ApplicationProgramObject::getWord(uint32_t addr)
|
||||||
{
|
{
|
||||||
return ::getWord(_data + addr);
|
return ::getWord(TableObject::data() + addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ApplicationProgramObject::getInt(uint32_t addr)
|
uint32_t ApplicationProgramObject::getInt(uint32_t addr)
|
||||||
{
|
{
|
||||||
return ::getInt(_data + addr);
|
return ::getInt(TableObject::data() + addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t* ApplicationProgramObject::save(uint8_t* buffer)
|
uint8_t* ApplicationProgramObject::save(uint8_t* buffer)
|
||||||
|
@ -45,7 +45,7 @@ uint8_t* AssociationTableObject::save(uint8_t* buffer)
|
|||||||
uint8_t* AssociationTableObject::restore(uint8_t* buffer)
|
uint8_t* AssociationTableObject::restore(uint8_t* buffer)
|
||||||
{
|
{
|
||||||
buffer = TableObject::restore(buffer);
|
buffer = TableObject::restore(buffer);
|
||||||
_tableData = (uint16_t*)_data;
|
_tableData = (uint16_t*)data();
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ void AssociationTableObject::beforeStateChange(LoadState& newState)
|
|||||||
if (newState != LS_LOADED)
|
if (newState != LS_LOADED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_tableData = (uint16_t*)_data;
|
_tableData = (uint16_t*)data();
|
||||||
}
|
}
|
||||||
|
|
||||||
static PropertyDescription _propertyDescriptions[] =
|
static PropertyDescription _propertyDescriptions[] =
|
||||||
|
@ -52,7 +52,7 @@ uint8_t* GroupObjectTableObject::restore(uint8_t* buffer)
|
|||||||
{
|
{
|
||||||
buffer = TableObject::restore(buffer);
|
buffer = TableObject::restore(buffer);
|
||||||
|
|
||||||
_tableData = (uint16_t*)_data;
|
_tableData = (uint16_t*)data();
|
||||||
initGroupObjects();
|
initGroupObjects();
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
@ -95,12 +95,12 @@ void GroupObjectTableObject::beforeStateChange(LoadState& newState)
|
|||||||
if (newState != LS_LOADED)
|
if (newState != LS_LOADED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_tableData = (uint16_t*)_data;
|
_tableData = (uint16_t*)data();
|
||||||
|
|
||||||
if (!initGroupObjects())
|
if (!initGroupObjects())
|
||||||
{
|
{
|
||||||
newState = LS_ERROR;
|
newState = LS_ERROR;
|
||||||
TableObject::_errorCode = E_SOFTWARE_FAULT;
|
TableObject::errorCode(E_SOFTWARE_FAULT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,8 @@ void TableObject::readProperty(PropertyID id, uint32_t start, uint32_t& count, u
|
|||||||
case PID_ERROR_CODE:
|
case PID_ERROR_CODE:
|
||||||
data[0] = _errorCode;
|
data[0] = _errorCode;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
InterfaceObject::readProperty(id, start, count, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,6 +40,8 @@ void TableObject::writeProperty(PropertyID id, uint8_t start, uint8_t* data, uin
|
|||||||
//case PID_MCB_TABLE:
|
//case PID_MCB_TABLE:
|
||||||
// TODO
|
// TODO
|
||||||
// break;
|
// break;
|
||||||
|
default:
|
||||||
|
InterfaceObject::writeProperty(id, start, data, count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,8 +57,9 @@ uint8_t TableObject::propertySize(PropertyID id)
|
|||||||
return 1;
|
return 1;
|
||||||
case PID_OBJECT_TYPE:
|
case PID_OBJECT_TYPE:
|
||||||
return 2;
|
return 2;
|
||||||
|
default:
|
||||||
|
return InterfaceObject::propertySize(id);
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TableObject::~TableObject()
|
TableObject::~TableObject()
|
||||||
@ -157,6 +162,9 @@ void TableObject::loadEvent(uint8_t* data)
|
|||||||
case LS_ERROR:
|
case LS_ERROR:
|
||||||
loadEventError(data);
|
loadEventError(data);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
/* do nothing */
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,3 +271,18 @@ void TableObject::additionalLoadControls(uint8_t* data)
|
|||||||
_errorCode = E_MAX_TABLE_LENGTH_EXEEDED;
|
_errorCode = E_MAX_TABLE_LENGTH_EXEEDED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t* TableObject::data()
|
||||||
|
{
|
||||||
|
return _data;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t TableObject::size()
|
||||||
|
{
|
||||||
|
return _size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TableObject::errorCode(ErrorCode errorCode)
|
||||||
|
{
|
||||||
|
_errorCode = errorCode;
|
||||||
|
}
|
@ -3,23 +3,53 @@
|
|||||||
#include "interface_object.h"
|
#include "interface_object.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This class provides common functionality for interface objects that are configured by ETS with MemorWrite.
|
||||||
|
*/
|
||||||
class TableObject: public InterfaceObject
|
class TableObject: public InterfaceObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* @brief The constuctor.
|
||||||
|
* @param platform the Platform on which the software runs. The class uses the memory management features of Platform.
|
||||||
|
*/
|
||||||
TableObject(Platform& platform);
|
TableObject(Platform& platform);
|
||||||
virtual void readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t* data);
|
virtual void readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t* data);
|
||||||
virtual void writeProperty(PropertyID id, uint8_t start, uint8_t* data, uint8_t count);
|
virtual void writeProperty(PropertyID id, uint8_t start, uint8_t* data, uint8_t count);
|
||||||
virtual uint8_t propertySize(PropertyID id);
|
virtual uint8_t propertySize(PropertyID id);
|
||||||
|
/**
|
||||||
|
* @brief The destructor.
|
||||||
|
*/
|
||||||
virtual ~TableObject();
|
virtual ~TableObject();
|
||||||
|
/**
|
||||||
|
* @brief This method returns the ::LoadState of the interface object.
|
||||||
|
*/
|
||||||
LoadState loadState();
|
LoadState loadState();
|
||||||
virtual uint8_t* save(uint8_t* buffer);
|
virtual uint8_t* save(uint8_t* buffer);
|
||||||
virtual uint8_t* restore(uint8_t* buffer);
|
virtual uint8_t* restore(uint8_t* buffer);
|
||||||
protected:
|
protected:
|
||||||
|
/**
|
||||||
|
* @brief This method is called before the interface object enters a new ::Loadstate.
|
||||||
|
* If there is a error changing the state newState should be set to ::LS_ERROR and errorCode()
|
||||||
|
* to a reason for the failure.
|
||||||
|
*/
|
||||||
virtual void beforeStateChange(LoadState& newState) {}
|
virtual void beforeStateChange(LoadState& newState) {}
|
||||||
uint8_t* _data = 0;
|
|
||||||
uint32_t _size = 0;
|
/**
|
||||||
ErrorCode _errorCode = E_NO_FAULT;
|
* @brief returns the internal data of the interface object. This pointer belongs to the TableObject class and
|
||||||
private:
|
* must not be freed.
|
||||||
|
*/
|
||||||
|
uint8_t* data();
|
||||||
|
/**
|
||||||
|
* @brief returns the size of the internal data of the interface object int byte.
|
||||||
|
*/
|
||||||
|
uint32_t size();
|
||||||
|
/**
|
||||||
|
* @brief Set the reason for a state change failure.
|
||||||
|
*/
|
||||||
|
void errorCode(ErrorCode errorCode);
|
||||||
|
|
||||||
|
private:
|
||||||
uint32_t tableReference();
|
uint32_t tableReference();
|
||||||
bool allocTable(uint32_t size, bool doFill, uint8_t fillByte);
|
bool allocTable(uint32_t size, bool doFill, uint8_t fillByte);
|
||||||
void loadEvent(uint8_t* data);
|
void loadEvent(uint8_t* data);
|
||||||
@ -31,4 +61,7 @@ private:
|
|||||||
void loadState(LoadState newState);
|
void loadState(LoadState newState);
|
||||||
LoadState _state = LS_UNLOADED;
|
LoadState _state = LS_UNLOADED;
|
||||||
Platform& _platform;
|
Platform& _platform;
|
||||||
|
uint8_t *_data = 0;
|
||||||
|
uint32_t _size = 0;
|
||||||
|
ErrorCode _errorCode = E_NO_FAULT;
|
||||||
};
|
};
|
||||||
|
@ -356,6 +356,9 @@ void TransportLayer::dataIndividualConfirm(AckType ack, uint16_t destination, Ho
|
|||||||
void TransportLayer::dataGroupIndication(uint16_t destination, HopCountType hopType, Priority priority, uint16_t source, TPDU& tpdu)
|
void TransportLayer::dataGroupIndication(uint16_t destination, HopCountType hopType, Priority priority, uint16_t source, TPDU& tpdu)
|
||||||
{
|
{
|
||||||
uint16_t tsap = _groupAddressTable.getTsap(destination);
|
uint16_t tsap = _groupAddressTable.getTsap(destination);
|
||||||
|
if (tsap == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
_applicationLayer.dataGroupIndication(hopType, priority, tsap, tpdu.apdu());
|
_applicationLayer.dataGroupIndication(hopType, priority, tsap, tpdu.apdu());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,7 +389,7 @@ void TransportLayer::dataSystemBroadcastConfirm(AckType ack, HopCountType hopTyp
|
|||||||
|
|
||||||
void TransportLayer::dataGroupRequest(AckType ack, HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu)
|
void TransportLayer::dataGroupRequest(AckType ack, HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu)
|
||||||
{
|
{
|
||||||
uint16_t groupAdress = _groupAddressTable.getGa(tsap);
|
uint16_t groupAdress = _groupAddressTable.getGroupAddress(tsap);
|
||||||
TPDU& tpdu = apdu.frame().tpdu();
|
TPDU& tpdu = apdu.frame().tpdu();
|
||||||
_networkLayer->dataGroupRequest(ack, groupAdress, hopType, priority, tpdu);
|
_networkLayer->dataGroupRequest(ack, groupAdress, hopType, priority, tpdu);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user