slacm.component module

Created on Sep 19, 2020

@author: esdev

class slacm.component.Component[source]

Bases: object

Base class for all components.

ERR = -1
FINALIZE = 2
OK = 0
SETUP = 1
START = 3
STOP = 4
activate()[source]

Method executed before the message handlers are activated. Runs in the component thread.

deactivate()[source]

Method executed when the component is stopped. Runs in the component thread.

class slacm.component.ComponentThread(parent)[source]

Bases: Thread

Component executor thread.

activate()[source]

Activate all ports.

deactivate()[source]

Deactivate all ports.

executeHandlerFor(socket)[source]

Execute the handler for the port corresponding to the socket. The handler is always allowed to run to completion, the operation is never preempted.

finalize()[source]

Execute the ‘finalize’ phase of component initialization. Finalize all ports, and connect the ‘client’ ports with the discovery service.

get_netInfo()[source]

Return the network interface information.

locateHandler(portName)[source]

Locate the handler belonging to the the name port.

recvControl()[source]

Receive a control message from the parent via the control socket.

run()[source]

Main loop of component thread.

runCommand(msg)[source]

Run a control command sent to the component thread by its parent actor.

scheduler(sockets)[source]

Priority scheduler for the component message processing.

The priority order is determined by the order of component ports. The dictionary of active sockets is scanned, and the they are inserted into a priority queue (according to their priority value). The queue is processed (in order of priority). After each invocation, the inputs are polled (in a no-wait operation) and the priority queue is updated.

sendControl(msg)[source]

Send a message via the control socket (to the parent)

setup()[source]

Execute the ‘setup’ phase of component initialization. Construct all ports, and register the ‘server’ ports with the discovery service.

setupControl()[source]

Set up the inner ‘control’ socket (for receiving commands)

setupDisco()[source]

Setup the component as a client of the discovery service.

setupPoller()[source]

Setup the poller for the component thread, initially for the control socket only.

terminate()[source]

Terminate all ports.

updatePoller()[source]

Update the poller with all the input ports.