Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » [ATL] Unique rule has double output
[ATL] Unique rule has double output [message #1737819] Wed, 13 July 2016 09:25 Go to next message
Gunnar Arndt is currently offline Gunnar ArndtFriend
Messages: 62
Registered: June 2012
Member
Dear friends,

I've run into the strange situation that a 'unique lazy' rule seems to create double output, of which only one is finally inserted into the output model.
I run a validator on my output model after the ATL transformation has completed, and get the following error message:

Invalid content: ProcedureRealisation Error details: The required feature 'flow' of 'Procedure[592710.3]/ProcedureRealisation' must be set


The first part of the Procedure's ID (in the current case, 592710) is copied from the corresponding AbstractTreeTransformer in the input model, whereas the second part (3) is a counter that runs during the ATL transformation. The objects have a URL as meta data, so I can safely match objects of the input and the output model. Surprisingly, there is no Procedure with the ID 592710.3 in the output model - instead there is one with the ID 592710.61 for the corresponding AbstractTreeTransformer, which has the (also unique) Flow mentioned in the above error message.
The relevant part of the rules which creates the Procedure looks as follows:

unique lazy rule TreeWithoutJumps2Procedure {
	from
		  source: transformate!AbstractTreeTransformer
	to
		otxProcedure: otx!Procedure (
                        -- Copy the source's ID and append a counter.
			id <- source.getId()->debug('TreeWithoutJumps2Procedure::otxProcedure ' + source.sourceUrl),
    	                name <- source.hashBase('Procedure'),
			metaData <- thisModule.createMetaData(source.sourceUrl),
			realisation <- otxProcedureRealisation
		),
	    otxProcedureRealisation: otx!ProcedureRealisation (
			flow <- thisModule.Tree2StartFlow(source)
		),
		otxLocalDeclarations: otx!LocalDeclarations (
		)
	do {
 	    -- Continue transformation here (with the StartNode).
            -- The current rule can be called recursively!
		source.successor.growSelfFlow();
	}
}

unique lazy rule Tree2StartFlow {
	from
		source: transformate!AbstractTreeTransformer
	to
		flow: otx!Flow
}


The following debug message are printed from the first rule's 'to' block:

TreeWithoutJumps2Procedure::otxProcedure .../Pruefungen/CAN-Bus-OFF/Antriebs-CAN-Bus-OFF-Fehler: '592710.3'
TreeWithoutJumps2Procedure::otxProcedure .../Pruefungen/CAN-Bus-OFF/Antriebs-CAN-Bus-OFF-Fehler: '592710.61'


That suggests that the rule is indeed called twice, and creates different output each time. Have I misunderstood anything about 'unique' rules? Or is there a problem with the recursion mentioned in the 'do' block, by which the rule may be called recursively before it has returned from the first call (which, at closer sight, is the definition of recursion)?

A general hint on why I often use lazy rules, both unique and non-unique ones: I transform between the storage formats of graphical programming languages, which means that there are procedures and variables, which are declared once (matched rule or unique lazy rule), and can be referenced or called often (non-unique lazy rule). As in the given case, there is both a procedure and a variable for the input object, matched rules alone wouldn't do the trick - unique lazy rules allow the required output object to be acquired for each use case (procedure call, variable assignment, whatever). That seems to go wrong somehow, so I'm looking forward to your ideas what I can do about it.
Re: [ATL] Unique rule has double output [message #1738072 is a reply to message #1737819] Fri, 15 July 2016 14:41 Go to previous message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 351
Registered: September 2012
Location: Belgium
Senior Member

Recursion in unique lazy rules is problematic when calling the same rule with the same input twice. This is because the rule is only considered "invoked" on a certain input when its return value has become available (subsequent invocations on the same input will directly return the stored return value).

Cheers,
Dennis
Previous Topic:Can't use lazy rules with EMFTVM in Refining mode
Next Topic:Refining Mode: Clone Element and add it to same parent
Goto Forum:
  


Current Time: Tue Nov 21 04:42:50 GMT 2017

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

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