|
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 | |
| str | _mHost = "localhost" |
| IP to connect to. | |
| int | _mPort = 21319 if not "MeVisLabTestCenterPort" in os.environ else int(os.environ["MeVisLabTestCenterPort"]) |
| Port to use for the connection. | |
| bool | _mConnected = False |
| Status of the connection. | |
| _msocket = None | |
| Main socket of the server. | |
| _csocket = None | |
| Connection socket. | |
| _mErrorCode = Error.OK | |
| Internal error code used to track the last error. | |
| str | _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.
|
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 230 of file IPC.py.
References _mErrorCode, _mErrorMsg, TestCenterAdvanced.IPC.ComMaster.disconnect(), and TestCenterAdvanced.IPC.ComSlave.disconnect().
Referenced by _recv(), _send(), TestCenterAdvanced.IPC.ComMaster.disconnect(), TestCenterAdvanced.IPC.ComSlave.disconnect(), recv(), and 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 183 of file IPC.py.
References _csocket, _handleError(), and recv().
Referenced by 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 121 of file IPC.py.
References _csocket, _handleError(), _mMsgLength, and send().
Referenced by 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 213 of file IPC.py.
References _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 221 of file IPC.py.
References _mErrorCode, and _mErrorMsg.
| TestCenterAdvanced.IPC.Communicator.getPort | ( | self | ) |
| TestCenterAdvanced.IPC.Communicator.isConnected | ( | self | ) |
Get the connection status of the IPC client.
Definition at line 89 of file IPC.py.
References _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 155 of file IPC.py.
References _handleError(), _mConnected, and _recv().
Referenced by _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 97 of file IPC.py.
References _handleError(), _mConnected, and _send().
Referenced by _send().
|
protected |
Connection socket.
Definition at line 72 of file IPC.py.
Referenced by TestCenterAdvanced.IPC.ComSlave.__del__(), _recv(), _send(), TestCenterAdvanced.IPC.ComMaster.disconnect(), and TestCenterAdvanced.IPC.ComSlave.disconnect().
|
protected |
Status of the connection.
Definition at line 67 of file IPC.py.
Referenced by TestCenterAdvanced.IPC.ComMaster.disconnect(), TestCenterAdvanced.IPC.ComSlave.disconnect(), isConnected(), recv(), and send().
|
protected |
Internal error code used to track the last error.
Definition at line 75 of file IPC.py.
Referenced by _handleError(), getLastError(), and getLastErrorWithMessage().
|
protected |
Internal error messages.
Definition at line 77 of file IPC.py.
Referenced by _handleError(), and getLastErrorWithMessage().
|
protected |
|
staticprotected |
|
protected |
|
protected |