Parlons Arduino > JMRI et Arduino
Communication JMRI/ARduino
ares13:
Bonjour.
Suite de mes investigations pour connecter JMRI au Mega pour les aiguillages...
Quelqu'un aurait il eu ce message au lancement du script TurnoutDataTransfer.py dans la console systeme de JMRI.
Le problème ne semble pas venir du script mais plutot du "javapackage".
Merci d'avance pour votre aide.
Andrès
2020-01-07 23:03:29,581 jython.RunJythonScript ERROR - Unable to execute script. [AWT-EventQueue-0]
javax.script.ScriptException: AttributeError: 'javapackage' object has no attribute 'beans' in <script> at line number 32
at org.python.jsr223.PyScriptEngine.scriptException(PyScriptEngine.java:222)
at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:59)
at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:64)
at java.scripting/javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:249)
at jmri.script.JmriScriptEngineManager.eval(JmriScriptEngineManager.java:394)
at jmri.script.JmriScriptEngineManager.eval(JmriScriptEngineManager.java:331)
at jmri.jmrit.jython.RunJythonScript.invoke(RunJythonScript.java:111)
at jmri.jmrit.jython.RunJythonScript.actionPerformed(RunJythonScript.java:84)
at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967)
at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2308)
at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)
at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
at java.desktop/javax.swing.AbstractButton.doClick(AbstractButton.java:369)
at java.desktop/javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1020)
at java.desktop/javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1064)
at java.desktop/java.awt.Component.processMouseEvent(Component.java:6636)
at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3342)
at java.desktop/java.awt.Component.processEvent(Component.java:6401)
at java.desktop/java.awt.Container.processEvent(Container.java:2263)
at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5012)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4844)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918)
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4547)
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4488)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307)
at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2762)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4844)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Caused by: Traceback (most recent call last):
File "<script>", line 32, in <module>
AttributeError: 'javapackage' object has no attribute 'beans'
at org.python.core.Py.AttributeError(Py.java:207)
at org.python.core.PyObject.noAttributeError(PyObject.java:1032)
at org.python.core.PyObject.__getattr__(PyObject.java:1027)
at org.python.pycode._pyx1.f$0(<script>:64)
at org.python.pycode._pyx1.call_function(<script>)
at org.python.core.PyTableCode.call(PyTableCode.java:171)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1614)
at org.python.core.__builtin__.eval(__builtin__.java:497)
at org.python.core.__builtin__.eval(__builtin__.java:501)
at org.python.util.PythonInterpreter.eval(PythonInterpreter.java:259)
at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:57)
... 43 more
ares13:
Voilà.
C'est tombé en marche, en ajoutant "import java.beans" au debut du script TurnoutDataTransfer.py. ça fonctionne, en espérant que ce ne soit pas un expédient!
Par la même occasion pour réinitialiser tous les aiguillage à "Direct" j'ai utilisé le script de la livraison JMRI "TurnoutReset.py" ( qui m'a permis d'initialiser "java.beans"...)
# Reset a turnout to Closed every time it's clicked Thrown
#
# This might be used so that a turnout icon on a panel sits
# in one position, ready to be clicked and fire a route
#
# The top of the file defines the needed code. There are some
# lines near the bottom you should edit to adapt it to your
# particular layout.
#
# Author: Bob Jacobsen, copyright 2005
# Part of the JMRI distribution
# updated )3dBc( 8/1/2020
import jmri
import java
import java.beans
# First, define the listener.
class MyListener(java.beans.PropertyChangeListener):
def propertyChange(self, event):
if ( event.propertyName == "KnownState" ) :
if ( event.newValue == THROWN ) :
turnouts.provideTurnout(event.source.systemName).setState(CLOSED)
# Define a routine to make it easy to attach listeners
def SetTurnoutToReset(name) :
t = turnouts.provideTurnout(name)
t.setState(CLOSED)
t.addPropertyChangeListener(MyListener())
# Attach listeners to the desired turnouts
# (Edit the following to apply to your layout)
for t in range (2,70):
SetTurnoutToReset("AT"+str(t))
#Reset all Turnouts of the table
Cheers
Andrès
fcot2002:
Salut @ tous !
Je ne sais pas comment vous faites pour avoir autant de messages d'erreurs. :o :o :o
Chapeaux bas les gars
Chris:
Bonjour,
impossible de faire fonctionner les scripts, tout le reste fonctionne, mais dans la console système de JMRI j'ai le message suivant :
2020-09-15 18:17:16,288 jython.RunJythonScript ERROR - Unable to execute script. [AWT-EventQueue-0]
javax.script.ScriptException: NameError: global name 'extport' is not defined in <script> at line number 86
....
....
Caused by: Traceback (most recent call last):
File "<script>", line 86, in <module>
File "<script>", line 22, in __init__
NameError: global name 'extport' is not defined
Ne connaissant pas JavaScript, je suis incapable d'en déduire quelque chose.
j'ai bien mis mon port "COM6" partout,
la même vitesse, toutes les opérations dans l'ordre, rien n'y fait.
Merci d'avance pour vos lumières.
Chris:
Bonjour,
après avoir résolu mes problèmes précédents, je me pose une nouvelle question :
JMRI peut il gérer un port série en entré et sortie en même temps ?
Je m'explique :
je voudrais connecter JMRI à mon arduino pour lire les ILS et transmettre les infos à JMRI qui en retour modifiera la position des aiguillages.
Autrement dit, faire en un seul script ce que font de façon séparée les 2 scripts SensorScan et TurnOutScan...
Existe-t-il un script qui gérerait les 2?
Cordialement
Navigation
[#] Page suivante
[*] Page précédente
Utiliser la version classique