From cb840c22017b0ed4d4e2c1fc93162bd04dfafeaf Mon Sep 17 00:00:00 2001 From: Thomas Kunze Date: Tue, 25 Jun 2019 21:21:58 +0200 Subject: [PATCH] add class diagram, protect constuctors of *PDU --- .travis.yml | 4 +- src/knx.h | 83 ++++++++++++++++++++++++++++++++++++++++++ src/knx/apdu.h | 22 ++++++----- src/knx/bau_systemB.h | 38 +++++++++---------- src/knx/group_object.h | 2 +- src/knx/npdu.h | 9 +++-- src/knx/tpdu.h | 10 +++-- 7 files changed, 131 insertions(+), 37 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7a135b7..07a7239 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,8 +34,8 @@ before_install: - if [ "$MODE" = "ARDUINO" ]; then sed -i 's#compiler.warning_level=all#compiler.warning_level=default#' ~/.arduino15/preferences.txt; fi # changes for bsec lib # samd - - if [ "$MODE" = "ARDUINO" ]; then sed -ri 's#(recipe.c.combine.pattern=[^$]*\{archive_file\}")( -Wl,--end-group)#\1 {compiler.libraries.ldflags}\2#' ~/.arduino15/packages/arduino/hardware/samd/1.6.21/platform.txt; fi - - if [ "$MODE" = "ARDUINO" ]; then sed -i 's#compiler.elf2hex.extra_flags=#compiler.elf2hex.extra_flags=\ncompiler.libraries.ldflags=#' ~/.arduino15/packages/arduino/hardware/samd/1.6.21/platform.txt; fi + - if [ "$MODE" = "ARDUINO" ]; then sed -ri 's#(recipe.c.combine.pattern=[^$]*\{archive_file\}")( -Wl,--end-group)#\1 {compiler.libraries.ldflags}\2#' ~/.arduino15/packages/arduino/hardware/samd/1.8.1/platform.txt; fi + - if [ "$MODE" = "ARDUINO" ]; then sed -i 's#compiler.elf2hex.extra_flags=#compiler.elf2hex.extra_flags=\ncompiler.libraries.ldflags=#' ~/.arduino15/packages/arduino/hardware/samd/1.8.1/platform.txt; fi # esp8266 - if [ "$MODE" = "ARDUINO" ]; then sed -ri 's#(recipe.c.combine.pattern=[^$]*\{compiler.c.elf.libs\})( -Wl,--end-group "-L\{build.path\}")#\1 {compiler.libraries.ldflags}\2#' ~/.arduino15/packages/esp8266/hardware/esp8266/2.5.2/platform.txt; fi - if [ "$MODE" = "ARDUINO" ]; then sed -i 's#compiler.elf2hex.extra_flags=#compiler.elf2hex.extra_flags=\ncompiler.libraries.ldflags=#' ~/.arduino15/packages/esp8266/hardware/esp8266/2.5.2/platform.txt; fi diff --git a/src/knx.h b/src/knx.h index 02d228d..9ead5cd 100644 --- a/src/knx.h +++ b/src/knx.h @@ -1,3 +1,86 @@ #pragma once +/** \page Classdiagramm + * This diagramm shows the most important classes. +@startuml +skinparam monochrome true +skinparam componentStyle uml2 +package knx { +class BusAccessUnit [[class_bus_access_unit.html]] +class DeviceObject [[class_device_object.html]] +class BauSystemB [[class_bau_system_b.html]] +BusAccessUnit<|--BauSystemB +class ApplicationProgramObject [[class_application_program_object.html]] +BauSystemB*--ApplicationProgramObject +DeviceObject--*BauSystemB +class AddressTableObject [[class_address_table_object.html]] +BauSystemB*--AddressTableObject +class AssociationTableObject [[class_association_table_object.html]] +BauSystemB*--AssociationTableObject +class GroupObjectTableObject [[class_group_object_table_object.html]] +BauSystemB*--GroupObjectTableObject +class GroupObject [[class_group_object.html]] +GroupObject<--GroupObjectTableObject +GroupObjectTableObject<--GroupObject +class ApplicationLayer [[class_application_layer.html]] +ApplicationLayer--*BauSystemB +class TransportLayer [[class_transport_layer.html]] +TransportLayer--*BauSystemB +class NetworkLayer [[class_network_layer.html]] +NetworkLayer--*BauSystemB +class DataLinkLayer [[class_data_link_layer.html]] +DataLinkLayer--*BauSystemB +ApplicationLayer-->BusAccessUnit +ApplicationLayer-->TransportLayer +TransportLayer-->ApplicationLayer +TransportLayer-->NetworkLayer +NetworkLayer-->TransportLayer +NetworkLayer-->DataLinkLayer +DataLinkLayer-->NetworkLayer +TransportLayer-->AddressTableObject +DataLinkLayer-->AddressTableObject +DataLinkLayer-->DeviceObject +ApplicationLayer-->AssociationTableObject +class Dpt [[class_dpt.html]] +GroupObject->Dpt +package knx-ip +{ +class IpDataLinkLayer [[class_ip_data_link_layer.html]] +IpDataLinkLayer--|>DataLinkLayer +class Bau57B0 [[class_bau57_b0.html]] +Bau57B0--|>BauSystemB +Bau57B0*--IpDataLinkLayer +class IpParameterObject [[class_ip_parameter_object.html]] +IpParameterObject-->DeviceObject +Bau57B0*--IpParameterObject +IpDataLinkLayer-->IpParameterObject +} +package knx-tp +{ +class TpUartDataLinkLayer [[class_tp_uart_data_link_layer.html]] +TpUartDataLinkLayer--|>DataLinkLayer +class Bau07B0 [[class_bau07_b0.html]] +Bau07B0*--TpUartDataLinkLayer +Bau07B0--|>BauSystemB +} +} + +package platfom +{ +class Platform [[class_platform.html]] +class SamdPlatform [[class_samd_platform.html]] +Platform<|--SamdPlatform +class EspPlatform [[class_esp_platform.html]] +Platform<|--EspPlatform +class LinuxPlatform [[class_linux_platform.html]] +LinuxPlatform--|>Platform +} +package frontend +{ +class KnxFacade [[class_knx_facade.html]] +BauSystemB<--KnxFacade +} +knx-->Platform +@enduml + */ #include "knx_facade.h" diff --git a/src/knx/apdu.h b/src/knx/apdu.h index 61dd3e8..6322579 100644 --- a/src/knx/apdu.h +++ b/src/knx/apdu.h @@ -11,14 +11,8 @@ class CemiFrame; class APDU { friend class CemiFrame; -public: - /** - * The constructor. - * @param data The data of the APDU. Encoding depends on the ::ApduType. The class doesn't - * take possession of this pointer. - * @param frame The CemiFrame this APDU is part of. - */ - APDU(uint8_t* data, CemiFrame& frame); + + public: /** * Get the type of the APDU. */ @@ -43,7 +37,17 @@ public: * Print the contents of the APDU to console. */ void printPDU(); -private: + + protected: + /** + * The constructor. + * @param data The data of the APDU. Encoding depends on the ::ApduType. The class doesn't + * take possession of this pointer. + * @param frame The CemiFrame this APDU is part of. + */ + APDU(uint8_t* data, CemiFrame& frame); + + private: uint8_t* _data; CemiFrame& _frame; }; \ No newline at end of file diff --git a/src/knx/bau_systemB.h b/src/knx/bau_systemB.h index bc0c03e..d701b74 100644 --- a/src/knx/bau_systemB.h +++ b/src/knx/bau_systemB.h @@ -35,28 +35,28 @@ protected: uint16_t memoryAddress, uint8_t* data) override; void memoryReadIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t number, uint16_t memoryAddress) override; - void deviceDescriptorReadIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t descriptorType); - void restartRequestIndication(Priority priority, HopCountType hopType, uint16_t asap); - void authorizeIndication(Priority priority, HopCountType hopType, uint16_t asap, uint32_t key); - void userMemoryReadIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t number, uint32_t memoryAddress); - void userMemoryWriteIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t number, - uint32_t memoryAddress, uint8_t* memoryData); - void propertyDescriptionReadIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t objectIndex, - uint8_t propertyId, uint8_t propertyIndex); - void propertyValueWriteIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t objectIndex, - uint8_t propertyId, uint8_t numberOfElements, uint16_t startIndex, uint8_t* data, uint8_t length); - void propertyValueReadIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t objectIndex, - uint8_t propertyId, uint8_t numberOfElements, uint16_t startIndex); - void individualAddressReadIndication(HopCountType hopType); - void individualAddressWriteIndication(HopCountType hopType, uint16_t newaddress); + void deviceDescriptorReadIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t descriptorType) override; + void restartRequestIndication(Priority priority, HopCountType hopType, uint16_t asap) override; + void authorizeIndication(Priority priority, HopCountType hopType, uint16_t asap, uint32_t key) override; + void userMemoryReadIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t number, uint32_t memoryAddress) override; + void userMemoryWriteIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t number, + uint32_t memoryAddress, uint8_t* memoryData) override; + void propertyDescriptionReadIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t objectIndex, + uint8_t propertyId, uint8_t propertyIndex) override; + void propertyValueWriteIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t objectIndex, + uint8_t propertyId, uint8_t numberOfElements, uint16_t startIndex, uint8_t* data, uint8_t length) override; + void propertyValueReadIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t objectIndex, + uint8_t propertyId, uint8_t numberOfElements, uint16_t startIndex) override; + void individualAddressReadIndication(HopCountType hopType) override; + void individualAddressWriteIndication(HopCountType hopType, uint16_t newaddress) override; void groupValueWriteLocalConfirm(AckType ack, uint16_t asap, Priority priority, HopCountType hopType, - uint8_t* data, uint8_t dataLength, bool status); - void groupValueReadLocalConfirm(AckType ack, uint16_t asap, Priority priority, HopCountType hopType, bool status); - void groupValueReadIndication(uint16_t asap, Priority priority, HopCountType hopType); + uint8_t* data, uint8_t dataLength, bool status) override; + void groupValueReadLocalConfirm(AckType ack, uint16_t asap, Priority priority, HopCountType hopType, bool status) override; + void groupValueReadIndication(uint16_t asap, Priority priority, HopCountType hopType) override; void groupValueReadAppLayerConfirm(uint16_t asap, Priority priority, HopCountType hopType, - uint8_t* data, uint8_t dataLength); + uint8_t* data, uint8_t dataLength) override; void groupValueWriteIndication(uint16_t asap, Priority priority, HopCountType hopType, - uint8_t* data, uint8_t dataLength); + uint8_t* data, uint8_t dataLength) override; virtual InterfaceObject* getInterfaceObject(uint8_t idx) = 0; diff --git a/src/knx/group_object.h b/src/knx/group_object.h index 690f33e..0a536f3 100644 --- a/src/knx/group_object.h +++ b/src/knx/group_object.h @@ -83,7 +83,7 @@ public: ComFlag commFlag(); /** * Set the current state of the group object. Application code should only use this to set the state to ::Ok after - * reading a ::Update to mark the changed group object as processed. This is optional. + * reading a ::Updated to mark the changed group object as processed. This is optional. */ void commFlag(ComFlag value); diff --git a/src/knx/npdu.h b/src/knx/npdu.h index c233f31..b069809 100644 --- a/src/knx/npdu.h +++ b/src/knx/npdu.h @@ -8,9 +8,8 @@ class TPDU; class NPDU { friend class CemiFrame; -public: - NPDU(uint8_t* data, CemiFrame& frame); + public: uint8_t octetCount() const; void octetCount(uint8_t value); uint8_t length() const; @@ -18,7 +17,11 @@ public: void hopCount(uint8_t value); CemiFrame& frame(); TPDU& tpdu(); -private: + + protected: + NPDU(uint8_t* data, CemiFrame& frame); + + private: uint8_t* _data; CemiFrame& _frame; }; \ No newline at end of file diff --git a/src/knx/tpdu.h b/src/knx/tpdu.h index 6294600..0760d53 100644 --- a/src/knx/tpdu.h +++ b/src/knx/tpdu.h @@ -8,8 +8,8 @@ class APDU; class TPDU { friend class CemiFrame; -public: - TPDU(uint8_t* data, CemiFrame& frame); + + public: TpduType type() const; void type(TpduType type); @@ -26,7 +26,11 @@ public: CemiFrame& frame(); void printPDU(); -private: + + protected: + TPDU(uint8_t* data, CemiFrame& frame); + + private: uint8_t* _data; CemiFrame& _frame; };