Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » mutual calling relationship
mutual calling relationship [message #1841436] Mon, 17 May 2021 02:54 Go to next message
永祺 卜 is currently offline 永祺 卜Friend
Messages: 1
Registered: May 2021
Junior Member
hello everyone
When I transform the two models through ATL, due to the sequence of code execution, I found that if I transform two elements with mutual calling relationship, the former elements will not be able to call the latter elements. I tried many methods, but they can't solve it. I hope you can give me some help. Thank you!
lazy rule Task2Interaction {
	from
		ta : IS!Actor
	using{    
		callm:RE!CallMessage=ta.intentionalelement->select(e | e.oclIsTypeOf(IS!Task))->collect(e | thisModule.Task2CallMessages(e));
		
		mes:RE!MessageEnd=IS!Task.allInstances()->collect(e | thisModule.Task2MessageEndS(e));
		
	}
	to 
		inter : RE!Interaction (
			name <- ta.name,
			
			messages <- callm ,
			ends <- mes
		) 
}
lazy rule Task2MessageEndS {
	from
		ta : IS!Task
	to 
		mes : RE!MessageEnd (
			name <- ta.name+'Sender',
			
			message <- IS!Task.allInstances()->select(e | e.name=ta.name).asSequence()
			->collect(e |RE!CallMessage.allInstances()->select(message | message.name=e.name))

		)
}
lazy rule Task2CallMessages {
	from
		ta : IS!Task
	to 
		cme : RE!CallMessage (
			name <- ta.name,
			
			receivingEnd <- IS!Task.allInstances()->select(e | e.name+'Sender'=ta.name+'Sender').asSequence()
			->collect(e |RE!MessageEnd.allInstances()->select(receivingEnd | receivingEnd.name=e.name+'Sender'))
		)		
}
Re: mutual calling relationship [message #1841481 is a reply to message #1841436] Tue, 18 May 2021 16:03 Go to previous message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 581
Registered: September 2012
Location: Belgium
Senior Member

It is not directly clear to me how the different RE!MessageEnd and RE!CallMessage elements should relate to each other: they are created according to different logic in the Task2Interaction rule., and the code used to "find" related target elements in Task2MessageEndS and Task2CallMessages simply seems to fetch all elements generated by the other rule (which is impossible).

In any case, you cannot navigate the target model, so you cannot find elements generated by other rules without using ATL's tracing mechanism. If you're able to use unique lazy rules, you can just invoke the rule multiple times on the same input element, and it will always return the same output element. Whenever you need to access the output element, you just invoke the unique lazy rule again on its corresponding input element and capture the return value. Caveat: in the case of bidirectional dependencies between two target elements, you MUST generate them from the same (unique) lazy rule, or you will trigger an infinite loop.

If you can specify a global condition for when certain output elements should be created ("for all ..."), you can use ATL's normal matched rules. Matched rules allow you to work with bidirectional dependencies between output elements spread across different rules via implicit source-to-target element tracing.

Is there a specific reason why you chose to use lazy rules instead of normal rules?


Cheers,
Dennis
Previous Topic:ATL 4.4.0 release
Next Topic:Executing ATL Launcher with 2 MetaModels as input
Goto Forum:
  


Current Time: Sat Nov 11 08:17:29 GMT 2023

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

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

Back to the top