Without a continue idle timer the cpu usage is lower...

parent b6ff20d0
...@@ -46,10 +46,9 @@ void SkyliveProtocol::startPlugin() ...@@ -46,10 +46,9 @@ void SkyliveProtocol::startPlugin()
std::cout << "SkyliveProtocol initialized in thread " << thread() << std::endl; std::cout << "SkyliveProtocol initialized in thread " << thread() << std::endl;
registerHandler((QString)"connectTelescopes", &SkyliveProtocol::handle_connect); registerHandler((QString)"connectTelescopes", &SkyliveProtocol::handle_connect);
QTimer *parsetimer = new QTimer(); pktTimer = new QTimer();
QObject::connect(parsetimer, SIGNAL(timeout()), this, SLOT(processPackets())); QObject::connect(pktTimer, SIGNAL(timeout()), this, SLOT(processPackets()));
parsetimer->start(); pktTimer->start();
} }
...@@ -63,6 +62,9 @@ void SkyliveProtocol::processPackets() ...@@ -63,6 +62,9 @@ void SkyliveProtocol::processPackets()
QString cmd(pkt.cmd); QString cmd(pkt.cmd);
std::cout << "Packages in Queue: " << cmd.toStdString() <<std::endl; std::cout << "Packages in Queue: " << cmd.toStdString() <<std::endl;
} else {
if(pktTimer->isActive())
pktTimer->stop();
} }
} }
...@@ -144,6 +146,9 @@ void SkyliveProtocol::readFromNetwork() ...@@ -144,6 +146,9 @@ void SkyliveProtocol::readFromNetwork()
} }
case PROTO_END: case PROTO_END:
protoQueue.enqueue(protoMsg); protoQueue.enqueue(protoMsg);
//processPackets();
if(!pktTimer->isActive())
pktTimer->start();
case CMD_END: case CMD_END:
case PARAM_END: case PARAM_END:
SM_TCPCLIENT=CONNECTED; SM_TCPCLIENT=CONNECTED;
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
//#include <QNetworkSession> //#include <QNetworkSession>
#include <QByteArray> #include <QByteArray>
#include <QQueue> #include <QQueue>
#include <QTimer>
#include "pluginsinterfaces.h" #include "pluginsinterfaces.h"
#include "ipcmsg.h" #include "ipcmsg.h"
...@@ -93,6 +94,7 @@ class SkyliveProtocol : public QObject, SkylivexPluginInterface ...@@ -93,6 +94,7 @@ class SkyliveProtocol : public QObject, SkylivexPluginInterface
_SM_TCPCLIENT SM_TCPCLIENT; _SM_TCPCLIENT SM_TCPCLIENT;
SKProtoMsg protoMsg; SKProtoMsg protoMsg;
QQueue<SKProtoMsg> protoQueue; QQueue<SKProtoMsg> protoQueue;
QTimer* pktTimer;
public: public:
......
...@@ -72,11 +72,6 @@ int main(int argc, char *argv[]) ...@@ -72,11 +72,6 @@ int main(int argc, char *argv[])
// and give a slot to the ITC/IPC in the main loop // and give a slot to the ITC/IPC in the main loop
QTimer::singleShot(0, skx, SLOT(initialize())); QTimer::singleShot(0, skx, SLOT(initialize()));
// process IPC events when we are in idle from the main window
QTimer *skxprocess = new QTimer(skx);
QObject::connect(skxprocess, SIGNAL(timeout()), skx, SLOT(process()));
skxprocess->start();
// connect core with the mainwin // connect core with the mainwin
QObject::connect(skx, SIGNAL(msgForMainWin(SKMessage::SKMessage&)), &mainw, SLOT(msgFromCore(SKMessage::SKMessage&))); QObject::connect(skx, SIGNAL(msgForMainWin(SKMessage::SKMessage&)), &mainw, SLOT(msgFromCore(SKMessage::SKMessage&)));
QObject::connect(&mainw, SIGNAL(putMessage(SKMessage::SKMessage&)), skx, SLOT(receiveFromMainWin(SKMessage::SKMessage&))); QObject::connect(&mainw, SIGNAL(putMessage(SKMessage::SKMessage&)), skx, SLOT(receiveFromMainWin(SKMessage::SKMessage&)));
......
...@@ -55,10 +55,6 @@ void SkyliveX::initialize() ...@@ -55,10 +55,6 @@ void SkyliveX::initialize()
} }
void SkyliveX::process()
{
}
void SkyliveX::loadPlugins() void SkyliveX::loadPlugins()
{ {
......
...@@ -66,7 +66,6 @@ class SkyliveX : public QObject ...@@ -66,7 +66,6 @@ class SkyliveX : public QObject
public slots: public slots:
void initialize(); void initialize();
void process();
void receiveFromMainWin(SKMessage::SKMessage &msg); void receiveFromMainWin(SKMessage::SKMessage &msg);
void receiveFromPlugins(SKMessage::SKMessage msg); void receiveFromPlugins(SKMessage::SKMessage msg);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment