Home » Modeling » ATL » output structured model by called rules
output structured model by called rules [message #1005562] |
Sat, 26 January 2013 17:33 |
Alessandro Ranieri Messages: 16 Registered: November 2012 |
Junior Member |
|
|
Hello,
I want to know what is, for you, the best approach to my kind of problem:
I have to map an input element on an output element, but the latter has an internal structure such that i have to create other elements to complete the trasformation.
My first idea is to create the element of output model and then to invoke a called rule to create the nested elements.
Unfortunately performing this approach I encountered an error. For example:
rule process(stateMac : UML!StateMachine, component : UML!Class ){
to
process : PROMELA!process
(
name <- component.name,
mainLoop <- loop
),
loop : PROMELA!loop
(
cases <- stateMac.region.first().subvertex->collect( v | thisModule.createStateCond(v.name) )
)
}
rule createStateCond( state : String )
{
to
cond : PROMELA!condition
(
statement <- 'state == '.concat(state)
)
}
This example gave me the error:
org.eclipse.m2m.atl.engine.emfvm.VMException: Operation not found: vvp2promela : ASMModule.including(java.util.ArrayList)
at process#41(vvp2promela.atl[130:13-130:97])
local variables: self=vvp2promela : ASMModule, stateMac=TSR!TSR_Sm, component=TSR!TSR, states=Sequence {}, process=TSRPRO!TSR, loop=TSRPRO!<unnamed>, v=TSR!Initial0
at __applystatesTransitions2enumeration#105(vvp2promela.atl[101:3-101:43])
local variables: self=vvp2promela : ASMModule, link=TransientLink {rule = statesTransitions2enumeration, sourceElements = {stateMac = org.eclipse.uml2.uml.internal.impl.StateMachineImpl@1fb3806 (name: TSR_Sm, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false) (isReentrant: false), component = org.eclipse.uml2.uml.internal.impl.ClassImpl@1a85206 (name: TSR, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false)}, targetElements = {state_enum = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1615705 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@1766c97 (name: mtypeEnumeration) (instanceClassName: null) (abstract: false, interface: false)), transition_enum = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1981f83 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@1766c97 (name: mtypeEnumeration) (instanceClassName: null) (abstract: false, interface: false))}, variables = {}}, component=TSR!TSR, stateMac=TSR!TSR_Sm, state_enum=TSRPRO!state, transition_enum=TSRPRO!transition
at __exec__#18(vvp2promela.atl)
local variables: self=vvp2promela : ASMModule, e=TransientLink {rule = statesTransitions2enumeration, sourceElements = {stateMac = org.eclipse.uml2.uml.internal.impl.StateMachineImpl@1fb3806 (name: TSR_Sm, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false) (isReentrant: false), component = org.eclipse.uml2.uml.internal.impl.ClassImpl@1a85206 (name: TSR, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false)}, targetElements = {state_enum = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1615705 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@1766c97 (name: mtypeEnumeration) (instanceClassName: null) (abstract: false, interface: false)), transition_enum = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1981f83 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@1766c97 (name: mtypeEnumeration) (instanceClassName: null) (abstract: false, interface: false))}, variables = {}}
at main#26(vvp2promela.atl)
local variables: self=vvp2promela : ASMModule
Thanks in advance for the help!
Alessandro
[Updated on: Sat, 26 January 2013 18:55] Report message to a moderator
|
|
|
Re: output structured model with called rules [message #1005584 is a reply to message #1005562] |
Sat, 26 January 2013 19:41 |
|
Op 26/01/13 18:33, Alessandro Ranieri schreef:
> Hello,
>
> I want to know what is, for you, the best approach to my kind of problem:
>
> I have to map a input an element on an output element, but the latter has an
> internal structure such that i have to create other elements to complete the
> trasformation.
>
> My first idea is to create the element of output model and then to invoke a
> called rule to create the nested elements.
> Unfortunately performing this approach I encountered an error. For example:
>
>
> rule process(stateMac : UML!StateMachine, component : UML!Class ){
> to
> process : PROMELA!process
> (
> name <- component.name,
> mainLoop <- loop
> ),
> loop : PROMELA!loop
> (
> cases <- stateMac.region.first().subvertex->collect( v |
> thisModule.createStateCond(v.name) ) )
> }
>
>
> rule createStateCond( state : String )
> {
> to
> cond : PROMELA!condition
> (
> statement <- 'state == '.concat(state)
> )
> }
I recall a question similar to yours coming up in the newsgroups before, where
another user was also trying to program his/her own model traversal strategy.
This is not how to use ATL by default.
ATL has something called the "implicit tracing mechanism", which works only on
matched rules
(http://wiki.eclipse.org/ATL/User_Guide_-_The_ATL_Language#Matched_Rules).
This means that whenever you use the binding operator ('<-'), the right-hand
value is first checked against the transformation traces to see if the value
got transformed. I yes, the right-hand value is implicitly replaced by its
transformation result before being assigned.
Unfortunately, I found no good documentation on this on the ATL wiki(!). The
Class2Relational example is missing. Normally, Open Model Course Ware has this
tutorial (http://www.eclipse.org/gmt/omcw/), but it appears to have been
removed(?).
In any case, your specific transformation would follow this skeleton:
rule StateMachineToProcess
{
from
stateMac : UML!StateMachine
using {
component : UML!Class = stateMac...;
}
to
process : PROMELA!process
(
name <- component.name,
mainLoop <- loop
),
loop : PROMELA!loop
(
cases <- stateMac.region.first().subvertex
)
}
rule StateToCondition
{
from
state : UML!State
to
cond : PROMELA!condition
(
statement <- 'state == ' + state.toString()
)
}
In this transformation, stateMac.region.first().subvertex is automatically
translated from a collection of UML!State to a collection of
PROMELA!condition, because of the traces generated by the StateToCondition rule.
Regards,
Dennis
Cheers,
Dennis
|
|
| | | | |
Goto Forum:
Current Time: Thu Sep 26 06:39:41 GMT 2024
Powered by FUDForum. Page generated in 0.06487 seconds
|