Skip to content

Commit

Permalink
dpt14
Browse files Browse the repository at this point in the history
  • Loading branch information
thelsing committed Sep 17, 2024
1 parent e4431d6 commit 1a8a02f
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 131 deletions.
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ set(SOURCES
./knx/group_object/dpt/dpt12.h
./knx/group_object/dpt/dpt13.cpp
./knx/group_object/dpt/dpt13.h
./knx/group_object/dpt/dpt14.cpp
./knx/group_object/dpt/dpt14.h
./knx/group_object/dpt/dptconvert.cpp
./knx/group_object/dpt/dptconvert.h
./knx/group_object/group_object.cpp
Expand Down
81 changes: 0 additions & 81 deletions src/knx/group_object/dpt/dpt.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,87 +3,6 @@
#include "../group_object.h"
namespace Knx
{
#define DPT_Value_Acceleration Dpt(14, 0)
#define DPT_Value_Acceleration_Angular Dpt(14, 1)
#define DPT_Value_Activation_Energy Dpt(14, 2)
#define DPT_Value_Activity Dpt(14, 3)
#define DPT_Value_Mol Dpt(14, 4)
#define DPT_Value_Amplitude Dpt(14, 5)
#define DPT_Value_AngleRad Dpt(14, 6)
#define DPT_Value_AngleDeg Dpt(14, 7)
#define DPT_Value_Angular_Momentum Dpt(14, 8)
#define DPT_Value_Angular_Velocity Dpt(14, 9)
#define DPT_Value_Area Dpt(14, 10)
#define DPT_Value_Capacitance Dpt(14, 11)
#define DPT_Value_Charge_DensitySurface Dpt(14, 12)
#define DPT_Value_Charge_DensityVolume Dpt(14, 13)
#define DPT_Value_Compressibility Dpt(14, 14)
#define DPT_Value_Conductance Dpt(14, 15)
#define DPT_Value_Electrical_Conductivity Dpt(14, 16)
#define DPT_Value_Density Dpt(14, 17)
#define DPT_Value_Electric_Charge Dpt(14, 18)
#define DPT_Value_Electric_Current Dpt(14, 19)
#define DPT_Value_Electric_CurrentDensity Dpt(14, 20)
#define DPT_Value_Electric_DipoleMoment Dpt(14, 21)
#define DPT_Value_Electric_Displacement Dpt(14, 22)
#define DPT_Value_Electric_FieldStrength Dpt(14, 23)
#define DPT_Value_Electric_Flux Dpt(14, 24)
#define DPT_Value_Electric_FluxDensity Dpt(14, 25)
#define DPT_Value_Electric_Polarization Dpt(14, 26)
#define DPT_Value_Electric_Potential Dpt(14, 27)
#define DPT_Value_Electric_PotentialDifference Dpt(14, 28)
#define DPT_Value_ElectromagneticMoment Dpt(14, 29)
#define DPT_Value_Electromotive_Force Dpt(14, 30)
#define DPT_Value_Energy Dpt(14, 31)
#define DPT_Value_Force Dpt(14, 32)
#define DPT_Value_Frequency Dpt(14, 33)
#define DPT_Value_Angular_Frequency Dpt(14, 34)
#define DPT_Value_Heat_Capacity Dpt(14, 35)
#define DPT_Value_Heat_FlowRate Dpt(14, 36)
#define DPT_Value_Heat_Quantity Dpt(14, 37)
#define DPT_Value_Impedance Dpt(14, 38)
#define DPT_Value_Length Dpt(14, 39)
#define DPT_Value_Light_Quantity Dpt(14, 40)
#define DPT_Value_Luminance Dpt(14, 41)
#define DPT_Value_Luminous_Flux Dpt(14, 42)
#define DPT_Value_Luminous_Intensity Dpt(14, 43)
#define DPT_Value_Magnetic_FieldStrength Dpt(14, 44)
#define DPT_Value_Magnetic_Flux Dpt(14, 45)
#define DPT_Value_Magnetic_FluxDensity Dpt(14, 46)
#define DPT_Value_Magnetic_Moment Dpt(14, 47)
#define DPT_Value_Magnetic_Polarization Dpt(14, 48)
#define DPT_Value_Magnetization Dpt(14, 49)
#define DPT_Value_MagnetomotiveForce Dpt(14, 50)
#define DPT_Value_Mass Dpt(14, 51)
#define DPT_Value_MassFlux Dpt(14, 52)
#define DPT_Value_Momentum Dpt(14, 53)
#define DPT_Value_Phase_AngleRad Dpt(14, 54)
#define DPT_Value_Phase_AngleDeg Dpt(14, 55)
#define DPT_Value_Power Dpt(14, 56)
#define DPT_Value_Power_Factor Dpt(14, 57)
#define DPT_Value_Pressure Dpt(14, 58)
#define DPT_Value_Reactance Dpt(14, 59)
#define DPT_Value_Resistance Dpt(14, 60)
#define DPT_Value_Resistivity Dpt(14, 61)
#define DPT_Value_SelfInductance Dpt(14, 62)
#define DPT_Value_SolidAngle Dpt(14, 63)
#define DPT_Value_Sound_Intensity Dpt(14, 64)
#define DPT_Value_Speed Dpt(14, 65)
#define DPT_Value_Stress Dpt(14, 66)
#define DPT_Value_Surface_Tension Dpt(14, 67)
#define DPT_Value_Common_Temperature Dpt(14, 68)
#define DPT_Value_Absolute_Temperature Dpt(14, 69)
#define DPT_Value_TemperatureDifference Dpt(14, 70)
#define DPT_Value_Thermal_Capacity Dpt(14, 71)
#define DPT_Value_Thermal_Conductivity Dpt(14, 72)
#define DPT_Value_ThermoelectricPower Dpt(14, 73)
#define DPT_Value_Time Dpt(14, 74)
#define DPT_Value_Torque Dpt(14, 75)
#define DPT_Value_Volume Dpt(14, 76)
#define DPT_Value_Volume_Flux Dpt(14, 77)
#define DPT_Value_Weight Dpt(14, 78)
#define DPT_Value_Work Dpt(14, 79)
#define DPT_Value_ApparentPower Dpt(14, 80)
#define DPT_Access_Data Dpt(15, 0)
#define DPT_String_ASCII Dpt(16, 0)
#define DPT_String_8859_1 Dpt(16, 1)
Expand Down
19 changes: 19 additions & 0 deletions src/knx/group_object/dpt/dpt14.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "dpt14.h"

#include "dptconvert.h"

Knx::Go_SizeCode Knx::Dpt14::size() const
{
return Go_4_Octets;
}

void Knx::Dpt14::encode(uint8_t* data) const
{
float32ToPayload(data, 0, _value, 0xFFFFFFFF);
}

bool Knx::Dpt14::decode(uint8_t* data)
{
_value = float32FromPayload(data, 0);
return true;
}
97 changes: 97 additions & 0 deletions src/knx/group_object/dpt/dpt14.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#pragma once
#include "dpt.h"
namespace Knx
{
class Dpt14: public ValueDpt<float>
{
public:
Dpt14() {};
Dpt14(float value) : ValueDpt(value) {}
Go_SizeCode size() const override;

void encode(uint8_t* data) const override;
bool decode(uint8_t* data) override;
};

typedef Dpt14 DPT_Value_Acceleration;
typedef Dpt14 DPT_Value_Acceleration_Angular;
typedef Dpt14 DPT_Value_Activation_Energy;
typedef Dpt14 DPT_Value_Activity;
typedef Dpt14 DPT_Value_Mol;
typedef Dpt14 DPT_Value_Amplitude;
typedef Dpt14 DPT_Value_AngleRad;
typedef Dpt14 DPT_Value_AngleDeg;
typedef Dpt14 DPT_Value_Angular_Momentum;
typedef Dpt14 DPT_Value_Angular_Velocity;
typedef Dpt14 DPT_Value_Area;
typedef Dpt14 DPT_Value_Capacitance;
typedef Dpt14 DPT_Value_Charge_DensitySurface;
typedef Dpt14 DPT_Value_Charge_DensityVolume;
typedef Dpt14 DPT_Value_Compressibility;
typedef Dpt14 DPT_Value_Conductance;
typedef Dpt14 DPT_Value_Electrical_Conductivity;
typedef Dpt14 DPT_Value_Density;
typedef Dpt14 DPT_Value_Electric_Charge;
typedef Dpt14 DPT_Value_Electric_Current;
typedef Dpt14 DPT_Value_Electric_CurrentDensity;
typedef Dpt14 DPT_Value_Electric_DipoleMoment;
typedef Dpt14 DPT_Value_Electric_Displacement;
typedef Dpt14 DPT_Value_Electric_FieldStrength;
typedef Dpt14 DPT_Value_Electric_Flux;
typedef Dpt14 DPT_Value_Electric_FluxDensity;
typedef Dpt14 DPT_Value_Electric_Polarization;
typedef Dpt14 DPT_Value_Electric_Potential;
typedef Dpt14 DPT_Value_Electric_PotentialDifference;
typedef Dpt14 DPT_Value_ElectromagneticMoment;
typedef Dpt14 DPT_Value_Electromotive_Force;
typedef Dpt14 DPT_Value_Energy;
typedef Dpt14 DPT_Value_Force;
typedef Dpt14 DPT_Value_Frequency;
typedef Dpt14 DPT_Value_Angular_Frequency;
typedef Dpt14 DPT_Value_Heat_Capacity;
typedef Dpt14 DPT_Value_Heat_FlowRate;
typedef Dpt14 DPT_Value_Heat_Quantity;
typedef Dpt14 DPT_Value_Impedance;
typedef Dpt14 DPT_Value_Length;
typedef Dpt14 DPT_Value_Light_Quantity;
typedef Dpt14 DPT_Value_Luminance;
typedef Dpt14 DPT_Value_Luminous_Flux;
typedef Dpt14 DPT_Value_Luminous_Intensity;
typedef Dpt14 DPT_Value_Magnetic_FieldStrength;
typedef Dpt14 DPT_Value_Magnetic_Flux;
typedef Dpt14 DPT_Value_Magnetic_FluxDensity;
typedef Dpt14 DPT_Value_Magnetic_Moment;
typedef Dpt14 DPT_Value_Magnetic_Polarization;
typedef Dpt14 DPT_Value_Magnetization;
typedef Dpt14 DPT_Value_MagnetomotiveForce;
typedef Dpt14 DPT_Value_Mass;
typedef Dpt14 DPT_Value_MassFlux;
typedef Dpt14 DPT_Value_Momentum;
typedef Dpt14 DPT_Value_Phase_AngleRad;
typedef Dpt14 DPT_Value_Phase_AngleDeg;
typedef Dpt14 DPT_Value_Power;
typedef Dpt14 DPT_Value_Power_Factor;
typedef Dpt14 DPT_Value_Pressure;
typedef Dpt14 DPT_Value_Reactance;
typedef Dpt14 DPT_Value_Resistance;
typedef Dpt14 DPT_Value_Resistivity;
typedef Dpt14 DPT_Value_SelfInductance;
typedef Dpt14 DPT_Value_SolidAngle;
typedef Dpt14 DPT_Value_Sound_Intensity;
typedef Dpt14 DPT_Value_Speed;
typedef Dpt14 DPT_Value_Stress;
typedef Dpt14 DPT_Value_Surface_Tension;
typedef Dpt14 DPT_Value_Common_Temperature;
typedef Dpt14 DPT_Value_Absolute_Temperature;
typedef Dpt14 DPT_Value_TemperatureDifference;
typedef Dpt14 DPT_Value_Thermal_Capacity;
typedef Dpt14 DPT_Value_Thermal_Conductivity;
typedef Dpt14 DPT_Value_ThermoelectricPower;
typedef Dpt14 DPT_Value_Time;
typedef Dpt14 DPT_Value_Torque;
typedef Dpt14 DPT_Value_Volume;
typedef Dpt14 DPT_Value_Volume_Flux;
typedef Dpt14 DPT_Value_Weight;
typedef Dpt14 DPT_Value_Work;
typedef Dpt14 DPT_Value_ApparentPower;
}
45 changes: 0 additions & 45 deletions src/knx/group_object/dpt/dptconvert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ namespace Knx
{
if (payload_length > 0)
{
// DPT 14.* - 32 Bit Float
if (datatype.mainGroup == 14 && datatype.subGroup <= 79 && !datatype.index)
return busValueToFloat32(payload, payload_length, datatype, value);

// DPT 15.* - Access Data
if (datatype.mainGroup == 15 && !datatype.subGroup && datatype.index <= 5)
return busValueToAccess(payload, payload_length, datatype, value);
Expand Down Expand Up @@ -203,34 +199,13 @@ namespace Knx
return false;
}

int busValueToUnsigned32(const uint8_t* payload, size_t payload_length, const Dpt& datatype, KNXValue& value)
{
ASSERT_PAYLOAD(4);
value = unsigned32FromPayload(payload, 0);
return true;
}

int busValueToSigned32(const uint8_t* payload, size_t payload_length, const Dpt& datatype, KNXValue& value)
{
ASSERT_PAYLOAD(4);
value = signed32FromPayload(payload, 0);
return true;
}

int busValueToLongTimePeriod(const uint8_t* payload, size_t payload_length, const Dpt& datatype, KNXValue& value)
{
ASSERT_PAYLOAD(4);
value = signed32FromPayload(payload, 0);
return true;
}

int busValueToFloat32(const uint8_t* payload, size_t payload_length, const Dpt& datatype, KNXValue& value)
{
ASSERT_PAYLOAD(4);
value = float32FromPayload(payload, 0);
return true;
}

int busValueToAccess(const uint8_t* payload, size_t payload_length, const Dpt& datatype, KNXValue& value)
{
ASSERT_PAYLOAD(4);
Expand Down Expand Up @@ -674,26 +649,6 @@ namespace Knx
return true;
}

int valueToBusValueLongTimePeriod(const KNXValue& value, uint8_t* payload, size_t payload_length, const Dpt& datatype)
{
if ((int64_t)value < INT64_C(-2147483648) || (int64_t)value > INT64_C(2147483647))
return false;

signed32ToPayload(payload, 0, (uint64_t)value, 0xFFFFFFFF);
return true;
}

int valueToBusValueFloat32(const KNXValue& value, uint8_t* payload, size_t payload_length, const Dpt& datatype)
{
double numValue = value;

if (numValue < (-8388608.0 * pow(2, 255)) || numValue > (8388607.0 * pow(2, 255)))
return false;

float32ToPayload(payload, 0, numValue, 0xFFFFFFFF);
return true;
}

int valueToBusValueAccess(const KNXValue& value, uint8_t* payload, size_t payload_length, const Dpt& datatype)
{
switch (datatype.index)
Expand Down
4 changes: 0 additions & 4 deletions src/knx/group_object/dpt/dptconvert.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ namespace Knx
//KNX to internal
int busValueToUnsigned32(const uint8_t* payload, size_t payload_length, const Dpt& datatype, KNXValue& value);
int busValueToSigned32(const uint8_t* payload, size_t payload_length, const Dpt& datatype, KNXValue& value);
int busValueToLongTimePeriod(const uint8_t* payload, size_t payload_length, const Dpt& datatype, KNXValue& value);
int busValueToFloat32(const uint8_t* payload, size_t payload_length, const Dpt& datatype, KNXValue& value);
int busValueToAccess(const uint8_t* payload, size_t payload_length, const Dpt& datatype, KNXValue& value);
int busValueToString(const uint8_t* payload, size_t payload_length, const Dpt& datatype, KNXValue& value);
int busValueToScene(const uint8_t* payload, size_t payload_length, const Dpt& datatype, KNXValue& value);
Expand All @@ -74,8 +72,6 @@ namespace Knx
//Internal to KNX
int valueToBusValueUnsigned32(const KNXValue& value, uint8_t* payload, size_t payload_length, const Dpt& datatype);
int valueToBusValueSigned32(const KNXValue& value, uint8_t* payload, size_t payload_length, const Dpt& datatype);
int valueToBusValueLongTimePeriod(const KNXValue& value, uint8_t* payload, size_t payload_length, const Dpt& datatype);
int valueToBusValueFloat32(const KNXValue& value, uint8_t* payload, size_t payload_length, const Dpt& datatype);
int valueToBusValueAccess(const KNXValue& value, uint8_t* payload, size_t payload_length, const Dpt& datatype);
int valueToBusValueString(const KNXValue& value, uint8_t* payload, size_t payload_length, const Dpt& datatype);
int valueToBusValueScene(const KNXValue& value, uint8_t* payload, size_t payload_length, const Dpt& datatype);
Expand Down
3 changes: 2 additions & 1 deletion src/knx/group_object/dpt/dpts.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
#include "dpt10.h"
#include "dpt11.h"
#include "dpt12.h"
#include "dpt13.h"
#include "dpt13.h"
#include "dpt14.h"

0 comments on commit 1a8a02f

Please sign in to comment.