further implementeion of sunspec features

This commit is contained in:
Boernsman 2020-12-01 16:44:26 +01:00
parent 5a2be02340
commit 6a56838c8f
14 changed files with 264 additions and 163 deletions

View File

@ -40,7 +40,32 @@ IntegrationPluginSunSpec::IntegrationPluginSunSpec()
void IntegrationPluginSunSpec::setupThing(ThingSetupInfo *info)
{
if (info->thing()->thingClassId() == sunspecInverterThingClassId) {
if (info->thing()->thingClassId() == sunspecConnectionThingClassId) {
QHostAddress address = QHostAddress(info->thing()->paramValue(sunspecConnectionThingIpAddressParamTypeId).toString());
SunSpec *sunSpec = new SunSpec(address, 502, this);
m_sunSpecConnections.insert(info->thing(), sunSpec);
if (!sunSpec->connectModbus()) {
QTimer::singleShot(2000, info, [this, info] {
setupThing(info);
});
qCWarning(dcSunSpec()) << "Error connecting to SunSpec device";
return;
}
connect(sunSpec, &SunSpec::connectionStateChanged, info, [info] (bool status) {
qCDebug(dcSunSpec()) << "Modbus Inverter init finished" << status;
if (status) {
info->finish(Thing::ThingErrorNoError);
} else {
info->finish(Thing::ThingErrorHardwareFailure);
}
});
connect(info, &ThingSetupInfo::aborted, sunSpec, [info, this] {
m_sunSpecConnections.take(info->thing())->deleteLater();
});
//connect(sunSpec, &SunSpecInverter::inverterDataReceived, this, &IntegrationPluginSunSpec::onInverterDataReceived);
} else if (info->thing()->thingClassId() == sunspecInverterThingClassId) {
QHostAddress address = QHostAddress(info->thing()->paramValue(sunspecInverterThingIpAddressParamTypeId).toString());
SunSpecInverter *sunSpecInverter = new SunSpecInverter(address, 502, this);
m_sunSpecInverters.insert(info->thing(), sunSpecInverter);
@ -229,14 +254,14 @@ void IntegrationPluginSunSpec::executeAction(ThingActionInfo *info)
connect(info, &ThingActionInfo::aborted, this, [requestId, this] {m_asyncActions.remove(requestId);});
}
} else if (action.actionTypeId() == sunspecStorageEnableChargingLimitActionTypeId) {
int value = (action.param(sunspecStorageEnableChargingLimitActionEnableChargingLimitParamTypeId).value().toBool() << 1) | thing->stateValue(sunspecStorageEnableDischargingLimitStateTypeId).toBool();
/*int value = (action.param(sunspecStorageEnableChargingLimitActionEnableChargingLimitParamTypeId).value().toBool() << 1) | thing->stateValue(sunspecStorageEnableDischargingLimitStateTypeId).toBool();
QUuid requestId = sunSpecStorage->setStorageControlMode(value);
if (requestId.isNull()) {
info->finish(Thing::ThingErrorHardwareFailure);
} else {
m_asyncActions.insert(requestId, info);
connect(info, &ThingActionInfo::aborted, this, [requestId, this] {m_asyncActions.remove(requestId);});
}
}*/
} else if (action.actionTypeId() == sunspecStorageChargingRateActionTypeId) {
QUuid requestId = sunSpecStorage->setChargingRate(action.param(sunspecStorageChargingRateActionChargingRateParamTypeId).value().toInt());
if (requestId.isNull()) {
@ -246,14 +271,14 @@ void IntegrationPluginSunSpec::executeAction(ThingActionInfo *info)
connect(info, &ThingActionInfo::aborted, this, [requestId, this] {m_asyncActions.remove(requestId);});
}
} else if (action.actionTypeId() == sunspecStorageEnableDischargingLimitActionTypeId) {
int value = (action.param(sunspecStorageEnableDischargingLimitActionEnableDischargingLimitParamTypeId).value().toBool() << 1) | thing->stateValue(sunspecStorageEnableChargingLimitStateTypeId).toBool();
/*int value = (action.param(sunspecStorageEnableDischargingLimitActionEnableDischargingLimitParamTypeId).value().toBool() << 1) | thing->stateValue(sunspecStorageEnableChargingLimitStateTypeId).toBool();
QUuid requestId = sunSpecStorage->setStorageControlMode(value);
if (requestId.isNull()) {
info->finish(Thing::ThingErrorHardwareFailure);
} else {
m_asyncActions.insert(requestId, info);
connect(info, &ThingActionInfo::aborted, this, [requestId, this] {m_asyncActions.remove(requestId);});
}
}*/
} else if (action.actionTypeId() == sunspecStorageDischargingRateActionTypeId) {
QUuid requestId = sunSpecStorage->setDischargingRate(action.param(sunspecStorageDischargingRateActionDischargingRateParamTypeId).value().toInt());
if (requestId.isNull()) {
@ -299,6 +324,23 @@ void IntegrationPluginSunSpec::onPluginConfigurationChanged(const ParamTypeId &p
}
}
void IntegrationPluginSunSpec::onConnectionStateChanged(bool status)
{
Q_UNUSED(status)
}
void IntegrationPluginSunSpec::onWriteRequestExecuted(QUuid requestId, bool success)
{
Q_UNUSED(requestId)
Q_UNUSED(success)
}
void IntegrationPluginSunSpec::onWriteRequestError(QUuid requestId, const QString &error)
{
Q_UNUSED(requestId)
Q_UNUSED(error)
}
void IntegrationPluginSunSpec::onInverterDataReceived(const SunSpecInverter::InverterData &inverterData)
{
SunSpecInverter *inverter = static_cast<SunSpecInverter *>(sender());
@ -413,6 +455,7 @@ void IntegrationPluginSunSpec::onStorageDataReceived(const SunSpecStorage::Stora
void IntegrationPluginSunSpec::onMeterDataReceived(const SunSpecMeter::MeterData &meterData)
{
Q_UNUSED(meterData)
SunSpecMeter *meter = static_cast<SunSpecMeter *>(sender());
Thing *thing = m_sunSpecMeters.key(meter);
@ -424,6 +467,7 @@ void IntegrationPluginSunSpec::onMeterDataReceived(const SunSpecMeter::MeterData
void IntegrationPluginSunSpec::onTrackerDataReceived(const SunSpecTracker::TrackerData &trackerData)
{
Q_UNUSED(trackerData)
SunSpecTracker *tracker = static_cast<SunSpecTracker *>(sender());
Thing *thing = m_sunSpecTrackers.key(tracker);

View File

@ -60,12 +60,12 @@ public:
private:
PluginTimer *m_refreshTimer = nullptr;
QHash<QUuid, ThingActionInfo *> m_asyncActions;
QHash<Thing *, SunSpec *> m_sunSpecConnections;
QHash<Thing *, SunSpecInverter *> m_sunSpecInverters;
QHash<Thing *, SunSpecStorage *> m_sunSpecStorages;
QHash<Thing *, SunSpecMeter *> m_sunSpecMeters;
QHash<Thing *, SunSpecTracker *> m_sunSpecTrackers;
void update(Thing *thing);
private slots:
void onRefreshTimer();

View File

@ -1,7 +1,7 @@
{
"name": "SunSpec",
"displayName": "sunspec",
"id": "73c7efcc-80d5-4166-ad97-2cbbeb129d91",
"id": "cb4bdec6-cf2c-4a0f-9709-42d951ca2d8b",
"paramTypes":[
{
"id": "52da5222-9a94-47a2-9adc-004541d2f5ed",
@ -18,11 +18,61 @@
"displayName": "SunSpec",
"id": "c143a7b4-a16c-4fff-86a3-9ffab3d6841d",
"thingClasses": [
{
"name": "sunspecConnection",
"displayName": "SunSpec Device",
"id": "f51853f3-8815-4cf3-b337-45cda1f3e6d5",
"createMethods": [ "User" ],
"interfaces": ["connectable"],
"paramTypes": [
{
"id": "6be6abc4-e2b2-4687-9343-0e5164ed0ab2",
"name":"ipAddress",
"displayName": "IP address",
"type": "QString"
},
{
"id": "04970315-ed3a-45ce-98fc-35ae3c4eb27b",
"name":"manufacturer",
"displayName": "Manufacturer",
"type": "QString",
"readOnly": true,
"defaultValue": "Unkown"
},
{
"id": "58146c26-17d3-458e-a13f-d7f306c20c44",
"name":"deviceModel",
"displayName": "Device model",
"type": "QString",
"readOnly": true,
"defaultValue": "Unkown"
},
{
"id": "6ed498e1-37ca-4bb7-bac7-463509c7784e",
"name":"serialNumber",
"displayName": "Serial number",
"type": "QString",
"readOnly": true,
"defaultValue": "Unkown"
}
],
"stateTypes":[
{
"id": "3e767ad0-b4b3-4398-94c1-00579ea09ca8",
"name": "connected",
"displayName": "Connected",
"displayNameEvent": "Connected changed",
"type": "bool",
"defaultValue": false,
"cached": false
}
]
},
{
"name": "sunspecInverter",
"displayName": "SunSpec Inverter",
"id": "2e4122ea-96a5-415c-b5e2-7d6012265a83",
"createMethods": [ "User" ],
"createMethods": [ "Auto" ],
"interfaces": ["connectable"],
"paramTypes": [
{
@ -226,7 +276,7 @@
"name": "sunspecMeter",
"displayName": "SunSpec Meter",
"id": "68f822f9-ff30-4275-b229-39a3674fead7",
"createMethods": [ "User" ],
"createMethods": [ "Auto" ],
"interfaces": ["connectable"],
"paramTypes": [
{
@ -385,7 +435,7 @@
"name": "sunspecTracker",
"displayName": "SunSpec Tracker",
"id": "9941da30-a6d6-475d-8244-3c2145b419e6",
"createMethods": [ "User" ],
"createMethods": [ "Auto" ],
"interfaces": ["connectable"],
"paramTypes": [
{
@ -445,7 +495,7 @@
"name": "sunspecStorage",
"displayName": "SunSpec Storage",
"id": "9a643ba8-346c-4127-a2f8-956a7133d75e",
"createMethods": [ "User" ],
"createMethods": [ "Auto" ],
"interfaces": ["connectable"],
"paramTypes": [
{
@ -587,7 +637,7 @@
"name": "sunspecStringCombiner",
"displayName": "SunSpec String Combiner",
"id": "7787f238-f5a3-4ba5-b3ec-7d513b87bf71",
"createMethods": [ "User" ],
"createMethods": [ "Auto" ],
"interfaces": ["connectable"],
"paramTypes": [
{

View File

@ -48,7 +48,6 @@ SunSpec::SunSpec(const QHostAddress &hostAddress, uint port, QObject *parent) :
SunSpec::~SunSpec()
{
}
bool SunSpec::connectModbus()
@ -56,6 +55,21 @@ bool SunSpec::connectModbus()
return m_modbusTcpClient->connectDevice();;
}
QString SunSpec::manufacturer()
{
return m_manufacturer;
}
QString SunSpec::deviceModel()
{
return m_deviceModel;
}
QString SunSpec::serialNumber()
{
return m_serialNumber;
}
void SunSpec::findBaseRegister()
{
qCDebug(dcSunSpec()) << "find base register";
@ -109,7 +123,7 @@ void SunSpec::findModbusMap(const QList<BlockId> &ids, uint modbusAddressOffset)
uint modbusAddress = unit.startAddress();
BlockId blockId = BlockId(unit.value(0));
int blockLength = unit.value(1);
if (blockId > 800 || blockId == BlockId::End) {
if (blockId > 800 || blockId == BlockIdEnd) {
qCDebug(dcSunSpec()) << "Block id not found, Id:" << ids;
modbusMapSearchFinished(ids, 0, "Ids not found");
return;

View File

@ -88,84 +88,84 @@ public:
Q_ENUM(SunSpecEvent1)
enum BlockId {
Common = 1,
BasicAggregator = 2,
SecureDatasetReadRequest = 3,
SecureDatasetReadResponse = 4,
SecureWriteRequest = 5,
SecureWriteSequentialRequest = 6,
SecureWriteResponseModel = 7,
GetDeviceSecurityCertificate = 8,
SetOperatorSecurityCertificate = 9,
CommunicationInterfaceHeader = 10,
EthernetLinkLayer = 11,
IPv4 = 12,
IPv6 = 13,
ProxyServer = 14,
InterfaceCountersModel = 15,
SimpleIpNetwork = 16,
SerialInterface = 17,
CellularLink = 18,
PPPLink = 19,
InverterSinglePhase = 101,
InverterSplitPhase = 102,
InverterThreePhase = 103,
InverterSinglePhaseFloat = 111,
InverterSplitPhaseFloat = 112,
InverterThreePhaseFloat = 113,
Nameplate = 120,
BasicSettings = 121,
MeasurementsStatus = 122,
ImmediateControls = 123,
Storage = 124,
Pricing = 125,
StaticVoltVAR = 126,
FreqWattParam = 127,
DynamicReactiveCurrent = 128,
LVRTD = 129,
HVRTD = 130,
WattPF = 131,
VoltWatt = 132,
BasicScheduling = 133,
FreqWattCrv = 134,
LFRT = 135,
HFRT = 136,
LVRTC = 137,
HVRTC = 138,
MultipleMPPTInverterExtensionModel = 160,
SinglePhaseMeter = 201,
SplitSinglePhaseMeter = 202,
WyeConnectThreePhaseMeter = 203,
DeltaConnectThreePhaseMeter = 204,
SinglePhaseMeterFloat = 211,
SplitSinglePhaseMeterFloat = 212,
WyeConnectThreePhaseMeterFloat = 213,
DeltaConnectThreePhaseMeterFloat = 214,
SecureACMeterSelectedReadings = 220,
IrradianceModel = 302,
BackOfModuleTemperatureModel = 303,
InclinometerModel = 304,
GPS = 305,
ReferencePointModel = 306,
BaseMet = 307,
MiniMetModel = 308,
StringCombiner = 401,
StringCombinerAdvanced = 402,
StringCombinerCurrent = 403,
StringCombinerCurrentAdvanced = 404,
SolarModuleFloat = 501,
SolarModule = 502,
TrackerController = 601,
EnergyStorageBaseModel = 801,
BatteryBaseModel = 802,
LithiumIonBatteryModel = 803,
VerisStatusConfiguration = 64001,
MersenGreenString = 64020,
EltekInverterExtension = 64101,
OutBackAXSDevice = 64110,
BasicChargeController = 64111,
OutBackFMChargeController = 64112,
End = 65535
BlockIdCommon = 1,
BlockIdBasicAggregator = 2,
BlockIdSecureDatasetReadRequest = 3,
BlockIdSecureDatasetReadResponse = 4,
BlockIdSecureWriteRequest = 5,
BlockIdSecureWriteSequentialRequest = 6,
BlockIdSecureWriteResponseModel = 7,
BlockIdGetDeviceSecurityCertificate = 8,
BlockIdSetOperatorSecurityCertificate = 9,
BlockIdCommunicationInterfaceHeader = 10,
BlockIdEthernetLinkLayer = 11,
BlockIdIPv4 = 12,
BlockIdIPv6 = 13,
BlockIdProxyServer = 14,
BlockIdInterfaceCountersModel = 15,
BlockIdSimpleIpNetwork = 16,
BlockIdSerialInterface = 17,
BlockIdCellularLink = 18,
BlockIdPPPLink = 19,
BlockIdInverterSinglePhase = 101,
BlockIdInverterSplitPhase = 102,
BlockIdInverterThreePhase = 103,
BlockIdInverterSinglePhaseFloat = 111,
BlockIdInverterSplitPhaseFloat = 112,
BlockIdInverterThreePhaseFloat = 113,
BlockIdNameplate = 120,
BlockIdBasicSettings = 121,
BlockIdMeasurementsStatus = 122,
BlockIdImmediateControls = 123,
BlockIdStorage = 124,
BlockIdPricing = 125,
BlockIdStaticVoltVAR = 126,
BlockIdFreqWattParam = 127,
BlockIdDynamicReactiveCurrent = 128,
BlockIdLVRTD = 129,
BlockIdHVRTD = 130,
BlockIdWattPF = 131,
BlockIdVoltWatt = 132,
BlockIdBasicScheduling = 133,
BlockIdFreqWattCrv = 134,
BlockIdLFRT = 135,
BlockIdHFRT = 136,
BlockIdLVRTC = 137,
BlockIdHVRTC = 138,
BlockIdMultipleMPPTInverterExtensionModel = 160,
BlockIdSinglePhaseMeter = 201,
BlockIdSplitSinglePhaseMeter = 202,
BlockIdWyeConnectThreePhaseMeter = 203,
BlockIdDeltaConnectThreePhaseMeter = 204,
BlockIdSinglePhaseMeterFloat = 211,
BlockIdSplitSinglePhaseMeterFloat = 212,
BlockIdWyeConnectThreePhaseMeterFloat = 213,
BlockIdDeltaConnectThreePhaseMeterFloat = 214,
BlockIdSecureACMeterSelectedReadings = 220,
BlockIdIrradianceModel = 302,
BlockIdBackOfModuleTemperatureModel = 303,
BlockIdInclinometerModel = 304,
BlockIdGPS = 305,
BlockIdReferencePointModel = 306,
BlockIdBaseMet = 307,
BlockIdMiniMetModel = 308,
BlockIdStringCombiner = 401,
BlockIdStringCombinerAdvanced = 402,
BlockIdStringCombinerCurrent = 403,
BlockIdStringCombinerCurrentAdvanced = 404,
BlockIdSolarModuleFloat = 501,
BlockIdSolarModule = 502,
BlockIdTrackerController = 601,
BlockIdEnergyStorageBaseModel = 801,
BlockIdBatteryBaseModel = 802,
BlockIdLithiumIonBatteryModel = 803,
BlockIdVerisStatusConfiguration = 64001,
BlockIdMersenGreenString = 64020,
BlockIdEltekInverterExtension = 64101,
BlockIdOutBackAXSDevice = 64110,
BlockIdBasicChargeController = 64111,
BlockIdOutBackFMChargeController = 64112,
BlockIdEnd = 65535
};
Q_ENUM(BlockId)
@ -182,9 +182,9 @@ public:
int m_slaveId = 1;
int m_baseRegister = 40000;
bool m_floatingPointRepresentation = false;
QString m_manufacturer = "unkown";
QString m_deviceModel = "unknown";
QString m_serialNumber = "unknown";
QString m_manufacturer = "Unknown";
QString m_deviceModel = "Unknown";
QString m_serialNumber = "Unknown";
void findBaseRegister();
void findModbusMap(const QList<BlockId> &mapIds, uint modbusAddressOffset = 69);
@ -214,9 +214,6 @@ signals:
private slots:
void onModbusStateChanged(QModbusDevice::State state);
void onRequestExecuted(QUuid requestId, bool success);
void onRequestError(QUuid requestId, const QString &error);
void onReceivedHoldingRegister(quint32 slaveAddress, quint32 modbusRegister, const QVector<quint16> &values);
};

View File

@ -37,12 +37,12 @@ SunSpecInverter::SunSpecInverter(const QHostAddress &hostAddress, uint port, QOb
if (state == QModbusDevice::ConnectedState) {
qCDebug(dcSunSpec()) << "Inverter connected successfully";
QList<BlockId> mapIds;
mapIds.append(BlockId::InverterSinglePhase);
mapIds.append(BlockId::InverterSplitPhase);
mapIds.append(BlockId::InverterThreePhase);
mapIds.append(BlockId::InverterSinglePhaseFloat);
mapIds.append(BlockId::InverterSplitPhaseFloat);
mapIds.append(BlockId::InverterThreePhaseFloat);
mapIds.append(BlockIdInverterSinglePhase);
mapIds.append(BlockIdInverterSplitPhase);
mapIds.append(BlockIdInverterThreePhase);
mapIds.append(BlockIdInverterSinglePhaseFloat);
mapIds.append(BlockIdInverterSplitPhaseFloat);
mapIds.append(BlockIdInverterThreePhaseFloat);
findModbusMap(mapIds);
}
});
@ -75,9 +75,9 @@ void SunSpecInverter::onModbusMapReceived(SunSpec::BlockId mapId, uint mapLength
{
Q_UNUSED(mapLength)
switch (mapId) {
case BlockId::InverterSinglePhase:
case BlockId::InverterSplitPhase:
case BlockId::InverterThreePhase: {
case BlockIdInverterSinglePhase:
case BlockIdInverterSplitPhase:
case BlockIdInverterThreePhase: {
InverterData inverterData;
inverterData.acCurrent= convertValueWithSSF(data[Model10X::Model10XAcCurrent], data[Model10X::Model10XAmpereScaleFactor]);
inverterData.acPower = convertValueWithSSF(data[Model10X::Model10XACPower], data[Model10X::Model10XWattScaleFactor]);
@ -99,9 +99,9 @@ void SunSpecInverter::onModbusMapReceived(SunSpec::BlockId mapId, uint mapLength
emit inverterDataReceived(inverterData);
} break;
case BlockId::InverterSinglePhaseFloat:
case BlockId::InverterSplitPhaseFloat:
case BlockId::InverterThreePhaseFloat: {
case BlockIdInverterSinglePhaseFloat:
case BlockIdInverterSplitPhaseFloat:
case BlockIdInverterThreePhaseFloat: {
InverterData inverterData;
inverterData.acCurrent = convertFloatValues(data[Model11X::Model11XAcCurrent], data[Model11X::Model11XAcCurrent+1]);

View File

@ -100,14 +100,13 @@ public:
void getInverterMap();
private:
BlockId m_id = BlockId::InverterThreePhase; //e.g. 103 for three phase inverter, 113 for three phase inverter with floating point representation
BlockId m_id = BlockIdInverterThreePhase; //e.g. 103 for three phase inverter, 113 for three phase inverter with floating point representation
uint m_mapLength = 0;
uint m_mapModbusStartRegister = 40000;
void readInverterBlockHeader();
private slots:
void onConnectionStateChanged();
void onModbusMapReceived(BlockId mapId, uint mapLength, QVector<quint16> data);
signals:

View File

@ -37,14 +37,14 @@ SunSpecMeter::SunSpecMeter(const QHostAddress &hostAddress, uint port, QObject *
if (state == QModbusDevice::ConnectedState) {
qCDebug(dcSunSpec()) << "Meter connected successfully";
QList<BlockId> mapIds;
mapIds.append(BlockId::SinglePhaseMeter);
mapIds.append(BlockId::SplitSinglePhaseMeter);
mapIds.append(BlockId::WyeConnectThreePhaseMeter);
mapIds.append(BlockId::DeltaConnectThreePhaseMeter);
mapIds.append(BlockId::SinglePhaseMeterFloat);
mapIds.append(BlockId::SplitSinglePhaseMeterFloat);
mapIds.append(BlockId::WyeConnectThreePhaseMeterFloat);
mapIds.append(BlockId::DeltaConnectThreePhaseMeterFloat);
mapIds.append(BlockIdSinglePhaseMeter);
mapIds.append(BlockIdSplitSinglePhaseMeter);
mapIds.append(BlockIdWyeConnectThreePhaseMeter);
mapIds.append(BlockIdDeltaConnectThreePhaseMeter);
mapIds.append(BlockIdSinglePhaseMeterFloat);
mapIds.append(BlockIdSplitSinglePhaseMeterFloat);
mapIds.append(BlockIdWyeConnectThreePhaseMeterFloat);
mapIds.append(BlockIdDeltaConnectThreePhaseMeterFloat);
findModbusMap(mapIds);
}
});

View File

@ -73,15 +73,14 @@ public:
void geMeterMap();
private:
BlockId m_id = BlockId::DeltaConnectThreePhaseMeter;
BlockId m_id = BlockIdDeltaConnectThreePhaseMeter;
uint m_mapLength = 0;
uint m_mapModbusStartRegister = 40000;
void readMeterBlockHeader();
private slots:
void onConnectionStateChanged();
void onModbusMapReceived(BlockId mapId, uint mapLength, QVector<quint16> data);
// void onModbusMapReceived(BlockId mapId, uint mapLength, QVector<quint16> data);
signals:
void initFinished();

View File

@ -37,7 +37,7 @@ SunSpecStorage::SunSpecStorage(const QHostAddress &hostAddress, uint port, QObje
if (state == QModbusDevice::ConnectedState) {
qCDebug(dcSunSpec()) << "Inverter connected successfully";
QList<BlockId> mapIds;
mapIds.append(BlockId::Storage);
mapIds.append(BlockIdStorage);
findModbusMap(mapIds);
}
});
@ -112,7 +112,7 @@ void SunSpecStorage::onModbusMapReceived(SunSpec::BlockId mapId, uint mapLength,
{
Q_UNUSED(mapLength)
switch (mapId) {
case BlockId::Storage: {
case BlockIdStorage: {
StorageData storageData;
storageData.chargingState = ChargingState(data[Model124::Model124ChargeStatus]);
emit storageDataReceived(storageData);

View File

@ -91,14 +91,13 @@ public:
void getStorageMap();
private:
BlockId m_id = BlockId::EnergyStorageBaseModel;
BlockId m_id = BlockIdEnergyStorageBaseModel;
uint m_mapLength = 0;
uint m_mapModbusStartRegister = 40000;
void readStorageBlockHeader();
private slots:
void onConnectionStateChanged();
void onModbusMapReceived(BlockId mapId, uint mapLength, const QVector<quint16> &data);
signals:

View File

@ -37,10 +37,10 @@ SunSpecStringCombiner::SunSpecStringCombiner(const QHostAddress &hostAddress, ui
if (state == QModbusDevice::ConnectedState) {
qCDebug(dcSunSpec()) << "String combiner connected successfully";
QList<BlockId> mapIds;
mapIds.append(BlockId::StringCombiner);
mapIds.append(BlockId::StringCombinerCurrent);
mapIds.append(BlockId::StringCombinerAdvanced);
mapIds.append(BlockId::StringCombinerCurrentAdvanced);
mapIds.append(BlockIdStringCombiner);
mapIds.append(BlockIdStringCombinerCurrent);
mapIds.append(BlockIdStringCombinerAdvanced);
mapIds.append(BlockIdStringCombinerCurrentAdvanced);
findModbusMap(mapIds);
}
});
@ -71,15 +71,16 @@ void SunSpecStringCombiner::readStringCombinerMapHeader()
void SunSpecStringCombiner::onModbusMapReceived(SunSpec::BlockId mapId, uint mapLength, QVector<quint16> data)
{
Q_UNUSED(data);
switch (mapId) {
case BlockId::StringCombiner: {
case BlockIdStringCombiner: {
int rbCount = (mapLength-14)/8;
qCDebug(dcSunSpec()) << "Map" << mapId << "Repeating Block Count" << rbCount;
} break;
case BlockId::StringCombinerCurrent:
case BlockId::StringCombinerAdvanced:
case BlockId::StringCombinerCurrentAdvanced: {
case BlockIdStringCombinerCurrent:
case BlockIdStringCombinerAdvanced:
case BlockIdStringCombinerCurrentAdvanced: {
//StringCombinerData stringCombinerData;
//stringCombinerData.acCurrent= convertValueWithSSF(data[Model10X::Model10XAcCurrent], data[Model10X::Model10XAmpereScaleFactor]);
} break;

View File

@ -42,32 +42,32 @@ public:
//Map401 length: 14 + (RB Count * 8)
//Map403 length: 16 + (RB Count * 8)
enum Map401 {
CurrentScaleFactor = 0,
AmpHourScaleFactor = 1,
VoltageScaleFactor = 2,
MaximumDCCurrentRating = 3,
NumberOfInputs = 4,
Events = 5,
VendorDefniedEvents = 7,
TotalMeasuredCurrent = 9,
TotalMeteredAmpHours = 10,
OutputVoltage = 12,
InternalOperatingTemperature = 13
Map401CurrentScaleFactor = 0,
Map401AmpHourScaleFactor = 1,
Map401VoltageScaleFactor = 2,
Map401MaximumDCCurrentRating = 3,
Map401NumberOfInputs = 4,
Map401Events = 5,
Map401VendorDefniedEvents = 7,
Map401TotalMeasuredCurrent = 9,
Map401TotalMeteredAmpHours = 10,
Map401OutputVoltage = 12,
Map401InternalOperatingTemperature = 13
};
enum Map402 {
CurrentScaleFactor,
AmpHourScaleFactor,
VoltageScaleFactor
PowerScale factor
EnergyScale factor
Maximum DC Current Rating
Number of Inputs
Bitmask value. Events
Bitmask value. Vendor defnied events
Total measured current
Total metered Amp-hours
OutputVoltage
Map402CurrentScaleFactor,
Map402AmpHourScaleFactor,
Map402VoltageScaleFactor,
Map402PowerScaleFactor,
Map402EnergyScaleFactor,
Map402MaximumDCCurrentRating,
Map402NumberOfInputs,
Map402BitmaskValueEvents,
Map402BitmaskvalueVendorDefniedEvents,
Map402TotalMeasuredCurrent,
Map402TotalMeteredAmpHours,
Map402OutputVoltage
};
enum Map401RB { //Repeating block
@ -111,14 +111,13 @@ public:
void getStringCombinerMap();
private:
BlockId m_id = BlockId::StringCombiner;
BlockId m_id = BlockIdStringCombiner;
uint m_mapLength = 0;
uint m_mapModbusStartRegister = 40000;
void readStringCombinerMapHeader();
private slots:
void onConnectionStateChanged();
void onModbusMapReceived(BlockId mapId, uint mapLength, QVector<quint16> data);
signals:

View File

@ -60,15 +60,14 @@ public:
void getTrackerMap();
private:
BlockId m_id = BlockId::TrackerController;
BlockId m_id = BlockIdTrackerController;
uint m_mapLength = 0;
uint m_mapModbusStartRegister = 40000;
void readTrackerBlockHeader();
private slots:
void onConnectionStateChanged();
void onModbusMapReceived(BlockId mapId, uint mapLength, QVector<quint16> data);
//void onModbusMapReceived(BlockId mapId, uint mapLength, QVector<quint16> data);
signals:
void initFinished();