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 > Generating C++ code for system simulation > Overview of generating C++ code for system simulation (C++ code) > Overview of generating C++ code for system simulation (C++ code)
  
Overview of generating C++ code for system simulation (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 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.cpp file. For more information, see the SimParams.cpp file section that follows.
The provided project file requires Visual Studio .NET for C++ (including Visual Studio Express) and the core 32 bit build environment from the Microsoft SDK installed.
For more information about simulation of a target application, see Introduction to system generation and simulation (system 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\AxTLSLib
%PROGRAMDATA%\PTC Integrity Modeler\TWComms\TWClientAndBridge\TheClient
%PROGRAMDATA%\PTC Integrity Modeler\TWComms\UtilityLibs
%PROGRAMDATA%\PTC Integrity Modeler\Cpp Concurrency
%PROGRAMDATA%\PTC Integrity Modeler\CPP Simulation
Typically %PROGRAMDATA% expands to C:\ProgramData.
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 one of the following ACS Code Generator DLL:
Cpp Win32 Animation- use this Code Generator DLL for generating a Windows application that can be debugged in Modeler.
The preceding Code Generator DLLs generate C++ code that includes notification calls to interact with Modeler.
If you have installed Modeler to the default location, the supplied Code Generator DLLs reside in subfolders of the following folder (the name of a Code Generator DLL's folder matches that of the Code Generator DLL).
For Windows Vista and later operating systems:
C:\Users\<user>\AppData\Roaming\ItsShadow\ScriptDir\CppGen
For 64-bit versions of pre Windows Vista operating systems:
C:\Program Files (x86)\PTC Integrity Modeler\Modeler\System\CppGen
For 32-bit versions of pre Windows Vista operating systems:
C:\Program Files\PTC Integrity Modeler\Modeler\System\CppGen
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.
You can generate C++ code for simulation of a system and automatically build the application through the «Build Rule» stereotype. Tell me more...
SimParams.cpp 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.cpp. The content of the SimParams.cpp 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.cpp 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.cpp file you must set the gSimMachineAddress global variable to the IP address of the computer on which you want to perform the simulation.
Note that when the SimParams.cpp 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.cpp 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.cpp file will be set to the value you set in the registry.
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:
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.