add support for propertyDescriptionRead

(descriptions are still missing)
This commit is contained in:
Thomas Kunze 2018-04-13 22:08:10 +02:00
parent 7eb629a4e6
commit 39edb63caf
16 changed files with 188 additions and 3 deletions

View File

@ -83,3 +83,17 @@ void AddressTableObject::beforeStateChange(LoadState& newState)
_groupAddresses = (uint16_t*)_data;
}
static PropertyDescription _propertyDescriptions[] = { };
static uint8_t _propertyCount = sizeof(_propertyDescriptions) / sizeof(PropertyDescription);
uint8_t AddressTableObject::propertyCount()
{
return _propertyCount;
}
PropertyDescription* AddressTableObject::propertyDescriptions()
{
return _propertyDescriptions;
}

View File

@ -6,7 +6,10 @@ class AddressTableObject: public TableObject
{
public:
AddressTableObject(uint8_t* memoryReference);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Woverloaded-virtual"
void readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t* data);
#pragma GCC diagnostic pop
uint16_t entryCount();
uint16_t getGa(uint16_t tsap);
uint16_t getTsap(uint16_t ga);
@ -15,6 +18,8 @@ public:
bool contains(uint16_t addr);
protected:
virtual void beforeStateChange(LoadState& newState);
uint8_t propertyCount();
PropertyDescription* propertyDescriptions();
private:
uint16_t* _groupAddresses;
};

View File

@ -85,3 +85,18 @@ uint8_t* ApplicationProgramObject::restore(uint8_t* buffer)
return TableObject::restore(buffer);
}
static PropertyDescription _propertyDescriptions[] = {};
static uint8_t _propertyCount = sizeof(_propertyDescriptions) / sizeof(PropertyDescription);
uint8_t ApplicationProgramObject::propertyCount()
{
return _propertyCount;
}
PropertyDescription* ApplicationProgramObject::propertyDescriptions()
{
return _propertyDescriptions;
}

View File

@ -6,7 +6,10 @@ class ApplicationProgramObject: public TableObject
{
public:
ApplicationProgramObject(uint8_t* memoryReference);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Woverloaded-virtual"
void readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t* data);
#pragma GCC diagnostic pop
void writeProperty(PropertyID id, uint8_t start, uint8_t* data, uint8_t count);
uint8_t propertySize(PropertyID id);
uint8_t* data(uint32_t addr);
@ -15,6 +18,9 @@ public:
uint32_t getInt(uint32_t addr);
uint8_t* save(uint8_t* buffer);
uint8_t* restore(uint8_t* buffer);
protected:
uint8_t propertyCount();
PropertyDescription* propertyDescriptions();
private:
uint8_t _programVersion[5];
};

View File

@ -66,4 +66,18 @@ void AssociationTableObject::beforeStateChange(LoadState& newState)
return;
_tableData = (uint16_t*)_data;
}
static PropertyDescription _propertyDescriptions[] = { };
static uint8_t _propertyCount = sizeof(_propertyDescriptions) / sizeof(PropertyDescription);
uint8_t AssociationTableObject::propertyCount()
{
return _propertyCount;
}
PropertyDescription* AssociationTableObject::propertyDescriptions()
{
return _propertyDescriptions;
}

View File

@ -6,7 +6,10 @@ class AssociationTableObject: public TableObject
{
public:
AssociationTableObject(uint8_t* memoryReference);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Woverloaded-virtual"
void readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t* data);
#pragma GCC diagnostic pop
uint16_t entryCount();
uint16_t operator[](uint16_t idx);
uint8_t* save(uint8_t* buffer);
@ -15,6 +18,8 @@ public:
int32_t translateAsap(uint16_t asap);
protected:
void beforeStateChange(LoadState& newState);
uint8_t propertyCount();
PropertyDescription* propertyDescriptions();
private:
uint16_t* _tableData;
};

View File

@ -181,9 +181,16 @@ void Bau57B0::userMemoryWriteIndication(Priority priority, HopCountType hopType,
void Bau57B0::propertyDescriptionReadIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t objectIndex,
uint8_t propertyId, uint8_t propertyIndex)
{
// TODO: reply correctly
bool writeEnable = false;
uint8_t type = 0;
uint16_t numberOfElements = 0;
uint8_t access = 0;
InterfaceObject* obj = getInterfaceObject(objectIndex);
if (obj)
obj->readPropertyDescription(propertyId, propertyIndex, writeEnable, type, numberOfElements, access);
_appLayer.propertyDescriptionReadResponse(AckRequested, priority, hopType, asap, objectIndex, propertyId, propertyIndex,
false, 0, 0, 0);
writeEnable, type, numberOfElements, access);
}
void Bau57B0::propertyValueWriteIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t objectIndex,

View File

@ -253,3 +253,17 @@ void DeviceObject::version(uint16_t value)
{
_version = value;
}
static PropertyDescription _propertyDescriptions[] = {};
static uint8_t _propertyCount = sizeof(_propertyDescriptions) / sizeof(PropertyDescription);
uint8_t DeviceObject::propertyCount()
{
return _propertyCount;
}
PropertyDescription* DeviceObject::propertyDescriptions()
{
return _propertyDescriptions;
}

View File

