riaps.run.timPort module

Created on Oct 10, 2016

@author: riaps

class riaps.run.timPort.TimPort(parentPart, portName, portSpec)[source]

Bases: Port

Timer port

activate()[source]

Activate the timer port

cancel()[source]

Cancel the sporadic timer

deactivate()[source]

Deactivate the timer port

getDelay()[source]

Get the current delay (for sporadic timer)

getInfo()[source]

Retrieve configuration information about the port. Abstract, subclasses must implement this method.

Returns:

a tuple containing the name of the port’s type: req,rep,clt,srv,qry,ans,pub,sub,ins,or tim; the kind of the port (global, local, internal); the name of the port object; the name of the message type; the host and the port number.

Return type:

PortInfo

getPeriod()[source]

Read the period of the periodic timer

getSocket()[source]

Return the socket(s) used by the port object. Abstract, subclasses must implement this method.

Returns:

a low-level socket

Return type:

zmq.Socket

halt()[source]

Halt the timer

inSocket()[source]

Return True if the socket can be used for input. Abstract, subclasses must implement this method.

Returns:

logical value indicating whether the socket is for input.

Type:

bool

launch()[source]

Launch (start) the sporadic timer

recv()[source]

Receive time stamp (a float) as a byte array

recv_pyobj()[source]

Receive a Python data object (if possible) through the port. Abstract, subclasses must implement this method.

The raw message received is deserialized using pickle and returned. Messages received this way had to be sent using the send_pyobj method.

Returns:

a Python data object

Type:

any Python data type

reset()[source]

Reset the port object. Subclasses can override this method.

Reset is to be used when a send or receive operation fails and the port needs to be re-initialized.

running()[source]

Returns True if the timer is running

send()[source]

Send a byte array (if possible) out through the port.

Used for sending a message that has been serialized into bytes previously.

Parameters:

msg – the message packed into a bytes

Return type:

bytes

send_pyobj(msg)[source]

Send a Python data object (if possible) out through the port. Abstract, subclasses must implement this method.

The object is serialized using pickle and sent. Messages sent using this method are received using the recv_pyobj method.

Parameters:

msg (any Python data type) – the message to be sent.

setDelay(_delay)[source]

Set the current delay (for sporadic timer)

setPeriod(_period)[source]

Set the period - will be changed after the next firing. Period must be positive

setup()[source]

Initialize the port object (after construction but before socket creation). Abstract, subclasses must implement this method.

setupSocket(owner)[source]

Setup the socket. Abstract, subclasses must implement this method.

Parameters:

owner (Component) – The Component the port belongs to. This operation must be called from the component thread only.

terminate()[source]

Terminate the timer

class riaps.run.timPort.TimerThread(parent)[source]

Bases: Thread

class Command(value)[source]

Bases: Enum

An enumeration.

ACTIVATE = 2
CANCEL = 5
DEACTIVATE = 3
HALT = 6
START = 4
TERMINATE = 1
cmdError(where, cmd)[source]
getDelay()[source]

Get the current delay (for sporadic timer)

getPeriod()[source]

Read out the period

ready()[source]
run()[source]

Method representing the thread’s activity.

You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.

running()[source]

Returns True if the timer is running

setDelay(_delay)[source]

Set the current delay (for sporadic timer)

setPeriod(_period)[source]

Set the period (for periodic timer). Takes effect after the next firing.

waitFor(timeout=None)[source]