Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Lazy rule: problem with a counter
Lazy rule: problem with a counter [message #1760875] Wed, 03 May 2017 20:35 Go to next message
im hello world is currently offline im hello worldFriend
Messages: 44
Registered: February 2017
Member
Hi,
I created a counter to increment the id of a LocReady:
helper def: counter: Integer =0;
lazy rule LocReady {
	from
		b: BP!Bo
	
	to
		locR: upp!Loc (
			id <- 'id0' + thisModule.counter)
do { 
		thisModule.counter<- thisModule.counter+1;
}
and i have a rule in which i call my lazy rule 'LocReady'
rule xyz{
(...)
source: upp!Source (
			ref <- thisModule.LocReady(b).refGetValue('id')),
 tr: upp!tr(
source <- source)   
}

i want to do a reference to the id of my LocReady in the rule xyz, the problem is with the counter, in the rule i notice that counter is always incremented(i get the id of locReady+1 and not the id. i note that i don't do an other incrementation in the rule
for example:
<locReady id="id09">
<tr>
<source id="id012">
what do you think the problem is?
thanks.

[Updated on: Thu, 04 May 2017 09:00]

Report message to a moderator

Re: Lazy rule: problem with a counter [message #1760918 is a reply to message #1760875] Thu, 04 May 2017 10:36 Go to previous messageGo to next message
im hello world is currently offline im hello worldFriend
Messages: 44
Registered: February 2017
Member
i have a counter incremented in a lazy rule which is still incremented in a matched rule when i call that lazy Rule, when,in the matched rule i just need a reference to the id created in the lazy rule.
Any Help Please.

regards
Re: Lazy rule: problem with a counter [message #1763657 is a reply to message #1760918] Thu, 18 May 2017 11:58 Go to previous messageGo to next message
im hello world is currently offline im hello worldFriend
Messages: 44
Registered: February 2017
Member
Hi,
Any idea can help me Please,

Regards
Re: Lazy rule: problem with a counter [message #1763800 is a reply to message #1763657] Fri, 19 May 2017 20:53 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 371
Registered: September 2012
Location: Belgium
Senior Member

I think your lazy rule returns the value of thisModule.counter rather than locR. Can you change your code as follows and try again:
lazy rule LocReady {
	from
		b: BP!Bo
	
	to
		locR: upp!Loc (
			id <- 'id0' + thisModule.counter)
do { 
		thisModule.counter<- thisModule.counter+1;
		locR;
}


Cheers,
Dennis
Re: Lazy rule: problem with a counter [message #1763857 is a reply to message #1763800] Mon, 22 May 2017 09:38 Go to previous messageGo to next message
im hello world is currently offline im hello worldFriend
Messages: 44
Registered: February 2017
Member
Hi Dennis,
Thank you very much,
but it doesn't work, i always get the same problem.
well, i tried to do the counter in a helper just like this

helper def: Id : Integer = 0;

 helper def: getId() : String =
 thisModule.refSetValue('Id', thisModule.Id + 1).Id.toString(); 

so my lazy rule becomes:

lazy rule LocReady {
	from
		b: BP!Bo
	
	to
		locR: upp!Loc (
			id <- 'id0' + thisModule.getId()
         ...)


and when i call it in my matched rule to reference to the id of locR i always get the same problem: the reference appear but,
it doesn't references to the locR id, it continues to be incremented , so as a result i get the wrong id reference.
I don't really find the cause that the id created in a lazyRule , when called in a matched rule, don't stop to be incremented

[Updated on: Mon, 22 May 2017 09:40]

Report message to a moderator

Re: Lazy rule: problem with a counter [message #1764487 is a reply to message #1763857] Tue, 30 May 2017 13:12 Go to previous messageGo to next message
im hello world is currently offline im hello worldFriend
Messages: 44
Registered: February 2017
Member
Hi Dennis,
sorry, please can you help me ?
Thank you a lot.
Re: Lazy rule: problem with a counter [message #1765114 is a reply to message #1764487] Tue, 06 June 2017 19:22 Go to previous message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 371
Registered: September 2012
Location: Belgium
Senior Member

I've did a small experiment with a counter helper, and found that it works (see attached Eclipse project). Perhaps the problem lies in your "xyz" rule?

Cheers,
Dennis
Previous Topic:problem with the iteration
Next Topic:xsi:schemaLocation in output XMI
Goto Forum:
  


Current Time: Mon Jul 16 20:22:28 GMT 2018

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

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

Back to the top