Simulink UCGN Hello World

From UcgnWiki

Jump to: navigation, search
(Prerequisites)
 
Line 7: Line 7:
The '''SimulinkUcgnDistribution''' contains a "Hello World" example, in the simulink/Examples/HelloWorld subfolder. You will find a simple Simulink model showing how to set up a design and then process it through the stages of model transformation and code-generation. The model is intended to show some of the basic concepts available.
The '''SimulinkUcgnDistribution''' contains a "Hello World" example, in the simulink/Examples/HelloWorld subfolder. You will find a simple Simulink model showing how to set up a design and then process it through the stages of model transformation and code-generation. The model is intended to show some of the basic concepts available.
-
The following files are part of the design
+
The following files are part of the design (located in ./simulink/Examples/HelloWorld)
-
* '''TST_HelloWorldModel.mdl''' - the simulink model
+
* '''TST_HelloWorldModel.mdl''' - the simulink model  
* '''GBL_Constants.m''' - showing how workspace parameters are used as "tunable parameters"
* '''GBL_Constants.m''' - showing how workspace parameters are used as "tunable parameters"
* '''FCS_FlightControlSystemDefinitions.m''' - showing how to work with bus objects
* '''FCS_FlightControlSystemDefinitions.m''' - showing how to work with bus objects
Line 19: Line 19:
* '''SimulinkUcgn.bat''' - batchfile to run model transformation and code generator
* '''SimulinkUcgn.bat''' - batchfile to run model transformation and code generator
 +
All files listed above are located in the ./simulink/Examples/HelloWorld folder.
== Prerequisites ==  
== Prerequisites ==  
* Java JRE 1.6 or newer
* Java JRE 1.6 or newer
-
* Matlab R2009b, Simulink 7.4  
+
* Matlab R2009b, Simulink 7.4
-
 
+
(most of the testing has been done using Simulink 7.4. Settings in the file SlcConfiguration.xml check for simulink version, but you can override it by performing a global search and replace, replacing 7.4 with your version in SlcConfiguration.xml)
== Setup ==  
== Setup ==  
Line 32: Line 33:
* Modify '''SlcGenExport_TST_HelloWorldModel.m''', to point to your <br />UcgnBasePath = '<your UCGN_SIMULINK_BASE>';
* Modify '''SlcGenExport_TST_HelloWorldModel.m''', to point to your <br />UcgnBasePath = '<your UCGN_SIMULINK_BASE>';
* Modify '''SlcProject.xml''', to point to UCGN_SIMULINK_BASE/work as the Working Directory <br /><workingDirectory><your UCGN_SIMULINK_BASE>\work</workingDirectory>
* Modify '''SlcProject.xml''', to point to UCGN_SIMULINK_BASE/work as the Working Directory <br /><workingDirectory><your UCGN_SIMULINK_BASE>\work</workingDirectory>
-
* Modify '''SimulinkUcgn.bat''', to point to your UCGN_SIMULINK_BASE<br />set UCGN_SIMULINK_BASE=<your UCGN_SIMULINK_BASE>
+
* Modify '''SimulinkUcgn.bat''', to point to your UCGN_SIMULINK_BASE<br />set UCGN_SIMULINK_BASE=<your UCGN_SIMULINK_BASE> (enclose in quotes if your path containes spaces!)
Line 67: Line 68:
TST_HelloWorldModel_Calculate(FCS_FlightControlSystem_StatusStructuredType *FcsStatus,            /* Input  */
TST_HelloWorldModel_Calculate(FCS_FlightControlSystem_StatusStructuredType *FcsStatus,            /* Input  */
                               GBL_Types_Double                              TerrainElevationM,    /* Input  */
                               GBL_Types_Double                              TerrainElevationM,    /* Input  */
-
                               GBL_Types_UInt32                            *PilotRecommendation); /* Output */
+
                               GBL_Definitions_EjectionCmdEnumeratedType    *PilotRecommendation); /* Output */
</source>
</source>
Line 73: Line 74:
And a section from the source file '''TST_HelloWorldModel.c''':
And a section from the source file '''TST_HelloWorldModel.c''':
-
<pre>
+
<source lang="c">
   /*
   /*
       (RelationalOperator) TST_HelloWorldModel.TST_HelloWorldModel.LowAltitude
       (RelationalOperator) TST_HelloWorldModel.TST_HelloWorldModel.LowAltitude
Line 98: Line 99:
   if (FcsStatus->InAir && (FcsStatus->LeftEngFailed || FcsStatus->RightEngFailed) && LowAltitude) {
   if (FcsStatus->InAir && (FcsStatus->LeftEngFailed || FcsStatus->RightEngFailed) && LowAltitude) {
-
       *(PilotRecommendation) = (GBL_Types_UInt32)(GBL_Definitions_EjectionCmd_EjectAsap);
+
       *(PilotRecommendation) = GBL_Definitions_EjectionCmd_EjectAsap;
   } /* end of if */
   } /* end of if */
   else {
   else {
-
       *(PilotRecommendation) = (GBL_Types_UInt32)(GBL_Definitions_EjectionCmd_DontEject);
+
       *(PilotRecommendation) = GBL_Definitions_EjectionCmd_DontEject;
   } /* end of else */
   } /* end of else */
-
 
+
</source>
-
</pre>
+
This is the type definition resulting from the bus object FCS_FlightControlSystem_Status
This is the type definition resulting from the bus object FCS_FlightControlSystem_Status
-
<pre>
+
<source lang="c">
typedef struct FCS_FlightControlSystem_StatusStructuredTypeTag {
typedef struct FCS_FlightControlSystem_StatusStructuredTypeTag {
Line 121: Line 121:
} FCS_FlightControlSystem_StatusStructuredType;
} FCS_FlightControlSystem_StatusStructuredType;
-
</pre>
+
</source>
The (emulated) enumerated type definition in GBL_Definitions looks like this
The (emulated) enumerated type definition in GBL_Definitions looks like this
-
<pre>
+
<source lang="c">
typedef enum GBL_Definitions_EjectionCmdEnumeratedTypeTag {
typedef enum GBL_Definitions_EjectionCmdEnumeratedTypeTag {
Line 133: Line 133:
} GBL_Definitions_EjectionCmdEnumeratedType;
} GBL_Definitions_EjectionCmdEnumeratedType;
-
</pre>
+
</source>

Latest revision as of 15:38, 27 May 2011

Personal tools