Jython not used [message #1851654] |
Tue, 12 April 2022 00:23 |
Henning Riedel Messages: 310 Registered: July 2009 |
Senior Member |
|
|
I wanted to try out EASE in the latest Artop-4.15.1 environment to script some things. There are several problems I encounter:
First of all, I'm just using 0.8.0 and also only PyDev 8.2.0, since these are the last versions as it seems, that still support Java-8. Artop is not yet ready to run on Java-11.
Even though Javascript seems to work (execution), when I try to compare a getSelection(), if it is an instance of the interface ISignalTriggering, it does not work, since it seems, Javascript does not understand Java Interfaces.
Now I tried Python, but here there seems to be even more problems:
It always starts with Py4J, except when explicitly started with RunAs Jython.
When I use the script integration, where in the script I say to add it to the popupmenu of the ProjectExplorer, it always starts with Py4J, but never with Jython. I tried now almost anywhere to get rid of Py4J / Python, and set everthing to Jython, but nothing seems to work. I added a print("sysver, sys.version) and it always shows version 3.9 python.
I tried also the script-engine : Jython or Jython !Py4J or just !Py4J or !Python
but it always starts with Python 3.9 over Py4J.
Also, I still haven't figured out, how to actually access Java packages like the autosar40 metamodel Java package in python script. In Javascript it seems to work, but not in Python.
Maybe some up-to-date documentation would also help, since most of the documentation and tutorials are from 2014 to 2017 and only seem to use Javascript.
The Javascript version, where at least it does not bail out with "don't know Packages"
/*
name : artoolsJS
toolbar : Projecct Explorer
popup : Project Explorer
description : test
*/
loadModule('/System/Platform');
loadModule('/System/Resources');
loadModule('/System/UI');
var project = getProject('test_ar');
var autosarRelease = org.artop.aal.workspace.preferences.IAutosarWorkspacePreferences.AUTOSAR_RELEASE.get(project);
var editingDomain = org.eclipse.sphinx.emf.util.WorkspaceEditingDomainUtil.getEditingDomain(project, autosarRelease);
var contentTypeID = Packages.autosar40.util.Autosar40ReleaseDescriptor.ARXML_CONTENT_TYPE_ID;
print('Project ' + project.name);
print('arrelease ' + autosarRelease);
var sel = getSelection();
//var ccf = Packages.autosar40.system.fibex.fibexcore.corecommunication.CoreCommunicationFactory;
//var xx = ccf.createISignalTriggering();
if (sel instanceof Packages.autosar40.system.fibex.fibexcore.corecommunication.impl.ISignalTriggeringImpl) {
print("sel ISignalTriggering " + sel.shortName)
} else {
print("sel 'dont know'" + sel)
}
--> always returns with "sel don't know"
The Python Script looks like:
#! /usr/bin/env python
# name : artools
# toolbar : Projecct Explorer
# popup : Project Explorer
# script-engine : Jython <-- no matter what I write here
# description : test
loadModule('/System/Platform');
loadModule('/System/Resources');
loadModule('/System/UI');
#import autosar40.system.fibex.fibexcore.corecommunication.ISignalTriggering <-- if enabled, exception package not found
print("sysver ", sys.version) # <-- I always get Python 3.9 printed here
project = getProject('test_ar')
autosarRelease = org.artop.aal.workspace.preferences.IAutosarWorkspacePreferences.AUTOSAR_RELEASE.get(project)
editingDomain = org.eclipse.sphinx.emf.util.WorkspaceEditingDomainUtil.getEditingDomain(project, autosarRelease)
contentTypeID = Packages.autosar40.util.Autosar40ReleaseDescriptor.ARXML_CONTENT_TYPE_ID # <-- exception "Name "Packages" is not defined
print('Project ' + project.name)
print('arrelease ' + autosarRelease)
sel = getSelection()
if isinstance(sel, Packages.autosar40.system.fibex.fibexcore.corecommunication.ISignalTriggering):
print("sel ISignalTriggering " + sel.shortName)
else :
print("sel 'dont know'" + sel)
[Updated on: Tue, 12 April 2022 00:26] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03500 seconds