Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » get the instance of the Main AcceleoGenerator class from query invoke
get the instance of the Main AcceleoGenerator class from query invoke [message #1841980] Sat, 05 June 2021 17:21 Go to next message
Thomas Barth is currently offline Thomas BarthFriend
Messages: 14
Registered: March 2021
Junior Member
Hi,

I want to access the instance of the Main class (extends AbstractAcceleoGenerator) with which a model is generated from a java method which is invoked by an acceleo query.

How to do so?

For now I use static members but this certainly dirty and unstable.

[Updated on: Sat, 05 June 2021 17:22]

Report message to a moderator

Re: get the instance of the Main AcceleoGenerator class from query invoke [message #1841981 is a reply to message #1841980] Sat, 05 June 2021 18:39 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7265
Registered: July 2009
Senior Member
HI

invoke is used to extend the model capabilities. The Main class is an implementation artefact that is noting to do with modeling so from a purist perspective it should be invisible.

Using static instances seems like a very sensible approach.

If you really wanted to be elegant, you could create an Acceleo tooling model to represent all the hidden artefacts so that a single invoke could give you a handle on the modelled Acceleo tooling. You could do this but why bother?

Regards

Ed Willink
Re: get the instance of the Main AcceleoGenerator class from query invoke [message #1841984 is a reply to message #1841981] Sat, 05 June 2021 20:31 Go to previous messageGo to next message
Thomas Barth is currently offline Thomas BarthFriend
Messages: 14
Registered: March 2021
Junior Member
Hi Ed,

for now static is OK as the generator is used within eclipse by a single human user so as far as I understood the system, there cannot be more that one instance at a time.

Not sure if I got you right but extending the model to contain a handle to the instance sounds like a very good approach, Ill try that.

There are two reasons why I want to try it.
1: Im not too sure on this one as I only have a rough Idea on how to do it but maybe at some point I want to take the code and offer the Model to Text Generation as a service where I would need some kind of scheduler to ensure the jobs are sequentially executed or I need to ensure that multiple instances can operation without interfering.
2: It feels hacky and dirty to take an object oriented approach and mix it with static variables which actually belong to the object and not to the class.

Thanks a lot for the inspiration and thanks a lot for helping me (and the other guys) in general, I really appreciate it.
Re: get the instance of the Main AcceleoGenerator class from query invoke [message #1841988 is a reply to message #1841984] Sun, 06 June 2021 06:49 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7265
Registered: July 2009
Senior Member
Hi

If you are enthusiastic about Acceleo and want to make it available in a different context, I recommend that you establish a close relationship with the Acceleo team so that your work can enhance rather than fork Acceleo.

I fear that you may find that your users have different metamodel resolution requirements and so you may find that the current URI fudge, that only works for simple models, has to be revisited. You may find that other pain points also justify your time.

wrt an Acceleo tooling model, consider a similar Eclipse tooling model, which already exists as workbench.xmi which instantiates many metamodels such as http://www.eclipse.org/ui/2010/UIModel/application. You could write a Java invoke to get at the Workbench root and from there, an Acceleo M2T could locate many other things. But again I ask why bother? If a user really wants so much insight at the Java level, much better to program in Java or Xtend. I really doubt such users exist.

In a web application, providing an ability for users to browse the underlying application will of course aggravate security challenges,

Truly static in a multi-use application could well be a serious problem. The easiest solution is to ensure that each use runs a new copy of the Acceleo application. Else each use creates a new worker thread and you use ThreadLocals. New copies have the major advantage that it is really hard for one usage to crash the overall application and so mess up other usages. New threads allow test harnesses to simulate multiple concurrent usages. Maybe new runs and worker threads.

Regards

Ed Willink

[Updated on: Sun, 06 June 2021 07:03]

Report message to a moderator

Re: get the instance of the Main AcceleoGenerator class from query invoke [message #1841991 is a reply to message #1841988] Sun, 06 June 2021 11:33 Go to previous messageGo to next message
Thomas Barth is currently offline Thomas BarthFriend
Messages: 14
Registered: March 2021
Junior Member
Hi,

the metamodel would be fixed and the service would only offer generation for this one metamodel.

Let me summarize what I do and where I want to go with it:
As part of my PhD Thesis I defined a EMF metamodel describing a (safety)(multicore) deeply embedded system.
http://www.barth-dev.de/wp-content/uploads/2020/02/Session_4.2_Barth_paper.pdf
Signalflows can be drawn with Sirius and an model specific runtime environment as well as a safety report can be generated with Acceleo.
For now the Runtime Environment utilizes an underlying Realtime Operating System but I plan to get rid of that part after the PhD so that the runtime environment also handles scheduling, memory protections, stacks etc. and becomes a "all in one" solution but Im not sure if it really works outside of my head.
A prototype of the tool is already successfully used in academic and industrial projects.

Besides the use in an professional environment (for which I plan to offer commercial consulting) I am thinking about to make the tool freely available but with limited functionality (e.g. no Safety and requirements modeling). For that usecase Im thinking about a web application which basically has the same functionality as the Eclipse implementation. For that web application it would be nice if I could reuse as much code as possible from EMF so that maintenance of both implementations becomes easy and doable in a reasonable timeframe. Of course there also could be a "light" version of the eclipse application to do the same as the web app but here I would need to buy some consultancy because though its working, I am an electrical engineer and embedded developer and not a trained java developer so with my knowledge now (with knowledge being a function of time) it feels better to reuse the parts out of EMF I fully understand instead of releasing something with blind spots in it. Its a dynamic process on where Im heading with it right now.

[Updated on: Sun, 06 June 2021 22:23]

Report message to a moderator

Re: get the instance of the Main AcceleoGenerator class from query invoke [message #1842021 is a reply to message #1841991] Mon, 07 June 2021 13:24 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7265
Registered: July 2009
Senior Member
Hi

Good luck making money from modeling. Few are succeeding. Most users expect it all to be free, particularly those of use who provide free software.

You will be be close to a trained Java developer by the time things work. You may find it helpful to have 100% (not 99,99%) Open Source plugins and distinct proprietary plugins. Stay well clear of fragment plugins.

I cannot really imagine what your textual output does, but if you want to tease your users adequately then provide the full safety and requirements modeling for free, restrict your charging to full functionality rather than stub functionality safety and requirements M2T.

Remember also that today, while working on your PhD, your work may seem like the most important thing in the world. Tomorrow when you are faced with the realities of earning money in the jobs market, your wonderful service may evolve into a millstone.

I write from bitter experience. OCL and QVT could be wonderful if they worked well, but with tiny support teams and almost zero funding, tool quality is very disappointing and really struggling to chase the mainstream.. The reality is that large parts of industry are seriously uninterested, and increasingly uninterested, in modeling. As for UML, for many it is just a joke.

Regards

Ed Willink
Re: get the instance of the Main AcceleoGenerator class from query invoke [message #1842031 is a reply to message #1842021] Mon, 07 June 2021 20:36 Go to previous messageGo to next message
Thomas Barth is currently offline Thomas BarthFriend
Messages: 14
Registered: March 2021
Junior Member
Hi Ed,

Thank you a lot for sharing your experience. I can imagine that it was/is bitter to see a brilliant idea not reaching its full potential.
I personally want to thank you for the effort you put into Eclipse, OCL etc. as it helped me to implement the concept of my thesis with reasonable effort while learning a lot about bigger scale open source software projects and Java.
I released some open source software projects and know how demanding and ungrateful that can be, so also thank you for your support in this forum.

You are definitely right with your warning!
I mainly focus on automotive and machinery where model based software development is widespread (e.g. AUTOSAR, Simulink etc.) and even becoming more popular due to the increasing complexity of hardware and functionality but also due to the fact that safety software development needs to be documented for certification and M2T partially brings that automatically.
In the first years of the thesis I felt like you said, that this is the most important thing in the world but over the years I realized that though there is a demand for what I do, its hard to get into the market and to compete with existing solutions.
There are many things that need to be right for a project to succeed. A brilliant idea and implementation even with a demand on the market might be not enough and I am aware of that.
The idea to get startet (for now) would be not to sell the tool (which would require ex(t/p)ensive documentation, qualification, certification) but to use it as part of general consultancy in the area of embedded systems (for safety critical applications).
Maybe that doesn't work out but its worth a try because I have seen that it adds value for the customer in the projects it is used in.

The project a nutshell:
It allows you to model dataflows and software behavior (with an own graphical notation based on UML and SySML) as well as underlying hardware, logical functionality and (safety)requirements.
Which piece of software is executed when and on which piece of hardware and which data is exchanged between all the pieces of software in your system.
The textual output is C or C++ code implementing an runtime environment (in accordance with safety standards and with tractability to all related elements in the model) where all the user has to do is to add logic within the blocks he defined in the model without the need to fiddle with the complexity of a state of the art (muliticore)microcontroller with RTOS or certain safety requirements stated by the standards, which can be pretty challenging if implemented by hand.
Moreover a a safety report shall be generated, on which Im currently working and which is the last practical part of the project which started around 5 years ago.

[Updated on: Mon, 07 June 2021 22:04]

Report message to a moderator

Re: get the instance of the Main AcceleoGenerator class from query invoke [message #1842039 is a reply to message #1842031] Tue, 08 June 2021 04:41 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7265
Registered: July 2009
Senior Member
Hi

If you want to autogenerate C code (IMHO autogenerated C++ is pointless since the enhancements of C++ are to provide isolation between human programmers) I would look for, else develop, a C model so that you do M2M to an OO model then M2M to a C model then re-use an M2T fo C. At least this separates the concerns and makes retargeting to other languages much easier.

Regards

Ed Willink
Re: get the instance of the Main AcceleoGenerator class from query invoke [message #1842055 is a reply to message #1842039] Tue, 08 June 2021 09:10 Go to previous messageGo to next message
Thomas Barth is currently offline Thomas BarthFriend
Messages: 14
Registered: March 2021
Junior Member
Hi

Thanks for this inspiration which sounds interesting but I don't think I need something like that.
The model isn't a 1 to 1 representation of resulting classes and objects but rather abstract at some points because its easier for the designer this way. I decide what to generate out of the abstract definition during transformation.
I could generate another model which represents the actual codebase as intermediate step but I don't see too much benefit from that. An interesting idea though.
The generated C code also follows an object oriented approach by creating structs as objects and designated functions for each type of struct. I can reuse a lot of code this way and it has certain advantages.
The C++ code is used by humans and the compilation process is kind of a first consistency check + since the system architecture is based on objects, the code is nicer, more compact and easier to understand.
I don't see a need to target other languages than C and C++ for now as they are still state of the art in this field. Maybe at some point rust but not in the near future.

[Updated on: Tue, 08 June 2021 12:01]

Report message to a moderator

Re: get the instance of the Main AcceleoGenerator class from query invoke [message #1842069 is a reply to message #1842055] Tue, 08 June 2021 12:50 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7265
Registered: July 2009
Senior Member
Hi

It seems like your 'transformation' is clever, so I cannot recommend too strongly, do not use an M2T. M2T is great for simple text serialization but gets really klunky when you need strategic planning. For strategic planning you need at least one an intermediate model and an M2M to generate it. If you try to make an M2T do the job for you you will find it gets more and more cumbersome as you try to shoehorn the strategic planning into helpers. An early implementation of the OCL2Java code generator started as an Acceleo M2T and the strategic planning to weave invalid etc forced me to move on.

Regards

Ed Willink
Previous Topic:Acceleo within Sirius
Next Topic:Passing a Type as parameter in acceleo always results in AnyType
Goto Forum:
  


Current Time: Tue Sep 21 12:17:25 GMT 2021

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

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

Back to the top