¿ªÔÆÌåÓý

Locked Re: Changing state of an internal sensor in a script #sensors


 

Derek,

There are a multitude of initialization solutions using LRoutes, Routes, Logix, LogixNG, or scripts.

The easy solution for internal sensors is selecting the "Initial Sensor State" menu item from the Sensor table "Defaults" menu and setting the initial state to "Inactive".

Dave Sand


----- Original message -----
From: Derek Uttley <derekuttley@...>
Subject: [jmriusers] Changing state of an internal sensor in a script
Date: Thursday, September 05, 2024 10:29 AM

Good Day
I have created an internal sensor IS4 on my PanelPro layout diagram. I want this sensor to be set to INACTIVE on startup of JMRI. This sensor, when manually selected, will indicate the direction of travel on a bidirectional piece of track.
?
self.direction = sensors.provideSensor(¡°IS4¡±)
self.dirstate = self.direction.getKnownState()
print self.dirstate # this value is either 2 for ACTIVE or 4 for INACTIVE
?
How do I force the state of IS4 to INACTIVE on startup?
?
Derek.

Join [email protected] to automatically receive all group messages.