Simulator generation

The simulator generator allows to generate a simulator for a CommaSuite model. It can be generated for a single interface and for a component. For the interfaces that contain triggers with parameters, replies and notifications with variables or any (*) value parameter files are required.

To enable simulator generation add a task to the .prj file, e.g. using content assist (ctrl + space). See the next example of the Imaging Component Example which generates a simulator for a single interface IImage and for component Supervision.

import "Supervision.component"

Project ImagingProject {

    Generate Simulator {
        Simulator_IImage for interface IImage
        {
            params: "IImage/IImage.params"
        }
        Simulator_Supervision for component Supervision
        {
            params: "IImage/IImage.params"
                    "ITemperature/ITemperature.params"
                    "IAcq/IAcq.params"
        }
    }
}

To generate the simulator, run the .prj (right click on the .prj file → Run AsRun generators). By selecting Run AsGenerate and execute simulator the generated simulators are started after generation. A simulator can also be started to executing the start.bat file in the generated folder in src-gen/simulator.

Execution the simulator for the IImage interface leads to the following user interface:

image

The client and server section allow to execute actions:

  • The Client section contains all commands and signals

  • The Server section shows all replies and notifications.

  • Grayed out actions cannot be executed in the current state.

  • To execute an action click on an enabled action in the Actions section.

Notice that the executed actions are added to the log and sequence (visualization) section.

The controls section allows to

  • Log states: shows current state(s) in the log

  • Log variables: shows current values of variables in the log

  • Step back: undo last action

  • Reset: undo all actions

  • Save state: save current situation

  • Restore state: return to last saved situation

The Save button in the top left corner allows to save the log to a text file or as a recording that can be used in the test application. Moreover, the sequence visualization can be saved as a png picture.

Multiple clients or servers on a single port

For a component simulation, by default each provided port has a single client and each required port a single server. An alternative is to specify the number of clients and servers explicitly for each port, either using the default parameters of any other parameter file. See the next example:

Generate Simulator {
        Simulator_Supervision for component Supervision
        {
            params: "IImage/IImage.params" "ITemperature/ITemperature.params" "IAcq/IAcq.params"
            client t ports iTempPort default_params
            client v ports iVacPort default_params
            client c1 ports iImagPort "IImage/IImage2.params"
            client c2 ports iImagPort default_params
            server p1 ports iPumpPort default_params
            server p2 ports iPumpPort default_params
            server a  ports iAcqPort default_params
        }
    }

It should be noted that if parameters are not required for a given port, 'default_params' still needs to be given.

If no clients or servers are specified for a given port, there will be no default client/server generated for it.

Limitations:

  • Simulation of component models:

    • Component models with parts are not supported (compound components)

  • Time and data constraints are not supported