Skip to content

A conditional group of single line actions

Leon Starr edited this page Nov 6, 2023 · 3 revisions

In the example below, the line with the ? consists of single decision action. On a data flow diagram this would just be a bubble outputting mutually exclusive control flows. In Scrall, a variable is set and tested. An empty instance set variable evaluates as false, a table variable with zero rows/tuples evaluates as false, a false boolean variable will, of course, evaluate as false. A scalar type, on the other hand, must be explicitly tested to evaluate as false since its structure is opaque to our relational world.

Below that first decision action, an expression is evaluated to decide which block of actions to execute. The second action block is enclosed in {} brackets and spread across multiple lines.

cabin in shaft .= /R2/Cabin
xfer .= cabin in shaft/R53/Transfer
call in progress .= xfer/R49/Floor Service( Direction: cabin in shaft.Travel direction )

fwd dest .= cabin in shaft.Ping( dir: cabin in shaft.Travel direction )
fwd dest? destination aslev .= fwd dest :
    !call in progress? {
        // Search opposite the travel direction only if not servicing
        // a floor request in the current direction
        rev dest .= cabin in shaft.Ping( dir: Travel direction.opposite() )
        rev dest? cabin in shaft.Travel direction.toggle()
        destination aslev .= rev dest // may be empty
    }

This example is an excerpt from the R53 assigner state model in the Elevator 3 Case Study. Its purpose is to search for a destination ahead of the Cabin in its current travel direction and, if none is found and there is no active floor call request (arrow button at floor), search behind the Cabin for a destination.

After attempting to select a forward destination, fwd dest, the value is checked and, if a destination was found it is saved as destination aslev. Otherwise, if no call in porgress was detected the bracketed action block, which looks in the opposite direction, is executed.

See the section on Conditional Execution under Control Flow for more about conditional processing.

Introduction

Model semantics

Flows (as Variables)

Constants and literals

Structure of an activity

Accessing the class model

Data flow


Grammar and parsing notes

Components

Clone this wiki locally