Feature: Added basic Grid Profile parser which shows the used profile and version
Other values are still outstanding.
This commit is contained in:
parent
c9508d2660
commit
00bc631e87
@ -6,6 +6,16 @@
|
||||
#include "../Hoymiles.h"
|
||||
#include <cstring>
|
||||
|
||||
const std::array<const ProfileType_t, PROFILE_TYPE_COUNT> GridProfileParser::_profileTypes = { {
|
||||
{ 0x02, 0x00, "no data (yet)" },
|
||||
{ 0x03, 0x00, "Germany - DE_VDE4105_2018" },
|
||||
{ 0x0a, 0x00, "European - EN 50549-1:2019" },
|
||||
{ 0x0c, 0x00, "AT Tor - EU_EN50438" },
|
||||
{ 0x0d, 0x04, "France" },
|
||||
{ 0x12, 0x00, "Poland" },
|
||||
{ 0x37, 0x00, "Swiss - CH_NA EEA-NE7-CH2020" },
|
||||
} };
|
||||
|
||||
GridProfileParser::GridProfileParser()
|
||||
: Parser()
|
||||
{
|
||||
@ -28,6 +38,23 @@ void GridProfileParser::appendFragment(uint8_t offset, uint8_t* payload, uint8_t
|
||||
_gridProfileLength += len;
|
||||
}
|
||||
|
||||
String GridProfileParser::getProfileName()
|
||||
{
|
||||
for (auto& ptype : _profileTypes) {
|
||||
if (ptype.lIdx == _payloadGridProfile[0] && ptype.hIdx == _payloadGridProfile[1]) {
|
||||
return ptype.Name;
|
||||
}
|
||||
}
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
String GridProfileParser::getProfileVersion()
|
||||
{
|
||||
char buffer[10];
|
||||
snprintf(buffer, sizeof(buffer), "%d.%d.%d", (_payloadGridProfile[2] >> 4) & 0x0f, _payloadGridProfile[2] & 0x0f, _payloadGridProfile[3]);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> GridProfileParser::getRawData()
|
||||
{
|
||||
std::vector<uint8_t> ret;
|
||||
|
||||
@ -3,6 +3,13 @@
|
||||
#include "Parser.h"
|
||||
|
||||
#define GRID_PROFILE_SIZE 141
|
||||
#define PROFILE_TYPE_COUNT 7
|
||||
|
||||
typedef struct {
|
||||
uint8_t lIdx;
|
||||
uint8_t hIdx;
|
||||
const char* Name;
|
||||
} ProfileType_t;
|
||||
|
||||
class GridProfileParser : public Parser {
|
||||
public:
|
||||
@ -10,9 +17,14 @@ public:
|
||||
void clearBuffer();
|
||||
void appendFragment(uint8_t offset, uint8_t* payload, uint8_t len);
|
||||
|
||||
String getProfileName();
|
||||
String getProfileVersion();
|
||||
|
||||
std::vector<uint8_t> getRawData();
|
||||
|
||||
private:
|
||||
uint8_t _payloadGridProfile[GRID_PROFILE_SIZE] = {};
|
||||
uint8_t _gridProfileLength = 0;
|
||||
|
||||
static const std::array<const ProfileType_t, PROFILE_TYPE_COUNT> _profileTypes;
|
||||
};
|
||||
@ -42,6 +42,9 @@ void WebApiGridProfileClass::onGridProfileStatus(AsyncWebServerRequest* request)
|
||||
auto data = inv->GridProfile()->getRawData();
|
||||
|
||||
copyArray(&data[0], data.size(), raw);
|
||||
|
||||
root["name"] = inv->GridProfile()->getProfileName();
|
||||
root["version"] = inv->GridProfile()->getProfileVersion();
|
||||
}
|
||||
|
||||
response->setLength();
|
||||
|
||||
@ -6,6 +6,19 @@
|
||||
</BootstrapAlert>
|
||||
|
||||
<template v-if="hasValidData">
|
||||
<table class="table table-hover">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>{{ $t('gridprofile.Name') }}</td>
|
||||
<td>{{ gridProfileList.name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{{ $t('gridprofile.Version') }}</td>
|
||||
<td>{{ gridProfileList.version }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<BootstrapAlert :show="true" variant="danger">
|
||||
<h4 class="info-heading">
|
||||
<BIconInfoSquare class="fs-2" /> {{ $t('gridprofile.GridprofileSupport') }}
|
||||
|
||||
@ -155,6 +155,8 @@
|
||||
"gridprofile": {
|
||||
"NoInfo": "@:devinfo.NoInfo",
|
||||
"NoInfoLong": "@:devinfo.NoInfoLong",
|
||||
"Name": "Name",
|
||||
"Version": "Version",
|
||||
"GridprofileSupport": "Unterstütze die Entwicklung",
|
||||
"GridprofileSupportLong": "Weitere Informationen sind <a href=\"https://github.com/tbnobody/OpenDTU/wiki/Grid-Profile-Parser\" target=\"_blank\">hier</a> zu finden."
|
||||
},
|
||||
|
||||
@ -155,6 +155,8 @@
|
||||
"gridprofile": {
|
||||
"NoInfo": "@:devinfo.NoInfo",
|
||||
"NoInfoLong": "@:devinfo.NoInfoLong",
|
||||
"Name": "Name",
|
||||
"Version": "Version",
|
||||
"GridprofileSupport": "Support the development",
|
||||
"GridprofileSupportLong": "Please see <a href=\"https://github.com/tbnobody/OpenDTU/wiki/Grid-Profile-Parser\" target=\"_blank\">here</a> for further information."
|
||||
},
|
||||
|
||||
@ -155,6 +155,8 @@
|
||||
"gridprofile": {
|
||||
"NoInfo": "@:devinfo.NoInfo",
|
||||
"NoInfoLong": "@:devinfo.NoInfoLong",
|
||||
"Name": "Name",
|
||||
"Version": "Version",
|
||||
"GridprofileSupport": "Support the development",
|
||||
"GridprofileSupportLong": "Please see <a href=\"https://github.com/tbnobody/OpenDTU/wiki/Grid-Profile-Parser\" target=\"_blank\">here</a> for further information."
|
||||
},
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
export interface GridProfileStatus {
|
||||
raw: Array<number>;
|
||||
name: String;
|
||||
version: String;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user