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.
37 lines
979 B
37 lines
979 B
4 years ago
|
#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);
|
||
|
}
|
||
|
|