/** * Constructor */ Telemetry::Telemetry(UAVTalk* utalk, UAVObjectManager* objMngr) { this->utalk = utalk; this->objMngr = objMngr; mutex = new QMutex(QMutex::Recursive); // Process all objects in the list QList< QList<UAVObject*> > objs = objMngr->getObjects(); for (int objidx = 0; objidx < objs.length(); ++objidx) { registerObject(objs[objidx][0]); // we only need to register one instance per object type } // Listen to new object creations connect(objMngr, SIGNAL(newObject(UAVObject*)), this, SLOT(newObject(UAVObject*))); connect(objMngr, SIGNAL(newInstance(UAVObject*)), this, SLOT(newInstance(UAVObject*))); // Listen to transaction completions connect(utalk, SIGNAL(transactionCompleted(UAVObject*)), this, SLOT(transactionCompleted(UAVObject*))); // Get GCS stats object gcsStatsObj = GCSTelemetryStats::GetInstance(objMngr); // Setup transaction timer transPending = false; transTimer = new QTimer(this); transTimer->stop(); connect(transTimer, SIGNAL(timeout()), this, SLOT(transactionTimeout())); // Setup and start the periodic timer timeToNextUpdateMs = 0; updateTimer = new QTimer(this); connect(updateTimer, SIGNAL(timeout()), this, SLOT(processPeriodicUpdates())); updateTimer->start(1000); // Setup and start the stats timer txErrors = 0; txRetries = 0; }
ModbusClient::ModbusClient(QObject *parent) : QObject(parent) { statusConnected = false; isWaitingForResponse = false; transactionID = 1; //Create table of registers holdingRegistersSize = 127; holdingRegisters = new quint16[holdingRegistersSize]; for(int i=0 ; i<holdingRegistersSize ; i++) { holdingRegisters[i]=0; } responseTimer = new QTimer(this); setResponseTimerTimeout(500); connect(responseTimer,SIGNAL(timeout()),this,SLOT(transactionTimeout())); mySocket = new QTcpSocket(this); connect(mySocket, SIGNAL(disconnected()), this, SLOT(disconnected())); connect(mySocket, SIGNAL(connected()),this,SLOT(connected())); connect(mySocket, SIGNAL(readyRead()), this, SLOT(readDataAndCheck())); }