¿ªÔÆÌåÓý

Locked Re: Clear an active EntryExit pair using jython script


 

Thanks for a quick answer.

I got this working:
import java
import jmri

eep = jmri.InstanceManager.getDefault(jmri.jmrit.entryexit.EntryExitPairs)
#print ( eep.getEntryExitList() )

for destPoint in eep.getNamedBeanList():
? ? if destPoint.getState() == ACTIVE:
? ? ? ? print destPoint
? ? ? ? print destPoint.getSystemName()
? ? ? ? print '? ? clear it'
? ? ? ? eep.setSingleSegmentRoute(destPoint.getSystemName())
But last row is not implemented in 4.10 (since4.11.1)

The output I get if I put a comment mark on last line is:
>>> import java
... import jmri
...?
... eep = jmri.InstanceManager.getDefault(jmri.jmrit.entryexit.EntryExitPairs)
... #print ( eep.getEntryExitList() )
...?
... for destPoint in eep.getNamedBeanList():
...? ? ?if destPoint.getState() == ACTIVE:
...? ? ? ? ?print destPoint
...? ? ? ? ?print destPoint.getSystemName()
...? ? ? ? ?print '? ? clear it'
... #? ? ? ? eep.setSingleSegmentRoute(destPoint.getSystemName())
jmri.jmrit.entryexit.DestinationPoints@ee26d8ff
ae2e9664-5541-4c5e-8412-451de18c57ea
? ? clear it

So is there a way to clear it in 4.10?

/Best Regards
Benny

Den s?n 5 aug. 2018 kl 23:13 skrev Dave Sand <ds@...>:

Benny,

To expand on Bob¡¯s example, this includes clearing a route segment.

import java
import jmri

eep = jmri.InstanceManager.getDefault(jmri.jmrit.entryexit.EntryExitPairs)

for destPoint in eep.getNamedBeanSet():
? ? print destPoint
? ? if destPoint.getState() == ACTIVE:
? ? ? ? print ' ? ?clear it'
? ? ? ? eep.setSingleSegmentRoute(destPoint.getSystemName())


Dave Sand



On Aug 5, 2018, at 3:50 PM, Bob Jacobsen <rgj1927@...> wrote:

Python vs Java syntax can be confusing.? The JavaDocs are in Java syntax, but Python (often, but not always) expects an additional ¡°self¡± argument?that comes from calling it on an object, i.e. something.foo() ends up calling (in Python) ?foo(something)

The second error below is because you¡¯re calling getEntryExitList on something that isn¡¯t of type ?jmri.jmrit.entryexit.EntryExitPairs but rather something?else.

Try this:

?ee = jmri.InstanceManager.getDefault(jmri.jmrit.entryexit.EntryExitPairs)
?print ( ee.getEntryExitList() )

Bob

On Aug 5, 2018, at 1:21 PM, Benny Tj?der <etxbct@...> wrote:

Hi,
Do anyone have an jython example how to clear an EntryExit pair?
I have tried to get all pairs using getEntryExitList() but get error:
TypeError: getEntryExitList(): expected 1 args; got 0

In doc () it does not have an argument.
I've tried to put in the panel as argument than I get error:
TypeError: getEntryExitList(): self arg can't be coerced to jmri.jmrit.entryexit.EntryExitPairs

I'm using jmri 4.10 with java 1.8.0_181

/Best Regards
Benny Tj?der



--
Bob Jacobsen
rgj1927@...






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