remove label from considered fields

This commit is contained in:
Wolfgang Hottgenroth 2020-11-18 13:42:55 +01:00
parent 857ed8ad68
commit 5714d3f6ed
Signed by: wn
GPG Key ID: 6C1E5E531E0D5D7F
2 changed files with 12 additions and 59 deletions

View File

@ -5,18 +5,13 @@
#include <stdint.h>
#include <stdbool.h>
#define MBUSFRAMEFIELD_LABELLENGTH 16
typedef struct {
char label[MBUSFRAMEFIELD_LABELLENGTH];
uint8_t index;
} t_mbusFrameField;
#define MBUSDEVICE_NAMELENGTH 24
#define MBUSDEVICE_NUM_OF_CONSIDEREDFIELDS 4
typedef struct {
char deviceName[MBUSDEVICE_NAMELENGTH];
uint8_t address;
t_mbusFrameField consideredField[MBUSDEVICE_NUM_OF_CONSIDEREDFIELDS];
int8_t consideredField[MBUSDEVICE_NUM_OF_CONSIDEREDFIELDS];
uint32_t requests;
uint32_t failures;
int32_t period;

View File

@ -173,13 +173,11 @@ static void parseAndPrintFrame(t_mbusCommHandle *localMbusCommHandle) {
record;
record = record->next, i++) {
for (uint8_t j = 0; j < MBUSDEVICE_NUM_OF_CONSIDEREDFIELDS; j++) {
if ((localMbusCommHandle->device->consideredField[j].index == i) &&
(strlen(localMbusCommHandle->device->consideredField[j].label) > 0)) {
if (localMbusCommHandle->device->consideredField[j] == i) {
parsedVIB_t parsedVIB = parseVIB(record->drh.vib);
coloredMsg(LOG_YELLOW, false, "mbc papf [%d] parsed VIB N: %s, U: %s, E: %d",
localMbusCommHandle->requestId,
parsedVIB.name, parsedVIB.unit, parsedVIB.exponent);
if (parsedVIB.found) {
uint32_t value = strtol(mbus_data_record_value(record), NULL, 10);
float weightedValue = ((float) value) * powf(10.0, ((float) parsedVIB.exponent));
@ -187,9 +185,9 @@ static void parseAndPrintFrame(t_mbusCommHandle *localMbusCommHandle) {
localMbusCommHandle->requestId, parsedVIB.name, weightedValue, parsedVIB.unit,
value, parsedVIB.exponent);
} else {
coloredMsg(LOG_YELLOW, true, "mbc papf [%d] L:%s, VIF: 0x%02x U:%s V:%s",
coloredMsg(LOG_YELLOW, true, "mbc papf [%d] L:%d, VIF: 0x%02x U:%s V:%s",
localMbusCommHandle->requestId,
localMbusCommHandle->device->consideredField[j].label,
localMbusCommHandle->device->consideredField[j],
record->drh.vib.vif,
mbus_data_record_unit(record),
mbus_data_record_value(record));
@ -505,12 +503,7 @@ static t_mbusDevice devices[] = {
{
.deviceName = "Total Power",
.address = 80,
.consideredField = {
{ .label = "energy", .index = 0 },
{ .label = "power", .index = 17 },
{ .label = "", .index = 0 },
{ .label = "", .index = 0 }
},
.consideredField = { 0, 17, -1, -1 },
.requests = 0,
.failures = 0,
.period = 60,
@ -520,12 +513,7 @@ static t_mbusDevice devices[] = {
{
.deviceName = "Computer Power",
.address = 85,
.consideredField = {
{ .label = "energy", .index = 0 },
{ .label = "power", .index = 4 },
{ .label = "voltage", .index = 2 },
{ .label = "current", .index = 3 }
},
.consideredField = { 0, 4, 2, 3 },
.requests = 0,
.failures = 0,
.period = 60,
@ -535,12 +523,7 @@ static t_mbusDevice devices[] = {
{
.deviceName = "Dryer Power",
.address = 81,
.consideredField = {
{ .label = "energy", .index = 0 },
{ .label = "power", .index = 4 },
{ .label = "voltage", .index = 2 },
{ .label = "current", .index = 3 }
},
.consideredField = { 0, 4, 2, 3 },
.requests = 0,
.failures = 0,
.period = 60,
@ -550,12 +533,7 @@ static t_mbusDevice devices[] = {
{
.deviceName = "Laundry Power",
.address = 82,
.consideredField = {
{ .label = "energy", .index = 0 },
{ .label = "power", .index = 4 },
{ .label = "voltage", .index = 2 },
{ .label = "current", .index = 3 }
},
.consideredField = { 0, 4, 2, 3 },
.requests = 0,
.failures = 0,
.period = 60,
@ -565,12 +543,7 @@ static t_mbusDevice devices[] = {
{
.deviceName = "Dishwasher Power",
.address = 83,
.consideredField = {
{ .label = "energy", .index = 0 },
{ .label = "power", .index = 4 },
{ .label = "voltage", .index = 2 },
{ .label = "current", .index = 3 }
},
.consideredField = { 0, 4, 2, 3 },
.requests = 0,
.failures = 0,
.period = 60,
@ -580,12 +553,7 @@ static t_mbusDevice devices[] = {
{
.deviceName = "Light Power",
.address = 84,
.consideredField = {
{ .label = "energy", .index = 0 },
{ .label = "power", .index = 4 },
{ .label = "voltage", .index = 2 },
{ .label = "current", .index = 3 }
},
.consideredField = { 0, 4, 2, 3 },
.requests = 0,
.failures = 0,
.period = 15,
@ -595,12 +563,7 @@ static t_mbusDevice devices[] = {
{
.deviceName = "Freezer Power",
.address = 86,
.consideredField = {
{ .label = "energy", .index = 0 },
{ .label = "power", .index = 4 },
{ .label = "voltage", .index = 2 },
{ .label = "current", .index = 3 }
},
.consideredField = { 0, 4, 2, 3 },
.requests = 0,
.failures = 0,
.period = 60,
@ -610,12 +573,7 @@ static t_mbusDevice devices[] = {
{
.deviceName = "Fridge Power",
.address = 87,
.consideredField = {
{ .label = "energy", .index = 0 },
{ .label = "power", .index = 4 },
{ .label = "voltage", .index = 2 },
{ .label = "current", .index = 3 }
},
.consideredField = { 0, 4, 2, 3 },
.requests = 0,
.failures = 0,
.period = 60,