# Activity 5: Generate a simulator

In this tutorial, models are mainly validated by means of monitoring with respect to correct traces. For a new - not yet implemented - interface, such traces are not available. In such a situation, simulation can be useful to validate the model.

To generate a simulation, first values for input parameters of commands and signals have to specified in a .params file. For the IService interface, this can be done as follows:

- Create file IService.params in folder IService by right-clicking on folder IService and selecting New > File.

- Insert the following lines in this file:

    import "IService.interface"

    interface: IService

- Use content assist (CTRL + SPACE) and select Autocomplete missing triggers. This creates a template where, for each relevant state, input values for the command LoadProduct have to specified.

- Replace PRODUCT by an instance of type ProductName, i,e, ProductName::WATER, ProductName::JUICE, or ProductName::COLA. Note that multiple values can be specified, for instance,

    trigger: LoadProduct
      state: Operational
        params: ( ProductName::WATER )
        params: ( ProductName::COLA )
      state: Error
        params: ( ProductName::JUICE )

Extend the project file VendingMachine.prj with the following task for simulator generation:

    Generate Simulator {
        Simulator_IService for interface IService
        {
            params: "IService/IService.params"
        }
    }

Generate the simulator by right-clicking on the .prj file and selecting Run As → Run generators. Wait for the generation to end - see the green progress bar in the bottom right corner - and navigate to folder src-gen/simulator/ and double-click on the generated .jar file. An alternative is to combine generation and execution by using Run As → Generate and execute generator.

In the simulator, one can select an allowed action of the client or the server, if any. Next the action can be executed by clicking on it in the Action(s) column. Reply actions are preceded by "R:". Observe that the set of possible actions for LoadProduct depends on the values specified in IService.params.