Scrollkeeper— A Scrollkeeper instance keeps track of the state of slots, sensors and switches.</>
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.
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.
getLocoSlot(address)(Slot) — Return the slot id associated with the loc address.</>getSensorState(id)— Return the state of the sensor.</>getSwitchState(id)— Return the state of the switch.</>messageListener(msg)— Handles incoming messages and updates internal state.</>sendMessage(message)— place a message in the output queue of the interface.</>updateSensor(address,level)— Update the attributes of a sensor.</>updateSlot(id,**kwargs)— Update attributes of a slot.</>updateSwitch(address,thrown,engage)— update the status of a switch.</>
messageListener(msg)
Handles incoming messages and updates internal state.
If information refering an unknown slot comes in, it will issue a slot status request.
msg(Message) — An instance of a (subclass of a) Message.
updateSlot(id, **kwargs)
Update attributes of a slot.
The method is thread safe.
id(int) — The slot id.
updateSensor(address, level=None)
Update the attributes of a sensor.
The method is thread safe.
address(int) — The address of the sensor. This is zero based.level(bool, optional) — Either True (on) or False (off). Defaults to None.
updateSwitch(address, thrown=None, engage=None)
update the status of a switch.
The method is thread safe.
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.
getLocoSlot(address)
Return the slot id associated with the loc address.
If there is no slot known for this loc, request slot data.
address(int) — loc address
ValueError— if no slot data is available for this loc address
The Slot instance associated with this loc address.
getSwitchState(id)
Return the state of the switch.
if the switch is unknown, request the status.
getSensorState(id)
Return the state of the sensor.
if the sensor is unknown, request the status.
sendMessage(message)
place a message in the output queue of the interface.