Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » re-execute rule to duplicate object generation
re-execute rule to duplicate object generation [message #632517] Wed, 13 October 2010 09:53 Go to next message
James Sharp is currently offline James SharpFriend
Messages: 20
Registered: September 2010
Junior Member
Hi Chaps,

I need to be able to create certain elements more than once. To do this I thought it would just be necessary to write:

cProc.definesParameters := vProc.reactsTo.equivalent();
cProcPrime.definesParameters := vProc.reactsTo.equivalent();

However this shifts the ownership of the generate objects, how can I force ETL to re-run the rule and regenerate the elements?


Also is there a way of specifying using equivalent() or equivalents() a method for calling certain rules which have a particular output.

My translation requires that I distinguish between different port types by thier direction and create different target elements accordingly. How can I separate the calling of these two rules?

Many Thanks,

James
Re: re-execute rule to duplicate object generation [message #632538 is a reply to message #632517] Wed, 13 October 2010 10:33 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi James,

James Sharp wrote:
> Hi Chaps,
>
> I need to be able to create certain elements more than once. To do this
> I thought it would just be necessary to write:
>
> cProc.definesParameters := vProc.reactsTo.equivalent();
> cProcPrime.definesParameters := vProc.reactsTo.equivalent();
>
> However this shifts the ownership of the generate objects, how can I
> force ETL to re-run the rule and regenerate the elements?

You'll need to use an operation instead of a rule in this case (rules
are executed only once per source element).

>
>
> Also is there a way of specifying using equivalent() or equivalents() a
> method for calling certain rules which have a particular output.
> My translation requires that I distinguish between different port types
> by thier direction and create different target elements accordingly. How
> can I separate the calling of these two rules?

A solution to this might be to specify two rules with appropriate guards.

>
> Many Thanks,
>
> James

Cheers,
Dimitris
Re: re-execute rule to duplicate object generation [message #632595 is a reply to message #632538] Wed, 13 October 2010 14:24 Go to previous messageGo to next message
James Sharp is currently offline James SharpFriend
Messages: 20
Registered: September 2010
Junior Member
Hi Dimitris,

Thanks for the clarification, I will convert to an operation as suggested.

RE the calling of different rules, I already use two different rules with guards.

However they were both being called using equivalent() and as one returned a different object type then this cas causing issues.
I have found that if I make one rule lazy and one rule normal and rely on the normal rule to sort itself out this resolves the issue.


Thanks for your help,

Cheers,

James
Re: re-execute rule to duplicate object generation [message #632605 is a reply to message #632595] Wed, 13 October 2010 14:56 Go to previous messageGo to next message
James Sharp is currently offline James SharpFriend
Messages: 20
Registered: September 2010
Junior Member
Hi Dimitris,

Sorry but this doesn't seem to have worked - I had left a line commented out that I shouldn't have.

I have the line:

c.containsChannels.addAll(v.containsEntity.definesPort.equiv alent());

This should in theory call the lazy rule:
@lazy
rule OutputPort2Channel
transform port : vhdl!Port
to channel : csp!Channel {
guard : port.hasDirection.name.toLowerCase() == "out"
channel.name = port.name;
channel.definesParameters := new csp!ChannelParameterList;
only one element assigned to OutputPorts
var typeRef = new csp!TypeRef;
typeRef.containsType := GetDataType(port);

channel.definesParameters.parameterTypes.add(typeRef);

}
However it seems that the result of the equivalent() that I am using here is returning the following:
Bag {TypeRef [], TypeRef [], TypeRef [], TypeRef [], Channel [name=ready, ], Channel [name=dispense, ], Channel [name=ret, ], Channel [name=coin, ]}

This is returning the values not only from the rule specified above but also from one of the normal rules as well. How can I stop this equivalent() from running on a normal rule? Or just ensure that only the lazy rule abore is run?

Many Thanks,

James
Re: re-execute rule to duplicate object generation [message #632621 is a reply to message #632605] Wed, 13 October 2010 15:22 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi James,

I'm afraid you can't. You should either filter the results of
v.containsEntity.definesPort.equivalent() or replace the Port->Channel
rules with operations so that you get more fine-grained control.

Cheers,
Dimitris

James Sharp wrote:
> Hi Dimitris,
>
> Sorry but this doesn't seem to have worked - I had left a line commented
> out that I shouldn't have.
>
> I have the line:
>
> c.containsChannels.addAll(v.containsEntity.definesPort.equiv alent());
>
> This should in theory call the lazy rule:
> @lazy
> rule OutputPort2Channel
> transform port : vhdl!Port
> to channel : csp!Channel {
> guard : port.hasDirection.name.toLowerCase() == "out"
> channel.name = port.name;
> channel.definesParameters := new csp!ChannelParameterList;
> only one element assigned to OutputPorts
> var typeRef = new csp!TypeRef;
> typeRef.containsType := GetDataType(port);
>
> channel.definesParameters.parameterTypes.add(typeRef);
>
> }
> However it seems that the result of the equivalent() that I am using
> here is returning the following:
> Bag {TypeRef [], TypeRef [], TypeRef [], TypeRef [], Channel
> [name=ready, ], Channel [name=dispense, ], Channel [name=ret, ], Channel
> [name=coin, ]}
>
> This is returning the values not only from the rule specified above but
> also from one of the normal rules as well. How can I stop this
> equivalent() from running on a normal rule? Or just ensure that only the
> lazy rule abore is run?
>
> Many Thanks,
>
> James
Re: re-execute rule to duplicate object generation [message #632626 is a reply to message #632621] Wed, 13 October 2010 15:53 Go to previous messageGo to next message
James Sharp is currently offline James SharpFriend
Messages: 20
Registered: September 2010
Junior Member
Hi Dimitris,

Thanks, didn't realise a restirction before a .equivalent() was possible:

c.containsChannels.addAll(v.containsEntity.definesPort.selec t(port : vhdl!Port|port.hasDirection.name.toLowerCase() == "out").equivalent());


If I have placed this restriction before the equivalent, is the guard still required within the lazy rule now (as seen below)?

@lazy
rule OutputPort2Channel
transform port : vhdl!Port
to channel : csp!Channel {
guard : port.hasDirection.name.toLowerCase() == "out"

Cheers,

James
Re: re-execute rule to duplicate object generation [message #632630 is a reply to message #632626] Wed, 13 October 2010 16:00 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi James,

I think you'll still need the guard. To reduce duplication you could
define an operation vhdl!Port isOut() { return
self.hasDirection.name..toLowerCase() == "out";} and call it from both
places in your code.

Cheers,
Dimitris

James Sharp wrote:
> Hi Dimitris,
>
> Thanks, didn't realise a restirction before a .equivalent() was possible:
>
> c.containsChannels.addAll(v.containsEntity.definesPort.selec t(port :
> vhdl!Port|port.hasDirection.name.toLowerCase() == "out").equivalent());
>
>
> If I have placed this restriction before the equivalent, is the guard
> still required within the lazy rule now (as seen below)?
>
> @lazy
> rule OutputPort2Channel
> transform port : vhdl!Port
> to channel : csp!Channel {
> guard : port.hasDirection.name.toLowerCase() == "out"
> Cheers,
>
> James
Previous Topic:Assigning rule generated target model elements to a contained reference
Next Topic:Running ETL examples
Goto Forum:
  


Current Time: Sat Nov 22 17:00:12 GMT 2014

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

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