Book a Demo

Author Topic: Code Generation Template: state machine code generation  (Read 2200 times)

Jsc

  • EA User
  • **
  • Posts: 23
  • Karma: +0/-0
    • View Profile
Code Generation Template: state machine code generation
« on: December 04, 2019, 11:39:32 pm »
Hello, I am a novice for code generation. My EA version is EA 13.5 unified. I am trying to write a new language to generate class diagram and state machine to a XML file, which can be imported into PLC programm like CodeSys and Twincat.

I built a simple class with two attributes, two operations and two state machines.The attributes and operations are able to be generated perfectly. But only one state machine can be generated. I post also my code in Template.
Template Class:
Code: [Select]
%className%
$StateMachineGUID = %EASL_GET("Collection", classGUID, "AllStateMachines")%
%if $StateMachineGUID !=""%
 %EASLList="StateMachine" @separator="\n" @indent="" @owner=classGUID @collection="AllStateMachines"%
%else%
  /*hello world*/
%endIf%
%list="Attribute" @separator="\n" @indent="  "%
%list="Operation" @separator="\n" @indent="  "%

Template StateMachine:
Code: [Select]
$GUID = $parameter1
$ClassName= %EASL_GET("Property",$GUID,"Name")%
 $ClassName
 \t\t$ClassName
%EASLList="State" @separator="\n" @indent="\t\t" @owner=$GUID @collection="States"%
\t\tInitial
« Last Edit: December 04, 2019, 11:48:16 pm by Jsc »