Integrations (PTC products, 3rd party products and code) > Code integration (Ada, ARINC 653, C, C#, C++, IDL, Java, SQL and VB) > System generation for simulation - C, C++ and Java code > What's new in system generation and simulation (system simulation) > Introduction to system generation and simulation (system simulation)
  
Introduction to system generation and simulation (system simulation)
System simulation allows you to simulate your system in Modeler, including the animation of State Diagrams and optionally simulation of the system's user interface.
During a simulation you can inject events and operations, and interrogate and set attribute values. For C++ and Java code applications, you can set breakpoints. You can view the notification log in Modeler and save the notification log to a file.
To generate code and simulate your system, you require a Modeler license, a Simulation license, an ACS license and a license for the code language you are generating.
State machine generation
The objective of the generation process is to implement the most obvious possible translation of each state machine for each Class that owns a State Diagram through a State Machine. Assuming the State Diagrams are correctly defined, the generated code will compile and run without requiring further editing.
We have chosen to generate code which responds to events sent to a class (from operations, time-out, changes etc.) - this is referred to as a passive class structure, because objects of the class only respond to external events. Passive class code-generation leads to the state-machine code appearing in various different operations in the class, rather than having a single operation that contains all the state-machine behavior.
You generate state machine code through Automatic Code Synchronizer (ACS).
* 
UML refers to State Diagrams as State Machines.
Generating C, C++ and Java code applications for simulation
To simulate a C, C++ and Java code application, you must use the appropriate ACS Code Generator DLL that generates an application that includes notification calls so that the application can be simulated in Modeler.
For C++, use the following Code Generator DLL:
Cpp Win32 Animation
Note that you can generate C++ code for simulation of a system and automatically build the application through the «Build Rule» stereotype. See Generating C++ code for simulation of a system and automatically building the application (C++ code).
For C, use the following Code Generator DLL:
C Win32 Animation
For Java, use the following Code Generator DLL:
Java Generator Animation
Through the State Simulation toolbar in Modeler, you can then load the listener dll and simulate your application.
Instance diagrams
When you run a simulation with animation enabled, Modeler animates temporary read-only copies of your State Diagrams - these diagrams are called instance diagrams.
When simulating a C, C++ or Java code system, Modeler can simulate multiple instances of a Class' State Diagram. The name of the first instance diagram is prefixed by '1 - ', the second instance diagram is prefixed by '2 - ' and so on.
You can restrict which State Diagrams are animated by disabling the 'Enable Open Diagram Mode' button and then opening only those State Diagrams you want to animate before running the simulation.
Through the State Simulation toolbar, you can clear the animation from Instance Diagrams, and close all Instance Diagrams.
System simulation
In Modeler, you use the State Simulation toolbar to load the listener dll and start the simulation, and then interact with the simulation.
You can inject events and operations, and interrogate and set attribute values through the Inject/Query dialog. The Inject/Query dialog works with the instance of the class that is associated with the instance diagram that is selected before opening the Inject/Query dialog.
For C++ and Java code applications you can set breakpoints.
You can view the notification log in Modeler and save the notification log to a file.
You can simulate your system's user interface using, for example, Microsoft VisualBasic.
Supplied system simulations
So that you can see simulations working, the following models are supplied with the files required to perform a simulation:
Heart Monitor C model (C application)
Heart Monitor Java model (Java application)
Traffic Lights model (C++ application)
Waste System model (C++ application)