Home » Archived » M2M (model-to-model transformation) » [ATL] : Insertion Order in Sequence ?
[ATL] : Insertion Order in Sequence ? [message #39609] |
Mon, 21 May 2007 09:57 |
Eclipse User |
|
|
|
Originally posted by: tristan.faure.c-s.fr
I have a question about the insertion in a Sequence
I have an attribute fparamters where i have to insert parameters if i code
in a matched rule
fparameters <- thisModule.newVariable ('1'),
fparameters <- thisModule.newVariable ('2'),
fparameters <- thisModule.newVariable ('3'),
fparameters <- thisModule.newVariable ('4')
Is the insertion order is guarantee ? because i checked in the xml
generated and it is in the invert order . . . what is precnised by ATL for
insertion ?
|
|
| |
Re: [ATL] : Insertion Order in Sequence ? [message #39735 is a reply to message #39642] |
Mon, 21 May 2007 15:51 |
Frédéric Jouault Messages: 572 Registered: July 2009 |
Senior Member |
|
|
Hi Tristan,
> I have a question about the insertion in a Sequence
>
> I have an attribute fparamters where i have to insert parameters if i
> code in a matched rule
>
> fparameters <- thisModule.newVariable ('1'),
> fparameters <- thisModule.newVariable ('2'),
> fparameters <- thisModule.newVariable ('3'),
> fparameters <- thisModule.newVariable ('4')
>
> Is the insertion order is guarantee ? because i checked in the xml
> generated and it is in the invert order . . . what is precnised by ATL
> for insertion ?
You should rather write something like:
fparameters <- Sequence {
thisModule.newVariable ('1'),
thisModule.newVariable ('2'),
thisModule.newVariable ('3'),
thisModule.newVariable ('4')
}
This way, you explicitly state that you use a Sequence and initialize
fparameters only once, which results in simpler code.
Note that the fparameters reference must also be ordered in the
metamodel for this to work.
> hum sorry i think my question was a little stupid i didn't checked
> correctly . . . the order is good in my xml
Considering that I still have something to say about this issue even
though you reported it was solved, I do think your question is
interesting anyway :-).
Best regards,
Frédéric Jouault
|
|
|
Re: [ATL] : Insertion Order in Sequence ? [message #39827 is a reply to message #39735] |
Tue, 22 May 2007 08:21 |
Eclipse User |
|
|
|
Originally posted by: tristan.faure.c-s.fr
Thank you for your answer but i have something strange with this solution
...
I've this code =>
rule Package2System {
from
p : UML!Package (p.oclIsTypeOf(UML!Package))
using {
seq : Sequence(UML!Operations) = p.getOperations() ;
}
to
s : _IF!System (
id <- p.name,
signal <- completesignal,
signal <- callsignal,
signal <- returnsignal,
process <- p.getProcesses(),
process <- thisModule.createGroupManager(),
),
completesignal : _IF!Signal (
id <- 'u2i__complete'
),
callsignal : distinct _IF!Signal foreach (e in seq)(
id <- 'u2i__call_' + e.owner.name + '_' + e.name,
-- default parameters for a call signal
fparameters <- Sequence {
thisModule.newVariable ('waiting','pid'),
thisModule.newVariable ('caller','pid'),
thisModule.newVariable ('callerObj','pid'),
thisModule.newVariable ('callee','pid')
}
),
returnsignal : distinct _IF!Signal foreach (i in seq)(
id <- 'u2i__return_' + i.owner.name + '_' + i.name,
-- default parameters for a return signal
fparameters <- Sequence{ thisModule.newVariable ('callerObj','pid'),
thisModule.newVariable ('callee','pid')
}
)
}
and the code for newVariable :
rule newVariable(sid : String, thetype : String) {
to
v : _IF!Vars (
name <- sid,
type <- thetype
)
do {
v ;
}
}
and i have a null pointer execution ...
the most strange is the xml state at the end of the execution each
variable is in a different signal
<signal id="u2i__call_Stack_opcs_pop">
<fparameters type="pid" name="waiting"/>
</signal>
<signal id="u2i__call_Stack_opcs_push">
<fparameters type="pid" name="caller"/>
</signal>
<signal id="u2i__call_Stack_pop">
<fparameters type="pid" name="callerObj"/>
</signal>
<signal id="u2i__call_Stack_push">
<fparameters type="pid" name="callee"/>
and what i want is all the variable in each state ....
It worked correctly without the Sequence {....
Regards
Tristan FAURE
|
|
|
Re: [ATL] : Insertion Order in Sequence ? [message #40012 is a reply to message #39827] |
Tue, 22 May 2007 11:03 |
Frédéric Jouault Messages: 572 Registered: July 2009 |
Senior Member |
|
|
Hello,
Your problem seems to be with the iterative target pattern element
(i.e., "distinct"-"foreach").
Please, see the following post, which deals with a similar issue:
http://dev.eclipse.org/newslists/news.eclipse.modeling.m2m/m sg00815.html
Regards,
Frédéric Jouault
Tristan FAURE wrote:
> Thank you for your answer but i have something strange with this
> solution ...
>
> I've this code =>
> rule Package2System {
> from
> p : UML!Package (p.oclIsTypeOf(UML!Package))
> using {
> seq : Sequence(UML!Operations) = p.getOperations() ;
> }
> to
> s : _IF!System (
> id <- p.name,
> signal <- completesignal,
> signal <- callsignal,
> signal <- returnsignal,
> process <- p.getProcesses(),
> process <- thisModule.createGroupManager(),
> ),
> completesignal : _IF!Signal (
> id <- 'u2i__complete'
> ),
> callsignal : distinct _IF!Signal foreach (e in seq)(
> id <- 'u2i__call_' + e.owner.name + '_' + e.name,
> -- default parameters for a call signal
> fparameters <- Sequence {
> thisModule.newVariable ('waiting','pid'),
> thisModule.newVariable ('caller','pid'),
> thisModule.newVariable ('callerObj','pid'),
> thisModule.newVariable ('callee','pid')
> }
> ),
> returnsignal : distinct _IF!Signal foreach (i in seq)(
> id <- 'u2i__return_' + i.owner.name + '_' + i.name,
> -- default parameters for a return signal
> fparameters <- Sequence{ thisModule.newVariable
> ('callerObj','pid'),
> thisModule.newVariable ('callee','pid')
> }
> )
> }
>
> and the code for newVariable :
>
> rule newVariable(sid : String, thetype : String) {
> to v : _IF!Vars (
> name <- sid,
> type <- thetype
> )
> do {
> v ;
> }
> }
>
> and i have a null pointer execution ... the most strange is the xml
> state at the end of the execution each variable is in a different signal
>
> <signal id="u2i__call_Stack_opcs_pop">
> <fparameters type="pid" name="waiting"/>
> </signal>
> <signal id="u2i__call_Stack_opcs_push">
> <fparameters type="pid" name="caller"/>
> </signal>
> <signal id="u2i__call_Stack_pop">
> <fparameters type="pid" name="callerObj"/>
> </signal>
> <signal id="u2i__call_Stack_push">
> <fparameters type="pid" name="callee"/>
>
> and what i want is all the variable in each state .... It worked
> correctly without the Sequence {....
>
> Regards
>
> Tristan FAURE
>
|
|
|
Re: [ATL] : Insertion Order in Sequence ? [message #40074 is a reply to message #40012] |
Tue, 22 May 2007 12:38 |
Eclipse User |
|
|
|
Originally posted by: tristan.faure.c-s.fr
I'm sorry my two posts seems equivalent but i think you answer to my other
post. (that i'm trying to resolve with your solution) but here I applied
Sequence {thisModule.NewVariable, .... } and it doesn't work
I'm sorry :s
|
|
| | | |
Re: [ATL] : Insertion Order in Sequence ? [message #59362 is a reply to message #39735] |
Fri, 24 August 2007 14:19 |
Eclipse User |
|
|
|
Originally posted by: r.c.ladan.tue.nl
Frédéric Jouault wrote:
> Hi Tristan,
>
> > I have a question about the insertion in a Sequence
> >
> > I have an attribute fparamters where i have to insert parameters if i
> > code in a matched rule
> >
> > fparameters <- thisModule.newVariable ('1'),
> > fparameters <- thisModule.newVariable ('2'),
> > fparameters <- thisModule.newVariable ('3'),
> > fparameters <- thisModule.newVariable ('4')
> >
> > Is the insertion order is guarantee ? because i checked in the xml
> > generated and it is in the invert order . . . what is precnised by ATL
> > for insertion ?
>
> You should rather write something like:
>
> fparameters <- Sequence {
> thisModule.newVariable ('1'),
> thisModule.newVariable ('2'),
> thisModule.newVariable ('3'),
> thisModule.newVariable ('4')
> }
>
> This way, you explicitly state that you use a Sequence and initialize
> fparameters only once, which results in simpler code.
>
> Note that the fparameters reference must also be ordered in the
> metamodel for this to work.
>
[hijacking the thread...]
I have these definitions in my .km3 file :
class BehaviourElement {
...
}
class ClassInstance extends BehaviourElement {
...
reference message[*] : Message oppositeOf classinstance;
...
}
class Message extends BehaviourElement {
...
reference classinstance[1-2] ordered : ClassInstance oppositeOf message;
...
}
but if I assign a Sequence value to the classinstance reference it sometimes comes out reversed
i.e. Sequence{1,2} becomes Sequence{2,1}, but other times the assignment is in order. It seems
to happen when assigning the Sequence value to a reference which also got assigned to in its parent
ATL rule, i.e. :
rule a {
from be : BehaviourElement
to be1 : BehaviourElement(
...
classinstance <- Sequence{r1}
...
)
...
}
rule b extends a {
from be : BehaviourElement(strict)
to be1 : BehaviourElement(
...
classinstance <- Sequence{r2,r3} -- outcome could be anything
...
},
be2 : BehaviourElement(
...
classinstance <- Sequence{r2,r3} -- ok
...
)
}
I guess the ATL engine looses track of order when merging the old and new sequences?
Since I need to filter out some elements, having a fixed order would be quite convenient.
This is with atl2006 and ATL 2.0RC2 (CVS 2007-08-24).
Thanks,
Rene
|
|
|
Goto Forum:
Current Time: Wed Apr 24 16:44:55 GMT 2024
Powered by FUDForum. Page generated in 0.03690 seconds
|