added interfaces and fixed inverter states

This commit is contained in:
Boernsman 2021-02-03 20:59:21 +01:00
parent 1020dd90a4
commit 62dc0ab825
6 changed files with 130 additions and 93 deletions

View File

@ -65,21 +65,29 @@ void IntegrationPluginSunSpec::init()
m_modbusAddressParamTypeIds.insert(sunspecSplitPhaseMeterThingClassId, sunspecSplitPhaseMeterThingModbusAddressParamTypeId); m_modbusAddressParamTypeIds.insert(sunspecSplitPhaseMeterThingClassId, sunspecSplitPhaseMeterThingModbusAddressParamTypeId);
m_modbusAddressParamTypeIds.insert(sunspecThreePhaseMeterThingClassId, sunspecThreePhaseMeterThingModbusAddressParamTypeId); m_modbusAddressParamTypeIds.insert(sunspecThreePhaseMeterThingClassId, sunspecThreePhaseMeterThingModbusAddressParamTypeId);
m_acPowerStateTypeIds.insert(sunspecSinglePhaseInverterThingClassId, sunspecSinglePhaseInverterAcPowerStateTypeId); m_inverterCurrentPowerStateTypeIds.insert(sunspecSinglePhaseInverterThingClassId, sunspecSinglePhaseInverterCurrentPowerStateTypeId);
m_acPowerStateTypeIds.insert(sunspecSplitPhaseInverterThingClassId, sunspecSplitPhaseInverterAcPowerStateTypeId); m_inverterCurrentPowerStateTypeIds.insert(sunspecSplitPhaseInverterThingClassId, sunspecSplitPhaseInverterCurrentPowerStateTypeId);
m_acPowerStateTypeIds.insert(sunspecThreePhaseInverterThingClassId, sunspecThreePhaseInverterAcPowerStateTypeId); m_inverterCurrentPowerStateTypeIds.insert(sunspecThreePhaseInverterThingClassId, sunspecThreePhaseInverterCurrentPowerStateTypeId);
m_acEnergyStateTypeIds.insert(sunspecSinglePhaseInverterThingClassId, sunspecSinglePhaseInverterAcEnergyStateTypeId); m_inverterTotalEnergyProducedStateTypeIds.insert(sunspecSinglePhaseInverterThingClassId, sunspecSinglePhaseInverterTotalEnergyProducedStateTypeId);
m_acEnergyStateTypeIds.insert(sunspecSplitPhaseInverterThingClassId, sunspecSplitPhaseInverterAcEnergyStateTypeId); m_inverterTotalEnergyProducedStateTypeIds.insert(sunspecSplitPhaseInverterThingClassId, sunspecSplitPhaseInverterTotalEnergyProducedStateTypeId);
m_acEnergyStateTypeIds.insert(sunspecThreePhaseInverterThingClassId, sunspecThreePhaseInverterAcEnergyStateTypeId); m_inverterTotalEnergyProducedStateTypeIds.insert(sunspecThreePhaseInverterThingClassId, sunspecThreePhaseInverterTotalEnergyProducedStateTypeId);
m_inverterOperatingStateTypeIds.insert(sunspecSinglePhaseMeterThingClassId, sunspecSinglePhaseInverterOperatingStateStateTypeId); m_inverterOperatingStateTypeIds.insert(sunspecSinglePhaseInverterThingClassId, sunspecSinglePhaseInverterOperatingStateStateTypeId);
m_inverterOperatingStateTypeIds.insert(sunspecSplitPhaseMeterThingClassId, sunspecSplitPhaseInverterOperatingStateStateTypeId); m_inverterOperatingStateTypeIds.insert(sunspecSplitPhaseInverterThingClassId, sunspecSplitPhaseInverterOperatingStateStateTypeId);
m_inverterOperatingStateTypeIds.insert(sunspecThreePhaseMeterThingClassId, sunspecThreePhaseInverterOperatingStateStateTypeId); m_inverterOperatingStateTypeIds.insert(sunspecThreePhaseInverterThingClassId, sunspecThreePhaseInverterOperatingStateStateTypeId);
m_inverterErrorStateTypeIds.insert(sunspecSinglePhaseMeterThingClassId, sunspecSinglePhaseInverterErrorStateTypeId); m_inverterErrorStateTypeIds.insert(sunspecSinglePhaseInverterThingClassId, sunspecSinglePhaseInverterErrorStateTypeId);
m_inverterErrorStateTypeIds.insert(sunspecSplitPhaseMeterThingClassId, sunspecSplitPhaseInverterErrorStateTypeId); m_inverterErrorStateTypeIds.insert(sunspecSplitPhaseInverterThingClassId, sunspecSplitPhaseInverterErrorStateTypeId);
m_inverterErrorStateTypeIds.insert(sunspecThreePhaseMeterThingClassId, sunspecThreePhaseInverterErrorStateTypeId); m_inverterErrorStateTypeIds.insert(sunspecThreePhaseInverterThingClassId, sunspecThreePhaseInverterErrorStateTypeId);
m_inverterCabinetTemperatureStateTypeIds.insert(sunspecSinglePhaseInverterThingClassId, sunspecSinglePhaseInverterCabinetTemperatureStateTypeId);
m_inverterCabinetTemperatureStateTypeIds.insert(sunspecSplitPhaseInverterThingClassId, sunspecSplitPhaseInverterCabinetTemperatureStateTypeId);
m_inverterCabinetTemperatureStateTypeIds.insert(sunspecThreePhaseInverterThingClassId, sunspecThreePhaseInverterCabinetTemperatureStateTypeId);
m_inverterAcCurrentStateTypeIds.insert(sunspecSinglePhaseInverterThingClassId, sunspecSinglePhaseInverterTotalCurrentStateTypeId);
m_inverterAcCurrentStateTypeIds.insert(sunspecSplitPhaseInverterThingClassId, sunspecSplitPhaseInverterTotalCurrentStateTypeId);
m_inverterAcCurrentStateTypeIds.insert(sunspecThreePhaseInverterThingClassId, sunspecThreePhaseInverterTotalCurrentStateTypeId);
m_frequencyStateTypeIds.insert(sunspecSinglePhaseInverterThingClassId, sunspecSinglePhaseInverterFrequencyStateTypeId); m_frequencyStateTypeIds.insert(sunspecSinglePhaseInverterThingClassId, sunspecSinglePhaseInverterFrequencyStateTypeId);
m_frequencyStateTypeIds.insert(sunspecSplitPhaseInverterThingClassId, sunspecSplitPhaseInverterFrequencyStateTypeId); m_frequencyStateTypeIds.insert(sunspecSplitPhaseInverterThingClassId, sunspecSplitPhaseInverterFrequencyStateTypeId);
@ -638,14 +646,18 @@ void IntegrationPluginSunSpec::onInverterDataReceived(const SunSpecInverter::Inv
qCDebug(dcSunSpec()) << " - Operating state" << inverterData.operatingState; qCDebug(dcSunSpec()) << " - Operating state" << inverterData.operatingState;
thing->setStateValue(m_connectedStateTypeIds.value(thing->thingClassId()), true); thing->setStateValue(m_connectedStateTypeIds.value(thing->thingClassId()), true);
thing->setStateValue(m_acPowerStateTypeIds.value(thing->thingClassId()), inverterData.acPower/1000.00); thing->setStateValue(m_inverterCurrentPowerStateTypeIds.value(thing->thingClassId()), inverterData.acPower/1000.00);
thing->setStateValue(m_acEnergyStateTypeIds.value(thing->thingClassId()), inverterData.acEnergy/1000.00); thing->setStateValue(m_inverterTotalEnergyProducedStateTypeIds.value(thing->thingClassId()), inverterData.acEnergy/1000.00);
thing->setStateValue(m_frequencyStateTypeIds.value(thing->thingClassId()), inverterData.lineFrequency); thing->setStateValue(m_frequencyStateTypeIds.value(thing->thingClassId()), inverterData.lineFrequency);
thing->setStateValue(sunspecThreePhaseInverterTotalCurrentStateTypeId, inverterData.acCurrent); thing->setStateValue(m_inverterAcCurrentStateTypeIds.value(thing->thingClassId()), inverterData.acCurrent);
thing->setStateValue(sunspecThreePhaseInverterCabinetTemperatureStateTypeId, inverterData.cabinetTemperature); thing->setStateValue(m_inverterCabinetTemperatureStateTypeIds.value(thing->thingClassId()), inverterData.cabinetTemperature);
if (thing->thingClassId() == sunspecSplitPhaseInverterThingClassId) { if (thing->thingClassId() == sunspecSinglePhaseInverterThingClassId) {
thing->setStateValue(sunspecSinglePhaseInverterPhaseVoltageStateTypeId, inverterData.phaseVoltageAN);
} else if (thing->thingClassId() == sunspecSplitPhaseInverterThingClassId) {
thing->setStateValue(sunspecSplitPhaseInverterPhaseANVoltageStateTypeId, inverterData.phaseVoltageAN); thing->setStateValue(sunspecSplitPhaseInverterPhaseANVoltageStateTypeId, inverterData.phaseVoltageAN);
thing->setStateValue(sunspecSplitPhaseInverterPhaseBNVoltageStateTypeId, inverterData.phaseVoltageBN); thing->setStateValue(sunspecSplitPhaseInverterPhaseBNVoltageStateTypeId, inverterData.phaseVoltageBN);
@ -693,39 +705,39 @@ void IntegrationPluginSunSpec::onInverterDataReceived(const SunSpecInverter::Inv
//FIXME: Event1 may have multiple states at once. Only one is stated in nymea //FIXME: Event1 may have multiple states at once. Only one is stated in nymea
if (inverterData.event1.overTemperature) { if (inverterData.event1.overTemperature) {
thing->setStateValue(sunspecThreePhaseInverterErrorStateTypeId, "Over temperature"); thing->setStateValue(m_inverterErrorStateTypeIds.value(thing->thingClassId()), "Over temperature");
} else if (inverterData.event1.underTemperature) { } else if (inverterData.event1.underTemperature) {
thing->setStateValue(sunspecThreePhaseInverterErrorStateTypeId, "Under temperature"); thing->setStateValue(m_inverterErrorStateTypeIds.value(thing->thingClassId()), "Under temperature");
} else if (inverterData.event1.groundFault) { } else if (inverterData.event1.groundFault) {
thing->setStateValue(sunspecThreePhaseInverterErrorStateTypeId, "Ground fault"); thing->setStateValue(m_inverterErrorStateTypeIds.value(thing->thingClassId()), "Ground fault");
} else if (inverterData.event1.memoryLoss) { } else if (inverterData.event1.memoryLoss) {
thing->setStateValue(sunspecThreePhaseInverterErrorStateTypeId, "Memory loss"); thing->setStateValue(m_inverterErrorStateTypeIds.value(thing->thingClassId()), "Memory loss");
} else if (inverterData.event1.acOverVolt) { } else if (inverterData.event1.acOverVolt) {
thing->setStateValue(sunspecThreePhaseInverterErrorStateTypeId, "AC voltage above limit"); thing->setStateValue(m_inverterErrorStateTypeIds.value(thing->thingClassId()), "AC voltage above limit");
} else if (inverterData.event1.cabinetOpen) { } else if (inverterData.event1.cabinetOpen) {
thing->setStateValue(sunspecThreePhaseInverterErrorStateTypeId, "Cabinet open"); thing->setStateValue(m_inverterErrorStateTypeIds.value(thing->thingClassId()), "Cabinet open");
} else if (inverterData.event1.acDisconnect) { } else if (inverterData.event1.acDisconnect) {
thing->setStateValue(sunspecThreePhaseInverterErrorStateTypeId, "AC disconnect open"); thing->setStateValue(m_inverterErrorStateTypeIds.value(thing->thingClassId()), "AC disconnect open");
} else if (inverterData.event1.acUnderVolt) { } else if (inverterData.event1.acUnderVolt) {
thing->setStateValue(sunspecThreePhaseInverterErrorStateTypeId, "AC voltage under limit"); thing->setStateValue(m_inverterErrorStateTypeIds.value(thing->thingClassId()), "AC voltage under limit");
} else if (inverterData.event1.dcDicconnect) { } else if (inverterData.event1.dcDicconnect) {
thing->setStateValue(sunspecThreePhaseInverterErrorStateTypeId, "DC disconnect open"); thing->setStateValue(m_inverterErrorStateTypeIds.value(thing->thingClassId()), "DC disconnect open");
} else if (inverterData.event1.dcOverVoltage) { } else if (inverterData.event1.dcOverVoltage) {
thing->setStateValue(sunspecThreePhaseInverterErrorStateTypeId, "DC over voltage"); thing->setStateValue(m_inverterErrorStateTypeIds.value(thing->thingClassId()), "DC over voltage");
} else if (inverterData.event1.overFrequency) { } else if (inverterData.event1.overFrequency) {
thing->setStateValue(sunspecThreePhaseInverterErrorStateTypeId, "Frequency above limit"); thing->setStateValue(m_inverterErrorStateTypeIds.value(thing->thingClassId()), "Frequency above limit");
} else if (inverterData.event1.gridDisconnect) { } else if (inverterData.event1.gridDisconnect) {
thing->setStateValue(sunspecThreePhaseInverterErrorStateTypeId, "Grid disconnect"); thing->setStateValue(m_inverterErrorStateTypeIds.value(thing->thingClassId()), "Grid disconnect");
} else if (inverterData.event1.hwTestFailure) { } else if (inverterData.event1.hwTestFailure) {
thing->setStateValue(sunspecThreePhaseInverterErrorStateTypeId, "Hardware test failure"); thing->setStateValue(m_inverterErrorStateTypeIds.value(thing->thingClassId()), "Hardware test failure");
} else if (inverterData.event1.manualShutdown) { } else if (inverterData.event1.manualShutdown) {
thing->setStateValue(sunspecThreePhaseInverterErrorStateTypeId, "Manual shutdown"); thing->setStateValue(m_inverterErrorStateTypeIds.value(thing->thingClassId()), "Manual shutdown");
} else if (inverterData.event1.underFrequency) { } else if (inverterData.event1.underFrequency) {
thing->setStateValue(sunspecThreePhaseInverterErrorStateTypeId, "Frequency under limit"); thing->setStateValue(m_inverterErrorStateTypeIds.value(thing->thingClassId()), "Frequency under limit");
} else if (inverterData.event1.blownStringFuse) { } else if (inverterData.event1.blownStringFuse) {
thing->setStateValue(sunspecThreePhaseInverterErrorStateTypeId, "Blown string fuse on input"); thing->setStateValue(m_inverterErrorStateTypeIds.value(thing->thingClassId()), "Blown string fuse on input");
} else { } else {
thing->setStateValue(sunspecThreePhaseInverterErrorStateTypeId, "None"); thing->setStateValue(m_inverterErrorStateTypeIds.value(thing->thingClassId()), "None");
} }
} }
@ -801,13 +813,29 @@ void IntegrationPluginSunSpec::onMeterDataReceived(const SunSpecMeter::MeterData
qCDebug(dcSunSpec()) << " - Total real energy exported" << meterData.totalRealEnergyExported<< "[kWH]"; qCDebug(dcSunSpec()) << " - Total real energy exported" << meterData.totalRealEnergyExported<< "[kWH]";
qCDebug(dcSunSpec()) << " - Total real energy imported" << meterData.totalRealEnergyImported<< "[kWH]"; qCDebug(dcSunSpec()) << " - Total real energy imported" << meterData.totalRealEnergyImported<< "[kWH]";
thing->setStateValue(m_frequencyStateTypeIds.value(thing->thingClassId()), meterData.frequency);
thing->setStateValue(sunspecThreePhaseMeterTotalCurrentStateTypeId, meterData.totalAcCurrent); thing->setStateValue(sunspecThreePhaseMeterTotalCurrentStateTypeId, meterData.totalAcCurrent);
thing->setStateValue(sunspecThreePhaseMeterPhaseACurrentStateTypeId, meterData.phaseACurrent);
thing->setStateValue(sunspecThreePhaseMeterPhaseBCurrentStateTypeId, meterData.phaseBCurrent); if (thing->thingClassId() == sunspecSinglePhaseMeterThingClassId) {
thing->setStateValue(sunspecThreePhaseMeterPhaseCCurrentStateTypeId, meterData.phaseCCurrent); thing->setStateValue(sunspecSinglePhaseMeterPhaseACurrentStateTypeId, meterData.phaseACurrent);
thing->setStateValue(sunspecThreePhaseMeterLnACVoltageStateTypeId, meterData.voltageLN); thing->setStateValue(sunspecSinglePhaseMeterCurrentPowerEventTypeId, meterData.totalRealPower);
thing->setStateValue(sunspecThreePhaseMeterTotalRealPowerEventTypeId, meterData.totalRealPower); thing->setStateValue(sunspecSinglePhaseMeterLnACVoltageStateTypeId, meterData.voltageLN);
thing->setStateValue(sunspecThreePhaseMeterEnergyExportedStateTypeId, meterData.totalRealEnergyExported); thing->setStateValue(sunspecSinglePhaseMeterTotalEnergyProducedStateTypeId, meterData.totalRealEnergyExported);
thing->setStateValue(sunspecThreePhaseMeterEnergyImportedStateTypeId, meterData.totalRealEnergyImported); thing->setStateValue(sunspecSinglePhaseMeterTotalEnergyConsumedStateTypeId, meterData.totalRealEnergyImported);
thing->setStateValue(m_frequencyStateTypeIds.value(thing->thingClassId()), meterData.frequency); } else if (thing->thingClassId() == sunspecSplitPhaseMeterThingClassId) {
thing->setStateValue(sunspecSplitPhaseMeterPhaseACurrentStateTypeId, meterData.phaseACurrent);
thing->setStateValue(sunspecSplitPhaseMeterPhaseBCurrentStateTypeId, meterData.phaseBCurrent);
thing->setStateValue(sunspecSplitPhaseMeterCurrentPowerEventTypeId, meterData.totalRealPower);
thing->setStateValue(sunspecSplitPhaseMeterLnACVoltageStateTypeId, meterData.voltageLN);
thing->setStateValue(sunspecSplitPhaseMeterTotalEnergyProducedStateTypeId, meterData.totalRealEnergyExported);
thing->setStateValue(sunspecSplitPhaseMeterTotalEnergyConsumedStateTypeId, meterData.totalRealEnergyImported);
} else if (thing->thingClassId() == sunspecThreePhaseMeterThingClassId) {
thing->setStateValue(sunspecThreePhaseMeterPhaseACurrentStateTypeId, meterData.phaseACurrent);
thing->setStateValue(sunspecThreePhaseMeterPhaseBCurrentStateTypeId, meterData.phaseBCurrent);
thing->setStateValue(sunspecThreePhaseMeterPhaseCCurrentStateTypeId, meterData.phaseCCurrent);
thing->setStateValue(sunspecThreePhaseMeterLnACVoltageStateTypeId, meterData.voltageLN);
thing->setStateValue(sunspecThreePhaseMeterCurrentPowerEventTypeId, meterData.totalRealPower);
thing->setStateValue(sunspecThreePhaseMeterTotalEnergyProducedStateTypeId, meterData.totalRealEnergyExported);
thing->setStateValue(sunspecThreePhaseMeterTotalEnergyConsumedStateTypeId, meterData.totalRealEnergyImported);
}
} }

View File

@ -63,10 +63,13 @@ private:
QHash<ThingClassId, StateTypeId> m_connectedStateTypeIds; QHash<ThingClassId, StateTypeId> m_connectedStateTypeIds;
QHash<ThingClassId, StateTypeId> m_frequencyStateTypeIds; QHash<ThingClassId, StateTypeId> m_frequencyStateTypeIds;
QHash<ThingClassId, StateTypeId> m_acPowerStateTypeIds;
QHash<ThingClassId, StateTypeId> m_acEnergyStateTypeIds; QHash<ThingClassId, StateTypeId> m_inverterCurrentPowerStateTypeIds;
QHash<ThingClassId, StateTypeId> m_inverterTotalEnergyProducedStateTypeIds;
QHash<ThingClassId, StateTypeId> m_inverterOperatingStateTypeIds; QHash<ThingClassId, StateTypeId> m_inverterOperatingStateTypeIds;
QHash<ThingClassId, StateTypeId> m_inverterErrorStateTypeIds; QHash<ThingClassId, StateTypeId> m_inverterErrorStateTypeIds;
QHash<ThingClassId, StateTypeId> m_inverterCabinetTemperatureStateTypeIds;
QHash<ThingClassId, StateTypeId> m_inverterAcCurrentStateTypeIds;
PluginTimer *m_refreshTimer = nullptr; PluginTimer *m_refreshTimer = nullptr;
QHash<QUuid, ThingActionInfo *> m_asyncActions; QHash<QUuid, ThingActionInfo *> m_asyncActions;

View File

@ -40,7 +40,7 @@
"displayName": "SunSpec connection", "displayName": "SunSpec connection",
"id": "f51853f3-8815-4cf3-b337-45cda1f3e6d5", "id": "f51853f3-8815-4cf3-b337-45cda1f3e6d5",
"createMethods": [ "User" ], "createMethods": [ "User" ],
"interfaces": ["connectable"], "interfaces": ["gateway"],
"paramTypes": [ "paramTypes": [
{ {
"id": "6be6abc4-e2b2-4687-9343-0e5164ed0ab2", "id": "6be6abc4-e2b2-4687-9343-0e5164ed0ab2",
@ -105,7 +105,7 @@
"displayName": "SunSpec single phase inverter", "displayName": "SunSpec single phase inverter",
"id": "c5d5204e-3375-4b92-8128-fab77a671fed", "id": "c5d5204e-3375-4b92-8128-fab77a671fed",
"createMethods": [ "Auto" ], "createMethods": [ "Auto" ],
"interfaces": ["connectable"], "interfaces": ["extendedsmartmeterproducer", "connectable"],
"paramTypes": [ "paramTypes": [
{ {
"id": "41715d00-a947-4f43-a475-cea05790e01d", "id": "41715d00-a947-4f43-a475-cea05790e01d",
@ -153,11 +153,11 @@
}, },
{ {
"id": "f49591d6-d759-4be3-bafc-b6a7a72cf023", "id": "f49591d6-d759-4be3-bafc-b6a7a72cf023",
"name": "acPower", "name": "currentPower",
"displayName": "AC power", "displayName": "AC power",
"displayNameEvent": "AC power changed", "displayNameEvent": "AC power changed",
"type": "double", "type": "double",
"unit": "KiloWatt", "unit": "Watt",
"defaultValue": 0.00 "defaultValue": 0.00
}, },
{ {
@ -171,7 +171,7 @@
}, },
{ {
"id": "4c0407b3-5cd5-438d-bfa8-9a8d6695b458", "id": "4c0407b3-5cd5-438d-bfa8-9a8d6695b458",
"name": "acEnergy", "name": "totalEnergyProduced",
"displayName": "AC energy", "displayName": "AC energy",
"displayNameEvent": "AC energy changed", "displayNameEvent": "AC energy changed",
"type": "double", "type": "double",
@ -239,7 +239,7 @@
"displayName": "SunSpec split phase inverter", "displayName": "SunSpec split phase inverter",
"id": "61b38f93-d331-42bf-b1ef-d3fb16ad1230", "id": "61b38f93-d331-42bf-b1ef-d3fb16ad1230",
"createMethods": [ "Auto" ], "createMethods": [ "Auto" ],
"interfaces": ["connectable"], "interfaces": ["extendedsmartmeterproducer", "connectable"],
"paramTypes": [ "paramTypes": [
{ {
"id": "c42fb50e-210f-4b53-88eb-fa216e15f88f", "id": "c42fb50e-210f-4b53-88eb-fa216e15f88f",
@ -314,11 +314,11 @@
}, },
{ {
"id": "9235eb4b-906c-4557-8e18-bca268a367cc", "id": "9235eb4b-906c-4557-8e18-bca268a367cc",
"name": "acPower", "name": "currentPower",
"displayName": "AC power", "displayName": "AC power",
"displayNameEvent": "AC power changed", "displayNameEvent": "AC power changed",
"type": "double", "type": "double",
"unit": "KiloWatt", "unit": "Watt",
"defaultValue": 0.00 "defaultValue": 0.00
}, },
{ {
@ -332,7 +332,7 @@
}, },
{ {
"id": "fe3f8a65-121a-4ae1-b22a-ae325dc3e7e6", "id": "fe3f8a65-121a-4ae1-b22a-ae325dc3e7e6",
"name": "acEnergy", "name": "totalEnergyProduced",
"displayName": "AC energy", "displayName": "AC energy",
"displayNameEvent": "AC energy changed", "displayNameEvent": "AC energy changed",
"type": "double", "type": "double",
@ -400,7 +400,7 @@
"displayName": "SunSpec three phase inverter", "displayName": "SunSpec three phase inverter",
"id": "2e4122ea-96a5-415c-b5e2-7d6012265a83", "id": "2e4122ea-96a5-415c-b5e2-7d6012265a83",
"createMethods": [ "Auto" ], "createMethods": [ "Auto" ],
"interfaces": ["connectable"], "interfaces": ["extendedsmartmeterproducer", "connectable"],
"paramTypes": [ "paramTypes": [
{ {
"id": "8d5b2b58-ce46-406d-844e-f53136afcf09", "id": "8d5b2b58-ce46-406d-844e-f53136afcf09",
@ -493,11 +493,11 @@
}, },
{ {
"id": "14036f44-25fd-4e93-8e8c-c677b06a2c34", "id": "14036f44-25fd-4e93-8e8c-c677b06a2c34",
"name": "acPower", "name": "currentPower",
"displayName": "AC power", "displayName": "AC power",
"displayNameEvent": "AC power changed", "displayNameEvent": "AC power changed",
"type": "double", "type": "double",
"unit": "KiloWatt", "unit": "Watt",
"defaultValue": 0.00 "defaultValue": 0.00
}, },
{ {
@ -511,7 +511,7 @@
}, },
{ {
"id": "d493880d-eb58-4530-8010-8ea4f6d63387", "id": "d493880d-eb58-4530-8010-8ea4f6d63387",
"name": "acEnergy", "name": "totalEnergyProduced",
"displayName": "AC energy", "displayName": "AC energy",
"displayNameEvent": "AC energy changed", "displayNameEvent": "AC energy changed",
"type": "double", "type": "double",
@ -579,7 +579,7 @@
"displayName": "SunSpec single phase meter", "displayName": "SunSpec single phase meter",
"id": "7ffa43b8-b56f-4435-8509-980e9d81dfa8", "id": "7ffa43b8-b56f-4435-8509-980e9d81dfa8",
"createMethods": [ "Auto" ], "createMethods": [ "Auto" ],
"interfaces": ["connectable"], "interfaces": ["extendedsmartmeterconsumer", "connectable"],
"paramTypes": [ "paramTypes": [
{ {
"id": "7d6fcafb-c62e-4a21-aae2-f4041c487149", "id": "7d6fcafb-c62e-4a21-aae2-f4041c487149",
@ -646,16 +646,16 @@
}, },
{ {
"id": "93cf8c6a-2620-42ed-9070-e0726d7b1dbc", "id": "93cf8c6a-2620-42ed-9070-e0726d7b1dbc",
"name": "totalRealPower", "name": "currentPower",
"displayName": "Total real power", "displayName": "Total real power",
"displayNameEvent": "Total real power changed", "displayNameEvent": "Total real power changed",
"type": "double", "type": "double",
"unit": "KiloWatt", "unit": "Watt",
"defaultValue": 0.00 "defaultValue": 0.00
}, },
{ {
"id": "ba275bdf-f418-4ef0-afbe-ac425c6f6783", "id": "ba275bdf-f418-4ef0-afbe-ac425c6f6783",
"name": "energyExported", "name": "totalEnergyProduced",
"displayName": "Total real energy exported", "displayName": "Total real energy exported",
"displayNameEvent": "Total real energy exported changed", "displayNameEvent": "Total real energy exported changed",
"type": "double", "type": "double",
@ -664,7 +664,7 @@
}, },
{ {
"id": "c51dc6cb-5c05-4078-b11a-26afb2f85541", "id": "c51dc6cb-5c05-4078-b11a-26afb2f85541",
"name": "energyImported", "name": "totalEnergyConsumed",
"displayName": "Total real energy imported", "displayName": "Total real energy imported",
"displayNameEvent": "Total real energy imported changed", "displayNameEvent": "Total real energy imported changed",
"type": "double", "type": "double",
@ -678,7 +678,7 @@
"displayName": "SunSpec split phase meter", "displayName": "SunSpec split phase meter",
"id": "b8a18e45-5ff5-4f43-915f-04ee216c809d", "id": "b8a18e45-5ff5-4f43-915f-04ee216c809d",
"createMethods": [ "Auto" ], "createMethods": [ "Auto" ],
"interfaces": ["connectable"], "interfaces": ["extendedsmartmeterconsumer", "connectable"],
"paramTypes": [ "paramTypes": [
{ {
"id": "89aeec6d-abeb-48b5-9594-214ad5db2d03", "id": "89aeec6d-abeb-48b5-9594-214ad5db2d03",
@ -772,16 +772,16 @@
}, },
{ {
"id": "ef4bc0f8-f516-49b7-aba8-d5f987485aca", "id": "ef4bc0f8-f516-49b7-aba8-d5f987485aca",
"name": "totalRealPower", "name": "currentPower",
"displayName": "Total real power", "displayName": "Total real power",
"displayNameEvent": "Total real power changed", "displayNameEvent": "Total real power changed",
"type": "double", "type": "double",
"unit": "KiloWatt", "unit": "Watt",
"defaultValue": 0.00 "defaultValue": 0.00
}, },
{ {
"id": "8a63bd73-0546-4636-8da2-23238cc06fb2", "id": "8a63bd73-0546-4636-8da2-23238cc06fb2",
"name": "energyExported", "name": "totalEnergyProduced",
"displayName": "Total real energy exported", "displayName": "Total real energy exported",
"displayNameEvent": "Total real energy exported changed", "displayNameEvent": "Total real energy exported changed",
"type": "double", "type": "double",
@ -790,7 +790,7 @@
}, },
{ {
"id": "51ffb2ae-3920-40df-8290-bbf5b6e1a68f", "id": "51ffb2ae-3920-40df-8290-bbf5b6e1a68f",
"name": "energyImported", "name": "totalEnergyConsumed",
"displayName": "Total real energy imported", "displayName": "Total real energy imported",
"displayNameEvent": "Total real energy imported changed", "displayNameEvent": "Total real energy imported changed",
"type": "double", "type": "double",
@ -804,7 +804,7 @@
"displayName": "SunSpec three phase meter", "displayName": "SunSpec three phase meter",
"id": "68f822f9-ff30-4275-b229-39a3674fead7", "id": "68f822f9-ff30-4275-b229-39a3674fead7",
"createMethods": [ "Auto" ], "createMethods": [ "Auto" ],
"interfaces": ["connectable"], "interfaces": ["extendedsmartmeterconsumer", "connectable"],
"paramTypes": [ "paramTypes": [
{ {
"id": "a1960821-155c-4176-86fa-974429039182", "id": "a1960821-155c-4176-86fa-974429039182",
@ -916,16 +916,16 @@
}, },
{ {
"id": "c28c642f-46da-44de-ba0d-c4cbfadbf2cd", "id": "c28c642f-46da-44de-ba0d-c4cbfadbf2cd",
"name": "totalRealPower", "name": "currentPower",
"displayName": "Total real power", "displayName": "Total real power",
"displayNameEvent": "Total real power changed", "displayNameEvent": "Total real power changed",
"type": "double", "type": "double",
"unit": "KiloWatt", "unit": "Watt",
"defaultValue": 0.00 "defaultValue": 0.00
}, },
{ {
"id": "73ebf57f-1ad2-4d19-bfd9-9e0a514c1243", "id": "73ebf57f-1ad2-4d19-bfd9-9e0a514c1243",
"name": "energyExported", "name": "totalEnergyProduced",
"displayName": "Total real energy exported", "displayName": "Total real energy exported",
"displayNameEvent": "Total real energy exported changed", "displayNameEvent": "Total real energy exported changed",
"type": "double", "type": "double",
@ -934,7 +934,7 @@
}, },
{ {
"id": "63fa4721-1b0a-458c-b66c-17c161107f0d", "id": "63fa4721-1b0a-458c-b66c-17c161107f0d",
"name": "energyImported", "name": "totalEnergyConsumed",
"displayName": "Total real energy imported", "displayName": "Total real energy imported",
"displayNameEvent": "Total real energy imported changed", "displayNameEvent": "Total real energy imported changed",
"type": "double", "type": "double",

View File

@ -363,10 +363,9 @@ float SunSpec::convertValueWithSSF(quint32 rawValue, quint16 sunssf)
float SunSpec::convertFloatValues(quint16 rawValue0, quint16 rawValue1) float SunSpec::convertFloatValues(quint16 rawValue0, quint16 rawValue1)
{ {
float value; suns_modbus_v32_t value;
uint32_t i = qFromLittleEndian(((uint32_t)rawValue0 << 16) + rawValue1); value.u = (static_cast<uint32_t>(rawValue0) << 16) + rawValue1;
memcpy(&value, &i, sizeof(float)); return value.f;
return value;
} }
void SunSpec::onModbusStateChanged(QModbusDevice::State state) void SunSpec::onModbusStateChanged(QModbusDevice::State state)

View File

@ -42,6 +42,12 @@ class SunSpec : public QObject
public: public:
typedef union {
int32_t s;
uint32_t u;
float f;
} suns_modbus_v32_t;
enum MandatoryRegistersModel1 { enum MandatoryRegistersModel1 {
Manufacturer = 2, Manufacturer = 2,
Model = 18, Model = 18,

View File

@ -76,23 +76,24 @@ void SunSpecInverter::getInverterModelDataBlock()
SunSpecInverter::SunSpecEvent1 SunSpecInverter::bitfieldToSunSpecEvent1(quint16 register1, quint16 register2) SunSpecInverter::SunSpecEvent1 SunSpecInverter::bitfieldToSunSpecEvent1(quint16 register1, quint16 register2)
{ {
SunSpecEvent1 event1; SunSpecEvent1 event1;
Q_UNUSED(register2); quint32 value = (static_cast<quint32>(register1)<<16 | register2);
event1.groundFault = ((register1 & (0x01 << 0)) != 0); //qCDebug(dcSunSpec()) << "Event1" << QString::number(value, 16);
event1.dcOverVoltage = ((register1 & (0x01 << 1)) != 0); event1.groundFault = ((value & (0x01 << 0)) != 0);
event1.acDisconnect = ((register1 & (0x01 << 2)) != 0); event1.dcOverVoltage = ((value & (0x01 << 1)) != 0);
event1.dcDicconnect = ((register1 & (0x01 << 3)) != 0); event1.acDisconnect = ((value & (0x01 << 2)) != 0);
event1.gridDisconnect = ((register1 & (0x01 << 4)) != 0); event1.dcDicconnect = ((value & (0x01 << 3)) != 0);
event1.cabinetOpen = ((register1 & (0x01 << 5)) != 0); event1.gridDisconnect = ((value & (0x01 << 4)) != 0);
event1.manualShutdown = ((register1 & (0x01 << 6)) != 0); event1.cabinetOpen = ((value & (0x01 << 5)) != 0);
event1.overTemperature = ((register1 & (0x01 << 7)) != 0); event1.manualShutdown = ((value & (0x01 << 6)) != 0);
event1.overFrequency = ((register1 & (0x01 << 8)) != 0); event1.overTemperature = ((value & (0x01 << 7)) != 0);
event1.underFrequency = ((register1 & (0x01 << 9)) != 0); event1.overFrequency = ((value & (0x01 << 8)) != 0);
event1.acOverVolt = ((register1 & (0x01 << 10)) != 0); event1.underFrequency = ((value & (0x01 << 9)) != 0);
event1.acUnderVolt = ((register1 & (0x01 << 11)) != 0); event1.acOverVolt = ((value & (0x01 << 10)) != 0);
event1.blownStringFuse = ((register1 & (0x01 << 12)) != 0); event1.acUnderVolt = ((value & (0x01 << 11)) != 0);
event1.underTemperature = ((register1 & (0x01 << 13)) != 0); event1.blownStringFuse = ((value & (0x01 << 12)) != 0);
event1.memoryLoss = ((register1 & (0x01 << 14)) != 0); event1.underTemperature = ((value & (0x01 << 13)) != 0);
event1.hwTestFailure = ((register1 & (0x01 << 15)) != 0); event1.memoryLoss = ((value & (0x01 << 14)) != 0);
event1.hwTestFailure = ((value & (0x01 << 15)) != 0);
return event1; return event1;
} }