Identifying Errors with the Model Validation Report

Overview

Opaque expressions require precise syntax, but since they are manually typed into your modeling tool, they are prone to error. Even a single misspelled block property or operation in a transition effect will cause Moxie to throw an exception at simulation run time. Fortunately, Moxie provides a model validation report to assist you in identifying these errors before you run your simulation. In this section, you will intentionally introduce a couple of errors into your simulation and then use the model validation report and element locator to find the errors so that you can fix them.

This section covers the following concepts:

Model Validation Checks

The model validation report detects far more than just spelling errors in your opaque expressions. For example, here are some of the problems it checks for:

  • A property has no name, is misspelled, or has no type or visibility.
  • An operation has no name or is misspelled.
  • An operation parameter has no direction or has an unsupported direction such as OUT or INOUT.
  • An operation used in an opaque expression does not exist with the specified name and arity.
  • A property or operation is accessed illegally.
  • An expression is unparseable or missing a body.
  • An invalid type is assigned to a slot in an instance specification.

Prerequisites

Prerequisite Description
Moxie Installation You must have installed Moxie.
Tutorial Project You must start this section with the Moxie simulation project from the previous section. If you did not complete the previous section, you can use the following project from the Moxie installation: \documentation\tutorialFiles\02\GuardsAndEffects.mdzip
Recommended Reading Before completing this section, you may want to read the following help topics:

Instructions

Introduce errors into your simulation

  1. Open the project from the previous section.
  2. Select Moxie > Model Validation Report and observe the report states:
    No issue(s) found.
  3. In the PowerSystem State Machine diagram, double-click the transition from the PoweredOff state to the choice pseudostate.
  4. Add quotes to the Effect Body and Language so that it reads isPoweredOn = "true";. This will throw an exception when it tries to assign the literal string "true" to the boolean slot isPoweredOn.
  5. Double-click the transition from the choice pseudostate to the PoweredOn state.
  6. Misspell the property used as the Guard, for example: isPoweredOm.

Locate and fix the errors

The model validation report lists the ID of each error, and the element locator highlights the element associated with an ID in the Containment Tree. The element locator will ask to show the element if it is currently hidden in the tree, and it will highlight its parent if you choose No.

  1. Select Moxie > Model Validation Report and observe that the report states:
    OpaqueBehavior   Structure::PowerSystem::PowerSystem State Machine::::::
    ID:      _19_0_4_138703df_1615394485705_267792_44117
    Error: Cannot assign a value into a slot of an unrelated type
                Value Type: SysML::Libraries::PrimitiveValueTypes::String (_16_5_1_12c903cb_1245415335546_479030_4092)
                Slot Type : SysML::Libraries::PrimitiveValueTypes::Boolean (_16_5_1_12c903cb_1245415335546_39033_4086)


    OpaqueExpression Structure::PowerSystem::PowerSystem State Machine::::::unnamed1::
    ID:      _19_0_4_138703df_1615394565114_288378_44125
    Error: Type has no property named isPoweredOm
                Type: Structure::PowerSystem (_19_0_4_138703df_1614103126402_970856_43854)


    2 total issue(s).
    0 Warning(s), 2 Error(s)
  2. Copy (CtrlC) the ID of the first error listed in your report.
  3. In your No Magic modeling tool, select Moxie > Element Locator (or press CtrlAltShiftI).
  4. Paste (CtrlV) the ID you copied into the Element ID text box and click OK (or press Enter).
  5. Double-click the highlighted element to open its specification window.
  6. Fix the error you introduced earlier and click Close.
  7. Repeat the previous steps to locate and fix the second error.
  8. Select Moxie > Model Validation Report and observe that the report again states:
    No issue(s) found.
  9. Save your work before continuing.

Next Section >