[ATL] [newbie] acces to enumeration [message #32601] |
Thu, 19 April 2007 03:56  |
Eclipse User |
|
|
|
Originally posted by: tristan.faure.c-s.fr
Hi
I am new with ATL and i have to do model transformation from UML2 (Class /
statemachine) to IF (verification language)
I've made my metamodel IF and i have an ecore file and i don't have any
problem for some transformations but ....
i've defined an enumeration type in my ecore
<eClassifiers xsi:type="ecore:EEnum" name="ParametersMode">
<eLiterals name="null"/>
<eLiterals name="out" value="1"/>
<eLiterals name="inout" value="2"/>
<eLiterals name="in" value="3"/>
</eClassifiers>
and I don't know how to access to it from ATL rule
rule Property2Variables {
from
p : UML!Property
to
v : _IF!Vars (
name <- p.name,
mode <- ? ? ? ,
type <- p.getType()
)
}
at the launching I have a problem when i try to insert the mode because he
needs a parametersMode (my enum)
Thank you
|
|
|
|
|
|
Re: [ATL] [newbie] acces to enumeration [message #32738 is a reply to message #32705] |
Thu, 19 April 2007 05:29   |
Eclipse User |
|
|
|
Originally posted by: tristan.faure.c-s.fr
First i'm sorry because i'm using the web interface of the newsgroup and i
don't know if it is possible to join files so i will copy code here (if
you know a newsgroup software which works with proxy :/)
I'm also sorry the error was not the good there is no launching error but
there is this trace in the console :
============================================================ ===
****** BEGIN Stack Trace
message: cannot set feature _IF!Vars.mode to value null
exception:
java.lang.IllegalArgumentException: The value '' is not a valid enumerator
of 'ParametersMode'
at
org.eclipse.emf.ecore.impl.EFactoryImpl.createFromString(EFa ctoryImpl.java:269)
at
org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.getDefault Value(EStructuralFeatureImpl.java:129)
at
org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.getSetting Delegate(EStructuralFeatureImpl.java:780)
at
org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSettingDelegate (BasicEObjectImpl.java:1115)
at
org.eclipse.emf.ecore.impl.BasicEObjectImpl.eDynamicSet(Basi cEObjectImpl.java:709)
at
org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjec tImpl.java:683)
at
org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjec tImpl.java:654)
at
org.atl.engine.repositories.emf4atl.ASMEMFModelElement.set(A SMEMFModelElement.java:226)
at org.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:27 6)
at org.atl.engine.vm.ASMOperation.exec(ASMOperation.java:155)
at org.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java: 60)
at org.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java: 50)
at org.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:21 4)
at org.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:30 9)
at org.atl.engine.vm.ASMOperation.exec(ASMOperation.java:155)
at org.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java: 60)
at org.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java: 50)
at org.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:21 4)
at org.atl.engine.vm.ASMOperation.exec(ASMOperation.java:155)
at org.atl.engine.vm.ASMInterpreter.<init>(ASMInterpreter.java:276)
at org.atl.eclipse.engine.AtlLauncher.launch(AtlLauncher.java:1 36)
at org.atl.eclipse.engine.AtlLauncher.launch(AtlLauncher.java:9 4)
at org.atl.eclipse.engine.AtlLauncher.launch(AtlLauncher.java:6 8)
at org.atl.eclipse.engine.AtlLauncher.launch(AtlLauncher.java:6 4)
at
org.atl.eclipse.adt.launching.AtlLaunchConfigurationDelegate .runAtlLauncher(AtlLaunchConfigurationDelegate.java:230)
at
org.atl.eclipse.adt.launching.AtlLaunchConfigurationDelegate .runAtlLauncher(AtlLaunchConfigurationDelegate.java:168)
at
org.atl.eclipse.adt.launching.AtlLaunchConfigurationDelegate .runAtlLauncher(AtlLaunchConfigurationDelegate.java:145)
at
org.atl.eclipse.adt.launching.AtlLaunchConfigurationDelegate .runAtlLauncher(AtlLaunchConfigurationDelegate.java:121)
at
org.atl.eclipse.adt.launching.AtlLaunchConfigurationDelegate .launch(AtlLaunchConfigurationDelegate.java:97)
at
org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:710)
at
org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:603)
at
org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(D ebugUIPlugin.java:754)
at
org.eclipse.debug.internal.ui.DebugUIPlugin$6.run(DebugUIPlu gin.java:944)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)
A.main() : ??#24 null
local variables = {self=uml2if : ASMModule}
local stack = []
A.__exec__() : ??#38 null
local variables = {e=TransientLink {rule = 'Property2Variables',
sourceElements = {p = IN!cursor}, targetElements = {v = OUT!cursor},
variables = {}}, self=uml2if : ASMModule}
local stack = []
A.__applyProperty2Variables(1 : NTransientLink;) : ??#21 75:25-75:69
local variables = {v=OUT!cursor, p=IN!cursor, link=TransientLink {rule =
'Property2Variables', sourceElements = {p = IN!cursor}, targetElements =
{v = OUT!cursor}, variables = {}}, self=uml2if : ASMModule}
local stack = [OUT!cursor]
****** END Stack Trace
Execution terminated due to error (see launch configuration to allow
continuation after errors).
============================================================ ===
So this is my module it's just a prototype so it's not very big
============================================================ ===
module uml2if; -- Module Template
create OUT:_IF from IN:UML ;
-- getting the enum value from a string
helper def: getParametersMode(p : String) : IF!ParametersMode =
if (p = 'null') then
#null
else
if (p = 'out') then
#out
else
#null
endif
endif
;
helper context UML!Property def : getType() : String =
(
if (self.type = 'Integer') then
'integer'
else
'integer1'
endif
) ;
helper context UML!Package def : getProcesses() : Set(UML!Class) =
(
self.ownedMember->select(a|a.oclIsTypeOf(UML!Class))
);
rule Package2System {
from
p : UML!Package (p.oclIsTypeOf(UML!Package))
to
s : _IF!System (
id <- p.name,
process <- p.getProcesses()
)
}
rule Class2Process {
from
c : UML!Class (c.oclIsTypeOf(UML!Class))
to
s : _IF!Process (
id <- c.name ,
nbInstancesToStart <- '1',
vars
)
}
rule Vertex2State {
from
v : UML!Vertex (v.oclIsTypeOf(UML!Vertex))
to
s : _IF!State (
id <- v.name
)
}
rule Property2Variables {
from
p : UML!Property
to
v : _IF!Vars (
name <- p.name,
mode <- thisModule.getParametersNode('null') ,
type <- p.getType()
)
}
|
|
|
Re: [ATL] [newbie] acces to enumeration [message #32763 is a reply to message #32738] |
Thu, 19 April 2007 05:45   |
Eclipse User |
|
|
|
Originally posted by: Hugo.Bruneliere.univ-nantes.fr
Tristan FAURE a écrit :
> First i'm sorry because i'm using the web interface of the newsgroup and
> i don't know if it is possible to join files so i will copy code here
> (if you know a newsgroup software which works with proxy :/)
>
> I'm also sorry the error was not the good there is no launching error
> but there is this trace in the console :
>
> ============================================================ ===
>
> ****** BEGIN Stack Trace
> message: cannot set feature _IF!Vars.mode to value null
> exception: java.lang.IllegalArgumentException: The value '' is not a
> valid enumerator of 'ParametersMode'
> at
> org.eclipse.emf.ecore.impl.EFactoryImpl.createFromString(EFa ctoryImpl.java:269)
>
> at
> org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.getDefault Value(EStructuralFeatureImpl.java:129)
>
> at
> org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.getSetting Delegate(EStructuralFeatureImpl.java:780)
>
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSettingDelegate (BasicEObjectImpl.java:1115)
>
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eDynamicSet(Basi cEObjectImpl.java:709)
>
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjec tImpl.java:683)
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjec tImpl.java:654)
> at
> org.atl.engine.repositories.emf4atl.ASMEMFModelElement.set(A SMEMFModelElement.java:226)
>
> at org.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:27 6)
> at org.atl.engine.vm.ASMOperation.exec(ASMOperation.java:155)
> at org.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java: 60)
> at org.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java: 50)
> at org.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:21 4)
> at org.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:30 9)
> at org.atl.engine.vm.ASMOperation.exec(ASMOperation.java:155)
> at org.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java: 60)
> at org.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java: 50)
> at org.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:21 4)
> at org.atl.engine.vm.ASMOperation.exec(ASMOperation.java:155)
> at org.atl.engine.vm.ASMInterpreter.<init>(ASMInterpreter.java:276)
> at org.atl.eclipse.engine.AtlLauncher.launch(AtlLauncher.java:1 36)
> at org.atl.eclipse.engine.AtlLauncher.launch(AtlLauncher.java:9 4)
> at org.atl.eclipse.engine.AtlLauncher.launch(AtlLauncher.java:6 8)
> at org.atl.eclipse.engine.AtlLauncher.launch(AtlLauncher.java:6 4)
> at
> org.atl.eclipse.adt.launching.AtlLaunchConfigurationDelegate .runAtlLauncher(AtlLaunchConfigurationDelegate.java:230)
>
> at
> org.atl.eclipse.adt.launching.AtlLaunchConfigurationDelegate .runAtlLauncher(AtlLaunchConfigurationDelegate.java:168)
>
> at
> org.atl.eclipse.adt.launching.AtlLaunchConfigurationDelegate .runAtlLauncher(AtlLaunchConfigurationDelegate.java:145)
>
> at
> org.atl.eclipse.adt.launching.AtlLaunchConfigurationDelegate .runAtlLauncher(AtlLaunchConfigurationDelegate.java:121)
>
> at
> org.atl.eclipse.adt.launching.AtlLaunchConfigurationDelegate .launch(AtlLaunchConfigurationDelegate.java:97)
>
> at
> org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:710)
>
> at
> org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:603)
>
> at
> org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(D ebugUIPlugin.java:754)
>
> at
> org.eclipse.debug.internal.ui.DebugUIPlugin$6.run(DebugUIPlu gin.java:944)
> at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)
> A.main() : ??#24 null
> local variables = {self=uml2if : ASMModule}
> local stack = []
> A.__exec__() : ??#38 null
> local variables = {e=TransientLink {rule = 'Property2Variables',
> sourceElements = {p = IN!cursor}, targetElements = {v = OUT!cursor},
> variables = {}}, self=uml2if : ASMModule}
> local stack = []
> A.__applyProperty2Variables(1 : NTransientLink;) : ??#21 75:25-75:69
> local variables = {v=OUT!cursor, p=IN!cursor, link=TransientLink
> {rule = 'Property2Variables', sourceElements = {p = IN!cursor},
> targetElements = {v = OUT!cursor}, variables = {}}, self=uml2if :
> ASMModule}
> local stack = [OUT!cursor]
> ****** END Stack Trace
> Execution terminated due to error (see launch configuration to allow
> continuation after errors).
>
> ============================================================ ===
>
> So this is my module it's just a prototype so it's not very big
>
> ============================================================ ===
> module uml2if; -- Module Template
> create OUT:_IF from IN:UML ;
>
> -- getting the enum value from a string
> helper def: getParametersMode(p : String) : IF!ParametersMode =
> if (p = 'null') then
> #null
> else
> if (p = 'out') then
> #out
> else
> #null
> endif
> endif
> ;
>
> helper context UML!Property def : getType() : String =
> (
> if (self.type = 'Integer') then
> 'integer'
> else
> 'integer1'
> endif
> ) ;
>
> helper context UML!Package def : getProcesses() : Set(UML!Class) = (
> self.ownedMember->select(a|a.oclIsTypeOf(UML!Class))
>
> );
>
> rule Package2System {
> from
> p : UML!Package (p.oclIsTypeOf(UML!Package))
> to
> s : _IF!System (
> id <- p.name,
> process <- p.getProcesses()
> )
> }
>
> rule Class2Process {
> from
> c : UML!Class (c.oclIsTypeOf(UML!Class))
> to
> s : _IF!Process (
> id <- c.name ,
> nbInstancesToStart <- '1',
> vars
> )
> }
>
> rule Vertex2State {
> from v : UML!Vertex (v.oclIsTypeOf(UML!Vertex))
> to s : _IF!State (
> id <- v.name
> )
> }
>
> rule Property2Variables {
> from p : UML!Property to
> v : _IF!Vars (
> name <- p.name,
> mode <- thisModule.getParametersNode('null') ,
> type <- p.getType()
>
> )
> }
>
Is the IF!Vars.mode attribute of type IF!ParametersMode in your IF
metamodel?
--
--------------------------------------------------------
Hugo Bruneliere - R&D Engineer
ATLAS Group (INRIA & LINA) - University of Nantes
2, rue de la Houssiniere
44322 Nantes Cedex 3 - France
office +33 2 51 12 58 10 /\ cell.+33 6 07 42 45 30
EMail: Hugo.Bruneliere@univ-nantes.fr
http://www.sciences.univ-nantes.fr/lina/atl/
--------------------------------------------------------
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04684 seconds