Skip to main content



      Home
Home » Modeling » ATL » Lazy rule: problem with a counter
Lazy rule: problem with a counter [message #1760875] Wed, 03 May 2017 16:35 Go to next message
Eclipse UserFriend
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 05:00] by Moderator

Re: Lazy rule: problem with a counter [message #1760918 is a reply to message #1760875] Thu, 04 May 2017 06:36 Go to previous messageGo to next message
Eclipse UserFriend
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 07:58 Go to previous messageGo to next message
Eclipse UserFriend
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 16:53 Go to previous messageGo to next message
Eclipse UserFriend
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;
}
Re: Lazy rule: problem with a counter [message #1763857 is a reply to message #1763800] Mon, 22 May 2017 05:38 Go to previous messageGo to next message
Eclipse UserFriend
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 05:40] by Moderator

Re: Lazy rule: problem with a counter [message #1764487 is a reply to message #1763857] Tue, 30 May 2017 09:12 Go to previous messageGo to next message
Eclipse UserFriend
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 15:22 Go to previous message
Eclipse UserFriend
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?
Previous Topic:problem with the iteration
Next Topic:xsi:schemaLocation in output XMI
Goto Forum:
  


Current Time: Wed Jul 23 14:28:32 EDT 2025

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

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

Back to the top