iCub-main
Loading...
Searching...
No Matches
portthread.cpp
Go to the documentation of this file.
1#include "portthread.h"
2
3PortThread::PortThread(QObject *parent) :
4 QThread(parent)
5{
6 guiRpcPort = NULL;
9}
10
12{
13 guiRpcPort = new Port();
14 driftCompMonitorPort = new BufferedPort<Vector>();
15 driftCompInfoPort = new BufferedPort<Bottle>();
16
18
19 exec();
20
21 delete driftCompInfoPort;
23 delete guiRpcPort;
24}
25
27{
28 if(guiRpcPort){
29 guiRpcPort->interrupt();
30 guiRpcPort->close();
31 }
33 driftCompMonitorPort->interrupt();
34 driftCompMonitorPort->close();
35 }
37 driftCompInfoPort->interrupt();
38 driftCompInfoPort->close();
39 }
40}
41
43{
44 quit();
45 while (isRunning()) {
46 QThread::msleep(50);
47 }
48}
49
50
51Bottle PortThread::sendRpcCommand(bool responseExpected, SkinManagerCommand cmd){
52 Bottle resp;
53 // check whether the port is connected
54 if(guiRpcPort->getOutputCount()==0){
55 openErrorDialog(QString("Connection to the rpc port of the skinDriftCompensation\n"
56 "module not available. Connect and try again."));
57 return resp;
58 }
59
60 // create the bottle
61 Bottle b;
62 b.addInt32(cmd);
63 //g_print("Going to send rpc msg: %s\n", b.toString().c_str());
64 if(responseExpected){
65 guiRpcPort->write(b, resp);
66 }else{
67 guiRpcPort->write(b);
68 }
69 return resp;
70}
void portCreated()
Port * guiRpcPort
Definition portthread.h:43
void openErrorDialog(QString)
void closePorts()
BufferedPort< Vector > * driftCompMonitorPort
Definition portthread.h:44
Bottle sendRpcCommand(bool responseExpected, SkinManagerCommand cmd)
PortThread(QObject *parent=0)
Definition portthread.cpp:3
BufferedPort< Bottle > * driftCompInfoPort
Definition portthread.h:45
void stop()
cmd
Definition dataTypes.h:30