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 "../Hoymiles.h"
|
||||||
#include <cstring>
|
#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()
|
GridProfileParser::GridProfileParser()
|
||||||
: Parser()
|
: Parser()
|
||||||
{
|
{
|
||||||
@ -28,6 +38,23 @@ void GridProfileParser::appendFragment(uint8_t offset, uint8_t* payload, uint8_t
|
|||||||
_gridProfileLength += len;
|
_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> GridProfileParser::getRawData()
|
||||||
{
|
{
|
||||||
std::vector<uint8_t> ret;
|
std::vector<uint8_t> ret;
|
||||||
|
|||||||
@ -3,6 +3,13 @@
|
|||||||
#include "Parser.h"
|
#include "Parser.h"
|
||||||
|
|
||||||
#define GRID_PROFILE_SIZE 141
|
#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 {
|
class GridProfileParser : public Parser {
|
||||||
public:
|
public:
|
||||||
@ -10,9 +17,14 @@ public:
|
|||||||
void clearBuffer();
|
void clearBuffer();
|
||||||
void appendFragment(uint8_t offset, uint8_t* payload, uint8_t len);
|
void appendFragment(uint8_t offset, uint8_t* payload, uint8_t len);
|
||||||
|
|
||||||
|
String getProfileName();
|
||||||
|
String getProfileVersion();
|
||||||
|
|
||||||
std::vector<uint8_t> getRawData();
|
std::vector<uint8_t> getRawData();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t _payloadGridProfile[GRID_PROFILE_SIZE] = {};
|
uint8_t _payloadGridProfile[GRID_PROFILE_SIZE] = {};
|
||||||
uint8_t _gridProfileLength = 0;
|
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();
|
auto data = inv->GridProfile()->getRawData();
|
||||||
|
|
||||||
copyArray(&data[0], data.size(), raw);
|
copyArray(&data[0], data.size(), raw);
|
||||||
|
|
||||||
|
root["name"] = inv->GridProfile()->getProfileName();
|
||||||
|
root["version"] = inv->GridProfile()->getProfileVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
response->setLength();
|
response->setLength();
|
||||||
|
|||||||
@ -6,6 +6,19 @@
|
|||||||
</BootstrapAlert>
|
</BootstrapAlert>
|
||||||
|
|
||||||
<template v-if="hasValidData">
|
<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">
|
<BootstrapAlert :show="true" variant="danger">
|
||||||
<h4 class="info-heading">
|
<h4 class="info-heading">
|
||||||
<BIconInfoSquare class="fs-2" /> {{ $t('gridprofile.GridprofileSupport') }}
|
<BIconInfoSquare class="fs-2" /> {{ $t('gridprofile.GridprofileSupport') }}
|
||||||
|
|||||||
@ -155,6 +155,8 @@
|
|||||||
"gridprofile": {
|
"gridprofile": {
|
||||||
"NoInfo": "@:devinfo.NoInfo",
|
"NoInfo": "@:devinfo.NoInfo",
|
||||||
"NoInfoLong": "@:devinfo.NoInfoLong",
|
"NoInfoLong": "@:devinfo.NoInfoLong",
|
||||||
|
"Name": "Name",
|
||||||
|
"Version": "Version",
|
||||||
"GridprofileSupport": "Unterstütze die Entwicklung",
|
"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."
|
"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": {
|
"gridprofile": {
|
||||||
"NoInfo": "@:devinfo.NoInfo",
|
"NoInfo": "@:devinfo.NoInfo",
|
||||||
"NoInfoLong": "@:devinfo.NoInfoLong",
|
"NoInfoLong": "@:devinfo.NoInfoLong",
|
||||||
|
"Name": "Name",
|
||||||
|
"Version": "Version",
|
||||||
"GridprofileSupport": "Support the development",
|
"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."
|
"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": {
|
"gridprofile": {
|
||||||
"NoInfo": "@:devinfo.NoInfo",
|
"NoInfo": "@:devinfo.NoInfo",
|
||||||
"NoInfoLong": "@:devinfo.NoInfoLong",
|
"NoInfoLong": "@:devinfo.NoInfoLong",
|
||||||
|
"Name": "Name",
|
||||||
|
"Version": "Version",
|
||||||
"GridprofileSupport": "Support the development",
|
"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."
|
"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 {
|
export interface GridProfileStatus {
|
||||||
raw: Array<number>;
|
raw: Array<number>;
|
||||||
|
name: String;
|
||||||
|
version: String;
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user