QThread class used to receive commands, try to execute and respond to them.
More...
Public Member Functions | |
| def | __init__ (self, socketDescriptor, parent) |
| Initialization method for CommandThread. More... | |
| def | run (self) |
| Thread's functionality method. More... | |
Public Attributes | |
| socketDescriptor | |
| A Qt's qintptr socket descriptor to initialize tcpSocket. More... | |
| blockSize | |
| An int representing size of incoming tcp message. More... | |
QThread class used to receive commands, try to execute and respond to them.
This class describes a QThread used to receive a command string from a QTcpSocket, try to execute received string and send a repspondse whether the execution was successful or not.
Definition at line 97 of file communication.py.
| def communication.CommandThread.__init__ | ( | self, | |
| socketDescriptor, | |||
| parent | |||
| ) |
Initialization method for CommandThread.
A class instance is created, socketDescriptor and blockSize are initializated.
| socketDescriptor | A Qt's qintptr socket descriptor to initialize tcpSocket. |
| parent | A reference to an instance which will take thread's ownership. |
Definition at line 115 of file communication.py.
| def communication.CommandThread.run | ( | self | ) |
Thread's functionality method.
The starting point for the thread. After calling start(), the newly created thread calls this function. This function then tries to make QTcpSocket. It waits WAIT_TIME_MS for an incoming message. If message is received it checks its a whole message using blockSize sent in the first word as an UINT16 number. If a whole message is received, the thread tries to execute the message string and sends back an appropriate response. The response is Command failed - "error string" if the execution failed, or Command executed successfully otherwise. Then the thread is terminated.
Definition at line 132 of file communication.py.
| communication.CommandThread.blockSize |
An int representing size of incoming tcp message.
Definition at line 118 of file communication.py.
| communication.CommandThread.socketDescriptor |
A Qt's qintptr socket descriptor to initialize tcpSocket.
Definition at line 117 of file communication.py.