#include "Modbuswrapper.h" ModbusWrapper::ModbusWrapper(QObject *parent) : QObject(parent) { modBusObj = new modBusMaster(); connect(this, &ModbusWrapper::initConnectionOrder, modBusObj, &modBusMaster::init); connect(this, &ModbusWrapper::openConnectionOrder, modBusObj, &modBusMaster::open); connect(this, &ModbusWrapper::stopConnectionOrder, modBusObj, &modBusMaster::stop); modBusObj->moveToThread(&workerThread); workerThread.setObjectName("workerThread"); workerThread.start(); } ModbusWrapper::~ModbusWrapper() { workerThread.quit(); workerThread.wait(); } void ModbusWrapper::initWrapper(QString serialPort, int slaveAddress) { emit initConnectionOrder(); emit openConnectionOrder(serialPort, slaveAddress); } void ModbusWrapper::stopWrapper() { emit stopConnectionOrder(); } QBitArray ModbusWrapper::getCoilWrapper(int startAddress, quint16 numberOfEntries) { emit getCoilOrder(startAddress, numberOfEntries); }