Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Call EGL file from Java application
Call EGL file from Java application [message #1749525] Wed, 07 December 2016 18:18 Go to next message
Juan Sanchez is currently offline Juan SanchezFriend
Messages: 4
Registered: December 2016
Junior Member
Hi,

I am trying to call my .egl file from a Java application. Is there any simple way to invoke the .egl from Java?. I'm trying something like this:

	
	EglModule module = new EglModule();
	module.parse(new File("modelToCode.egl").getAbsoluteFile());
        EglTemplateFactory factory = new EglTemplateFactory();
        File templateFile = new File("modelToCode.egl");
        EglTemplate template = factory.load(templateFile);
        module.execute(template);


I have tried the standalone example but it is not working.I have also seen other examples with a call like module.execute() without any parameters ...

I really appreciate any help you can provide.
Re: Call EGL file from Java application [message #1749540 is a reply to message #1749525] Wed, 07 December 2016 22:22 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 1520
Registered: July 2009
Location: York, UK
Senior Member

Hi,

The following should do the trick.

EglTemplateFactoryModuleAdapter module = new EglTemplateFactoryModuleAdapter(new EglTemplateFactory());
module.parse(new File("modelToCode.egl"));
System.out.println(module.execute());


If you wish to orchestrate more than one templates you may want to use EGX [1].

Cheers,
Dimitris

[1] https://www.eclipse.org/epsilon/doc/articles/code-generation-tutorial-egl/
Re: Call EGL file from Java application [message #1749544 is a reply to message #1749540] Thu, 08 December 2016 00:41 Go to previous messageGo to next message
Juan Sanchez is currently offline Juan SanchezFriend
Messages: 4
Registered: December 2016
Junior Member
Hi Dimitris,

Thanks for your response, unfortunately it doesn't works.

The error is the next:
Exception in thread "main" Method 'generate' not found for: org.eclipse.epsilon.egl.EglTemplate@2d6e8792
at (....modelToCode.egl)

The modelToCode.egl code is the next:
[%
var main: Template := TemplateFactory.load('main.egl');
main.generate('../gen/main.c');
%]


Any suggestion?
Re: Call EGL file from Java application [message #1749547 is a reply to message #1749544] Thu, 08 December 2016 01:49 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 1520
Registered: July 2009
Location: York, UK
Senior Member

Does switching

new EglTemplateFactoryModuleAdapter(new EglTemplateFactory()); 


for

new EglTemplateFactoryModuleAdapter(new EglFileGeneratingTemplateFactory()); 


work?

Cheers,
Dimitris

[Updated on: Thu, 08 December 2016 01:50]

Report message to a moderator

Re: Call EGL file from Java application [message #1749574 is a reply to message #1749547] Thu, 08 December 2016 09:48 Go to previous messageGo to next message
Juan Sanchez is currently offline Juan SanchezFriend
Messages: 4
Registered: December 2016
Junior Member
No, it doesn't work

Exception in thread "main" Type 'Graph' not found

How can I add my model to the adapter?

Thanks again.

[Updated on: Thu, 08 December 2016 09:49]

Report message to a moderator

Re: Call EGL file from Java application [message #1749578 is a reply to message #1749574] Thu, 08 December 2016 10:09 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 1520
Registered: July 2009
Location: York, UK
Senior Member

Hi Juan,

That's much better; now all the parsing stuff works. I'd suggest having a look at [1] to see how you can load models and make them available to Epsilon programs.

Cheers,
Dimitris

[1] https://git.eclipse.org/c/epsilon/org.eclipse.epsilon.git/plain/examples/org.eclipse.epsilon.examples.standalone/src/org/eclipse/epsilon/examples/standalone/

[Updated on: Thu, 08 December 2016 11:10]

Report message to a moderator

Re: Call EGL file from Java application [message #1749584 is a reply to message #1749578] Thu, 08 December 2016 11:10 Go to previous messageGo to next message
Juan Sanchez is currently offline Juan SanchezFriend
Messages: 4
Registered: December 2016
Junior Member
Thank you so much Dimitris it works perfectly Smile
Re: Call EGL file from Java application [message #1749585 is a reply to message #1749584] Thu, 08 December 2016 11:11 Go to previous message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 1520
Registered: July 2009
Location: York, UK
Senior Member

Hi Juan,

Glad to hear that! Any other problems, give us a shout.

Cheers,
Dimitris
Previous Topic:Type casting in EOL?
Next Topic:help me for Learning
Goto Forum:
  


Current Time: Tue Apr 24 09:07:45 GMT 2018

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

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