Class to be used for sending commands. More...
Public Member Functions | |
| def | __init__ (self, host, port) |
| Initialization method for CommandClient. More... | |
| def | sendCommand (self, cmd) |
Method used to send commands from client to CommandServer. More... | |
| def | displayError (self, socketError) |
Qt's slot method to print out received tcpSocket's error. More... | |
Public Attributes | |
| host | |
A QtHostAddress to the CommandServer. More... | |
| port | |
An int of port at which CommandServer is listening. More... | |
| tcpSocket | |
A QTcpSocket used to contact CommandSErver | |
| blockSize | |
| An int representing size of incoming tcp message. More... | |
Class to be used for sending commands.
This class can be used in FreeCAD's or regular python console to send commands to a CommandServer using sendCommand(). The class prints logs as it moves along.
To send a commands do:
Definition at line 311 of file communication.py.
| def communication.CommandClient.__init__ | ( | self, | |
| host, | |||
| port | |||
| ) |
Initialization method for CommandClient.
A class instance is created and its attributes are initialized.
| host | A QtHostAddress to the CommandServer. |
| port | An int of port at which CommandServer is listening. |
Definition at line 334 of file communication.py.
| def communication.CommandClient.displayError | ( | self, | |
| socketError | |||
| ) |
Qt's slot method to print out received tcpSocket's error.
QAbstractSocket.RemoteHostClosedError is not printed, because it occurs naturally when the tcpSocket closes after a transaction is over. Except that all errors are printed.
| socketError | A QAbstractSocket::SocketError enum describing occurred error. |
Definition at line 446 of file communication.py.
| def communication.CommandClient.sendCommand | ( | self, | |
| cmd | |||
| ) |
Method used to send commands from client to CommandServer.
This method tries to connect to a specified host CommandServer via tcpSocket. If connection was successful, the command cmd is sent. Then the response is expected. If the response is equal to COMMAND_EXECUTED_CONFIRMATION_MESSAGE, then the execution was successful. The progress and result of sendCommand can be obtained from printed logs and return value.
| cmd | A str command to be executed. |
CLIENT_COMMAND_EXECUTED if all went great and command was executed. CLIENT_COMMAND_FAILED if cmd execution failed. CLIENT_ERROR_RESPONSE_NOT_COMPLETE if a response received was incomplete. CLIENT_ERROR_NO_RESPONSE if there was no response within WAIT_TIME_MS. CLIENT_ERROR_BLOCK_NOT_WRITTEN if communication failed during sending. CLIENT_ERROR_NO_CONNECTION if no connection to a host was established. Definition at line 361 of file communication.py.
| communication.CommandClient.blockSize |
An int representing size of incoming tcp message.
Definition at line 338 of file communication.py.
| communication.CommandClient.host |
A QtHostAddress to the CommandServer.
Definition at line 335 of file communication.py.
| communication.CommandClient.port |
An int of port at which CommandServer is listening.
Definition at line 336 of file communication.py.