Skip to content

Commit 00bc631

Browse files
committed
Feature: Added basic Grid Profile parser which shows the used profile and version
Other values are still outstanding.
1 parent c9508d2 commit 00bc631

8 files changed

Lines changed: 63 additions & 0 deletions

File tree

lib/Hoymiles/src/parser/GridProfileParser.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@
66
#include "../Hoymiles.h"
77
#include <cstring>
88

9+
const std::array<const ProfileType_t, PROFILE_TYPE_COUNT> GridProfileParser::_profileTypes = { {
10+
{ 0x02, 0x00, "no data (yet)" },
11+
{ 0x03, 0x00, "Germany - DE_VDE4105_2018" },
12+
{ 0x0a, 0x00, "European - EN 50549-1:2019" },
13+
{ 0x0c, 0x00, "AT Tor - EU_EN50438" },
14+
{ 0x0d, 0x04, "France" },
15+
{ 0x12, 0x00, "Poland" },
16+
{ 0x37, 0x00, "Swiss - CH_NA EEA-NE7-CH2020" },
17+
} };
18+
919
GridProfileParser::GridProfileParser()
1020
: Parser()
1121
{
@@ -28,6 +38,23 @@ void GridProfileParser::appendFragment(uint8_t offset, uint8_t* payload, uint8_t
2838
_gridProfileLength += len;
2939
}
3040

41+
String GridProfileParser::getProfileName()
42+
{
43+
for (auto& ptype : _profileTypes) {
44+
if (ptype.lIdx == _payloadGridProfile[0] && ptype.hIdx == _payloadGridProfile[1]) {
45+
return ptype.Name;
46+
}
47+
}
48+
return "Unknown";
49+
}
50+
51+
String GridProfileParser::getProfileVersion()
52+
{
53+
char buffer[10];
54+
snprintf(buffer, sizeof(buffer), "%d.%d.%d", (_payloadGridProfile[2] >> 4) & 0x0f, _payloadGridProfile[2] & 0x0f, _payloadGridProfile[3]);
55+
return buffer;
56+
}
57+
3158
std::vector<uint8_t> GridProfileParser::getRawData()
3259
{
3360
std::vector<uint8_t> ret;

lib/Hoymiles/src/parser/GridProfileParser.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,28 @@
33
#include "Parser.h"
44

55
#define GRID_PROFILE_SIZE 141
6+
#define PROFILE_TYPE_COUNT 7
7+
8+
typedef struct {
9+
uint8_t lIdx;
10+
uint8_t hIdx;
11+
const char* Name;
12+
} ProfileType_t;
613

714
class GridProfileParser : public Parser {
815
public:
916
GridProfileParser();
1017
void clearBuffer();
1118
void appendFragment(uint8_t offset, uint8_t* payload, uint8_t len);
1219

20+
String getProfileName();
21+
String getProfileVersion();
22+
1323
std::vector<uint8_t> getRawData();
1424

1525
private:
1626
uint8_t _payloadGridProfile[GRID_PROFILE_SIZE] = {};
1727
uint8_t _gridProfileLength = 0;
28+
29+
static const std::array<const ProfileType_t, PROFILE_TYPE_COUNT> _profileTypes;
1830
};

src/WebApi_gridprofile.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ void WebApiGridProfileClass::onGridProfileStatus(AsyncWebServerRequest* request)
4242
auto data = inv->GridProfile()->getRawData();
4343

4444
copyArray(&data[0], data.size(), raw);
45+
46+
root["name"] = inv->GridProfile()->getProfileName();
47+
root["version"] = inv->GridProfile()->getProfileVersion();
4548
}
4649

4750
response->setLength();

webapp/src/components/GridProfile.vue

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@
66
</BootstrapAlert>
77

88
<template v-if="hasValidData">
9+
<table class="table table-hover">
10+
<tbody>
11+
<tr>
12+
<td>{{ $t('gridprofile.Name') }}</td>
13+
<td>{{ gridProfileList.name }}</td>
14+
</tr>
15+
<tr>
16+
<td>{{ $t('gridprofile.Version') }}</td>
17+
<td>{{ gridProfileList.version }}</td>
18+
</tr>
19+
</tbody>
20+
</table>
21+
922
<BootstrapAlert :show="true" variant="danger">
1023
<h4 class="info-heading">
1124
<BIconInfoSquare class="fs-2" />&nbsp;{{ $t('gridprofile.GridprofileSupport') }}

webapp/src/locales/de.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@
155155
"gridprofile": {
156156
"NoInfo": "@:devinfo.NoInfo",
157157
"NoInfoLong": "@:devinfo.NoInfoLong",
158+
"Name": "Name",
159+
"Version": "Version",
158160
"GridprofileSupport": "Unterstütze die Entwicklung",
159161
"GridprofileSupportLong": "Weitere Informationen sind <a href=\"https://github.com/tbnobody/OpenDTU/wiki/Grid-Profile-Parser\" target=\"_blank\">hier</a> zu finden."
160162
},

webapp/src/locales/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@
155155
"gridprofile": {
156156
"NoInfo": "@:devinfo.NoInfo",
157157
"NoInfoLong": "@:devinfo.NoInfoLong",
158+
"Name": "Name",
159+
"Version": "Version",
158160
"GridprofileSupport": "Support the development",
159161
"GridprofileSupportLong": "Please see <a href=\"https://github.com/tbnobody/OpenDTU/wiki/Grid-Profile-Parser\" target=\"_blank\">here</a> for further information."
160162
},

webapp/src/locales/fr.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@
155155
"gridprofile": {
156156
"NoInfo": "@:devinfo.NoInfo",
157157
"NoInfoLong": "@:devinfo.NoInfoLong",
158+
"Name": "Name",
159+
"Version": "Version",
158160
"GridprofileSupport": "Support the development",
159161
"GridprofileSupportLong": "Please see <a href=\"https://github.com/tbnobody/OpenDTU/wiki/Grid-Profile-Parser\" target=\"_blank\">here</a> for further information."
160162
},
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
export interface GridProfileStatus {
22
raw: Array<number>;
3+
name: String;
4+
version: String;
35
}

0 commit comments

Comments
 (0)