Skip to main content


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 11:38 Go to next message
yesheng chai is currently offline yesheng chaiFriend
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 16:16 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 674
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, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
Nantes - France
--------------------------------------------------------
Re: Generate Multiple Elements [message #1040344 is a reply to message #1039810] Sat, 13 April 2013 12:05 Go to previous messageGo to next message
yesheng chai is currently offline yesheng chaiFriend
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 21:31 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 674
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, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
Nantes - France
--------------------------------------------------------
Re: Generate Multiple Elements [message #1042084 is a reply to message #1041992] Tue, 16 April 2013 01:02 Go to previous message
yesheng chai is currently offline yesheng chaiFriend
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: Thu Apr 25 19:32:04 GMT 2024

Powered by FUDForum. Page generated in 0.02969 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top