On Jan 28, 2025, at 5:50?PM, matis_kr via groups.io <matis_kr@...> wrote:
I managed to write a script that reads information from the LocoNet monitor and analyzes it in the program console, and I managed to write a script that automatically refreshes the slot monitor after a specified time. I am unable to write code that automatically triggers socket clearing.
Here are some code snippets that might help you put together what you’re trying to do.
First, get some system objects you’ll need (assuming you have only one LocoNet connection):
connection = jmri.InstanceManager.getList(jmri.jmrix.loconet.LocoNetSystemConnectionMemo).get(0);
slotManager = connection.getSlotManager()
trafficController = connection.getLnTrafficController()
Here’s how to get a reference to a specific Slot object:
slot = slotManager.getSlot(12)
where 12 is the index of the slot. You can use that to loop over the slots.
For the things you can do with that slot, see.
E.g. to get the speed from that slot
speed = slot.speed()
Some of the calls return a LocoNetMessage. For example, writeSpeed(speed) does that. You just send that message
message = slot.releaseSlot()
trafficController.sendLocoNetMessage(message)
What else would be useful?
Bob
—
Bob Jacobsen
rgj1927@...