diff --git a/schrack/cion-registers.json b/schrack/cion-registers.json
index 779762d..a796b9b 100644
--- a/schrack/cion-registers.json
+++ b/schrack/cion-registers.json
@@ -1,4 +1,5 @@
{
+ "className": "Cion",
"protocol": "RTU",
"endianness": "LittleEndian",
"blocks": [
diff --git a/schrack/cionmodbusrtuconnection.cpp b/schrack/cionmodbusrtuconnection.cpp
deleted file mode 100644
index 7bb4349..0000000
--- a/schrack/cionmodbusrtuconnection.cpp
+++ /dev/null
@@ -1,723 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-*
-* Copyright 2013 - 2022, nymea GmbH
-* Contact: contact@nymea.io
-*
-* This fileDescriptor is part of nymea.
-* This project including source code and documentation is protected by
-* copyright law, and remains the property of nymea GmbH. All rights, including
-* reproduction, publication, editing and translation, are reserved. The use of
-* this project is subject to the terms of a license agreement to be concluded
-* with nymea GmbH in accordance with the terms of use of nymea GmbH, available
-* under https://nymea.io/license
-*
-* GNU Lesser General Public License Usage
-* Alternatively, this project may be redistributed and/or modified under the
-* terms of the GNU Lesser General Public License as published by the Free
-* Software Foundation; version 3. This project is distributed in the hope that
-* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
-* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public License
-* along with this project. If not, see .
-*
-* For any further details and any questions please contact us under
-* contact@nymea.io or see our FAQ/Licensing Information on
-* https://nymea.io/license/faq
-*
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-*
-* WARNING
-*
-* This file has been autogenerated. Any changes in this file may be overwritten.
-* If you want to change something, update the register json or the tool.
-*
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-#include "cionmodbusrtuconnection.h"
-#include "loggingcategories.h"
-#include "math.h"
-
-NYMEA_LOGGING_CATEGORY(dcCionModbusRtuConnection, "CionModbusRtuConnection")
-
-CionModbusRtuConnection::CionModbusRtuConnection(ModbusRtuMaster *modbusRtuMaster, quint16 slaveId, QObject *parent) :
- QObject(parent),
- m_modbusRtuMaster(modbusRtuMaster),
- m_slaveId(slaveId)
-{
-
-}
-
-ModbusRtuMaster *CionModbusRtuConnection::modbusRtuMaster() const
-{
- return m_modbusRtuMaster;
-}
-quint16 CionModbusRtuConnection::slaveId() const
-{
- return m_slaveId;
-}
-ModbusDataUtils::ByteOrder CionModbusRtuConnection::endianness() const
-{
- return m_endianness;
-}
-void CionModbusRtuConnection::setEndianness(ModbusDataUtils::ByteOrder endianness)
-{
- if (m_endianness == endianness)
- return;
-
- m_endianness = endianness;
- emit endiannessChanged(m_endianness);
-}
-quint16 CionModbusRtuConnection::chargingEnabled() const
-{
- return m_chargingEnabled;
-}
-
-ModbusRtuReply *CionModbusRtuConnection::setChargingEnabled(quint16 chargingEnabled)
-{
- QVector values = ModbusDataUtils::convertFromUInt16(chargingEnabled);
- qCDebug(dcCionModbusRtuConnection()) << "--> Write \"Charging enabled\" register:" << 100 << "size:" << 1 << values;
- return m_modbusRtuMaster->writeHoldingRegisters(m_slaveId, 100, values);
-}
-
-quint16 CionModbusRtuConnection::chargingCurrentSetpoint() const
-{
- return m_chargingCurrentSetpoint;
-}
-
-ModbusRtuReply *CionModbusRtuConnection::setChargingCurrentSetpoint(quint16 chargingCurrentSetpoint)
-{
- QVector values = ModbusDataUtils::convertFromUInt16(chargingCurrentSetpoint);
- qCDebug(dcCionModbusRtuConnection()) << "--> Write \"Charging current setpoint\" register:" << 101 << "size:" << 1 << values;
- return m_modbusRtuMaster->writeHoldingRegisters(m_slaveId, 101, values);
-}
-
-quint16 CionModbusRtuConnection::statusBits() const
-{
- return m_statusBits;
-}
-
-quint16 CionModbusRtuConnection::cpSignalState() const
-{
- return m_cpSignalState;
-}
-
-float CionModbusRtuConnection::u1Voltage() const
-{
- return m_u1Voltage;
-}
-
-float CionModbusRtuConnection::gridVoltage() const
-{
- return m_gridVoltage;
-}
-
-quint16 CionModbusRtuConnection::minChargingCurrent() const
-{
- return m_minChargingCurrent;
-}
-
-quint16 CionModbusRtuConnection::currentChargingCurrentE3() const
-{
- return m_currentChargingCurrentE3;
-}
-
-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.
- emit initializationFinished();
-}
-
-void CionModbusRtuConnection::update()
-{
- updateChargingEnabled();
- updateChargingCurrentSetpoint();
- updateStatusBits();
- updateCpSignalState();
- updateU1Voltage();
- updateGridVoltage();
- updateMinChargingCurrent();
- updateE3Block();
- updateDurationsBlock();
-}
-
-void CionModbusRtuConnection::updateChargingEnabled()
-{
- // Update registers from Charging enabled
- qCDebug(dcCionModbusRtuConnection()) << "--> Read \"Charging enabled\" register:" << 100 << "size:" << 1;
- ModbusRtuReply *reply = readChargingEnabled();
- if (reply) {
- if (!reply->isFinished()) {
- connect(reply, &ModbusRtuReply::finished, this, [this, reply](){
- if (reply->error() == ModbusRtuReply::NoError) {
- QVector values = reply->result();
- qCDebug(dcCionModbusRtuConnection()) << "<-- Response from \"Charging enabled\" register" << 100 << "size:" << 1 << values;
- processChargingEnabledRegisterValues(values);
- }
- });
-
- connect(reply, &ModbusRtuReply::errorOccurred, this, [reply] (ModbusRtuReply::Error error){
- qCWarning(dcCionModbusRtuConnection()) << "ModbusRtu reply error occurred while updating \"Charging enabled\" registers" << error << reply->errorString();
- emit reply->finished();
- });
- }
- } else {
- qCWarning(dcCionModbusRtuConnection()) << "Error occurred while reading \"Charging enabled\" registers";
- }
-}
-
-void CionModbusRtuConnection::updateChargingCurrentSetpoint()
-{
- // 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 values = reply->result();
- qCDebug(dcCionModbusRtuConnection()) << "<-- Response from \"Charging current setpoint\" register" << 101 << "size:" << 1 << values;
- processChargingCurrentSetpointRegisterValues(values);
- }
- });
-
- connect(reply, &ModbusRtuReply::errorOccurred, this, [reply] (ModbusRtuReply::Error error){
- 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 \"Charging current setpoint\" registers";
- }
-}
-
-void CionModbusRtuConnection::updateStatusBits()
-{
- // Update registers from Mode3-State A, B, C, D, U
- qCDebug(dcCionModbusRtuConnection()) << "--> Read \"Mode3-State A, B, C, D, U\" 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 values = reply->result();
- qCDebug(dcCionModbusRtuConnection()) << "<-- Response from \"Mode3-State A, B, C, D, U\" register" << 121 << "size:" << 1 << values;
- processStatusBitsRegisterValues(values);
- }
- });
-
- connect(reply, &ModbusRtuReply::errorOccurred, this, [reply] (ModbusRtuReply::Error error){
- qCWarning(dcCionModbusRtuConnection()) << "ModbusRtu reply error occurred while updating \"Mode3-State A, B, C, D, U\" registers" << error << reply->errorString();
- emit reply->finished();
- });
- }
- } else {
- qCWarning(dcCionModbusRtuConnection()) << "Error occurred while reading \"Mode3-State A, B, C, D, U\" registers";
- }
-}
-
-void CionModbusRtuConnection::updateCpSignalState()
-{
- // Update registers from Status bits
- qCDebug(dcCionModbusRtuConnection()) << "--> Read \"Status bits\" register:" << 139 << "size:" << 1;
- ModbusRtuReply *reply = readCpSignalState();
- if (reply) {
- if (!reply->isFinished()) {
- connect(reply, &ModbusRtuReply::finished, this, [this, reply](){
- if (reply->error() == ModbusRtuReply::NoError) {
- QVector values = reply->result();
- qCDebug(dcCionModbusRtuConnection()) << "<-- Response from \"Status bits\" register" << 139 << "size:" << 1 << values;
- processCpSignalStateRegisterValues(values);
- }
- });
-
- connect(reply, &ModbusRtuReply::errorOccurred, this, [reply] (ModbusRtuReply::Error error){
- qCWarning(dcCionModbusRtuConnection()) << "ModbusRtu reply error occurred while updating \"Status bits\" registers" << error << reply->errorString();
- emit reply->finished();
- });
- }
- } else {
- qCWarning(dcCionModbusRtuConnection()) << "Error occurred while reading \"Status bits\" registers";
- }
-}
-
-void CionModbusRtuConnection::updateU1Voltage()
-{
- // Update registers from U1 voltage
- qCDebug(dcCionModbusRtuConnection()) << "--> Read \"U1 voltage\" register:" << 167 << "size:" << 1;
- ModbusRtuReply *reply = readU1Voltage();
- if (reply) {
- if (!reply->isFinished()) {
- connect(reply, &ModbusRtuReply::finished, this, [this, reply](){
- if (reply->error() == ModbusRtuReply::NoError) {
- QVector values = reply->result();
- qCDebug(dcCionModbusRtuConnection()) << "<-- Response from \"U1 voltage\" register" << 167 << "size:" << 1 << values;
- processU1VoltageRegisterValues(values);
- }
- });
-
- connect(reply, &ModbusRtuReply::errorOccurred, this, [reply] (ModbusRtuReply::Error error){
- qCWarning(dcCionModbusRtuConnection()) << "ModbusRtu reply error occurred while updating \"U1 voltage\" registers" << error << reply->errorString();
- emit reply->finished();
- });
- }
- } else {
- qCWarning(dcCionModbusRtuConnection()) << "Error occurred while reading \"U1 voltage\" registers";
- }
-}
-
-void CionModbusRtuConnection::updateGridVoltage()
-{
- // Update registers from Voltage of the power supply grid
- qCDebug(dcCionModbusRtuConnection()) << "--> Read \"Voltage of the power supply grid\" register:" << 302 << "size:" << 1;
- ModbusRtuReply *reply = readGridVoltage();
- if (reply) {
- if (!reply->isFinished()) {
- connect(reply, &ModbusRtuReply::finished, this, [this, reply](){
- if (reply->error() == ModbusRtuReply::NoError) {
- QVector values = reply->result();
- qCDebug(dcCionModbusRtuConnection()) << "<-- Response from \"Voltage of the power supply grid\" register" << 302 << "size:" << 1 << values;
- processGridVoltageRegisterValues(values);
- }
- });
-
- connect(reply, &ModbusRtuReply::errorOccurred, this, [reply] (ModbusRtuReply::Error error){
- qCWarning(dcCionModbusRtuConnection()) << "ModbusRtu reply error occurred while updating \"Voltage of the power supply grid\" registers" << error << reply->errorString();
- emit reply->finished();
- });
- }
- } else {
- qCWarning(dcCionModbusRtuConnection()) << "Error occurred while reading \"Voltage of the power supply grid\" registers";
- }
-}
-
-void CionModbusRtuConnection::updateMinChargingCurrent()
-{
- // Update registers from Minimum charging current
- qCDebug(dcCionModbusRtuConnection()) << "--> Read \"Minimum charging current\" register:" << 507 << "size:" << 1;
- ModbusRtuReply *reply = readMinChargingCurrent();
- if (reply) {
- if (!reply->isFinished()) {
- connect(reply, &ModbusRtuReply::finished, this, [this, reply](){
- if (reply->error() == ModbusRtuReply::NoError) {
- QVector values = reply->result();
- qCDebug(dcCionModbusRtuConnection()) << "<-- Response from \"Minimum charging current\" register" << 507 << "size:" << 1 << values;
- processMinChargingCurrentRegisterValues(values);
- }
- });
-
- connect(reply, &ModbusRtuReply::errorOccurred, this, [reply] (ModbusRtuReply::Error error){
- qCWarning(dcCionModbusRtuConnection()) << "ModbusRtu reply error occurred while updating \"Minimum charging current\" registers" << error << reply->errorString();
- emit reply->finished();
- });
- }
- } else {
- qCWarning(dcCionModbusRtuConnection()) << "Error occurred while reading \"Minimum charging current\" registers";
- }
-}
-
-void CionModbusRtuConnection::updateCurrentChargingCurrentE3()
-{
- // Update registers from Current charging Ampere
- qCDebug(dcCionModbusRtuConnection()) << "--> Read \"Current charging Ampere\" register:" << 126 << "size:" << 1;
- ModbusRtuReply *reply = readCurrentChargingCurrentE3();
- if (reply) {
- if (!reply->isFinished()) {
- connect(reply, &ModbusRtuReply::finished, this, [this, reply](){
- if (reply->error() == ModbusRtuReply::NoError) {
- QVector values = reply->result();
- qCDebug(dcCionModbusRtuConnection()) << "<-- Response from \"Current charging Ampere\" register" << 126 << "size:" << 1 << values;
- processCurrentChargingCurrentE3RegisterValues(values);
- }
- });
-
- connect(reply, &ModbusRtuReply::errorOccurred, this, [reply] (ModbusRtuReply::Error error){
- qCWarning(dcCionModbusRtuConnection()) << "ModbusRtu reply error occurred while updating \"Current charging Ampere\" registers" << error << reply->errorString();
- emit reply->finished();
- });
- }
- } else {
- qCWarning(dcCionModbusRtuConnection()) << "Error occurred while reading \"Current charging Ampere\" registers";
- }
-}
-
-void CionModbusRtuConnection::updateMaxChargingCurrentE3()
-{
- // Update registers from Maximum charging current
- qCDebug(dcCionModbusRtuConnection()) << "--> Read \"Maximum charging current\" register:" << 127 << "size:" << 1;
- ModbusRtuReply *reply = readMaxChargingCurrentE3();
- if (reply) {
- if (!reply->isFinished()) {
- connect(reply, &ModbusRtuReply::finished, this, [this, reply](){
- if (reply->error() == ModbusRtuReply::NoError) {
- QVector values = reply->result();
- qCDebug(dcCionModbusRtuConnection()) << "<-- Response from \"Maximum charging current\" register" << 127 << "size:" << 1 << values;
- processMaxChargingCurrentE3RegisterValues(values);
- }
- });
-
- connect(reply, &ModbusRtuReply::errorOccurred, this, [reply] (ModbusRtuReply::Error error){
- qCWarning(dcCionModbusRtuConnection()) << "ModbusRtu reply error occurred while updating \"Maximum charging current\" registers" << error << reply->errorString();
- emit reply->finished();
- });
- }
- } else {
- qCWarning(dcCionModbusRtuConnection()) << "Error occurred while reading \"Maximum charging current\" registers";
- }
-}
-
-void CionModbusRtuConnection::updateMaxChargingCurrentCableE3()
-{
- // Update registers from Maximum charging current of connected cable
- qCDebug(dcCionModbusRtuConnection()) << "--> Read \"Maximum charging current of connected cable\" register:" << 128 << "size:" << 1;
- ModbusRtuReply *reply = readMaxChargingCurrentCableE3();
- if (reply) {
- if (!reply->isFinished()) {
- connect(reply, &ModbusRtuReply::finished, this, [this, reply](){
- if (reply->error() == ModbusRtuReply::NoError) {
- QVector values = reply->result();
- qCDebug(dcCionModbusRtuConnection()) << "<-- Response from \"Maximum charging current of connected cable\" register" << 128 << "size:" << 1 << values;
- processMaxChargingCurrentCableE3RegisterValues(values);
- }
- });
-
- connect(reply, &ModbusRtuReply::errorOccurred, this, [reply] (ModbusRtuReply::Error error){
- qCWarning(dcCionModbusRtuConnection()) << "ModbusRtu reply error occurred while updating \"Maximum charging current of connected cable\" registers" << error << reply->errorString();
- emit reply->finished();
- });
- }
- } else {
- qCWarning(dcCionModbusRtuConnection()) << "Error occurred while reading \"Maximum charging current of connected cable\" 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 values = reply->result();
- qCDebug(dcCionModbusRtuConnection()) << "<-- Response from \"Charging duration\" register" << 151 << "size:" << 2 << values;
- processChargingDurationRegisterValues(values);
- }
- });
-
- 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 values = reply->result();
- qCDebug(dcCionModbusRtuConnection()) << "<-- Response from \"Plugged in duration\" register" << 153 << "size:" << 2 << values;
- processPluggedInDurationRegisterValues(values);
- }
- });
-
- 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";
- }
-}
-
-void CionModbusRtuConnection::updateE3Block()
-{
- // Update register block "e3"
- 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 blockValues = reply->result();
- qCDebug(dcCionModbusRtuConnection()) << "<-- Response from reading block \"e3\" register" << 126 << "size:" << 3 << blockValues;
- processCurrentChargingCurrentE3RegisterValues(blockValues.mid(0, 1));
- processMaxChargingCurrentE3RegisterValues(blockValues.mid(1, 1));
- processMaxChargingCurrentCableE3RegisterValues(blockValues.mid(2, 1));
- }
- });
-
- connect(reply, &ModbusRtuReply::errorOccurred, this, [reply] (ModbusRtuReply::Error error){
- qCWarning(dcCionModbusRtuConnection()) << "ModbusRtu reply error occurred while updating block \"e3\" registers" << error << reply->errorString();
- emit reply->finished();
- });
- }
- } else {
- qCWarning(dcCionModbusRtuConnection()) << "Error occurred while reading block \"e3\" registers";
- }
-}
-
-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 blockValues = reply->result();
- qCDebug(dcCionModbusRtuConnection()) << "<-- Response from reading block \"durations\" register" << 151 << "size:" << 4 << blockValues;
- processChargingDurationRegisterValues(blockValues.mid(0, 2));
- processPluggedInDurationRegisterValues(blockValues.mid(2, 2));
- }
- });
-
- 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);
-}
-
-ModbusRtuReply *CionModbusRtuConnection::readChargingCurrentSetpoint()
-{
- return m_modbusRtuMaster->readHoldingRegister(m_slaveId, 101, 1);
-}
-
-ModbusRtuReply *CionModbusRtuConnection::readStatusBits()
-{
- return m_modbusRtuMaster->readHoldingRegister(m_slaveId, 121, 1);
-}
-
-ModbusRtuReply *CionModbusRtuConnection::readCpSignalState()
-{
- return m_modbusRtuMaster->readHoldingRegister(m_slaveId, 139, 1);
-}
-
-ModbusRtuReply *CionModbusRtuConnection::readU1Voltage()
-{
- return m_modbusRtuMaster->readHoldingRegister(m_slaveId, 167, 1);
-}
-
-ModbusRtuReply *CionModbusRtuConnection::readGridVoltage()
-{
- return m_modbusRtuMaster->readHoldingRegister(m_slaveId, 302, 1);
-}
-
-ModbusRtuReply *CionModbusRtuConnection::readMinChargingCurrent()
-{
- return m_modbusRtuMaster->readHoldingRegister(m_slaveId, 507, 1);
-}
-
-ModbusRtuReply *CionModbusRtuConnection::readCurrentChargingCurrentE3()
-{
- return m_modbusRtuMaster->readHoldingRegister(m_slaveId, 126, 1);
-}
-
-ModbusRtuReply *CionModbusRtuConnection::readMaxChargingCurrentE3()
-{
- return m_modbusRtuMaster->readHoldingRegister(m_slaveId, 127, 1);
-}
-
-ModbusRtuReply *CionModbusRtuConnection::readMaxChargingCurrentCableE3()
-{
- return m_modbusRtuMaster->readHoldingRegister(m_slaveId, 128, 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::readBlockE3()
-{
- return m_modbusRtuMaster->readHoldingRegister(m_slaveId, 126, 3);
-}
-
-ModbusRtuReply *CionModbusRtuConnection::readBlockDurations()
-{
- return m_modbusRtuMaster->readHoldingRegister(m_slaveId, 151, 4);
-}
-
-void CionModbusRtuConnection::processChargingEnabledRegisterValues(const QVector values)
-{
- quint16 receivedChargingEnabled = ModbusDataUtils::convertToUInt16(values);
- if (m_chargingEnabled != receivedChargingEnabled) {
- m_chargingEnabled = receivedChargingEnabled;
- emit chargingEnabledChanged(m_chargingEnabled);
- }
-}
-
-void CionModbusRtuConnection::processChargingCurrentSetpointRegisterValues(const QVector values)
-{
- quint16 receivedChargingCurrentSetpoint = ModbusDataUtils::convertToUInt16(values);
- if (m_chargingCurrentSetpoint != receivedChargingCurrentSetpoint) {
- m_chargingCurrentSetpoint = receivedChargingCurrentSetpoint;
- emit chargingCurrentSetpointChanged(m_chargingCurrentSetpoint);
- }
-}
-
-void CionModbusRtuConnection::processStatusBitsRegisterValues(const QVector values)
-{
- quint16 receivedStatusBits = ModbusDataUtils::convertToUInt16(values);
- if (m_statusBits != receivedStatusBits) {
- m_statusBits = receivedStatusBits;
- emit statusBitsChanged(m_statusBits);
- }
-}
-
-void CionModbusRtuConnection::processCpSignalStateRegisterValues(const QVector values)
-{
- quint16 receivedCpSignalState = ModbusDataUtils::convertToUInt16(values);
- if (m_cpSignalState != receivedCpSignalState) {
- m_cpSignalState = receivedCpSignalState;
- emit cpSignalStateChanged(m_cpSignalState);
- }
-}
-
-void CionModbusRtuConnection::processU1VoltageRegisterValues(const QVector values)
-{
- float receivedU1Voltage = ModbusDataUtils::convertToUInt16(values) * 1.0 * pow(10, -2);
- if (m_u1Voltage != receivedU1Voltage) {
- m_u1Voltage = receivedU1Voltage;
- emit u1VoltageChanged(m_u1Voltage);
- }
-}
-
-void CionModbusRtuConnection::processGridVoltageRegisterValues(const QVector values)
-{
- float receivedGridVoltage = ModbusDataUtils::convertToUInt16(values) * 1.0 * pow(10, -2);
- if (m_gridVoltage != receivedGridVoltage) {
- m_gridVoltage = receivedGridVoltage;
- emit gridVoltageChanged(m_gridVoltage);
- }
-}
-
-void CionModbusRtuConnection::processMinChargingCurrentRegisterValues(const QVector values)
-{
- quint16 receivedMinChargingCurrent = ModbusDataUtils::convertToUInt16(values);
- if (m_minChargingCurrent != receivedMinChargingCurrent) {
- m_minChargingCurrent = receivedMinChargingCurrent;
- emit minChargingCurrentChanged(m_minChargingCurrent);
- }
-}
-
-void CionModbusRtuConnection::processCurrentChargingCurrentE3RegisterValues(const QVector values)
-{
- quint16 receivedCurrentChargingCurrentE3 = ModbusDataUtils::convertToUInt16(values);
- if (m_currentChargingCurrentE3 != receivedCurrentChargingCurrentE3) {
- m_currentChargingCurrentE3 = receivedCurrentChargingCurrentE3;
- emit currentChargingCurrentE3Changed(m_currentChargingCurrentE3);
- }
-}
-
-void CionModbusRtuConnection::processMaxChargingCurrentE3RegisterValues(const QVector values)
-{
- quint16 receivedMaxChargingCurrentE3 = ModbusDataUtils::convertToUInt16(values);
- if (m_maxChargingCurrentE3 != receivedMaxChargingCurrentE3) {
- m_maxChargingCurrentE3 = receivedMaxChargingCurrentE3;
- emit maxChargingCurrentE3Changed(m_maxChargingCurrentE3);
- }
-}
-
-void CionModbusRtuConnection::processMaxChargingCurrentCableE3RegisterValues(const QVector values)
-{
- quint16 receivedMaxChargingCurrentCableE3 = ModbusDataUtils::convertToUInt16(values);
- if (m_maxChargingCurrentCableE3 != receivedMaxChargingCurrentCableE3) {
- m_maxChargingCurrentCableE3 = receivedMaxChargingCurrentCableE3;
- emit maxChargingCurrentCableE3Changed(m_maxChargingCurrentCableE3);
- }
-}
-
-void CionModbusRtuConnection::processChargingDurationRegisterValues(const QVector values)
-{
- quint32 receivedChargingDuration = ModbusDataUtils::convertToUInt32(values, m_endianness);
- if (m_chargingDuration != receivedChargingDuration) {
- m_chargingDuration = receivedChargingDuration;
- emit chargingDurationChanged(m_chargingDuration);
- }
-}
-
-void CionModbusRtuConnection::processPluggedInDurationRegisterValues(const QVector values)
-{
- quint32 receivedPluggedInDuration = ModbusDataUtils::convertToUInt32(values, m_endianness);
- if (m_pluggedInDuration != receivedPluggedInDuration) {
- m_pluggedInDuration = receivedPluggedInDuration;
- emit pluggedInDurationChanged(m_pluggedInDuration);
- }
-}
-
-void CionModbusRtuConnection::verifyInitFinished()
-{
- if (m_pendingInitReplies.isEmpty()) {
- qCDebug(dcCionModbusRtuConnection()) << "Initialization finished of CionModbusRtuConnection";
- emit initializationFinished();
- }
-}
-
-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() << " - Charging current setpoint:" << cionModbusRtuConnection->chargingCurrentSetpoint() << " [A]" << "\n";
- debug.nospace().noquote() << " - Mode3-State A, B, C, D, U:" << cionModbusRtuConnection->statusBits() << "\n";
- debug.nospace().noquote() << " - Status bits:" << cionModbusRtuConnection->cpSignalState() << "\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:" << 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();
-}
-
diff --git a/schrack/cionmodbusrtuconnection.h b/schrack/cionmodbusrtuconnection.h
deleted file mode 100644
index a175aea..0000000
--- a/schrack/cionmodbusrtuconnection.h
+++ /dev/null
@@ -1,231 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-*
-* Copyright 2013 - 2022, nymea GmbH
-* Contact: contact@nymea.io
-*
-* This fileDescriptor is part of nymea.
-* This project including source code and documentation is protected by
-* copyright law, and remains the property of nymea GmbH. All rights, including
-* reproduction, publication, editing and translation, are reserved. The use of
-* this project is subject to the terms of a license agreement to be concluded
-* with nymea GmbH in accordance with the terms of use of nymea GmbH, available
-* under https://nymea.io/license
-*
-* GNU Lesser General Public License Usage
-* Alternatively, this project may be redistributed and/or modified under the
-* terms of the GNU Lesser General Public License as published by the Free
-* Software Foundation; version 3. This project is distributed in the hope that
-* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
-* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public License
-* along with this project. If not, see .
-*
-* For any further details and any questions please contact us under
-* contact@nymea.io or see our FAQ/Licensing Information on
-* https://nymea.io/license/faq
-*
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-*
-* WARNING
-*
-* This file has been autogenerated. Any changes in this file may be overwritten.
-* If you want to change something, update the register json or the tool.
-*
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-#ifndef CIONMODBUSRTUCONNECTION_H
-#define CIONMODBUSRTUCONNECTION_H
-
-#include
-
-#include "../modbus/modbusdatautils.h"
-#include
-
-class CionModbusRtuConnection : public QObject
-{
- Q_OBJECT
-public:
- enum Registers {
- RegisterChargingEnabled = 100,
- RegisterChargingCurrentSetpoint = 101,
- RegisterStatusBits = 121,
- RegisterCurrentChargingCurrentE3 = 126,
- RegisterMaxChargingCurrentE3 = 127,
- RegisterMaxChargingCurrentCableE3 = 128,
- RegisterCpSignalState = 139,
- RegisterChargingDuration = 151,
- RegisterPluggedInDuration = 153,
- RegisterU1Voltage = 167,
- RegisterGridVoltage = 302,
- RegisterMinChargingCurrent = 507
- };
- Q_ENUM(Registers)
-
- explicit CionModbusRtuConnection(ModbusRtuMaster *modbusRtuMaster, quint16 slaveId, QObject *parent = nullptr);
- ~CionModbusRtuConnection() = default;
-
- ModbusRtuMaster *modbusRtuMaster() const;
- quint16 slaveId() const;
-
- ModbusDataUtils::ByteOrder endianness() const;
- void setEndianness(ModbusDataUtils::ByteOrder endianness);
-
- /* Charging enabled - Address: 100, Size: 1 */
- quint16 chargingEnabled() const;
- ModbusRtuReply *setChargingEnabled(quint16 chargingEnabled);
-
- /* Charging current setpoint [A] - Address: 101, Size: 1 */
- quint16 chargingCurrentSetpoint() const;
- ModbusRtuReply *setChargingCurrentSetpoint(quint16 chargingCurrentSetpoint);
-
- /* Mode3-State A, B, C, D, U - Address: 121, Size: 1 */
- quint16 statusBits() const;
-
- /* Status bits - Address: 139, Size: 1 */
- quint16 cpSignalState() const;
-
- /* U1 voltage [V] - Address: 167, Size: 1 */
- float u1Voltage() const;
-
- /* Voltage of the power supply grid [V] - Address: 302, Size: 1 */
- float gridVoltage() const;
-
- /* Minimum charging current [A] - Address: 507, Size: 1 */
- quint16 minChargingCurrent() const;
-
- /* Current charging Ampere [A] - Address: 126, Size: 1 */
- quint16 currentChargingCurrentE3() const;
-
- /* Maximum charging current [A] - Address: 127, Size: 1 */
- quint16 maxChargingCurrentE3() const;
-
- /* Maximum charging current of connected cable [A] - Address: 128, Size: 1 */
- quint16 maxChargingCurrentCableE3() const;
-
- /* 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 126 with size of 3 registers containing following 3 properties:
- - Current charging Ampere [A] - Address: 126, Size: 1
- - Maximum charging current [A] - Address: 127, Size: 1
- - Maximum charging current of connected cable [A] - Address: 128, Size: 1
- */
- void updateE3Block();
-
- /* 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();
-
- virtual void initialize();
- virtual void update();
-
- void updateChargingEnabled();
- void updateChargingCurrentSetpoint();
- void updateStatusBits();
- void updateCpSignalState();
- void updateU1Voltage();
- void updateGridVoltage();
- void updateMinChargingCurrent();
-
- void updateCurrentChargingCurrentE3();
- void updateMaxChargingCurrentE3();
- void updateMaxChargingCurrentCableE3();
- void updateChargingDuration();
- void updatePluggedInDuration();
-
- ModbusRtuReply *readChargingEnabled();
- ModbusRtuReply *readChargingCurrentSetpoint();
- ModbusRtuReply *readStatusBits();
- ModbusRtuReply *readCpSignalState();
- ModbusRtuReply *readU1Voltage();
- ModbusRtuReply *readGridVoltage();
- ModbusRtuReply *readMinChargingCurrent();
- ModbusRtuReply *readCurrentChargingCurrentE3();
- ModbusRtuReply *readMaxChargingCurrentE3();
- ModbusRtuReply *readMaxChargingCurrentCableE3();
- ModbusRtuReply *readChargingDuration();
- ModbusRtuReply *readPluggedInDuration();
-
- /* 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 [A] - Address: 127, Size: 1
- - Maximum charging current of connected cable [A] - Address: 128, Size: 1
- */
- ModbusRtuReply *readBlockE3();
-
- /* 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
- */
- ModbusRtuReply *readBlockDurations();
-
-signals:
- void initializationFinished();
- void endiannessChanged(ModbusDataUtils::ByteOrder endianness);
-
- void chargingEnabledChanged(quint16 chargingEnabled);
- void chargingCurrentSetpointChanged(quint16 chargingCurrentSetpoint);
- void statusBitsChanged(quint16 statusBits);
- void cpSignalStateChanged(quint16 cpSignalState);
- 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:
- quint16 m_chargingEnabled = 0;
- quint16 m_chargingCurrentSetpoint = 6;
- quint16 m_statusBits = 85;
- quint16 m_cpSignalState = 0;
- 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;
-
- void processChargingEnabledRegisterValues(const QVector values);
- void processChargingCurrentSetpointRegisterValues(const QVector values);
- void processStatusBitsRegisterValues(const QVector values);
- void processCpSignalStateRegisterValues(const QVector values);
- void processU1VoltageRegisterValues(const QVector values);
- void processGridVoltageRegisterValues(const QVector values);
- void processMinChargingCurrentRegisterValues(const QVector values);
-
- void processCurrentChargingCurrentE3RegisterValues(const QVector values);
- void processMaxChargingCurrentE3RegisterValues(const QVector values);
- void processMaxChargingCurrentCableE3RegisterValues(const QVector values);
-
- void processChargingDurationRegisterValues(const QVector values);
- void processPluggedInDurationRegisterValues(const QVector values);
-
-
-private:
- ModbusRtuMaster *m_modbusRtuMaster = nullptr;
- quint16 m_slaveId = 1;
- QVector m_pendingInitReplies;
- ModbusDataUtils::ByteOrder m_endianness = ModbusDataUtils::ByteOrderBigEndian;
-
- void verifyInitFinished();
-
-
-};
-
-QDebug operator<<(QDebug debug, CionModbusRtuConnection *cionModbusRtuConnection);
-
-#endif // CIONMODBUSRTUCONNECTION_H
diff --git a/schrack/schrack.pro b/schrack/schrack.pro
index 88565a9..94fae58 100644
--- a/schrack/schrack.pro
+++ b/schrack/schrack.pro
@@ -1,20 +1,13 @@
include(../plugins.pri)
-QT += serialport serialbus
+# Generate modbus connection
+MODBUS_CONNECTIONS += cion-registers.json
+#MODBUS_TOOLS_CONFIG += VERBOSE
+include(../modbus.pri)
SOURCES += \
- integrationpluginschrack.cpp \
- cionmodbusrtuconnection.cpp \
- ../modbus/modbusdatautils.cpp
+ integrationpluginschrack.cpp
HEADERS += \
- integrationpluginschrack.h \
- cionmodbusrtuconnection.h \
- ../modbus/modbusdatautils.h
+ integrationpluginschrack.h
-OTHER_FILES += cion-registers.json
-
-modbusconnection.commands = python $${top_srcdir}/modbus/tools/generate-connection.py -j $${_PRO_FILE_PWD_}/cion-registers.json -o $${_PRO_FILE_PWD_} -c CionModbusRtuConnection
-QMAKE_EXTRA_TARGETS += modbusconnection
-
-#target.depends += modbusconnection