In the previous section, we have shown you how to execute the StopWatch model from the StopWatch Class. You can also use Cameo Simulation Toolkit to execute the model from an InstanceSpecification. With this feature, you can specify values to the slots of an InstanceSpecification. These values will be used as the input values for the execution such as using a ReadStructuralFeatureAction to read the values.

In this tutorial, our StopWatch contains only one value property, which is time. The time value will always reset to zero whenever the system enters the ready State. If we create an InstanceSpecification of StopWatch and use it for model execution, the result will be the same as the model execution of the StopWatch Class.

To create an InstanceSpecification of StopWatch


  1. Open a System Class diagram.
  2. Click Instance on the Class Diagram toolbar and click the System Class diagram. A new InstanceSpecification will be created and the Select Classifier dialog will open.

    The Select Classifier Dialog

  3. Select the StopWatch Class and click OK.
  4. On the Class diagram, name the created InstanceSpecification "stopwatch". Now we will need to create values and assign them to the slots.

 

To create values and assign them to the slots


  1. Right-click the symbol of the stopwatch InstanceSpecification and select Specification to open the Specification window of the stopwatch InstanceSpecification.
  2. Select the Slots node on the left-hand side of the dialog.
  3. Select the Structural Feature of the slot to which the values will be applied. In this case, select time:Integer[1].

    The Specification Dialog of the StopWatch InstanceSpecification

  4. Click the Create Value button. A new integer value will be created for the slot. If an Integer value is selected, a zero will be created by default. You can modify this value by typing a new value into the Value box.

    Setting a Slot Value in the Specification Dialog

  5. Click Close to close the Specification window. 


To start executing the stopwatch InstanceSpecification, right-click it either on the System Class diagram or in the containment browser and click Execute. A simulation session will be created in the Sessions tab of the Simulation window to execute this instance. The steps to run the execution are the same as those to execute the StopWatch Class.

The Simulation Window during the Execution of StopWatch Model from InstanceSpecification