Implemented method to get the amount of relevant digits
This commit is contained in:
parent
27ed4e3cda
commit
4049f6bdb7
@ -120,6 +120,25 @@ const char* StatisticsParser::getChannelFieldName(uint8_t channel, uint8_t field
|
||||
return fields[b[pos].fieldId];
|
||||
}
|
||||
|
||||
uint8_t StatisticsParser::getChannelFieldDigits(uint8_t channel, uint8_t fieldId)
|
||||
{
|
||||
uint8_t pos = getAssignIdxByChannelField(channel, fieldId);
|
||||
const byteAssign_t* b = _byteAssignment;
|
||||
|
||||
switch (b[pos].div) {
|
||||
case 1:
|
||||
return 0;
|
||||
case 10:
|
||||
return 1;
|
||||
case 100:
|
||||
return 2;
|
||||
case 1000:
|
||||
return 3;
|
||||
default:
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t StatisticsParser::getChannelCount()
|
||||
{
|
||||
const byteAssign_t* b = _byteAssignment;
|
||||
|
||||
@ -83,6 +83,7 @@ public:
|
||||
bool hasChannelFieldValue(uint8_t channel, uint8_t fieldId);
|
||||
const char* getChannelFieldUnit(uint8_t channel, uint8_t fieldId);
|
||||
const char* getChannelFieldName(uint8_t channel, uint8_t fieldId);
|
||||
uint8_t getChannelFieldDigits(uint8_t channel, uint8_t fieldId);
|
||||
|
||||
uint8_t getChannelCount();
|
||||
|
||||
|
||||
@ -134,6 +134,7 @@ void WebApiWsLiveClass::addField(JsonVariant& root, uint8_t idx, std::shared_ptr
|
||||
}
|
||||
root[idx][String(channel)][chanName]["v"] = inv->Statistics()->getChannelFieldValue(channel, fieldId);
|
||||
root[idx][String(channel)][chanName]["u"] = inv->Statistics()->getChannelFieldUnit(channel, fieldId);
|
||||
root[idx][String(channel)][chanName]["d"] = inv->Statistics()->getChannelFieldDigits(channel, fieldId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user