|
cut 3.3.0
|
Qt-based asynchronous MAL Request-Reply wrapper class. More...
Public Member Functions | |
| __init__ (self, str uri, bool autoconnect=False, bool async_if=False) | |
| Initializator for the MultiMalAdapter. | |
| set_timeout_connection (self, int timeout) | |
| Changes the default value for connection timeout. | |
| set_timeout_reply (self, int timeout) | |
| Changes the default value for reply timeout. | |
| get_interface (self) | |
| Returns the MAL RR client. | |
| get_mal (self) | |
| Returns the MAL implementation. | |
| get_factory (self) | |
| Returns the MAL factory. | |
| bool | is_autoconnection (self) |
| Returns value autoconnection flag. | |
| set_autoconnection (self, bool new_value) | |
| Sets autoconnection flag. | |
| bool | is_connected (self) |
| Indicates if the MalAdapter is currently connected or not. | |
| set_connection (self, bool new_value, int connection_timeout=DEFAULT_CONNECTION_TIMEOUT, int reply_timeout=DEFAULT_REPLY_TIMEOUT, bool force_connection=False) | |
| Main interaction point of the class. | |
| on_connection_changed (self, bool new_value) | |
| Handles reconnection if needed, this is the callback for autoconnection. | |
| list[str] | query_commands (self) |
| Prepares a list of method names that this server offers through its services. | |
| str | get_method_arg_type (self, str method_query) |
| Returns the datatype (MAL ICD string that defines the datatype) or the first argument of the method. | |
| get_timeout_millis (self) | |
| Returns the current timeout value for commands. | |
| set_timeout_millis (self, int timeout) | |
| Sets the timeout value for execution of commands. | |
| __getattr__ (self, name) | |
| Overrides. | |
| Any | command_inout (self, str cmd, list|None params=None) |
| Executes a command in the MAL RR Server. | |
| Task | command_in_task (self, str cmd, list|None params=None, started_slot=None, cancelled_slot=None, progress_slot=None, result_slot=None, error_slot=None, finished_slot=None, no_start=False) |
| Executes a command asynchronously via Task. | |
Static Public Attributes | |
| connection_changed = Signal(bool) | |
| Emitted when the connection state changes. | |
| connected | |
| Qt Property that indicates if the MalAdapter is "connected" or not. | |
Protected Member Functions | |
| _set_connected (self, bool state) | |
| Sets the property "connected" to true, and emits the connectionChanged signal. | |
| _connection_listener (self, bool status) | |
| Callback method for the MAL RR register listener. | |
| _connect (self, int connection_timeout=DEFAULT_CONNECTION_TIMEOUT, int reply_timeout=DEFAULT_REPLY_TIMEOUT) | |
| Implements the actual connection to the MAL Request Reply interface. | |
| MalRRService | _connect_to_service (self, str path, str if_xml, int connection_timeout=3000, int reply_timeout=3000) |
| Implements the actual connection to the MAL Request Reply interface. | |
| Type|None | _replace_sync_for_async (self, Type interface_class) |
| Returns the Async version of the MAL interface, given the Sync one. | |
Qt-based asynchronous MAL Request-Reply wrapper class.
Handles Requests and connection.
The MultiMalAdapter provides a complete solution to access a MAL RR server and its services. It is intended to be used in the MAL RR Plugin, but a developer may access still MAL and MAL Factory objects and directly invoke the services methods.
MultiMalAdapter also provides the connected Property, with the connection_changed(bool) Signal. Please use this Signal to program event based changes for your applications.
| comms.multimaladapter.MultiMalAdapter.__init__ | ( | self, | |
| str | uri, | ||
| bool | autoconnect = False, | ||
| bool | async_if = False ) |
Initializator for the MultiMalAdapter.
The MultiMalAdapter provides a complete solution to access a MAL RR server and its services. It is intended to be used in the MAL RR Plugin, but a developer may access still MAL and MAL Factory objects and directly invoke the services methods.
It requires a URI and allows so determine if the class instance will automatically connect to the server.
| uri | URI of the MAL Reply Request Endpoint |
| autoconnect | Boolean that indicates if the object will start and retry automatically its connection. |
| async_if | Boolean, if True the MultiMalAdapter class will use the Async interface |
| comms.multimaladapter.MultiMalAdapter.__getattr__ | ( | self, | |
| name ) |
Overrides.
|
protected |
Implements the actual connection to the MAL Request Reply interface.
This method is started in another thread, so certain member need to be protected by using threading.RLock.
It will try to connect to the Introspection interface to execute GetInterfaces(). From its results, it will then connect to the offered services.
|
protected |
Implements the actual connection to the MAL Request Reply interface.
This method is started in another thread, so certain member need to be protected by using threading.RLock.
|
protected |
Callback method for the MAL RR register listener.
| [in] | status | bool with the new status of connection |
|
protected |
Returns the Async version of the MAL interface, given the Sync one.
| [in] | interface_class | Class Type of the Sync MAL interface |
| Task comms.multimaladapter.MultiMalAdapter.command_in_task | ( | self, | |
| str | cmd, | ||
| list | None | params = None, | ||
| started_slot = None, | |||
| cancelled_slot = None, | |||
| progress_slot = None, | |||
| result_slot = None, | |||
| error_slot = None, | |||
| finished_slot = None, | |||
| no_start = False ) |
Executes a command asynchronously via Task.
Future results, result/error is handled through signals.
| [in] | cmd | Command name |
| [in] | params | Parameters list for the command to be executed. |
| [in] | started_slot | Optional slot called when the Task starts. |
| [in] | cancelled_slot | Optional slot called when the Task is cancelled. |
| [in] | progress_slot | Optional slot called with AMI (multiple replies) values. |
| [in] | result_slot | Optional slot called with the resolved result. |
| [in] | error_slot | Optional slot called on error. |
| [in] | finished_slot | Optional slot called when the task finishes. |
| [in] | no_start | Returns an unstarted Task. Useful for further configuration or testing. |
| Any comms.multimaladapter.MultiMalAdapter.command_inout | ( | self, | |
| str | cmd, | ||
| list | None | params = None ) |
Executes a command in the MAL RR Server.
The command in question is identified by #cmd and uses #params as the parameters for the command execution.
| [in] | cmd | Command name |
| [in] | params | Parameters list for the command to be executed. |
| comms.multimaladapter.MultiMalAdapter.get_factory | ( | self | ) |
Returns the MAL factory.
Use it to create structures.
| str comms.multimaladapter.MultiMalAdapter.get_method_arg_type | ( | self, | |
| str | method_query ) |
Returns the datatype (MAL ICD string that defines the datatype) or the first argument of the method.
| [in] | method_query | Method name as a string |
| comms.multimaladapter.MultiMalAdapter.on_connection_changed | ( | self, | |
| bool | new_value ) |
Handles reconnection if needed, this is the callback for autoconnection.
| [in] | new_value | Boolean, new connection state |
| comms.multimaladapter.MultiMalAdapter.set_connection | ( | self, | |
| bool | new_value, | ||
| int | connection_timeout = DEFAULT_CONNECTION_TIMEOUT, | ||
| int | reply_timeout = DEFAULT_REPLY_TIMEOUT, | ||
| bool | force_connection = False ) |
Main interaction point of the class.
Developers should invoke this to start a connection attempt, or request disconnection.
It does decision logic based on the state of connection.
If connection is requested, and is already connected, it will do nothing. If disconnection is requested, and is already disconnected, it will do nothing.
| [in] | new_value | Boolean. True to connect, False to disconnect |
| [in] | connection_timeout | int. Timeout for connection attemp in milliseconds |
| [in] | reply_timeout | int. Timeout for replies in milliseconds |
| [in] | force_connection | bool. Set to True to ignore an ongoing connection request and try anyways. |
| comms.multimaladapter.MultiMalAdapter.set_timeout_millis | ( | self, | |
| int | timeout ) |
Sets the timeout value for execution of commands.
|
static |
Qt Property that indicates if the MalAdapter is "connected" or not.
A bool that is true if connected, false when not. The MAL RR Client provides a connectionListener callback that informs of status changes. When status changes the connectionChanged signal is fired. It carries as argument the new status.
|
static |
Emitted when the connection state changes.
Provides two states: Connected (True) or Disconnected (False).
| bool | New state of connection: True = connected; False = disconnected |