TestCenter Reference
|
The Communicator is the superclass for the communicating entities. More...
Public Member Functions | |
__init__ (self) | |
getPort (self) | |
Get the port used for connections. | |
isConnected (self) | |
Get the connection status of the IPC client. | |
send (self, data, timeout) | |
Send the data via the socket using the given timeout. | |
recv (self, timeout) | |
Receive data via the socket using the given timeout. | |
getLastError (self) | |
Get a tuple describing the last error. | |
getLastErrorWithMessage (self) | |
Get a tuple describing the last error. | |
Protected Member Functions | |
_send (self, data, length, timeout) | |
Send's little helper. | |
_recv (self, length, timeout) | |
Receive's little helper. | |
_handleError (self, errorCode, errorMsg, silent=False) | |
Set the error code and message and disconnect from network. | |
Protected Attributes | |
_mHost | |
IP to connect to. | |
_mPort | |
Port to use for the connection. | |
_mConnected | |
Status of the connection. | |
_msocket | |
Main socket of the server. | |
_csocket | |
Connection socket. | |
_mErrorCode | |
Internal error code used to track the last error. | |
_mErrorMsg | |
Internal error messages. | |
Static Protected Attributes | |
int | _mMsgLength = 8192 |
Length of the messages sent between the two entities. | |
The Communicator is the superclass for the communicating entities.
This class contains the fundamental routines for sending messages between the two entities master and slave. The communication protocol consists of two parts. First the length of the message is sent via a string with exactly 16 bytes. This fixed length is essential as with asynchronous communication many non obvious things can happen (like only parts of messages being transmitted or concatenation of successivly sent messages). The second part of the communication protocol sends the actual data in junks of a given size.
TestCenterAdvanced.IPC.Communicator.__init__ | ( | self | ) |
Reimplemented in TestCenterAdvanced.IPC.ComSlave, and TestCenterAdvanced.IPC.ComMaster.
|
protected |
Set the error code and message and disconnect from network.
This method is just used to simplify the code as it combines all the actions required to handle the error case.
Definition at line 218 of file IPC.py.
References TestCenterAdvanced.IPC.Communicator._mErrorCode, TestCenterAdvanced.IPC.ComMaster._mErrorCode, TestCenterAdvanced.IPC.Communicator._mErrorMsg, TestCenterAdvanced.IPC.ComMaster._mErrorMsg, TestCenterAdvanced.IPC.ComMaster.disconnect(), and TestCenterAdvanced.IPC.ComSlave.disconnect().
Referenced by TestCenterAdvanced.IPC.Communicator._recv(), TestCenterAdvanced.IPC.Communicator._send(), TestCenterAdvanced.IPC.ComMaster.disconnect(), TestCenterAdvanced.IPC.ComSlave.disconnect(), TestCenterAdvanced.IPC.Communicator.recv(), and TestCenterAdvanced.IPC.Communicator.send().
|
protected |
Receive's little helper.
This method first waits for the socket to get ready for receiving. This is done using the timeout to assure this operation doesn't block everything. Afterwards data is received in junks of a size specified in _mMsgLength via the socket. The length of the data expected must be given.
Definition at line 174 of file IPC.py.
References TestCenterAdvanced.IPC.Communicator._csocket, TestCenterAdvanced.IPC.ComMaster._csocket, TestCenterAdvanced.IPC.ComSlave._csocket, TestCenterAdvanced.IPC.Communicator._handleError(), and TestCenterAdvanced.IPC.Communicator.recv().
Referenced by TestCenterAdvanced.IPC.Communicator.recv().
|
protected |
Send's little helper.
This method first waits for the socket to get ready for sending. This is done using the timeout to assure this operation doesn't block everything. Afterwards all data is send in junks of a size specified in _mMsgLength via the socket.
Definition at line 114 of file IPC.py.
References TestCenterAdvanced.IPC.Communicator._csocket, TestCenterAdvanced.IPC.ComMaster._csocket, TestCenterAdvanced.IPC.ComSlave._csocket, TestCenterAdvanced.IPC.Communicator._handleError(), TestCenterAdvanced.IPC.Communicator._mMsgLength, and TestCenterAdvanced.IPC.Communicator.send().
Referenced by TestCenterAdvanced.IPC.Communicator.send().
TestCenterAdvanced.IPC.Communicator.getLastError | ( | self | ) |
Get a tuple describing the last error.
Each failure event sets an internal error code which can be read using this method.
Definition at line 203 of file IPC.py.
References TestCenterAdvanced.IPC.Communicator._mErrorCode, and TestCenterAdvanced.IPC.ComMaster._mErrorCode.
TestCenterAdvanced.IPC.Communicator.getLastErrorWithMessage | ( | self | ) |
Get a tuple describing the last error.
Each failure event sets an internal error code which can be read using this method.
Definition at line 210 of file IPC.py.
References TestCenterAdvanced.IPC.Communicator._mErrorCode, TestCenterAdvanced.IPC.ComMaster._mErrorCode, TestCenterAdvanced.IPC.Communicator._mErrorMsg, and TestCenterAdvanced.IPC.ComMaster._mErrorMsg.
TestCenterAdvanced.IPC.Communicator.getPort | ( | self | ) |
Get the port used for connections.
Definition at line 78 of file IPC.py.
References TestCenterAdvanced.IPC.Communicator._mPort, TestCenterAdvanced.IPC.ComMaster._mPort, and TestCenterAdvanced.IPC.ComSlave._mPort.
TestCenterAdvanced.IPC.Communicator.isConnected | ( | self | ) |
Get the connection status of the IPC client.
Definition at line 84 of file IPC.py.
References TestCenterAdvanced.IPC.Communicator._mConnected, TestCenterAdvanced.IPC.ComMaster._mConnected, and TestCenterAdvanced.IPC.ComSlave._mConnected.
TestCenterAdvanced.IPC.Communicator.recv | ( | self, | |
timeout ) |
Receive data via the socket using the given timeout.
This method implements the receiving part of the protocol specified in the description of send. This method returns True if it succeeded sending the data, False otherwise.
Definition at line 147 of file IPC.py.
References TestCenterAdvanced.IPC.Communicator._handleError(), TestCenterAdvanced.IPC.Communicator._mConnected, TestCenterAdvanced.IPC.ComMaster._mConnected, TestCenterAdvanced.IPC.ComSlave._mConnected, and TestCenterAdvanced.IPC.Communicator._recv().
Referenced by TestCenterAdvanced.IPC.Communicator._recv().
TestCenterAdvanced.IPC.Communicator.send | ( | self, | |
data, | |||
timeout ) |
Send the data via the socket using the given timeout.
This method returns True if it succeeded sending the data, False otherwise.
Definition at line 91 of file IPC.py.
References TestCenterAdvanced.IPC.Communicator._handleError(), TestCenterAdvanced.IPC.Communicator._mConnected, TestCenterAdvanced.IPC.ComMaster._mConnected, TestCenterAdvanced.IPC.ComSlave._mConnected, and TestCenterAdvanced.IPC.Communicator._send().
Referenced by TestCenterAdvanced.IPC.Communicator._send().
|
protected |
Connection socket.
Definition at line 68 of file IPC.py.
Referenced by TestCenterAdvanced.IPC.ComMaster.__del__(), TestCenterAdvanced.IPC.ComSlave.__del__(), TestCenterAdvanced.IPC.Communicator._recv(), TestCenterAdvanced.IPC.Communicator._send(), TestCenterAdvanced.IPC.ComMaster.disconnect(), and TestCenterAdvanced.IPC.ComSlave.disconnect().
|
protected |
Status of the connection.
Definition at line 63 of file IPC.py.
Referenced by TestCenterAdvanced.IPC.ComMaster.__del__(), TestCenterAdvanced.IPC.ComMaster.disconnect(), TestCenterAdvanced.IPC.ComSlave.disconnect(), TestCenterAdvanced.IPC.Communicator.isConnected(), TestCenterAdvanced.IPC.Communicator.recv(), and TestCenterAdvanced.IPC.Communicator.send().
|
protected |
Internal error code used to track the last error.
Definition at line 71 of file IPC.py.
Referenced by TestCenterAdvanced.IPC.Communicator._handleError(), TestCenterAdvanced.IPC.Communicator.getLastError(), and TestCenterAdvanced.IPC.Communicator.getLastErrorWithMessage().
|
protected |
Internal error messages.
Definition at line 73 of file IPC.py.
Referenced by TestCenterAdvanced.IPC.Communicator._handleError(), and TestCenterAdvanced.IPC.Communicator.getLastErrorWithMessage().
|
protected |
|
staticprotected |
Length of the messages sent between the two entities.
Definition at line 54 of file IPC.py.
Referenced by TestCenterAdvanced.IPC.Communicator._send().
|
protected |
Port to use for the connection.
Definition at line 61 of file IPC.py.
Referenced by TestCenterAdvanced.IPC.Communicator.getPort().
|
protected |
Main socket of the server.
Definition at line 66 of file IPC.py.
Referenced by TestCenterAdvanced.IPC.ComMaster.__del__().