Fix building and JSON RPC for modbus management
This commit is contained in:
parent
9967b1007d
commit
1f247b30be
@ -121,7 +121,7 @@ ModbusRtuHandler::ModbusRtuHandler(ModbusRtuManager *modbusRtuManager, QObject *
|
|||||||
|
|
||||||
// ReconfigureModbusRtuMaster
|
// ReconfigureModbusRtuMaster
|
||||||
params.clear(); returns.clear();
|
params.clear(); returns.clear();
|
||||||
description = "Rconfigure the modbus RTU master with the given UUID and configuration.";
|
description = "Reconfigure the modbus RTU master with the given UUID and configuration.";
|
||||||
params.insert("modbusUuid", enumValueName(Uuid));
|
params.insert("modbusUuid", enumValueName(Uuid));
|
||||||
params.insert("serialPort", enumValueName(String));
|
params.insert("serialPort", enumValueName(String));
|
||||||
params.insert("baudrate", enumValueName(Uint));
|
params.insert("baudrate", enumValueName(Uint));
|
||||||
@ -141,7 +141,7 @@ ModbusRtuHandler::ModbusRtuHandler(ModbusRtuManager *modbusRtuManager, QObject *
|
|||||||
connect(modbusRtuManager->serialPortMonitor(), &SerialPortMonitor::serialPortRemoved, this, [=](const SerialPort &serialPort){
|
connect(modbusRtuManager->serialPortMonitor(), &SerialPortMonitor::serialPortRemoved, this, [=](const SerialPort &serialPort){
|
||||||
QVariantMap params;
|
QVariantMap params;
|
||||||
params.insert("serialPort", pack(serialPort));
|
params.insert("serialPort", pack(serialPort));
|
||||||
emit SerialPortAdded(params);
|
emit SerialPortRemoved(params);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -49,6 +49,7 @@ class ModbusRtuManager : public QObject
|
|||||||
public:
|
public:
|
||||||
enum ModbusRtuError {
|
enum ModbusRtuError {
|
||||||
ModbusRtuErrorNoError,
|
ModbusRtuErrorNoError,
|
||||||
|
ModbusRtuErrorNotAvailable,
|
||||||
ModbusRtuErrorUuidNotFound,
|
ModbusRtuErrorUuidNotFound,
|
||||||
ModbusRtuErrorHardwareNotFound,
|
ModbusRtuErrorHardwareNotFound,
|
||||||
ModbusRtuErrorConnectionFailed
|
ModbusRtuErrorConnectionFailed
|
||||||
|
|||||||
@ -157,17 +157,26 @@ bool ModbusRtuMasterImpl::connected() const
|
|||||||
|
|
||||||
bool ModbusRtuMasterImpl::connectDevice()
|
bool ModbusRtuMasterImpl::connectDevice()
|
||||||
{
|
{
|
||||||
|
#ifdef WITH_QTSERIALBUS
|
||||||
m_modbus->setConnectionParameter(QModbusDevice::SerialPortNameParameter, m_serialPort);
|
m_modbus->setConnectionParameter(QModbusDevice::SerialPortNameParameter, m_serialPort);
|
||||||
m_modbus->setConnectionParameter(QModbusDevice::SerialBaudRateParameter, m_baudrate);
|
m_modbus->setConnectionParameter(QModbusDevice::SerialBaudRateParameter, m_baudrate);
|
||||||
m_modbus->setConnectionParameter(QModbusDevice::SerialDataBitsParameter, m_dataBits);
|
m_modbus->setConnectionParameter(QModbusDevice::SerialDataBitsParameter, m_dataBits);
|
||||||
m_modbus->setConnectionParameter(QModbusDevice::SerialStopBitsParameter, m_stopBits);
|
m_modbus->setConnectionParameter(QModbusDevice::SerialStopBitsParameter, m_stopBits);
|
||||||
m_modbus->setConnectionParameter(QModbusDevice::SerialParityParameter, m_parity);
|
m_modbus->setConnectionParameter(QModbusDevice::SerialParityParameter, m_parity);
|
||||||
return m_modbus->connectDevice();
|
return m_modbus->connectDevice();
|
||||||
|
#else
|
||||||
|
qCWarning(dcModbusRtu()) << "Modbus is not available on this platform.";
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModbusRtuMasterImpl::disconnectDevice()
|
void ModbusRtuMasterImpl::disconnectDevice()
|
||||||
{
|
{
|
||||||
|
#ifdef WITH_QTSERIALBUS
|
||||||
m_modbus->disconnectDevice();
|
m_modbus->disconnectDevice();
|
||||||
|
#else
|
||||||
|
qCWarning(dcModbusRtu()) << "Modbus is not available on this platform.";
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
ModbusRtuReply *ModbusRtuMasterImpl::readCoil(int slaveAddress, int registerAddress, quint16 size)
|
ModbusRtuReply *ModbusRtuMasterImpl::readCoil(int slaveAddress, int registerAddress, quint16 size)
|
||||||
@ -217,6 +226,7 @@ ModbusRtuReply *ModbusRtuMasterImpl::readCoil(int slaveAddress, int registerAddr
|
|||||||
Q_UNUSED(slaveAddress)
|
Q_UNUSED(slaveAddress)
|
||||||
Q_UNUSED(registerAddress)
|
Q_UNUSED(registerAddress)
|
||||||
Q_UNUSED(size)
|
Q_UNUSED(size)
|
||||||
|
qCWarning(dcModbusRtu()) << "Modbus is not available on this platform.";
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
#endif
|
#endif
|
||||||
@ -269,6 +279,7 @@ ModbusRtuReply *ModbusRtuMasterImpl::readDiscreteInput(int slaveAddress, int reg
|
|||||||
Q_UNUSED(slaveAddress)
|
Q_UNUSED(slaveAddress)
|
||||||
Q_UNUSED(registerAddress)
|
Q_UNUSED(registerAddress)
|
||||||
Q_UNUSED(size)
|
Q_UNUSED(size)
|
||||||
|
qCWarning(dcModbusRtu()) << "Modbus is not available on this platform.";
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
#endif
|
#endif
|
||||||
@ -321,6 +332,7 @@ ModbusRtuReply *ModbusRtuMasterImpl::readInputRegister(int slaveAddress, int reg
|
|||||||
Q_UNUSED(slaveAddress)
|
Q_UNUSED(slaveAddress)
|
||||||
Q_UNUSED(registerAddress)
|
Q_UNUSED(registerAddress)
|
||||||
Q_UNUSED(size)
|
Q_UNUSED(size)
|
||||||
|
qCWarning(dcModbusRtu()) << "Modbus is not available on this platform.";
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
#endif
|
#endif
|
||||||
@ -373,6 +385,7 @@ ModbusRtuReply *ModbusRtuMasterImpl::readHoldingRegister(int slaveAddress, int r
|
|||||||
Q_UNUSED(slaveAddress)
|
Q_UNUSED(slaveAddress)
|
||||||
Q_UNUSED(registerAddress)
|
Q_UNUSED(registerAddress)
|
||||||
Q_UNUSED(size)
|
Q_UNUSED(size)
|
||||||
|
qCWarning(dcModbusRtu()) << "Modbus is not available on this platform.";
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
#endif
|
#endif
|
||||||
@ -427,6 +440,7 @@ ModbusRtuReply *ModbusRtuMasterImpl::writeCoils(int slaveAddress, int registerAd
|
|||||||
Q_UNUSED(slaveAddress)
|
Q_UNUSED(slaveAddress)
|
||||||
Q_UNUSED(registerAddress)
|
Q_UNUSED(registerAddress)
|
||||||
Q_UNUSED(values)
|
Q_UNUSED(values)
|
||||||
|
qCWarning(dcModbusRtu()) << "Modbus is not available on this platform.";
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
#endif
|
#endif
|
||||||
@ -482,6 +496,7 @@ ModbusRtuReply *ModbusRtuMasterImpl::writeHoldingRegisters(int slaveAddress, int
|
|||||||
Q_UNUSED(slaveAddress)
|
Q_UNUSED(slaveAddress)
|
||||||
Q_UNUSED(registerAddress)
|
Q_UNUSED(registerAddress)
|
||||||
Q_UNUSED(values)
|
Q_UNUSED(values)
|
||||||
|
qCWarning(dcModbusRtu()) << "Modbus is not available on this platform.";
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user