Book a Demo

Author Topic: How to customize the CTF template "Stm Signal Attribute Assignment" and others?  (Read 5051 times)

dandrus

  • EA Novice
  • *
  • Posts: 9
  • Karma: +1/-0
    • View Profile
I am new to EA but have spent weeks reading the excellent documentation.  My goal is to extend the C++ code generation to directly generate code that can link with our existing virtual platform libraries/framework/patterns.  I was encouraged at first by the Code Template Editor and the promise from the documentation that it was "fully configurable", but am now stuck.

Specifically, I want to modify the templates involved in statemachine generation.  I found this page which lists all the templates, but how do I edit them?  The code output in the EventProxy even has a message suggesting this is possible...

   // You can customize the template "Stm Signal Attribute Assignment" to generate initializer for "xyz"

As a side note, the documentation doesn't explain the relationship between the template substitution macro names e.g. %ClassBody% and the template names listed in the editor e.g. "Class Body".  Was whitespace just added for readability?  If so IMHO this creates more confusion than clarity.
« Last Edit: December 22, 2016, 07:54:03 am by dandrus »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Go to Package/Code Engineering/Code Generation Templates (in a pre-13 version). Don't ask me where the ribbon did put it.

From my experience you should no put too much effort in coding via EA. Code is better handled in an IDE. Use EA to design and implement an interface so your programmers get the idea and can code.

q.

RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1297
  • Karma: +21/-4
  • Read The Help!
    • View Profile
As I understand it, all the listed templates are 'standard' or system-supplied templates. You can't edit standard templates themselves. You can, however, use them as the base for your own customized templates.
Basically, the template editor helps you create and edit your own templates, largely based on copies of the standard templates.

The ribbon path is 'Code > Source Code > Configure > Code Template Editor'.
Best Regards, Roy

dandrus

  • EA Novice
  • *
  • Posts: 9
  • Karma: +1/-0
    • View Profile
Thank you both for your replies.  I am familiar with the Code Template Editor and the base templates.  This page of the EA User Guide describes the templates that perform the guts of the executable state machine code generation, and none of these are visible from the Code Template Editor that I can see. 

When generating executable state machines EA produces extra "framework" files that implement a base class StateMachineContext and a companion file EventProxy.cpp.   I want to modify the templates that generate these files.  The EA developer who created these templates output a comment that appears in EventProxy.cpp where they haven't finished the template:

 // You can customize the template "Stm Signal Attribute Assignment" to generate initializer for "xyz"

implying that  these templates are user editable, but I don't see how.

The question of whether I should even be attempting to do this is another matter for which I will start a separate thread.

Thanks again!

Don

RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1297
  • Karma: +21/-4
  • Read The Help!
    • View Profile
Well, some of the things listed on that page are templates, and some are MACROS. And unfortunately that is the only intelligent thing I can say about any of them. I will track down the person who looks after them and see what he suggests.
Best Regards, Roy

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Make a copy of the templates (since they are what their names says) and work on your own copies.

q.

dandrus

  • EA Novice
  • *
  • Posts: 9
  • Karma: +1/-0
    • View Profile
I found the templates in the Code Template Editor under Language: STM_C++_Structured