Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - dandrus

Pages: [1]
1
FWIW, here are the visual basic scripts I'm using to allow for external editing of the code templates.  By checking the "use JET 4.0" box in the general preferences of EA and converting the project to be based on the EABase_JET4.eap, you can then open the .eap file with Access 2013.  If you save each script below into a separate file you can import them into Access 2013 by going to Database Tools -> Visual Basic ->  right click on the project "db2"-> Import File... 

You also need to create two macros (Create->Macro), each with one action
export_templates macro: RunCode
                                         Function Name: export_templates()
import_templates macro: RunCode import_templates()
                                         Function Name: import_templates()

The only other trick is that you need to initially touch each template because by default the t_templates table is empty.  EA only puts the template into the table if it is modified somehow.  You only need to do this once, however, then do Configure->Transfer->ExportReferenceData (in EA13) which will save an XML that has your touched versions.  You can later import this into any other project at the start to force all the templates into modified state.

One limitation of these scripts is that they assume the templates for only one language have been modified in EA, and only one stereotype of the template is modified.  Extension is needed if you want to save/restore using separate subdirectories for each language and each stereotype.  These are already other fields in record set the scripts are already getting from the t_template table so this should be straightforward.  Another limitation is that to add new templates you first need to create it in the code template editor.

Attribute VB_Name = "ExportTemplates"
Option Compare Database

Type template_t
  filename As String
  template As String
End Type

Sub write_template_to_file(t As template_t)
  Dim fso As Object
  Dim strPath As String
  strPath = "C:\path\to\templates\" & t.filename & ".tpl"
  Set fso = CreateObject("Scripting.FileSystemObject")
  Dim oFile As Object
  Set oFile = fso.CreateTextFile(strPath)
  oFile.Write t.template
  oFile.Close
  Set fso = Nothing
  Set oFile = Nothing
End Sub

Public Function export_templates()
  Dim rs As Recordset
  Dim t As template_t
  Set rs = CurrentDb.OpenRecordset("t_template", dbOpenTable)
  Do While Not rs.EOF
    t.filename = rs(2)
    If Not IsNull(rs(5)) Then
      t.template = rs(5)
    Else
      t.template = ""
    End If
    write_template_to_file t
    rs.MoveNext
  Loop
  rs.Close
  Set rs = Nothing
End Function


--

Attribute VB_Name = "ImportTemplates"
Option Compare Database

Sub read_template_from_file(ByRef t As template_t)
  Dim fileNo As Integer
  Dim strPath As String
  strPath = "C:\path\to\templates\" & t.filename & ".tpl"
  fileNo = FreeFile 'Get first free file number
  Open strPath For Input As #fileNo
  t.template = Input$(LOF(fileNo), fileNo)
  Close #fileNo
End Sub

Public Function import_templates()
  Dim rs As Recordset
  Dim t As template_t
  Set rs = CurrentDb.OpenRecordset("t_template", dbOpenTable)
  Do While Not rs.EOF
    t.filename = rs(2)
    read_template_from_file t
    rs.Edit
    rs(5) = t.template
    rs.Update
    rs.MoveNext
  Loop
  rs.Close
  Set rs = Nothing
End Function

2
General Board / Re: Search for a string (grep) over all CTF base templates?
« on: December 25, 2016, 06:36:29 am »
Also, after doing a Project Transfer to the EABase_JET4.eap I was able to open the project in Access 2003.  The t_template table has the text of each modified template.  It may work to have a Visual Basic script in Access that updates the templates from my development text files...

3
I found the templates in the Code Template Editor under Language: STM_C++_Structured

4
Thanks Geert/qwerty.  One of the main motivations is to adhere to the model based engineering (MBE) principle "the model is an executable spec".  There is also a grand vision of having a hardware model generate first into C++, then loosely timed SystemC, then ultimately into VHDL. 

But putting the grand vision aside, if the model stops at the interfaces, can it really survive as a "golden spec"?  Our current process ensures that changes made by developers are reflected in the model because the flow doesn't support them just changing the code directly.  If the developers are implementing the code in an IDE, how do I maintain consistency between the code and the model?  If the model becomes irrelevant/outdated once the development is started then there is no requirements traceability and thus no MBE...

5
I've recently been put in charge of a project that is using IBM Rational Rhapsody such that all of the C++ source is generated (one way or another) from a UML/SysML model.  There was plenty of external python scripting that works around various limitations by fixing up the model via the Rhapsody COM interface.

My intention is to replace Rhapsody with EA.  The open architecture of the EA Code Template Framework (CTF) is inspiring since much of the complexity with the current development flow was caused by the inability to modify the code generation of Rhapsody.

I'm curious to hear people's advice on whether I'm headed down a road where EA will bring a different but equally complicated set of challenges...

6
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

7
I expect to be making considerable changes to the CTF base templates as well as integrating my own custom templates.  I'm tempted to methodically cut and paste each template into a separate text file so I can work on them using Eclipse, but I wanted to make sure there isn't a better way.  This will require me to keep track of each stereotype of each template and do a lot of cut-and-paste between Eclipse and the Code Template Editor to keep things in sync.  But without a way to even search for a string over all the templates, the Code Template Editor is insufficient.

8
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.

9
Bugs and Issues / Re: Cannot create Executable Statemachine artifact
« on: December 22, 2016, 06:22:07 am »
If you are just trying to create the <<executable statemachine>> artifact itself, it worked for me to
1. Create a new block definition diagram (or I also tried a state machine diagram)
2. drag the Executable StateMachine artifact from the toolbox and drop it onto the new diagram

If you are trying to get your class which contains your state machine to be a "property" inside the <<executable statemachine>> artifact, I ended up doing this:
1. Holding the control key first, click and drag the block containing your state machine and drop it onto the <<executable statemachine>> box
2. Choose to drop it as a "property"

Pages: [1]