Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Select the features to be transformed using if else statements in rules
Select the features to be transformed using if else statements in rules [message #1831167] Wed, 12 August 2020 21:18 Go to next message
Burak Karaduman is currently offline Burak KaradumanFriend
Messages: 84
Registered: July 2018
Member
Dear All,
rule SystemToIoTSystem {
	from
		pim: PIM!System
	to
		iot: PSM!IoTSystem (
			Name <- 'DesignIoTSystem',
			platformR <- pim.direct,							
			logman <- pim.logger,
			gateway <- pim.datacollector,
			
			[b]platform <-   if pim.indirect->size() >0 then
							pim.indirect
							else
								OclUndefined
							endif[/b]
		
		)
			
}



I already implemented using not a modular implementation.

It transforms pim.indirect to platform if the size of the usage is above 0 and else is OclUndefined, this rule works well Hoverwever, what I am trying to achieve is to make it more modular and functional as well as eliminating code repetition.


rule SystemToIoTSystem {
	from
		pim: PIM!System
	to
		iot: PSM!IoTSystem (
			Name <- 'DesignIoTSystem',
						
			logman <- pim.logger,
			gateway <- pim.datacollector,
			
			[b] if pim.indirect->size() >0 then
						platform <-  	pim.indirect
							else
						platformR <- pim.direct,				
							endif
		[/b]
		)
			
}


How can I make something like this, It gives errors. I also tried to do in "do { }". However it did not let me to use any feature mapping like " platformR <- pim.direct ".

Re: Select the features to be transformed using if else statements in rules [message #1831325 is a reply to message #1831167] Mon, 17 August 2020 12:57 Go to previous message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 581
Registered: September 2012
Location: Belgium
Senior Member

You can implement both scenarios in a separate rule, and use filter expressions in the "from" part to trigger the correct rule. To eliminate duplicate code, you can use rule inheritance:
-- @atlcompiler emftvm
module SystemToIoTSystem;
create OUT: PSM from IN: PIM;

abstract rule SystemToIoTSystem {
	from
		pim: PIM!System
	to
		iot: PSM!IoTSystem (
			name <- 'DesignIoTSystem',
			logman <- pim.logger,
			gateway <- pim.datacollector
		)
}

rule SystemToIoTSystemDirect extends SystemToIoTSystem {
	from
		pim: PIM!System (
			pim.indirect->isEmpty()
		)
	to
		iot: PSM!IoTSystem (
			platformR <- pim.direct
		)
}

rule SystemToIoTSystemIndirect extends SystemToIoTSystem {
	from
		pim: PIM!System (
			pim.indirect->notEmpty()
		)
	to
		iot: PSM!IoTSystem (
			platform <- pim.indirect
		)
}


Cheers,
Dennis
Previous Topic:Access to UML stereotypes from ATL EMFTVM script...
Next Topic:Need help with thisModule.resolveTemp(...)
Goto Forum:
  


Current Time: Sat Nov 11 08:18:03 GMT 2023

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

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

Back to the top