Double-threaded auxiliary
Auxiliary common Interface Definition
- module:
auxiliary
- synopsis:
base auxiliary interface
- class pykiso.auxiliary.AuxCommand(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Contain all available auxiliary’s commands.
- CREATE_AUXILIARY = 1
create auxiliary command id
- DELETE_AUXILIARY = 2
delete auxiliary command id
- class pykiso.auxiliary.AuxiliaryInterface(name=None, is_proxy_capable=False, connector_required=True, activate_log=None, tx_task_on=True, rx_task_on=True, auto_start=True)[source]
Common interface for all double threaded auxiliary. A so called << double threaded >> auxiliary, simply encapsulate two threads one for the reception and one for the transmmission.
Initialize auxiliary attributes
- Parameters:
name (
str
) – alias of the auxiliary instanceis_proxy_capable (
bool
) – notify if the current auxiliary could be (or not) associated to a proxy-auxiliary.connector_required (
bool
) – define if a connector is required for this auxiliary.activate_log (
List
[str
]) – loggers to deactivatetx_task_on – enable or not the tx thread
rx_task_on – enable or not the rx thread
auto_start (
bool
) – determine if the auxiliayry is automatically started (magic import) or manually (by user)
- create_instance()[source]
Start auxiliary’s running tasks and activities.
- Return type:
bool
- Returns:
True if the auxiliary is created otherwise False
- Raises:
AuxiliaryCreationError – if instance creation failed
- delete_instance()[source]
Stop auxiliary’s running tasks and activities.
- Return type:
bool
- Returns:
True if the auxiliary is deleted otherwise False
- resume()[source]
Resume current auxiliary’s run.
Warning
due to the usage of create_instance if an issue occurred the exception AuxiliaryCreationError is raised.
- Return type:
bool
- Returns:
True if the auxiliary is resumed otherwise False
- run_command(cmd_message, cmd_data=None, blocking=True, timeout_in_s=5, timeout_result=None)[source]
Send a request by transmitting it through queue_in and waiting for a response using queue_out.
- Parameters:
cmd_message (
Any
) – command request to the auxiliarycmd_data (
Any
) – data you would like to populate the command withblocking (
bool
) – If you want the command request to be blocking or nottimeout_in_s (
int
) – Number of time (in s) you want to wait for an answertimeout_result (
Any
) – Value to return when the command times out. Defaults to None.
- Raises:
pykiso.exceptions.AuxiliaryNotStarted – if a command is executed although the auxiliary was not started.
- Return type:
Any
- Returns:
True if the request is correctly executed otherwise False
- start()[source]
Force the auxiliary to start all running tasks and activities.
Warning
due to the usage of create_instance if an issue occurred the exception AuxiliaryCreationError is raised.
- Return type:
bool
- Returns:
True if the auxiliary is started otherwise False
- stop()[source]
Force the auxiliary to stop all running tasks and activities.
- Return type:
bool
- Returns:
True if the auxiliary is stopped otherwise False
- suspend()[source]
Supend current auxiliary’s run.
- Return type:
bool
- Returns:
True if the auxiliary is suspend otherwise False
- wait_for_queue_out(blocking=False, timeout_in_s=0)[source]
Wait for data from the queue out.
- Parameters:
blocking (
bool
) – True: wait for timeout to expire, False: return immediatelytimeout_in_s (
int
) – if blocking, wait the defined time in seconds
- Return type:
Optional
[Any
]- Returns:
data contained in the auxiliary’s queue_out
- pykiso.auxiliary.close_connector(func)[source]
Close current associated auxiliary’s channel.
- Parameters:
func (
Callable
) – decorated method- Return type:
Callable
- Returns:
inner decorated function