Also I was attempting to draft a script that would ping each turnout in JMRI and return its current state. I note that the first time I touch the turnout icon in Panel Pro Main Panel, the turnout will first change color to its actual state. If I touch a second time it will physically change its state. Therefore, I was looking for a way to poll each turnout (without changing its position) and update Panel Pro Main Panel accordingly.
?
In Visual Studio Code with Copilot (ChatGPT) tried this code but I did not work. UpdateTurnoutState function was supposed to read state and then set turnout to that state without changing it - simulating what happens when you touch the screen once and it updates.
?
class setStartup(jmri.jmrit.automat.AbstractAutomaton) :
? ? def init(self):
? ? ? ? self.turnouts = jmri.InstanceManager.getDefault(jmri.TurnoutManager)
? ? ? ? return
? ??
? ? def handle(self):
? ? ? ? self.waitMsec(500)
? ? ? ? self.updateTurnoutState("1001")
? ? ? ? self.waitMsec(500)
? ? ? ? self.updateTurnoutState("1002")
# repeat for as many turnouts
?
? ? ?def updateTurnoutState(self, turnoutId):
? ? ? ? turnout = self.turnouts.provideTurnout(turnoutId)
? ? ? ? currentState = turnout.getState()
? ? ? ? turnout.setState(currentState)
?
?