Integrations (PTC products, 3rd party products and code) > Code integration (Ada, ARINC 653, C, C#, C++, IDL, Java, SQL and VB) > C Code > Generating C Code > Overview of generating C code (C code) > Overview of modeling C code (C code) > Overview of modeling C code (C code) > Overview of generating C code for system simulation in Modeler (C code)
  
Overview of generating C code for system simulation in Modeler (C code)
This section of the Help provides only information for changing the generation of a system to allow simulation of that system.
Before using this section of the Help, you should be familiar with how to model and generate C code for systems through ACS.
Before you generate C code for system simulation you must build the dependent libraries.
If you want to generate a system on one computer and simulate that system on a different computer, additional changes are required, or if you want the application to send notifications calls to Modeler using a port other than the default 15777 port, you can do so by changing the registry and the generated SimParams.c file. For more information, see the SimParams.c file section that follows.
The provided project file requires Visual Studio .NET for C++ (including Visual Studio Express) installed.
For more information about simulation of a target application, see Introduction to system generation and simulation.
Building dependent libraries
Before you generate C code for system simulation you must build the dependent libraries. These dependent libraries are provided in the following folders:
%ProgramData%\PTC Integrity Modeler\TWComms\tw-c-sdk\build\platforms\win32
%ProgramData%\PTC Integrity Modeler\TWComms\tw-c-sdk\src\tls\win32
%ProgramData%\PTC Integrity Modeler\C Concurrency
%ProgramData%\PTC Integrity Modeler\C State Machine
%ProgramData%\PTC Integrity Modeler\C Simulation
The preceding folders include Visual Studio 2012, 2013 and 2015 Project files for building the libraries.
Generation of C code for simulation of a system
To generate C code for simulation of a system, you do not have to make any changes to your model. Generate the code using the following ACS Code Generator DLL:
C Win32 Animation - use this ACS Code Generator DLL for generating a Windows application for a system that can be simulated through Modeler.
The preceding Code Generator DLLs generate C code that includes notification calls to interact with Modeler.
If you installed Modeler to the default location, the preceding Code Generator DLLs reside in subfolders of the following folder.
For Windows 7 and later operating systems:
C:\Users\<user>\AppData\Roaming\ItsShadow\ScriptDir\C_Sync
For 64-bit versions of pre Windows 7 operating systems:
C:\Program Files (x86)\PTC Integrity Modeler\Modeler\System\C_Sync
For 32-bit versions of pre Windows 7 operating systems:
C:\Program Files\PTC Integrity Modeler\Modeler\System\C_Sync
When you create the Generation Settings Scheme through the Launch ACS/TDK dialog, ensure that on the Harness tab you select the Harness Class (specifies the initial state machine Class) and Classes to generate as stubs.
SimParams.c file
If you want to generate a system on one computer and simulate that system on a different computer, additional changes are required.
The ACS Code Generator DLLs for animation generate an additional file named SimParams.c. The content of the SimParams.c file will be similar to as follows:
#include "RtsSim.h"
extern const RtsClassInfo RtsModelInfo("bcc9a3ce-cab9-496b-9537-58483da92e32", RTS_MODEL);
SimHandler_Proxy* gSimHandler;
extern const int gSimPortNumber = 15777
extern const char* gSimMachineAddress = "127.0.0.1";
The SimParams.c file specifies the following information, which you can change if required:
The Model from which the application was generated (RtsModelInfo).
The TCP/IP port on which Modeler will receive notification calls from the application (gSimPortNumber)
The computer on which the simulation is going to be run (gSimMachineAddress).
Changing the computer on which the simulation is going to be run
The Animation Code Generator DLLs are set up so that generated applications can be simulated on the same computer.
If you want to generate an application on one computer and then simulate that application on a different computer, in the SimParams.c file you must set the gSimMachineAddress global variable to the IP address of the computer on which you want to perform the simulation.
* 
When the SimParams.c file is generated, the value of gSimMachineAddress global variable is determined by the value of the following registry key entry:
HKEY_CURRENT_USER\Software\Artisan Software Tools\Synchronizer\Simulation\MachineAddress
By default, the MachineAddress registry key is set to localhost, which sets the value of gSimMachineAddress global variable to the IP address of the computer that generated the SimParams.c file.
Changing the port on which Modeler receives notification calls from the application
By default, the generated application uses TCP/IP Port 15777 to send notification calls to Modeler when performing a simulation of an application.
* 
If your Modeler installation is an upgrade, the default TCP/IP Port may be set to 4242 rather than 15777.
If you want to use a different port, you must set up both the application and the computer performing the simulation to use the same port:
To set up the application to use a different port, on the computer that generates the application, set the value of the following registry key to the port you want to use:
HKEY_CURRENT_USER\Software\Artisan Software Tools\Synchronizer\Simulation\PortNumber
When you next generate the application, the gSimPortNumber global variable in the generated SimParams.c file will be set to the value you set in the registry.
HKEY_CURRENT_USER\Software\Artisan Software Tools\Synchronizer\Simulation\PortNumber
When you start a simulation session through the Modeler State Simulation toolbar, Modeler uses the Port specified in the preceding registry entry.
To set up the computer that is to performing the simulation to use a different port, on that computer set the value of the following registry key to the port you want to use: