Update schrack modbus registers and test calculations
parent
c5ebc4e5bb
commit
67402e339b
|
|
@ -25,12 +25,54 @@
|
|||
"type": "uint16",
|
||||
"registerType": "holdingRegister",
|
||||
"readSchedule": "update",
|
||||
"description": "Maximum charging current",
|
||||
"unit": "A",
|
||||
"defaultValue": 32,
|
||||
"access": "R"
|
||||
},
|
||||
{
|
||||
"id": "maxChargingCurrentCableE3",
|
||||
"address": 128,
|
||||
"size": 1,
|
||||
"type": "uint16",
|
||||
"registerType": "holdingRegister",
|
||||
"readSchedule": "update",
|
||||
"description": "Maximum charging current of connected cable",
|
||||
"unit": "A",
|
||||
"defaultValue": 32,
|
||||
"access": "R"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "durations",
|
||||
"readSchedule": "update",
|
||||
"registers": [
|
||||
{
|
||||
"id": "chargingDuration",
|
||||
"address": 151,
|
||||
"size": 2,
|
||||
"type": "uint32",
|
||||
"registerType": "holdingRegister",
|
||||
"readSchedule": "update",
|
||||
"description": "Charging duration",
|
||||
"unit": "ms",
|
||||
"defaultValue": 0,
|
||||
"access": "R"
|
||||
},
|
||||
{
|
||||
"id": "pluggedInDuration",
|
||||
"address": 153,
|
||||
"size": 2,
|
||||
"type": "uint32",
|
||||
"registerType": "holdingRegister",
|
||||
"readSchedule": "update",
|
||||
"description": "Plugged in duration",
|
||||
"unit": "ms",
|
||||
"defaultValue": 0,
|
||||
"access": "R"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"registers": [
|
||||
|
|
@ -52,7 +94,7 @@
|
|||
"type": "uint16",
|
||||
"registerType": "holdingRegister",
|
||||
"readSchedule": "update",
|
||||
"description": "Allowed charging current",
|
||||
"description": "Charging current setpoint",
|
||||
"unit": "A",
|
||||
"defaultValue": 6,
|
||||
"access": "RW"
|
||||
|
|
@ -64,34 +106,10 @@
|
|||
"type": "uint16",
|
||||
"registerType": "holdingRegister",
|
||||
"readSchedule": "update",
|
||||
"description": "Maximum charging current",
|
||||
"description": "Status bits",
|
||||
"defaultValue": 0,
|
||||
"access": "R"
|
||||
},
|
||||
{
|
||||
"id": "chargingDuration",
|
||||
"address": 151,
|
||||
"size": 2,
|
||||
"type": "uint32",
|
||||
"registerType": "holdingRegister",
|
||||
"readSchedule": "update",
|
||||
"description": "Charging duration",
|
||||
"unit": "ms",
|
||||
"defaultValue": 6,
|
||||
"access": "R"
|
||||
},
|
||||
{
|
||||
"id": "pluggedInDuration",
|
||||
"address": 153,
|
||||
"size": 2,
|
||||
"type": "uint32",
|
||||
"registerType": "holdingRegister",
|
||||
"readSchedule": "update",
|
||||
"description": "Plugged in duration",
|
||||
"unit": "ms",
|
||||
"defaultValue": 6,
|
||||
"access": "R"
|
||||
},
|
||||
{
|
||||
"id": "u1Voltage",
|
||||
"address": 167,
|
||||
|
|
@ -100,6 +118,7 @@
|
|||
"registerType": "holdingRegister",
|
||||
"readSchedule": "update",
|
||||
"description": "U1 voltage",
|
||||
"staticScaleFactor": -2,
|
||||
"unit": "V",
|
||||
"defaultValue": 32,
|
||||
"access": "R"
|
||||
|
|
@ -112,6 +131,7 @@
|
|||
"registerType": "holdingRegister",
|
||||
"readSchedule": "update",
|
||||
"description": "Voltage of the power supply grid",
|
||||
"staticScaleFactor": -2,
|
||||
"unit": "V",
|
||||
"defaultValue": 0,
|
||||
"access": "R"
|
||||
|
|
@ -125,7 +145,7 @@
|
|||
"readSchedule": "update",
|
||||
"description": "Minimum charging current",
|
||||
"unit": "A",
|
||||
"defaultValue": 6,
|
||||
"defaultValue": 13,
|
||||
"access": "R"
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ quint16 CionModbusRtuConnection::chargingCurrentSetpoint() const
|
|||
ModbusRtuReply *CionModbusRtuConnection::setChargingCurrentSetpoint(quint16 chargingCurrentSetpoint)
|
||||
{
|
||||
QVector<quint16> values = ModbusDataUtils::convertFromUInt16(chargingCurrentSetpoint);
|
||||
qCDebug(dcCionModbusRtuConnection()) << "--> Write \"Allowed charging current\" register:" << 101 << "size:" << 1 << values;
|
||||
qCDebug(dcCionModbusRtuConnection()) << "--> Write \"Charging current setpoint\" register:" << 101 << "size:" << 1 << values;
|
||||
return m_modbusRtuMaster->writeHoldingRegisters(m_slaveId, 101, values);
|
||||
}
|
||||
|
||||
|
|
@ -78,22 +78,12 @@ quint16 CionModbusRtuConnection::statusBits() const
|
|||
return m_statusBits;
|
||||
}
|
||||
|
||||
quint32 CionModbusRtuConnection::chargingDuration() const
|
||||
{
|
||||
return m_chargingDuration;
|
||||
}
|
||||
|
||||
quint32 CionModbusRtuConnection::pluggedInDuration() const
|
||||
{
|
||||
return m_pluggedInDuration;
|
||||
}
|
||||
|
||||
quint16 CionModbusRtuConnection::u1Voltage() const
|
||||
float CionModbusRtuConnection::u1Voltage() const
|
||||
{
|
||||
return m_u1Voltage;
|
||||
}
|
||||
|
||||
quint16 CionModbusRtuConnection::gridVoltage() const
|
||||
float CionModbusRtuConnection::gridVoltage() const
|
||||
{
|
||||
return m_gridVoltage;
|
||||
}
|
||||
|
|
@ -113,6 +103,21 @@ quint16 CionModbusRtuConnection::maxChargingCurrentE3() const
|
|||
return m_maxChargingCurrentE3;
|
||||
}
|
||||
|
||||
quint16 CionModbusRtuConnection::maxChargingCurrentCableE3() const
|
||||
{
|
||||
return m_maxChargingCurrentCableE3;
|
||||
}
|
||||
|
||||
quint32 CionModbusRtuConnection::chargingDuration() const
|
||||
{
|
||||
return m_chargingDuration;
|
||||
}
|
||||
|
||||
quint32 CionModbusRtuConnection::pluggedInDuration() const
|
||||
{
|
||||
return m_pluggedInDuration;
|
||||
}
|
||||
|
||||
void CionModbusRtuConnection::initialize()
|
||||
{
|
||||
// No init registers defined. Nothing to be done and we are finished.
|
||||
|
|
@ -124,12 +129,11 @@ void CionModbusRtuConnection::update()
|
|||
updateChargingEnabled();
|
||||
updateChargingCurrentSetpoint();
|
||||
updateStatusBits();
|
||||
updateChargingDuration();
|
||||
updatePluggedInDuration();
|
||||
updateU1Voltage();
|
||||
updateGridVoltage();
|
||||
updateMinChargingCurrent();
|
||||
updateE3Block();
|
||||
updateDurationsBlock();
|
||||
}
|
||||
|
||||
void CionModbusRtuConnection::updateChargingEnabled()
|
||||
|
|
@ -163,15 +167,15 @@ void CionModbusRtuConnection::updateChargingEnabled()
|
|||
|
||||
void CionModbusRtuConnection::updateChargingCurrentSetpoint()
|
||||
{
|
||||
// Update registers from Allowed charging current
|
||||
qCDebug(dcCionModbusRtuConnection()) << "--> Read \"Allowed charging current\" register:" << 101 << "size:" << 1;
|
||||
// Update registers from Charging current setpoint
|
||||
qCDebug(dcCionModbusRtuConnection()) << "--> Read \"Charging current setpoint\" register:" << 101 << "size:" << 1;
|
||||
ModbusRtuReply *reply = readChargingCurrentSetpoint();
|
||||
if (reply) {
|
||||
if (!reply->isFinished()) {
|
||||
connect(reply, &ModbusRtuReply::finished, this, [this, reply](){
|
||||
if (reply->error() == ModbusRtuReply::NoError) {
|
||||
QVector<quint16> values = reply->result();
|
||||
qCDebug(dcCionModbusRtuConnection()) << "<-- Response from \"Allowed charging current\" register" << 101 << "size:" << 1 << values;
|
||||
qCDebug(dcCionModbusRtuConnection()) << "<-- Response from \"Charging current setpoint\" register" << 101 << "size:" << 1 << values;
|
||||
quint16 receivedChargingCurrentSetpoint = ModbusDataUtils::convertToUInt16(values);
|
||||
if (m_chargingCurrentSetpoint != receivedChargingCurrentSetpoint) {
|
||||
m_chargingCurrentSetpoint = receivedChargingCurrentSetpoint;
|
||||
|
|
@ -181,26 +185,26 @@ void CionModbusRtuConnection::updateChargingCurrentSetpoint()
|
|||
});
|
||||
|
||||
connect(reply, &ModbusRtuReply::errorOccurred, this, [reply] (ModbusRtuReply::Error error){
|
||||
qCWarning(dcCionModbusRtuConnection()) << "ModbusRtu reply error occurred while updating \"Allowed charging current\" registers" << error << reply->errorString();
|
||||
qCWarning(dcCionModbusRtuConnection()) << "ModbusRtu reply error occurred while updating \"Charging current setpoint\" registers" << error << reply->errorString();
|
||||
emit reply->finished();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
qCWarning(dcCionModbusRtuConnection()) << "Error occurred while reading \"Allowed charging current\" registers";
|
||||
qCWarning(dcCionModbusRtuConnection()) << "Error occurred while reading \"Charging current setpoint\" registers";
|
||||
}
|
||||
}
|
||||
|
||||
void CionModbusRtuConnection::updateStatusBits()
|
||||
{
|
||||
// Update registers from Maximum charging current
|
||||
qCDebug(dcCionModbusRtuConnection()) << "--> Read \"Maximum charging current\" register:" << 121 << "size:" << 1;
|
||||
// Update registers from Status bits
|
||||
qCDebug(dcCionModbusRtuConnection()) << "--> Read \"Status bits\" register:" << 121 << "size:" << 1;
|
||||
ModbusRtuReply *reply = readStatusBits();
|
||||
if (reply) {
|
||||
if (!reply->isFinished()) {
|
||||
connect(reply, &ModbusRtuReply::finished, this, [this, reply](){
|
||||
if (reply->error() == ModbusRtuReply::NoError) {
|
||||
QVector<quint16> values = reply->result();
|
||||
qCDebug(dcCionModbusRtuConnection()) << "<-- Response from \"Maximum charging current\" register" << 121 << "size:" << 1 << values;
|
||||
qCDebug(dcCionModbusRtuConnection()) << "<-- Response from \"Status bits\" register" << 121 << "size:" << 1 << values;
|
||||
quint16 receivedStatusBits = ModbusDataUtils::convertToUInt16(values);
|
||||
if (m_statusBits != receivedStatusBits) {
|
||||
m_statusBits = receivedStatusBits;
|
||||
|
|
@ -210,70 +214,12 @@ void CionModbusRtuConnection::updateStatusBits()
|
|||
});
|
||||
|
||||
connect(reply, &ModbusRtuReply::errorOccurred, this, [reply] (ModbusRtuReply::Error error){
|
||||
qCWarning(dcCionModbusRtuConnection()) << "ModbusRtu reply error occurred while updating \"Maximum charging current\" registers" << error << reply->errorString();
|
||||
qCWarning(dcCionModbusRtuConnection()) << "ModbusRtu reply error occurred while updating \"Status bits\" registers" << error << reply->errorString();
|
||||
emit reply->finished();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
qCWarning(dcCionModbusRtuConnection()) << "Error occurred while reading \"Maximum charging current\" registers";
|
||||
}
|
||||
}
|
||||
|
||||
void CionModbusRtuConnection::updateChargingDuration()
|
||||
{
|
||||
// Update registers from Charging duration
|
||||
qCDebug(dcCionModbusRtuConnection()) << "--> Read \"Charging duration\" register:" << 151 << "size:" << 2;
|
||||
ModbusRtuReply *reply = readChargingDuration();
|
||||
if (reply) {
|
||||
if (!reply->isFinished()) {
|
||||
connect(reply, &ModbusRtuReply::finished, this, [this, reply](){
|
||||
if (reply->error() == ModbusRtuReply::NoError) {
|
||||
QVector<quint16> values = reply->result();
|
||||
qCDebug(dcCionModbusRtuConnection()) << "<-- Response from \"Charging duration\" register" << 151 << "size:" << 2 << values;
|
||||
quint32 receivedChargingDuration = ModbusDataUtils::convertToUInt32(values, ModbusDataUtils::ByteOrderBigEndian);
|
||||
if (m_chargingDuration != receivedChargingDuration) {
|
||||
m_chargingDuration = receivedChargingDuration;
|
||||
emit chargingDurationChanged(m_chargingDuration);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
connect(reply, &ModbusRtuReply::errorOccurred, this, [reply] (ModbusRtuReply::Error error){
|
||||
qCWarning(dcCionModbusRtuConnection()) << "ModbusRtu reply error occurred while updating \"Charging duration\" registers" << error << reply->errorString();
|
||||
emit reply->finished();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
qCWarning(dcCionModbusRtuConnection()) << "Error occurred while reading \"Charging duration\" registers";
|
||||
}
|
||||
}
|
||||
|
||||
void CionModbusRtuConnection::updatePluggedInDuration()
|
||||
{
|
||||
// Update registers from Plugged in duration
|
||||
qCDebug(dcCionModbusRtuConnection()) << "--> Read \"Plugged in duration\" register:" << 153 << "size:" << 2;
|
||||
ModbusRtuReply *reply = readPluggedInDuration();
|
||||
if (reply) {
|
||||
if (!reply->isFinished()) {
|
||||
connect(reply, &ModbusRtuReply::finished, this, [this, reply](){
|
||||
if (reply->error() == ModbusRtuReply::NoError) {
|
||||
QVector<quint16> values = reply->result();
|
||||
qCDebug(dcCionModbusRtuConnection()) << "<-- Response from \"Plugged in duration\" register" << 153 << "size:" << 2 << values;
|
||||
quint32 receivedPluggedInDuration = ModbusDataUtils::convertToUInt32(values, ModbusDataUtils::ByteOrderBigEndian);
|
||||
if (m_pluggedInDuration != receivedPluggedInDuration) {
|
||||
m_pluggedInDuration = receivedPluggedInDuration;
|
||||
emit pluggedInDurationChanged(m_pluggedInDuration);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
connect(reply, &ModbusRtuReply::errorOccurred, this, [reply] (ModbusRtuReply::Error error){
|
||||
qCWarning(dcCionModbusRtuConnection()) << "ModbusRtu reply error occurred while updating \"Plugged in duration\" registers" << error << reply->errorString();
|
||||
emit reply->finished();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
qCWarning(dcCionModbusRtuConnection()) << "Error occurred while reading \"Plugged in duration\" registers";
|
||||
qCWarning(dcCionModbusRtuConnection()) << "Error occurred while reading \"Status bits\" registers";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -288,7 +234,7 @@ void CionModbusRtuConnection::updateU1Voltage()
|
|||
if (reply->error() == ModbusRtuReply::NoError) {
|
||||
QVector<quint16> values = reply->result();
|
||||
qCDebug(dcCionModbusRtuConnection()) << "<-- Response from \"U1 voltage\" register" << 167 << "size:" << 1 << values;
|
||||
quint16 receivedU1Voltage = ModbusDataUtils::convertToUInt16(values);
|
||||
float receivedU1Voltage = ModbusDataUtils::convertToUInt16(values) * 1.0 * pow(10, -2);
|
||||
if (m_u1Voltage != receivedU1Voltage) {
|
||||
m_u1Voltage = receivedU1Voltage;
|
||||
emit u1VoltageChanged(m_u1Voltage);
|
||||
|
|
@ -317,7 +263,7 @@ void CionModbusRtuConnection::updateGridVoltage()
|
|||
if (reply->error() == ModbusRtuReply::NoError) {
|
||||
QVector<quint16> values = reply->result();
|
||||
qCDebug(dcCionModbusRtuConnection()) << "<-- Response from \"Voltage of the power supply grid\" register" << 302 << "size:" << 1 << values;
|
||||
quint16 receivedGridVoltage = ModbusDataUtils::convertToUInt16(values);
|
||||
float receivedGridVoltage = ModbusDataUtils::convertToUInt16(values) * 1.0 * pow(10, -2);
|
||||
if (m_gridVoltage != receivedGridVoltage) {
|
||||
m_gridVoltage = receivedGridVoltage;
|
||||
emit gridVoltageChanged(m_gridVoltage);
|
||||
|
|
@ -367,15 +313,15 @@ void CionModbusRtuConnection::updateMinChargingCurrent()
|
|||
void CionModbusRtuConnection::updateE3Block()
|
||||
{
|
||||
// Update register block "e3"
|
||||
qCDebug(dcCionModbusRtuConnection()) << "--> Read block \"e3\" registers from:" << 126 << "size:" << 2;
|
||||
ModbusRtuReply *reply = m_modbusRtuMaster->readHoldingRegister(m_slaveId, 126, 2);
|
||||
qCDebug(dcCionModbusRtuConnection()) << "--> Read block \"e3\" registers from:" << 126 << "size:" << 3;
|
||||
ModbusRtuReply *reply = m_modbusRtuMaster->readHoldingRegister(m_slaveId, 126, 3);
|
||||
if (reply) {
|
||||
if (!reply->isFinished()) {
|
||||
connect(reply, &ModbusRtuReply::finished, this, [this, reply](){
|
||||
if (reply->error() == ModbusRtuReply::NoError) {
|
||||
QVector<quint16> blockValues = reply->result();
|
||||
QVector<quint16> values;
|
||||
qCDebug(dcCionModbusRtuConnection()) << "<-- Response from reading block \"e3\" register" << 126 << "size:" << 2 << blockValues;
|
||||
qCDebug(dcCionModbusRtuConnection()) << "<-- Response from reading block \"e3\" register" << 126 << "size:" << 3 << blockValues;
|
||||
values = blockValues.mid(0, 1);
|
||||
quint16 receivedCurrentChargingCurrentE3 = ModbusDataUtils::convertToUInt16(values);
|
||||
if (m_currentChargingCurrentE3 != receivedCurrentChargingCurrentE3) {
|
||||
|
|
@ -390,6 +336,13 @@ void CionModbusRtuConnection::updateE3Block()
|
|||
emit maxChargingCurrentE3Changed(m_maxChargingCurrentE3);
|
||||
}
|
||||
|
||||
values = blockValues.mid(2, 1);
|
||||
quint16 receivedMaxChargingCurrentCableE3 = ModbusDataUtils::convertToUInt16(values);
|
||||
if (m_maxChargingCurrentCableE3 != receivedMaxChargingCurrentCableE3) {
|
||||
m_maxChargingCurrentCableE3 = receivedMaxChargingCurrentCableE3;
|
||||
emit maxChargingCurrentCableE3Changed(m_maxChargingCurrentCableE3);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -403,6 +356,45 @@ void CionModbusRtuConnection::updateE3Block()
|
|||
}
|
||||
}
|
||||
|
||||
void CionModbusRtuConnection::updateDurationsBlock()
|
||||
{
|
||||
// Update register block "durations"
|
||||
qCDebug(dcCionModbusRtuConnection()) << "--> Read block \"durations\" registers from:" << 151 << "size:" << 4;
|
||||
ModbusRtuReply *reply = m_modbusRtuMaster->readHoldingRegister(m_slaveId, 151, 4);
|
||||
if (reply) {
|
||||
if (!reply->isFinished()) {
|
||||
connect(reply, &ModbusRtuReply::finished, this, [this, reply](){
|
||||
if (reply->error() == ModbusRtuReply::NoError) {
|
||||
QVector<quint16> blockValues = reply->result();
|
||||
QVector<quint16> values;
|
||||
qCDebug(dcCionModbusRtuConnection()) << "<-- Response from reading block \"durations\" register" << 151 << "size:" << 4 << blockValues;
|
||||
values = blockValues.mid(0, 2);
|
||||
quint32 receivedChargingDuration = ModbusDataUtils::convertToUInt32(values, ModbusDataUtils::ByteOrderBigEndian);
|
||||
if (m_chargingDuration != receivedChargingDuration) {
|
||||
m_chargingDuration = receivedChargingDuration;
|
||||
emit chargingDurationChanged(m_chargingDuration);
|
||||
}
|
||||
|
||||
values = blockValues.mid(2, 2);
|
||||
quint32 receivedPluggedInDuration = ModbusDataUtils::convertToUInt32(values, ModbusDataUtils::ByteOrderBigEndian);
|
||||
if (m_pluggedInDuration != receivedPluggedInDuration) {
|
||||
m_pluggedInDuration = receivedPluggedInDuration;
|
||||
emit pluggedInDurationChanged(m_pluggedInDuration);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
connect(reply, &ModbusRtuReply::errorOccurred, this, [reply] (ModbusRtuReply::Error error){
|
||||
qCWarning(dcCionModbusRtuConnection()) << "ModbusRtu reply error occurred while updating block \"durations\" registers" << error << reply->errorString();
|
||||
emit reply->finished();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
qCWarning(dcCionModbusRtuConnection()) << "Error occurred while reading block \"durations\" registers";
|
||||
}
|
||||
}
|
||||
|
||||
ModbusRtuReply *CionModbusRtuConnection::readChargingEnabled()
|
||||
{
|
||||
return m_modbusRtuMaster->readHoldingRegister(m_slaveId, 100, 1);
|
||||
|
|
@ -418,16 +410,6 @@ ModbusRtuReply *CionModbusRtuConnection::readStatusBits()
|
|||
return m_modbusRtuMaster->readHoldingRegister(m_slaveId, 121, 1);
|
||||
}
|
||||
|
||||
ModbusRtuReply *CionModbusRtuConnection::readChargingDuration()
|
||||
{
|
||||
return m_modbusRtuMaster->readHoldingRegister(m_slaveId, 151, 2);
|
||||
}
|
||||
|
||||
ModbusRtuReply *CionModbusRtuConnection::readPluggedInDuration()
|
||||
{
|
||||
return m_modbusRtuMaster->readHoldingRegister(m_slaveId, 153, 2);
|
||||
}
|
||||
|
||||
ModbusRtuReply *CionModbusRtuConnection::readU1Voltage()
|
||||
{
|
||||
return m_modbusRtuMaster->readHoldingRegister(m_slaveId, 167, 1);
|
||||
|
|
@ -455,15 +437,16 @@ QDebug operator<<(QDebug debug, CionModbusRtuConnection *cionModbusRtuConnection
|
|||
{
|
||||
debug.nospace().noquote() << "CionModbusRtuConnection(" << cionModbusRtuConnection->modbusRtuMaster()->modbusUuid().toString() << ", " << cionModbusRtuConnection->modbusRtuMaster()->serialPort() << ", slave ID:" << cionModbusRtuConnection->slaveId() << ")" << "\n";
|
||||
debug.nospace().noquote() << " - Charging enabled:" << cionModbusRtuConnection->chargingEnabled() << "\n";
|
||||
debug.nospace().noquote() << " - Allowed charging current:" << cionModbusRtuConnection->chargingCurrentSetpoint() << " [A]" << "\n";
|
||||
debug.nospace().noquote() << " - Maximum charging current:" << cionModbusRtuConnection->statusBits() << "\n";
|
||||
debug.nospace().noquote() << " - Charging duration:" << cionModbusRtuConnection->chargingDuration() << " [ms]" << "\n";
|
||||
debug.nospace().noquote() << " - Plugged in duration:" << cionModbusRtuConnection->pluggedInDuration() << " [ms]" << "\n";
|
||||
debug.nospace().noquote() << " - Charging current setpoint:" << cionModbusRtuConnection->chargingCurrentSetpoint() << " [A]" << "\n";
|
||||
debug.nospace().noquote() << " - Status bits:" << cionModbusRtuConnection->statusBits() << "\n";
|
||||
debug.nospace().noquote() << " - U1 voltage:" << cionModbusRtuConnection->u1Voltage() << " [V]" << "\n";
|
||||
debug.nospace().noquote() << " - Voltage of the power supply grid:" << cionModbusRtuConnection->gridVoltage() << " [V]" << "\n";
|
||||
debug.nospace().noquote() << " - Minimum charging current:" << cionModbusRtuConnection->minChargingCurrent() << " [A]" << "\n";
|
||||
debug.nospace().noquote() << " - Current charging Ampere:" << cionModbusRtuConnection->currentChargingCurrentE3() << " [A]" << "\n";
|
||||
debug.nospace().noquote() << " - Maximum charging current of connected cable:" << cionModbusRtuConnection->maxChargingCurrentE3() << " [A]" << "\n";
|
||||
debug.nospace().noquote() << " - Maximum charging current:" << cionModbusRtuConnection->maxChargingCurrentE3() << " [A]" << "\n";
|
||||
debug.nospace().noquote() << " - Maximum charging current of connected cable:" << cionModbusRtuConnection->maxChargingCurrentCableE3() << " [A]" << "\n";
|
||||
debug.nospace().noquote() << " - Charging duration:" << cionModbusRtuConnection->chargingDuration() << " [ms]" << "\n";
|
||||
debug.nospace().noquote() << " - Plugged in duration:" << cionModbusRtuConnection->pluggedInDuration() << " [ms]" << "\n";
|
||||
return debug.quote().space();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ public:
|
|||
RegisterStatusBits = 121,
|
||||
RegisterCurrentChargingCurrentE3 = 126,
|
||||
RegisterMaxChargingCurrentE3 = 127,
|
||||
RegisterMaxChargingCurrentCableE3 = 128,
|
||||
RegisterChargingDuration = 151,
|
||||
RegisterPluggedInDuration = 153,
|
||||
RegisterU1Voltage = 167,
|
||||
|
|
@ -64,24 +65,18 @@ public:
|
|||
quint16 chargingEnabled() const;
|
||||
ModbusRtuReply *setChargingEnabled(quint16 chargingEnabled);
|
||||
|
||||
/* Allowed charging current [A] - Address: 101, Size: 1 */
|
||||
/* Charging current setpoint [A] - Address: 101, Size: 1 */
|
||||
quint16 chargingCurrentSetpoint() const;
|
||||
ModbusRtuReply *setChargingCurrentSetpoint(quint16 chargingCurrentSetpoint);
|
||||
|
||||
/* Maximum charging current - Address: 121, Size: 1 */
|
||||
/* Status bits - Address: 121, Size: 1 */
|
||||
quint16 statusBits() const;
|
||||
|
||||
/* Charging duration [ms] - Address: 151, Size: 2 */
|
||||
quint32 chargingDuration() const;
|
||||
|
||||
/* Plugged in duration [ms] - Address: 153, Size: 2 */
|
||||
quint32 pluggedInDuration() const;
|
||||
|
||||
/* U1 voltage [V] - Address: 167, Size: 1 */
|
||||
quint16 u1Voltage() const;
|
||||
float u1Voltage() const;
|
||||
|
||||
/* Voltage of the power supply grid [V] - Address: 302, Size: 1 */
|
||||
quint16 gridVoltage() const;
|
||||
float gridVoltage() const;
|
||||
|
||||
/* Minimum charging current [A] - Address: 507, Size: 1 */
|
||||
quint16 minChargingCurrent() const;
|
||||
|
|
@ -89,20 +84,33 @@ public:
|
|||
/* Current charging Ampere [A] - Address: 126, Size: 1 */
|
||||
quint16 currentChargingCurrentE3() const;
|
||||
|
||||
/* Maximum charging current of connected cable [A] - Address: 127, Size: 1 */
|
||||
/* Maximum charging current [A] - Address: 127, Size: 1 */
|
||||
quint16 maxChargingCurrentE3() const;
|
||||
|
||||
/* Read block from start addess 126 with size of 2 registers containing following 2 properties:
|
||||
/* Maximum charging current of connected cable [A] - Address: 128, Size: 1 */
|
||||
quint16 maxChargingCurrentCableE3() const;
|
||||
|
||||
/* Read block from start addess 126 with size of 3 registers containing following 3 properties:
|
||||
- Current charging Ampere [A] - Address: 126, Size: 1
|
||||
- Maximum charging current of connected cable [A] - Address: 127, Size: 1
|
||||
- Maximum charging current [A] - Address: 127, Size: 1
|
||||
- Maximum charging current of connected cable [A] - Address: 128, Size: 1
|
||||
*/
|
||||
void updateE3Block();
|
||||
/* Charging duration [ms] - Address: 151, Size: 2 */
|
||||
quint32 chargingDuration() const;
|
||||
|
||||
/* Plugged in duration [ms] - Address: 153, Size: 2 */
|
||||
quint32 pluggedInDuration() const;
|
||||
|
||||
/* Read block from start addess 151 with size of 4 registers containing following 2 properties:
|
||||
- Charging duration [ms] - Address: 151, Size: 2
|
||||
- Plugged in duration [ms] - Address: 153, Size: 2
|
||||
*/
|
||||
void updateDurationsBlock();
|
||||
|
||||
void updateChargingEnabled();
|
||||
void updateChargingCurrentSetpoint();
|
||||
void updateStatusBits();
|
||||
void updateChargingDuration();
|
||||
void updatePluggedInDuration();
|
||||
void updateU1Voltage();
|
||||
void updateGridVoltage();
|
||||
void updateMinChargingCurrent();
|
||||
|
|
@ -116,20 +124,19 @@ signals:
|
|||
void chargingEnabledChanged(quint16 chargingEnabled);
|
||||
void chargingCurrentSetpointChanged(quint16 chargingCurrentSetpoint);
|
||||
void statusBitsChanged(quint16 statusBits);
|
||||
void chargingDurationChanged(quint32 chargingDuration);
|
||||
void pluggedInDurationChanged(quint32 pluggedInDuration);
|
||||
void u1VoltageChanged(quint16 u1Voltage);
|
||||
void gridVoltageChanged(quint16 gridVoltage);
|
||||
void u1VoltageChanged(float u1Voltage);
|
||||
void gridVoltageChanged(float gridVoltage);
|
||||
void minChargingCurrentChanged(quint16 minChargingCurrent);
|
||||
void currentChargingCurrentE3Changed(quint16 currentChargingCurrentE3);
|
||||
void maxChargingCurrentE3Changed(quint16 maxChargingCurrentE3);
|
||||
void maxChargingCurrentCableE3Changed(quint16 maxChargingCurrentCableE3);
|
||||
void chargingDurationChanged(quint32 chargingDuration);
|
||||
void pluggedInDurationChanged(quint32 pluggedInDuration);
|
||||
|
||||
protected:
|
||||
ModbusRtuReply *readChargingEnabled();
|
||||
ModbusRtuReply *readChargingCurrentSetpoint();
|
||||
ModbusRtuReply *readStatusBits();
|
||||
ModbusRtuReply *readChargingDuration();
|
||||
ModbusRtuReply *readPluggedInDuration();
|
||||
ModbusRtuReply *readU1Voltage();
|
||||
ModbusRtuReply *readGridVoltage();
|
||||
ModbusRtuReply *readMinChargingCurrent();
|
||||
|
|
@ -137,13 +144,14 @@ protected:
|
|||
quint16 m_chargingEnabled = 0;
|
||||
quint16 m_chargingCurrentSetpoint = 6;
|
||||
quint16 m_statusBits = 0;
|
||||
quint32 m_chargingDuration = 6;
|
||||
quint32 m_pluggedInDuration = 6;
|
||||
quint16 m_u1Voltage = 32;
|
||||
quint16 m_gridVoltage = 0;
|
||||
quint16 m_minChargingCurrent = 6;
|
||||
float m_u1Voltage = 32;
|
||||
float m_gridVoltage = 0;
|
||||
quint16 m_minChargingCurrent = 13;
|
||||
quint16 m_currentChargingCurrentE3 = 6;
|
||||
quint16 m_maxChargingCurrentE3 = 32;
|
||||
quint16 m_maxChargingCurrentCableE3 = 32;
|
||||
quint32 m_chargingDuration = 0;
|
||||
quint32 m_pluggedInDuration = 0;
|
||||
|
||||
private:
|
||||
ModbusRtuMaster *m_modbusRtuMaster = nullptr;
|
||||
|
|
|
|||
|
|
@ -37,24 +37,7 @@ IntegrationPluginSchrack::IntegrationPluginSchrack()
|
|||
|
||||
void IntegrationPluginSchrack::init()
|
||||
{
|
||||
// connect(hardwareManager()->modbusRtuResource(), &ModbusRtuHardwareResource::modbusRtuMasterRemoved, this, [=] (const QUuid &modbusUuid){
|
||||
// qCDebug(dcEnergyMeters()) << "Modbus RTU master has been removed" << modbusUuid.toString();
|
||||
|
||||
// foreach (Thing *thing, myThings()) {
|
||||
// if (m_modbusUuidParamTypeIds.contains(thing->thingClassId())) {
|
||||
// if (thing->paramValue(m_modbusUuidParamTypeIds.value(thing->thingClassId())) == modbusUuid) {
|
||||
// qCWarning(dcEnergyMeters()) << "Modbus RTU hardware resource removed for" << thing << ". The thing will not be functional any more until a new resource has been configured for it.";
|
||||
// thing->setStateValue(m_connectionStateTypeIds[thing->thingClassId()], false);
|
||||
|
||||
// if (thing->thingClassId() == sdm630ThingClassId) {
|
||||
// delete m_sdmConnections.take(thing);
|
||||
// } else if (thing->thingClassId() == pro380ThingClassId) {
|
||||
// delete m_ineproConnections.take(thing);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
void IntegrationPluginSchrack::discoverThings(ThingDiscoveryInfo *info)
|
||||
|
|
@ -118,6 +101,8 @@ void IntegrationPluginSchrack::setupThing(ThingSetupInfo *info)
|
|||
} else {
|
||||
qCWarning(dcSchrack()) << "Modbus RTU resource disconnected" << thing << cionConnection->modbusRtuMaster()->serialPort();
|
||||
}
|
||||
|
||||
thing->setStateValue(cionConnectedStateTypeId, connected);
|
||||
});
|
||||
|
||||
connect(cionConnection, &CionModbusRtuConnection::chargingEnabledChanged, thing, [=](quint16 charging){
|
||||
|
|
@ -141,7 +126,6 @@ void IntegrationPluginSchrack::setupThing(ThingSetupInfo *info)
|
|||
connect(cionConnection, &CionModbusRtuConnection::currentChargingCurrentE3Changed, thing, [=](quint16 currentChargingCurrentE3){
|
||||
qCDebug(dcSchrack()) << "Current charging current E3 current changed:" << currentChargingCurrentE3;
|
||||
thing->setStateValue(cionMaxChargingCurrentStateTypeId, currentChargingCurrentE3);
|
||||
thing->setStateValue(cionConnectedStateTypeId, true);
|
||||
finishAction(cionMaxChargingCurrentStateTypeId);
|
||||
});
|
||||
|
||||
|
|
@ -151,43 +135,38 @@ void IntegrationPluginSchrack::setupThing(ThingSetupInfo *info)
|
|||
qCDebug(dcSchrack()) << "Maximum charging current E3 current changed:" << maxChargingCurrentE3;
|
||||
if (maxChargingCurrentE3 != 0) {
|
||||
thing->setStateMaxValue(cionMaxChargingCurrentStateTypeId, maxChargingCurrentE3);
|
||||
thing->setStateValue(cionConnectedStateTypeId, true);
|
||||
}
|
||||
});
|
||||
|
||||
connect(cionConnection, &CionModbusRtuConnection::statusBitsChanged, thing, [=](quint16 statusBits){
|
||||
qCDebug(dcSchrack()) << "Status bits changed:" << statusBits;
|
||||
thing->setStateValue(cionConnectedStateTypeId, true);
|
||||
});
|
||||
|
||||
connect(cionConnection, &CionModbusRtuConnection::minChargingCurrentChanged, thing, [=](quint16 minChargingCurrent){
|
||||
qCDebug(dcSchrack()) << "Minimum charging current changed:" << minChargingCurrent;
|
||||
thing->setStateMinValue(cionMaxChargingCurrentStateTypeId, minChargingCurrent);
|
||||
thing->setStateValue(cionConnectedStateTypeId, true);
|
||||
});
|
||||
|
||||
connect(cionConnection, &CionModbusRtuConnection::gridVoltageChanged, thing, [=](quint16 gridVoltage){
|
||||
qCDebug(dcSchrack()) << "Grid voltage changed:" << 1.0 * gridVoltage / 100;
|
||||
thing->setStateValue(cionConnectedStateTypeId, true);
|
||||
connect(cionConnection, &CionModbusRtuConnection::gridVoltageChanged, thing, [=](float gridVoltage){
|
||||
qCDebug(dcSchrack()) << "Grid voltage changed:" << gridVoltage;
|
||||
// updateCurrentPower(thing);
|
||||
});
|
||||
connect(cionConnection, &CionModbusRtuConnection::u1VoltageChanged, thing, [=](quint16 gridVoltage){
|
||||
qCDebug(dcSchrack()) << "U1 voltage changed:" << 1.0 * gridVoltage / 100;
|
||||
thing->setStateValue(cionConnectedStateTypeId, true);
|
||||
|
||||
connect(cionConnection, &CionModbusRtuConnection::u1VoltageChanged, thing, [=](float u1Voltage){
|
||||
qCDebug(dcSchrack()) << "U1 voltage changed:" << u1Voltage;
|
||||
updateCurrentPower(thing);
|
||||
});
|
||||
|
||||
connect(cionConnection, &CionModbusRtuConnection::pluggedInDurationChanged, thing, [=](quint32 pluggedInDuration){
|
||||
qCDebug(dcSchrack()) << "Plugged in duration changed:" << pluggedInDuration;
|
||||
thing->setStateValue(cionPluggedInStateTypeId, pluggedInDuration > 0);
|
||||
thing->setStateValue(cionConnectedStateTypeId, true);
|
||||
});
|
||||
|
||||
connect(cionConnection, &CionModbusRtuConnection::chargingDurationChanged, thing, [=](quint32 chargingDuration){
|
||||
qCDebug(dcSchrack()) << "Charging duration changed:" << chargingDuration;
|
||||
thing->setStateValue(cionChargingStateTypeId, chargingDuration > 0);
|
||||
thing->setStateValue(cionConnectedStateTypeId, true);
|
||||
});
|
||||
|
||||
|
||||
cionConnection->update();
|
||||
|
||||
// Initialize min/max to their defaults. If both, nymea and the wallbox are restarted simultaneously, nymea would cache the min/max while
|
||||
|
|
|
|||
Loading…
Reference in New Issue