Skip to content
module

pylnlib.Scrollkeeper

Classes
  • Scrollkeeper A Scrollkeeper instance keeps track of the state of slots, sensors and switches.</>
class

pylnlib.Scrollkeeper.Scrollkeeper(interface, slottrace=False)

A Scrollkeeper instance keeps track of the state of slots, sensors and switches.

A Scrollkeeper instance uses information sent to its messageListener method to keep track of changes to slots, sensors and switches. If it receives messages for which it does not have a Slot, Sensor or Switch instance, it will send requests to get this information.

Parameters
  • interface (Interface) used to send a message if no information on a particular item is present.
  • slottrace (bool, optional) log every internal update to the console. Defaults to False.
Methods
method

messageListener(msg)

Handles incoming messages and updates internal state.

If information refering an unknown slot comes in, it will issue a slot status request.

Parameters
  • msg (Message) An instance of a (subclass of a) Message.
method

updateSlot(id, **kwargs)

Update attributes of a slot.

The method is thread safe.

Parameters
  • id (int) The slot id.
method

updateSensor(address, level=None)

Update the attributes of a sensor.

The method is thread safe.

Parameters
  • address (int) The address of the sensor. This is zero based.
  • level (bool, optional) Either True (on) or False (off). Defaults to None.
method

updateSwitch(address, thrown=None, engage=None)

update the status of a switch.

The method is thread safe.

Parameters
  • address (int) The address of the switch. This is zero based.
  • thrown (bool, optional) direction of the switch. True (thrown, aka Open) or False (closed). Defaults to None.
  • engage (bool, optional) whether the servo is engaged. Defaults to None.
method

getLocoSlot(address)

Return the slot id associated with the loc address.

If there is no slot known for this loc, request slot data.

Parameters
  • address (int) loc address
Raises
  • ValueError if no slot data is available for this loc address
Returns (Slot)

The Slot instance associated with this loc address.

method

getSwitchState(id)

Return the state of the switch.

if the switch is unknown, request the status.

method

getSensorState(id)

Return the state of the sensor.

if the sensor is unknown, request the status.

method

sendMessage(message)

place a message in the output queue of the interface.