mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-01-18 01:11:58 +00:00
Updated Aidon parser with support for 3 phase IT/TT system
This commit is contained in:
parent
388d35c390
commit
fdfadb9bf9
@ -8,9 +8,11 @@ enum class Aidon
|
||||
{
|
||||
List1 = 0x01,
|
||||
List1PhaseShort = 0x09,
|
||||
List1PhaseLong = 0xff, // TODO: Need sample
|
||||
List1PhaseLong = 0x0E,
|
||||
List3PhaseShort = 0x0D,
|
||||
List3PhaseLong = 0x12
|
||||
List3PhaseLong = 0x12,
|
||||
List3PhaseITShort = 0x0C,
|
||||
List3PhaseITLong = 0x11,
|
||||
};
|
||||
|
||||
enum class Aidon_List1
|
||||
@ -73,6 +75,33 @@ enum class Aidon_List1Phase
|
||||
IGN_14,
|
||||
VoltageL1Int8,
|
||||
VoltageL1Enum,
|
||||
IGN_15,
|
||||
Timestamp_OBIS,
|
||||
Timestamp,
|
||||
IGN_16,
|
||||
CumulativeActiveImportEnergy_OBIS,
|
||||
CumulativeActiveImportEnergy,
|
||||
IGN_17,
|
||||
CumulativeActiveImportEnergyInt8,
|
||||
CumulativeActiveImportEnergyEnum,
|
||||
IGN_18,
|
||||
CumulativeActiveExportEnergy_OBIS,
|
||||
CumulativeActiveExportEnergy,
|
||||
IGN_19,
|
||||
CumulativeActiveExportEnergyInt8,
|
||||
CumulativeActiveExportEnergyEnum,
|
||||
IGN_20,
|
||||
CumulativeReactiveImportEnergy_OBIS,
|
||||
CumulativeReactiveImportEnergy,
|
||||
IGN_21,
|
||||
CumulativeReactiveImportEnergyInt8,
|
||||
CumulativeReactiveImportEnergyEnum,
|
||||
IGN_22,
|
||||
CumulativeReactiveExportEnergy_OBIS,
|
||||
CumulativeReactiveExportEnergy,
|
||||
IGN_23,
|
||||
CumulativeReactiveExportEnergyInt8,
|
||||
CumulativeReactiveExportEnergyEnum
|
||||
};
|
||||
|
||||
enum class Aidon_List3Phase
|
||||
@ -176,6 +205,101 @@ enum class Aidon_List3Phase
|
||||
CumulativeReactiveExportEnergyEnum
|
||||
};
|
||||
|
||||
enum class Aidon_List3PhaseIT
|
||||
{
|
||||
ListSize,
|
||||
IGN_0,
|
||||
ListVersionIdentifier_OBIS,
|
||||
ListVersionIdentifier,
|
||||
IGN_1,
|
||||
MeterID_OBIS,
|
||||
MeterID,
|
||||
IGN_2,
|
||||
MeterType_OBIS,
|
||||
MeterType,
|
||||
IGN_3,
|
||||
ActiveImportPower_OBIS,
|
||||
ActiveImportPower,
|
||||
IGN_4,
|
||||
ActiveImportPowerInt8,
|
||||
ActiveImportPowerEnum,
|
||||
IGN_5,
|
||||
ActiveExportPower_OBIS,
|
||||
ActiveExportPower,
|
||||
IGN_6,
|
||||
ActiveExportPowerInt8,
|
||||
ActiveExportPowerEnum,
|
||||
IGN_7,
|
||||
ReactiveImportPower_OBIS,
|
||||
ReactiveImportPower,
|
||||
IGN_8,
|
||||
ReactiveImportPowerInt8,
|
||||
ReactiveImportPowerEnum,
|
||||
IGN_9,
|
||||
ReactiveExportPower_OBIS,
|
||||
ReactiveExportPower,
|
||||
IGN_10,
|
||||
ReactiveExportPowerInt8,
|
||||
ReactiveExportPowerEnum,
|
||||
IGN_11,
|
||||
CurrentL1_OBIS,
|
||||
CurrentL1,
|
||||
IGN_12,
|
||||
CurrentL1Int8,
|
||||
CurrentL1Enum,
|
||||
IGN_13,
|
||||
CurrentL3_OBIS,
|
||||
CurrentL3,
|
||||
IGN_14,
|
||||
CurrentL3Int8,
|
||||
CurrentL3Enum,
|
||||
IGN_15,
|
||||
VoltageL1_OBIS,
|
||||
VoltageL1,
|
||||
IGN_16,
|
||||
VoltageL1Int8,
|
||||
VoltageL1Enum,
|
||||
IGN_17,
|
||||
VoltageL2_OBIS,
|
||||
VoltageL2,
|
||||
IGN_18,
|
||||
VoltageL2Int8,
|
||||
VoltageL2Enum,
|
||||
IGN_19,
|
||||
VoltageL3_OBIS,
|
||||
VoltageL3,
|
||||
IGN_20,
|
||||
VoltageL3Int8,
|
||||
VoltageL3Enum,
|
||||
IGN_21,
|
||||
Timestamp_OBIS,
|
||||
Timestamp,
|
||||
IGN_22,
|
||||
CumulativeActiveImportEnergy_OBIS,
|
||||
CumulativeActiveImportEnergy,
|
||||
IGN_23,
|
||||
CumulativeActiveImportEnergyInt8,
|
||||
CumulativeActiveImportEnergyEnum,
|
||||
IGN_24,
|
||||
CumulativeActiveExportEnergy_OBIS,
|
||||
CumulativeActiveExportEnergy,
|
||||
IGN_25,
|
||||
CumulativeActiveExportEnergyInt8,
|
||||
CumulativeActiveExportEnergyEnum,
|
||||
IGN_26,
|
||||
CumulativeReactiveImportEnergy_OBIS,
|
||||
CumulativeReactiveImportEnergy,
|
||||
IGN_27,
|
||||
CumulativeReactiveImportEnergyInt8,
|
||||
CumulativeReactiveImportEnergyEnum,
|
||||
IGN_28,
|
||||
CumulativeReactiveExportEnergy_OBIS,
|
||||
CumulativeReactiveExportEnergy,
|
||||
IGN_29,
|
||||
CumulativeReactiveExportEnergyInt8,
|
||||
CumulativeReactiveExportEnergyEnum
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -101,8 +101,6 @@ static void hanToJsonAidon3phase(int listSize, JsonObject& data, HanReader& hanR
|
||||
data["tQI"] = hanReader.getInt( (int)Aidon_List3Phase::CumulativeReactiveImportEnergy);
|
||||
data["tQO"] = hanReader.getInt( (int)Aidon_List3Phase::CumulativeReactiveExportEnergy);
|
||||
}
|
||||
|
||||
// TODO: Do not divide Aidon values by 10!?
|
||||
}
|
||||
|
||||
static void hanToJsonAidon1phase(int listSize, JsonObject& data, HanReader& hanReader, Stream *debugger)
|
||||
@ -118,7 +116,46 @@ static void hanToJsonAidon1phase(int listSize, JsonObject& data, HanReader& hanR
|
||||
data["U1"] = ((double) hanReader.getInt( (int)Aidon_List1Phase::VoltageL1)) / 10;
|
||||
}
|
||||
|
||||
// TODO Aidon::List1PhaseLong
|
||||
if (listSize >= (int)Aidon::List1PhaseLong)
|
||||
{
|
||||
data["tPI"] = hanReader.getInt( (int)Aidon_List1Phase::CumulativeActiveImportEnergy);
|
||||
data["tPO"] = hanReader.getInt( (int)Aidon_List1Phase::CumulativeActiveExportEnergy);
|
||||
data["tQI"] = hanReader.getInt( (int)Aidon_List1Phase::CumulativeReactiveImportEnergy);
|
||||
data["tQO"] = hanReader.getInt( (int)Aidon_List1Phase::CumulativeReactiveExportEnergy);
|
||||
}
|
||||
}
|
||||
|
||||
static void hanToJsonAidon3phaseIT(int listSize, JsonObject& data, HanReader& hanReader, Stream *debugger)
|
||||
{
|
||||
if (listSize >= (int)Aidon::List3PhaseITShort)
|
||||
{
|
||||
data["lv"] = hanReader.getString( (int)Aidon_List3PhaseIT::ListVersionIdentifier);
|
||||
data["id"] = hanReader.getString( (int)Aidon_List3PhaseIT::MeterID);
|
||||
data["type"] = hanReader.getString( (int)Aidon_List3PhaseIT::MeterType);
|
||||
int p = hanReader.getInt( (int)Aidon_List3PhaseIT::ActiveImportPower);
|
||||
data["P"] = p;
|
||||
data["Q"] = hanReader.getInt( (int)Aidon_List3PhaseIT::ReactiveExportPower);
|
||||
double i1 = ((double) hanReader.getInt( (int)Aidon_List3PhaseIT::CurrentL1)) / 10;
|
||||
double i3 = ((double) hanReader.getInt( (int)Aidon_List3PhaseIT::CurrentL3)) / 10;
|
||||
double u1 = ((double) hanReader.getInt( (int)Aidon_List3PhaseIT::VoltageL1)) / 10;
|
||||
double u2 = ((double) hanReader.getInt( (int)Aidon_List3PhaseIT::VoltageL2)) / 10;
|
||||
double u3 = ((double) hanReader.getInt( (int)Aidon_List3PhaseIT::VoltageL3)) / 10;
|
||||
double i2 = 0.00;
|
||||
data["I1"] = i1;
|
||||
data["I2"] = i2;
|
||||
data["I3"] = i3;
|
||||
data["U1"] = u1;
|
||||
data["U2"] = u2;
|
||||
data["U3"] = u3;
|
||||
}
|
||||
|
||||
if (listSize >= (int)Aidon::List3PhaseITLong)
|
||||
{
|
||||
data["tPI"] = hanReader.getInt( (int)Aidon_List3PhaseIT::CumulativeActiveImportEnergy);
|
||||
data["tPO"] = hanReader.getInt( (int)Aidon_List3PhaseIT::CumulativeActiveExportEnergy);
|
||||
data["tQI"] = hanReader.getInt( (int)Aidon_List3PhaseIT::CumulativeReactiveImportEnergy);
|
||||
data["tQO"] = hanReader.getInt( (int)Aidon_List3PhaseIT::CumulativeReactiveExportEnergy);
|
||||
}
|
||||
}
|
||||
|
||||
static void hanToJsonAidon(JsonObject& data, HanReader& hanReader, Stream *debugger)
|
||||
@ -141,6 +178,9 @@ static void hanToJsonAidon(JsonObject& data, HanReader& hanReader, Stream *debug
|
||||
case (int)Aidon::List1PhaseShort:
|
||||
case (int)Aidon::List1PhaseLong:
|
||||
return hanToJsonAidon1phase(listSize, data, hanReader, debugger);
|
||||
case (int)Aidon::List3PhaseITShort:
|
||||
case (int)Aidon::List3PhaseITLong:
|
||||
return hanToJsonAidon3phaseIT(listSize, data, hanReader, debugger);
|
||||
default:
|
||||
if (debugger) debugger->printf("Warning: Unknown listSize %d\n", listSize);
|
||||
return;
|
||||
|
||||
@ -44,13 +44,21 @@ void AmsWebServer::loop() {
|
||||
void AmsWebServer::setJson(StaticJsonDocument<500> json) {
|
||||
if(!json.isNull()) {
|
||||
p = json["data"]["P"].as<int>();
|
||||
|
||||
if(json["data"].containsKey("U1")) {
|
||||
u1 = json["data"]["U1"].as<double>();
|
||||
u2 = json["data"]["U2"].as<double>();
|
||||
u3 = json["data"]["U3"].as<double>();
|
||||
i1 = json["data"]["I1"].as<double>();
|
||||
i2 = json["data"]["I2"].as<double>();
|
||||
i3 = json["data"]["I3"].as<double>();
|
||||
|
||||
if(json["data"].containsKey("U2")) {
|
||||
u2 = json["data"]["U2"].as<double>();
|
||||
i2 = json["data"]["I2"].as<double>();
|
||||
|
||||
if(json["data"].containsKey("U3")) {
|
||||
u3 = json["data"]["U3"].as<double>();
|
||||
i3 = json["data"]["I3"].as<double>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(maxPwr == 0 && config->hasConfig() && config->fuseSize > 0 && config->distSys > 0) {
|
||||
int volt = config->distSys == 2 ? 400 : 230;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user