Opaque Expressions

Opaque behaviors have expressions that are specified by a Body and Language. Moxie requires opaque expressions' language type to be either English or unspecified. For opaque expression bodies, Moxie uses a Java-like syntax. This syntax enables you to easily traverse the current SysML object's properties and operations using the dot (.) operator, making the opaque expressions in your state machines much more readable. Moxie also provides a few global identifiers for the simulation that you can use in opaque expressions.

Java-like notation

Moxie evaluates expressions against the current context object, which is the instance specification that owns those expressions. So, given the class and instance specifications in Figure 1, the examples in the following table show how to navigate properties and operations using Moxie's Java-like notation. The example results are all for robert's state machine session, and they assume that the belongsToDepartment(department : String) operation is backed by an appropriate delegate implementation.

Figure 1: A class with instance specifications

Expression Description Result
nickname Accesses the context object's property. The string "Bob"
manager Accesses the context object's property. The instance specification alice
belongsToDepartment("Development") Executes the context object's operation. The boolean true
manager.nickname Accesses an accessible object's property. The string "Alice"
manager.belongsToDepartment("Development") Executes an accessible object's operation. The boolean true
nickname = "Robbie" Assigns a new value to the context object's property.

Supported features

The following table lists common Java-like features that Moxie supports.

Feature Description Notation
String Literals Are specified with either ' or ". 'Development', "Robbie"
Number Literals Are either integers or real numbers. 42, 3.14
Boolean Literals Are either true or false. true, false
Arithmetic Operators Add, subtract, multiply, divide, or find the remainder (modulus) of two numbers. +, -, *, /, %
Comparison Operators Check whether one number is less than, greater than, or equal to another number. <, <=, >, >=, ==, !=
Logical Operators Determine the logical "and", "or", or "not" of boolean values. &&, ||, !
Assignment Operator Assigns a new value to a property. =
Dot Operator Accesses the specified property of an object or executes the specified operation on the object. It may be chained, as long as the property or operation returns another object. manager.nickname, manager.belongsToDepartment("Development"), manager.manager.manager.nickname

Operators can accept values from literals, properties, or operation results, as long as the values have valid types. For example, an integer can be assigned to a real, but not vice versa. Arithmetic, comparison, and logical operators can only accept primitive types (SysML::Libraries::PrimitiveValueTypes).

Global identifiers

Opaque expressions often only need values that are either defined by the current context object or accessible through its properties, but Moxie provides a few identifiers that are available independent of class definitions, for use in special situations:

Identifier Meaning Description
$SELF The current context object $SELF is the implied start of an opaque expression in Moxie. So $SELF.nickname and nickname are equivalent. $SELF is most useful for when you need to pass the current context object as an argument to an operation, for example otherObject.accept($SELF).
$NOW The current simulation time $NOW is only available within state entry and exit behaviors and within transition guards and effects, not within triggers. Since Moxie treats transitions as instantaneous, $NOW will represent the same instant in time for the exit, the guard, the effect, and the entry executed by a transition. $NOW returns a >Moxie-Base::Structure::TimeInstant.
$SIMULATION_START The start time of the simulation $SIMULATION_START is available within state entry and exit behaviors and within transition triggers, guards, and effects. $SIMULATION_START returns a Moxie-Base::Structure::TimeInstant.
$SIMULATION_STOP The stop time of the simulation $SIMULATION_STOP is available within state entry and exit behaviors and within transition triggers, guards, and effects. $SIMULATION_STOP returns a Moxie-Base::Structure::TimeInstant.