publishing results
This commit is contained in:
parent
31cbe4fc7e
commit
b749bc8538
@ -113,9 +113,9 @@ static void printError(t_mbusCommHandle *localMbusCommHandle) {
|
|||||||
coloredMsg(LOG_YELLOW, true, "mbc pe [%d] Error ratio is %.2f",
|
coloredMsg(LOG_YELLOW, true, "mbc pe [%d] Error ratio is %.2f",
|
||||||
localMbusCommHandle->requestId,
|
localMbusCommHandle->requestId,
|
||||||
errorRatio);
|
errorRatio);
|
||||||
mqttPublishf(MBUS_TOPIC, "{\"Status\":\"Error\", \"RequestId\":\"%d\", \"Device\":\"%s\", \"Errors\":\"%d\", \"Requests\":\"%d\", \"ErrorRatio\":\"%.2f\"}",
|
mqttPublishf(MBUS_TOPIC, "{\"Status\":\"Error\", \"RequestId\":\"%d\", \"Device\":\"%s\", \"Errors\":\"%d\", \"Requests\":\"%d\", \"ErrorRatio\":\"%.2f\"}",
|
||||||
localMbusCommHandle->requestId, localMbusCommHandle->device->deviceName,
|
localMbusCommHandle->requestId, localMbusCommHandle->device->deviceName,
|
||||||
localMbusCommHandle->device->failures, localMbusCommHandle->device->requests, errorRatio);
|
localMbusCommHandle->device->failures, localMbusCommHandle->device->requests, errorRatio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -173,6 +173,9 @@ static void parseAndPrintFrame(t_mbusCommHandle *localMbusCommHandle) {
|
|||||||
}
|
}
|
||||||
mbus_data_record *record;
|
mbus_data_record *record;
|
||||||
int i;
|
int i;
|
||||||
|
char keys[MBUSDEVICE_NUM_OF_CONSIDEREDFIELDS];
|
||||||
|
float values[MBUSDEVICE_NUM_OF_CONSIDEREDFIELDS];
|
||||||
|
uint8_t numOfConsideredFields = 0;
|
||||||
for (record = data_var->record, i = 0;
|
for (record = data_var->record, i = 0;
|
||||||
record;
|
record;
|
||||||
record = record->next, i++) {
|
record = record->next, i++) {
|
||||||
@ -188,6 +191,9 @@ static void parseAndPrintFrame(t_mbusCommHandle *localMbusCommHandle) {
|
|||||||
coloredMsg(LOG_YELLOW, true, "mbc papf [%d] %s is %.1f %s (%d * 10^%d)",
|
coloredMsg(LOG_YELLOW, true, "mbc papf [%d] %s is %.1f %s (%d * 10^%d)",
|
||||||
localMbusCommHandle->requestId, parsedVIB.name, weightedValue, parsedVIB.unit,
|
localMbusCommHandle->requestId, parsedVIB.name, weightedValue, parsedVIB.unit,
|
||||||
value, parsedVIB.exponent);
|
value, parsedVIB.exponent);
|
||||||
|
keys[numOfConsideredFields] = parsedVIB.name;
|
||||||
|
values[numOfConsideredFields] = weightedValue;
|
||||||
|
numOfConsideredFields++;
|
||||||
} else {
|
} else {
|
||||||
coloredMsg(LOG_YELLOW, true, "mbc papf [%d] L:%d, 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->requestId,
|
||||||
@ -200,14 +206,36 @@ static void parseAndPrintFrame(t_mbusCommHandle *localMbusCommHandle) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mbus_data_record_free(data_var->record);
|
|
||||||
float errorRatio = ((float) localMbusCommHandle->device->failures) / ((float) localMbusCommHandle->device->requests);
|
float errorRatio = ((float) localMbusCommHandle->device->failures) / ((float) localMbusCommHandle->device->requests);
|
||||||
coloredMsg(LOG_YELLOW, true, "mbc papf [%d] Error ratio is %.2f",
|
coloredMsg(LOG_YELLOW, true, "mbc papf [%d] Error ratio is %.2f",
|
||||||
localMbusCommHandle->requestId,
|
localMbusCommHandle->requestId,
|
||||||
errorRatio);
|
errorRatio);
|
||||||
mqttPublishf(MBUS_TOPIC, "{\"Status\":\"Ok\", \"RequestId\":\"%d\", \"Device\":\"%s\", \"Errors\":\"%d\", \"Requests\":\"%d\", \"ErrorRatio\":\"%.2f\"}",
|
if (numOfConsideredFields == 1) {
|
||||||
localMbusCommHandle->requestId, localMbusCommHandle->device->deviceName,
|
mqttPublishf(MBUS_TOPIC, "{\"Status\":\"Ok\", \"RequestId\":\"%d\", \"Device\":\"%s\", \"Errors\":\"%d\", \"Requests\":\"%d\", \"ErrorRatio\":\"%.2f\", " \
|
||||||
localMbusCommHandle->device->failures, localMbusCommHandle->device->requests, errorRatio);
|
"\"Values\":{\"%s\":\"%.1\"}}",
|
||||||
|
localMbusCommHandle->requestId, localMbusCommHandle->device->deviceName,
|
||||||
|
localMbusCommHandle->device->failures, localMbusCommHandle->device->requests, errorRatio,
|
||||||
|
keys[0], values[0]);
|
||||||
|
} else if (numOfConsideredFields == 2) {
|
||||||
|
mqttPublishf(MBUS_TOPIC, "{\"Status\":\"Ok\", \"RequestId\":\"%d\", \"Device\":\"%s\", \"Errors\":\"%d\", \"Requests\":\"%d\", \"ErrorRatio\":\"%.2f\", " \
|
||||||
|
"\"Values\":{\"%s\":\"%.1\", \"%s\":\"%.1\"}}",
|
||||||
|
localMbusCommHandle->requestId, localMbusCommHandle->device->deviceName,
|
||||||
|
localMbusCommHandle->device->failures, localMbusCommHandle->device->requests, errorRatio,
|
||||||
|
keys[0], values[0], keys[1], values[1]);
|
||||||
|
} else if (numOfConsideredFields == 3) {
|
||||||
|
mqttPublishf(MBUS_TOPIC, "{\"Status\":\"Ok\", \"RequestId\":\"%d\", \"Device\":\"%s\", \"Errors\":\"%d\", \"Requests\":\"%d\", \"ErrorRatio\":\"%.2f\", " \
|
||||||
|
"\"Values\":{\"%s\":\"%.1f\", \"%s\":\"%.1f\", \"%s\":\"%.1f\"}}",
|
||||||
|
localMbusCommHandle->requestId, localMbusCommHandle->device->deviceName,
|
||||||
|
localMbusCommHandle->device->failures, localMbusCommHandle->device->requests, errorRatio,
|
||||||
|
keys[0], values[0], keys[1], values[1], keys[2], values[2]);
|
||||||
|
} else if (numOfConsideredFields == 4) {
|
||||||
|
mqttPublishf(MBUS_TOPIC, "{\"Status\":\"Ok\", \"RequestId\":\"%d\", \"Device\":\"%s\", \"Errors\":\"%d\", \"Requests\":\"%d\", \"ErrorRatio\":\"%.2f\", " \
|
||||||
|
"\"Values\":{\"%s\":\"%.1f\", \"%s\":\"%.1f\", \"%s\":\"%.1f\", \"%s\":\"%.1f\"}}",
|
||||||
|
localMbusCommHandle->requestId, localMbusCommHandle->device->deviceName,
|
||||||
|
localMbusCommHandle->device->failures, localMbusCommHandle->device->requests, errorRatio,
|
||||||
|
keys[0], values[0], keys[1], values[1], keys[2], values[2], keys[3], values[3]);
|
||||||
|
}
|
||||||
|
mbus_data_record_free(data_var->record);
|
||||||
} else {
|
} else {
|
||||||
coloredMsg(LOG_RED, true, "mbc papf [%d] err: unable to parse frame", localMbusCommHandle->requestId);
|
coloredMsg(LOG_RED, true, "mbc papf [%d] err: unable to parse frame", localMbusCommHandle->requestId);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user