Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Generate Multiple Elements
Generate Multiple Elements [message #1039633] Fri, 12 April 2013 07:38 Go to next message
yesheng chai is currently offline yesheng chai
Messages: 64
Registered: March 2013
Member
I encountered a problem and need your help in my ATL project. I
don't know how to define my rule . I want to get the file like:
<place name="a",id="1",ref="....">
<place name="b",id="2",ref="....">
<place name="c",id="3",ref="....">
The number of generated place elements was determined by the value of
atrribute capacity of source element.The reference need intialized with
other pattern element .
rule{
from s;MM!node
to t1:NN!place(
.........
)

}
How to define this rule?
Look forward to your reply!
Re: Generate Multiple Elements [message #1039810 is a reply to message #1039633] Fri, 12 April 2013 12:16 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo Bruneliere
Messages: 603
Registered: July 2009
Senior Member
Hello,

The order of the Place elements are not going to be determined by the NodeToPlace rule, it is only creating a Place out of a Node as it has to be.
This order is going to be determined by the reference (in another model element) that will actually "contain" these Place elements.
For instance:
rule XXXtoYYY {
   from
      x: MM!XXX
   to
      y: NN!YYY (
         places <- x.nodes->sortedBy(n | n.id)
      )

Best regards,

Hugo


------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
Re: Generate Multiple Elements [message #1040344 is a reply to message #1039810] Sat, 13 April 2013 08:05 Go to previous messageGo to next message
yesheng chai is currently offline yesheng chai
Messages: 64
Registered: March 2013
Member
I am sorry that I do not make clear my question.
For instance:
rule XXXtoYYY {
from
x: MM!XXX
to
y: NN!YYY (
......
)

xxx has a attribute cap.If the value of cap is 2,I want to get like:
<YYY ....>
<YYY ....>
If the value of cap is 3,I want to get like:
<YYY ....>
<YYY ....>
<YYY ....>
The value of cap is determined by input file.
How to define my rule?
Re: Generate Multiple Elements [message #1041992 is a reply to message #1040344] Mon, 15 April 2013 17:31 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo Bruneliere
Messages: 603
Registered: July 2009
Senior Member
Hello,

In that specific case, you can use a (unique) lazy rule that you can call multiple times as explained from http://wiki.eclipse.org/ATL/User_Guide_-_The_ATL_Language#Lazy_Rules.
However, note that the preferred type of rule in ATL is matched rules and that so-called lazy rules have to be used only when actually needed.

Best regards,

Hugo


------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
Re: Generate Multiple Elements [message #1042084 is a reply to message #1041992] Mon, 15 April 2013 21:02 Go to previous message
yesheng chai is currently offline yesheng chai
Messages: 64
Registered: March 2013
Member
Thank you very much !
Can you reply to the post whose name is "no one knows how to solve this problem" ?
Previous Topic:Get the value of MARTE element
Next Topic:EMFTVM: Problem using EDataType objects as parameter of lazy rules
Goto Forum:
  


Current Time: Fri Aug 29 14:16:50 EDT 2014

Powered by FUDForum. Page generated in 0.01849 seconds