|
| | __init__ (self, str uri, Type interface_class=None, str interface_fqn=DEFAULT_INTERFACE_FQN, bool autoconnect=False, bool async_if=False) |
| | Initializator for the MalAdapter.
|
| |
|
| 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.
|
| |
| | getInterface (self) |
| |
|
| get_mal (self) |
| | Returns the MAL implementation.
|
| |
| | getMal (self) |
| |
| | get_factory (self) |
| | Returns the MAL factory.
|
| |
| | getFactory (self) |
| |
|
bool | is_autoconnection (self) |
| | Returns value autoconnection flag.
|
| |
|
| set_autoconnection (self, bool new_value) |
| | Sets autoconnection flag.
|
| |
|
bool | isConnected (self) |
| | Indicates if the MalAdapter is currently connected or not.
|
| |
|
bool | is_connected (self) |
| | Indicates if the MalAdapter is currently connected or not.
|
| |
| | setConnected (self, bool state) |
| | Sets the property "connected" to true, and emits the connectionChanged signal.
|
| |
| | 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) |
| | Returns a list of strings where each entry is a command name.
|
| |
| 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.
|
| |
|
|
| _setConnected (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.
|
| |
| Type|None | _replace_sync_for_async (self, Type interface_class) |
| | Returns the Async version of the MAL interface, given the Sync one.
|
| |
Convenience class to avoid boilerplate code when using MAL Interface.
The MalAdapter provides a convenience base class to avoid boilerplate code when connecting to MAL Interfaces. The developer creates a new class that inherits from MalAdapter, and the only pending task, is to develop Slots that provide access to Methods in the Interface.
MalAdapter also provides the connected Property, with the connectionChanged(bool) Signal. Please use this Signal to program event based changes for your applications.
- See also
- Logger
-
QObject
from ModDemoserviceif.Demoserviceif.Commands import CommandsAsync
class DemoServiceFacade(MalAdapter):
def __init__(self, uri: str):
MalAdapter.__init__(self, uri, CommandsAsync)
def get_state(self, result_slot=None):
if not self.is_connected():
self.error("Application is not connected to the server. Please connect first.")
return
task = Task(self.get_interface().GetState)
if result_slot:
task.signals.result.connect(result_slot)
task.signals.result.connect(self.print_output)
task.signals.finished.connect(self.task_finished)
task.start()
def print_output(self, s):
self.debug(s)
def task_finished(self):
self.print_output("Task Finished!")
Implements Task and TaskSignals classes.
| comms.maladapter.MalAdapter.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.
- Parameters
-
| [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. |