You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

45 lines
980 B

#ifndef MODBUSMASTER_H
#define MODBUSMASTER_H
#include <QObject>
#include <QModbusDevice>
#include <QBitArray>
#include <QModbusDataUnit>
#include "ServoException.h"
#include "ModbusConfig.h"
class QModbusClient;
class QModbusReply;
class ModbusMaster : public QObject
{
Q_OBJECT
private:
bool _initialized = false;
QModbusClient* _modbusDevice = nullptr;
int _clientAddress;
QModbusDataUnit _modbusReplyUnit;
public:
explicit ModbusMaster(QObject* parent = nullptr);
void readRequest(QModbusDataUnit::RegisterType registerType,
int startAddress,
quint16 readSize);
void checkForError(QModbusReply* _reply);
void modbusReplyRecieved();
//uncrustify off
public slots:
//uncrustify on
void init();
void connectToDevice(ModbusConfig modbusConfig);
void connectionStateChanged(QModbusDevice::State state);
QBitArray getCoil(int startAddress, quint16 readSize);
QBitArray getInputCoil(int startAddress, quint16 readSize);
};
#endif //MODBUSMASTER_H