-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
198 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#include "dpt10.h" | ||
|
||
#include "dptconvert.h" | ||
#include "dpt11.h" | ||
|
||
Knx::Go_SizeCode Knx::DPT_Date::size() const | ||
{ | ||
return Go_3_Octets; | ||
} | ||
|
||
void Knx::DPT_Date::encode(uint8_t* data) const | ||
{ | ||
unsigned8ToPayload(data, 0, _day, 0x1F); | ||
unsigned8ToPayload(data, 1, _month, 0x0F); | ||
unsigned8ToPayload(data, 2, _year % 100, 0x7F); | ||
} | ||
|
||
bool Knx::DPT_Date::decode(uint8_t* data) | ||
{ | ||
_year = unsigned8FromPayload(data, 2) & 0x7F; | ||
_month = unsigned8FromPayload(data, 1) & 0x0F; | ||
_day = unsigned8FromPayload(data, 0) & 0x1F; | ||
|
||
if (_year > 99 || _month < 1 || _month > 12 || _day < 1) | ||
{ | ||
_year = 0; | ||
_month = 0; | ||
_day = 0; | ||
return false; | ||
} | ||
|
||
_year += _year >= 90 ? 1900 : 2000; | ||
return true; | ||
} | ||
|
||
uint8_t Knx::DPT_Date::day() const | ||
{ | ||
return _day; | ||
} | ||
|
||
void Knx::DPT_Date::day(uint8_t value) | ||
{ | ||
if (value < 1 || value > 31) | ||
return; | ||
|
||
_day = value; | ||
} | ||
|
||
uint8_t Knx::DPT_Date::month() const | ||
{ | ||
return _month; | ||
} | ||
|
||
void Knx::DPT_Date::month(uint8_t value) | ||
{ | ||
if (value < 1 || value > 12) | ||
return; | ||
|
||
_month = value; | ||
} | ||
|
||
uint16_t Knx::DPT_Date::year() const | ||
{ | ||
return _year; | ||
} | ||
|
||
void Knx::DPT_Date::year(uint16_t value) | ||
{ | ||
if (value < 1990 || value > 2089) | ||
return; | ||
|
||
_year = value; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#pragma once | ||
#include "dpt.h" | ||
namespace Knx | ||
{ | ||
class DPT_Date: public Dpt | ||
{ | ||
public: | ||
Go_SizeCode size() const override; | ||
|
||
void encode(uint8_t* data) const override; | ||
bool decode(uint8_t* data) override; | ||
|
||
uint8_t day() const; | ||
void day(uint8_t value); | ||
|
||
uint8_t month() const; | ||
void month(uint8_t value); | ||
|
||
uint16_t year() const; | ||
void year(uint16_t value); | ||
private: | ||
uint8_t _day; | ||
uint8_t _month; | ||
uint16_t _year; | ||
}; | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "dpt12.h" | ||
|
||
#include "dptconvert.h" | ||
|
||
Knx::Go_SizeCode Knx::Dpt12::size() const | ||
{ | ||
return Go_4_Octets; | ||
} | ||
|
||
void Knx::Dpt12::encode(uint8_t* data) const | ||
{ | ||
unsigned32ToPayload(data, 0, _value, 0xFFFFFFFF); | ||
} | ||
|
||
bool Knx::Dpt12::decode(uint8_t* data) | ||
{ | ||
_value = unsigned32FromPayload(data, 0); | ||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
#include "dpt.h" | ||
namespace Knx | ||
{ | ||
class Dpt12: public ValueDpt<uint32_t> | ||
{ | ||
public: | ||
Dpt12() {}; | ||
Dpt12(uint32_t value) : ValueDpt(value) {} | ||
Go_SizeCode size() const override; | ||
|
||
void encode(uint8_t* data) const override; | ||
bool decode(uint8_t* data) override; | ||
}; | ||
|
||
typedef Dpt12 DPT_Value_4_Ucount; | ||
typedef Dpt12 DPT_LongTimePeriod_Sec; | ||
typedef Dpt12 DPT_LongTimePeriod_Min; | ||
typedef Dpt12 DPT_LongTimePeriod_Hrs; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "dpt13.h" | ||
|
||
#include "dptconvert.h" | ||
|
||
Knx::Go_SizeCode Knx::Dpt13::size() const | ||
{ | ||
return Go_4_Octets; | ||
} | ||
|
||
void Knx::Dpt13::encode(uint8_t* data) const | ||
{ | ||
signed32ToPayload(data, 0, _value, 0xFFFFFFFF); | ||
} | ||
|
||
bool Knx::Dpt13::decode(uint8_t* data) | ||
{ | ||
_value = signed32FromPayload(data, 0); | ||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
#include "dpt.h" | ||
namespace Knx | ||
{ | ||
class Dpt13: public ValueDpt<int32_t> | ||
{ | ||
public: | ||
Dpt13() {}; | ||
Dpt13(int32_t value) : ValueDpt(value) {} | ||
Go_SizeCode size() const override; | ||
|
||
void encode(uint8_t* data) const override; | ||
bool decode(uint8_t* data) override; | ||
}; | ||
|
||
typedef Dpt13 DPT_Value_4_Count; | ||
typedef Dpt13 DPT_FlowRate_m3_h; | ||
typedef Dpt13 DPT_ActiveEnergy; | ||
typedef Dpt13 DPT_ApparantEnergy; | ||
typedef Dpt13 DPT_ReactiveEnergy; | ||
typedef Dpt13 DPT_ActiveEnergy_kWh; | ||
typedef Dpt13 DPT_ApparantEnergy_kVAh; | ||
typedef Dpt13 DPT_ReactiveEnergy_kVARh; | ||
typedef Dpt13 DPT_ActiveEnergy_MWh; | ||
typedef Dpt13 DPT_LongDeltaTimeSec; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters