inital commit
This commit is contained in:
53
vhfmillthread.cpp
Normal file
53
vhfmillthread.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
#include "vhfmillthread.h"
|
||||
|
||||
VhfMillThread::VhfMillThread(bool tcpI, int portI, const QString& hostI, const QString& serialPortI, QObject *parent):
|
||||
tcp(tcpI),
|
||||
port(portI),
|
||||
serialPort(serialPortI),
|
||||
host(hostI),
|
||||
QThread(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void VhfMillThread::run()
|
||||
{
|
||||
if(tcp)
|
||||
{
|
||||
QTcpSocket* microSocket = new QTcpSocket;
|
||||
microSocket->connectToHost(host, port, QIODevice::ReadWrite);
|
||||
if(!microSocket->waitForConnected(1000))
|
||||
{
|
||||
ret = -2;
|
||||
ready();
|
||||
return;
|
||||
}
|
||||
masterIODevice = microSocket;
|
||||
}
|
||||
else
|
||||
{
|
||||
QSerialPort* microPort = new QSerialPort;
|
||||
microPort->setPortName(serialPort);
|
||||
microPort->setBaudRate(115200);
|
||||
|
||||
if(!microPort->open(QIODevice::ReadWrite))
|
||||
{
|
||||
qDebug()<<"could not open serial port "<<serialPort;
|
||||
ret = -3;
|
||||
ready();
|
||||
return;
|
||||
}
|
||||
masterIODevice = microPort;
|
||||
}
|
||||
|
||||
mill = new VhfMill(masterIODevice);
|
||||
ret = 0;
|
||||
ready();
|
||||
exec();
|
||||
delete mill;
|
||||
delete masterIODevice;
|
||||
}
|
||||
|
||||
VhfMillThread::~VhfMillThread()
|
||||
{
|
||||
}
|
||||
|
Reference in New Issue
Block a user