To create a resetTime operation


  1. Right-click the StopWatch Class in the containment browser and select New Element > Operation.
  2. Name the new operation "resetTime". The resetTime operation will be created.

    Creating the ResetTime Operation



Next, we will use an Activity to define the resetTime operation. The Activity will contain the Actions and the flows that will show the steps to set the time value to zero.

To create a resetTime Activity


  1. Right-click the StopWatch Class in the containment browser and select New Element > Activity.
  2. Name the created Activity "resetTime".
  3. Add an Activity diagram to the resetTime Activity by right-clicking the resetTime Activity in the containment browser and select New Diagram > ActivityDiagram. The new Activity diagram will be created under the resetTime Activity. We will use the default name of this diagram, which is "resetTime".

    The ResetTime Activity and Its Activity Diagram


On the resetTime Activity diagram, you will need an AddStructuralFeatureValueAction to set the value of time:Integer[1] to zero. The structural feature of the AddStructuralFeatureValueAction must be set as the time attribute of the StopWatch Class.

To reset the time value of the StopWatch Object to zero using an AddStructuralFeatureValueAction


  1. Click Action > Any Action... on the Activity diagram toolbar (see the following figure). The Select Action MetaClass dialog will open. 

    Selecting Any Action on the Activity Diagram Toolbar

  2. Select AddStructuralFeatureValueAction and click OK.



  3. Click the resetTime Activity diagram to place the position of the created AddStructuralFeatureValueAction.
  4. Right-click the symbol of the AddStructuralFeatureValueAction on the resetTime Activity diagram and select Specification to open its Specification window.

    The AddStructuralFeatureValueAction Specification Dialog

  5. Scroll down to the Structural Feature row, select it, and click the button. The Select Property dialog will open.

    Select property dialog

  6. The Attribute time:Integer[1] of the StopWatch Class will be selected as the structural feature of this Action in this example.
  7. Click OK to close the SelectProperty dialog and return to the Specification window.
  8. Click the Is ReplaceAll row and select the check box. The AddStructuralFeatureValueAction will remove any existing value and assign a new value to the structural feature.

    Selecting the Is Replace All Attribute Check Box


We need to specify input pins for both the Object and the value of the AddStructuralFeatureValueAction metaClass. The object of the Classifier that contains the structural feature and its value will be supplied through these input pins respectively.

To create input pins


  1. Click the Pins node on the left-hand side of the AddStructuralFeatureValueActionSpecification dialog. The pins that are related to the AddStructuralFeatureValueAction will appear.
  2. Click the Value row and select InputPin.

    Assigning a Value to the Input Pin

  3. Name the input pin "t" and specify its type as Integer

    Specifying the Name of the Pin and Its Type for the Value

  4. Click the Close button. 

    The Display Pins Button on the Smart Manipulator Toolbar
  5. Select AddStructuralFeatureValueAction on the resetTime Activity diagram and click the Display Pins icon on the smart manipulator toolbar. The Select Pins dialog will open. 

    The Select Pins Dialog

  6. Select all pins and click OK.


To allow the object of the StopWatch to supply the value to self input using a ReadSelfAction


  1. Click Action > AnyAction... on the Activity diagram toolbar. The SelectActionMetaClass dialog will open.
  2. Select ReadSelfAction and click OK.
  3. Click the resetTime Activity diagram. A ReadSelfAction will be created on the diagram.

    Creating a ReadSelf Action

  4. Click ObjectFlow on the Activity diagram toolbar and click the self output pin of the ReadSelfAction and the self input pin of the AddStructuralFeatureValueAction. An object flow will be created to connect these two pins together.

     Connecting the Input and Output Pins with an Object Flow



Next, we will create a ValueSpecificationAction to supply a value to the input pin t of the AddStructuralFeatureValueAction.

To create a LiteralInteger of zero value using a ValueSpecificationAction


  1. Click Action > AnyAction... on the Activity diagram toolbar. The Select Action MetaClass dialog will open.
  2. Select ValueSpecificationAction and click OK to close the Select Action MetaClass dialog.
  3. Click the resetTime Activity diagram to create a ValueSpecificationAction.
  4. Right-click the ValueSpecificationAction on the resetTime Activity diagram and select Specification to open its Specification window.
  5. Select the Value row and click the ShowShortcutMenu button, and select Value SpecificationLiteral Integer to create a Literal Integer. 

    Creating a Literal Integer Value for the Value of Action

  6. A new Literal Integer with a default value of 0 will be created as the value of the ValueSpecificationAction.
  7. Right-click the pin result of the ValueSpecificationAction on the resetTime Activity diagram and select Specification to open its Specification window.
  8. Rename the output pin (result) to "t" and specify its type as Integer.

    The Output Pin with Its Type Assigned to the Result


    Connecting ValueSpecificationAction and addStructuralFeatureValueAction with an Object Flow

  9. Add an Initial stage and an Activity Final stage to the resetTime Activity diagram.
  10. Click ControlFlow on the Activity diagram toolbar to connect the Initial Node to the AddStructuralFeatureValueAction and the AddStructuralFeatureValueAction to the Final stage.




You have now created a complete resetTime Activity diagram. The next thing you will need to do is to set the Specification of the resetTime Activity to the resetTime operation.

To set the Specification of the resetTime Activity to the resetTime operation


  1. Right-click the resetTime Activity in the containment browser and select Specification to open its Specification window.
  2. Select the Specification row and click the button (see the following figure). The Select Element dialog will open.

    The Specification Attribute of the ResetTime Activity

  3. Select the resetTime operation of the StopWatch Class as the specification of the Activity and click OK to close the Select Element dialog.

    Select element dialog

  4. Click Close to close the Specification window.