@ -10,6 +10,8 @@ public:
uint8_t propertySize(PropertyID id);
uint8_t* save(uint8_t* buffer);
uint8_t* restore(uint8_t* buffer);
void readPropertyDescription(uint8_t propertyId, uint8_t& propertyIndex, bool& writeEnable, uint8_t& type, uint16_t& numberOfElements, uint8_t& access);
uint16_t induvidualAddress();
void induvidualAddress(uint16_t value);
@ -33,6 +35,9 @@ public:
void hardwareType(const uint8_t* value);
uint16_t version();
void version(uint16_t value);
protected:
uint8_t propertyCount();
PropertyDescription* propertyDescriptions();
private:
uint8_t _deviceControl;
uint8_t _routingCount;

View File

@ -119,3 +119,17 @@ bool GroupObjectTableObject::initGroupObjects()
return true;
}
static PropertyDescription _propertyDescriptions[] = { };
static uint8_t _propertyCount = sizeof(_propertyDescriptions) / sizeof(PropertyDescription);
uint8_t GroupObjectTableObject::propertyCount()
{
return _propertyCount;
}
PropertyDescription* GroupObjectTableObject::propertyDescriptions()
{
return _propertyDescriptions;
}

View File

@ -9,7 +9,10 @@ class GroupObjectTableObject: public TableObject
public:
GroupObjectTableObject(uint8_t* memoryReference);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Woverloaded-virtual"
void readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t* data);
#pragma GCC diagnostic pop
uint16_t entryCount();
GroupObject& get(uint16_t asap);
GroupObject& nextUpdatedObject(bool& valid);
@ -19,6 +22,8 @@ public:
virtual uint8_t* restore(uint8_t* buffer);
protected:
virtual void beforeStateChange(LoadState& newState);
uint8_t propertyCount();
PropertyDescription* propertyDescriptions();
private:
bool initGroupObjects();
uint16_t* _tableData = 0;

38
interface_object.cpp Normal file
View File

@ -0,0 +1,38 @@
#include "interface_object.h"
void InterfaceObject::readPropertyDescription(uint8_t propertyId, uint8_t& propertyIndex, bool& writeEnable, uint8_t& type, uint16_t& numberOfElements, uint8_t& access)
{
PropertyDescription* descriptions = propertyDescriptions();
uint8_t count = propertyCount();
PropertyDescription* desc = nullptr;
if (propertyId != 0)
{
for (uint8_t i = 0; i < count; i++)
{
PropertyDescription d = descriptions[propertyIndex];
if (d.Id != propertyId)
continue;
desc = &d;
propertyIndex = i;
break;
}
}
else
{
if (propertyIndex > 0 && propertyIndex < count)
{
desc = &descriptions[propertyIndex];
}
}
if (desc != nullptr)
{
writeEnable = desc->WriteEnable;
type = desc->Type;
numberOfElements = desc->MaxElements;
access = desc->Access;
}
}

View File

@ -57,6 +57,8 @@ public:
virtual void readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t* data) = 0;
virtual void writeProperty(PropertyID id, uint8_t start, uint8_t* data, uint8_t count) = 0;
virtual uint8_t propertySize(PropertyID id) = 0;
void readPropertyDescription(uint8_t propertyId, uint8_t& propertyIndex, bool& writeEnable, uint8_t& type, uint16_t& numberOfElements, uint8_t& access);
protected:
virtual uint8_t propertyCount() = 0;
virtual PropertyDescription* propertyDescriptions() = 0;
};

View File

@ -302,4 +302,18 @@ void IpParameterObject::additionalLoadControls(uint8_t* data)
loadState(LS_ERROR);
_errorCode = E_INVALID_OPCODE;
return;
}
static PropertyDescription _propertyDescriptions[] = { };
static uint8_t _propertyCount = sizeof(_propertyDescriptions) / sizeof(PropertyDescription);
uint8_t IpParameterObject::propertyCount()
{
return _propertyCount;
}
PropertyDescription* IpParameterObject::propertyDescriptions()
{
return _propertyDescriptions;
}

View File

@ -17,6 +17,9 @@ public:
uint32_t multicastAddress() const;
uint8_t ttl() const { return _ttl; }
protected:
uint8_t propertyCount();
PropertyDescription* propertyDescriptions();
private:
uint16_t _projectInstallationId = 0;
uint8_t _ipAssignmentMethod = 0;

View File

@ -9,6 +9,8 @@
*/
#pragma once
#include <stdint.h>
enum PropertyDataType
{
PDT_CONTROL = 0x00, //!< length: 1 read, 10 write
@ -163,4 +165,26 @@ enum ErrorCode
E_INVALID_CONNECTION_NUMBER = 16,
E_INVALID_GO_NUMBER = 17,
E_GO_TYPE_TOO_BIG = 18
};
enum AccessLevel
{
ReadLv0 = 0x00,
ReadLv1 = 0x10,
ReadLv2 = 0x20,
ReadLv3 = 0x30,
WriteLv0 = 0x00,
WriteLv1 = 0x01,
WriteLv2 = 0x02,
WriteLv3 = 0x03,
};
class PropertyDescription
{
public:
PropertyID Id;
bool WriteEnable;
PropertyDataType Type;
uint16_t MaxElements;
uint8_t Access;
};