Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Convert Float to Double - by refInvokeOperation?
Convert Float to Double - by refInvokeOperation? [message #987622] Tue, 27 November 2012 10:56 Go to next message
Gunnar Arndt is currently offline Gunnar ArndtFriend
Messages: 82
Registered: June 2012
Member
Hi members,

I'm trying to assign a Float value from a source model object to a Double attribute of the matching target model object:

rule Real2Term {
    from
    	source: transformate!RealTransformer
    to
    	otxTerm: otx!FloatLiteral (
    		value <- source.value -> refInvokeOperation('doubleValue', Sequence{})
    	)
}

which produces the error
org.eclipse.m2m.atl.engine.emfvm.VMException: Wrong use of refInvokeOperation
.
otxTerm.value is Double, source.value is Float. There is no doubleValue helper (similar to longValue), so I'm trying to access the Java method, which fails.
Thanks for helping.
Re: Convert Float to Double - by refInvokeOperation? [message #987635 is a reply to message #987622] Tue, 27 November 2012 11:42 Go to previous messageGo to next message
Gunnar Arndt is currently offline Gunnar ArndtFriend
Messages: 82
Registered: June 2012
Member
This seems to do the required transformation from Float to Double:
rule Real2Term {
    from
    	source: transformate!RealTransformer
    to
    	otxTerm: otx!FloatLiteral (
    		value <- 1.0 * source.value
    	)
}


However, I would be glad if you could provide an example on how to use refInvokeOperation. I have tried to do that several times unsuccessfully.
Thank you.
Re: Convert Float to Double - by refInvokeOperation? [message #987655 is a reply to message #987635] Tue, 27 November 2012 13:05 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 674
Registered: July 2009
Senior Member
The refInvokeOperation allows to call an operation of a given element type.
For instance considering an operation SampleOperation defined for the type transformate!RealTransformer in your example, it could be called like this:
source.refInvokeOperation('SampleOperation',Sequence{})

Hugo


--------------------------------------------------------
Hugo Bruneliere, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
Nantes - France
--------------------------------------------------------
Re: Convert Float to Double - by refInvokeOperation? [message #987666 is a reply to message #987622] Tue, 27 November 2012 13:53 Go to previous messageGo to next message
Gunnar Arndt is currently offline Gunnar ArndtFriend
Messages: 82
Registered: June 2012
Member
Hugo,

do I understand correctly that refInvokeOperation can only be used for model elements, but not - as I tried to do - for their attributes of 'plain' Java types, like Float in the given example?
Re: Convert Float to Double - by refInvokeOperation? [message #987671 is a reply to message #987666] Tue, 27 November 2012 14:21 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
refInvokeOperation has no sense if the method name is a contant.
This method is to be used with a variable method name otherwise you can call the method directly.
Re: Convert Float to Double - by refInvokeOperation? [message #987678 is a reply to message #987622] Tue, 27 November 2012 14:46 Go to previous message
Gunnar Arndt is currently offline Gunnar ArndtFriend
Messages: 82
Registered: June 2012
Member
Sylvain, I'm still not getting it - does that mean an ATL method (= a helper), or a Java method?
In other words: How to call a method 'directly'?
Previous Topic:ATL plugin in Eclipse
Next Topic:EDate in the transformations
Goto Forum:
  


Current Time: Wed Apr 24 22:52:34 GMT 2024

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

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

Back to the top