1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
void MyThread::run()
{
// création de la socket
_socket = new QTcpSocket(NULL);
_socket->moveToThread(this);
//socket Connection
connect(_socket, SIGNAL(readyRead()), this, SLOT(donneesRecues()), Qt::DirectConnection);
connect(_socket, SIGNAL(connected()), this, SLOT(connecte()), Qt::DirectConnection);
connect(_socket, SIGNAL(disconnected()), this, SLOT(deconnecte()), Qt::DirectConnection);
connect(_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(erreurSocket(QAbstractSocket::SocketError)), Qt::DirectConnection);
//start connection
ConnectionToPlc();
//creation du timer
_Timer = new QTimer;
_Timer->moveToThread(this);
//Timer Connection
connect (_Timer, SIGNAL(timeout()), this, SLOT(SendPacket()), Qt::DirectConnection);
//start loop
_Timer->start(_TimeScale);
exec();
} |
Partager