Gamma Traces
semantifyr-gamma verify, the VS Code extension, and Live show the run of a case as a Gamma execution trace, trace.get, which any Gamma tool reads next to the model.
The trace of BarrierDownWhileTrainInCrossing from the lesson:
import LevelCrossing
trace BarrierDownWhileTrainInCrossingTrace of BarrierDownWhileTrainInCrossing
step {
act {
reset
}
assert {
state trackA.Main.Free;
state trackB.Main.Free;
state controller.Main.Idle;
state barrier.Main.Up;
}
}
step {
act {
raise trackASensors.approach
raise trackASensors.near
raise trackASensors.enter
raise trackASensors.leave
raise trackBSensors.approach
raise trackBSensors.near
raise trackBSensors.enter
schedule component
}
assert {
transition trackA from Free to Approaching;
raise trackA.controller.trainApproaching;
transition trackB from Free to Approaching;
raise trackB.controller.trainApproaching;
state trackA.Main.Approaching;
state trackB.Main.Approaching;
state controller.Main.Idle;
state barrier.Main.Up;
}
}
step {
act {
raise trackASensors.approach
raise trackASensors.near
raise trackASensors.enter
raise trackASensors.leave
raise trackBSensors.near
raise trackBSensors.enter
schedule component
}
assert {
transition trackA from Approaching to Near;
transition trackB from Approaching to Near;
transition controller from Idle to TrainPresent when trackA.trainApproaching;
raise controller.barrier.lower;
state trackA.Main.Near;
state trackB.Main.Near;
state controller.Main.TrainPresent;
state barrier.Main.Up;
}
}
step {
act {
raise trackASensors.approach
raise trackASensors.enter
raise trackASensors.leave
raise trackBSensors.enter
schedule component
}
assert {
transition trackA from Near to InCrossing;
transition trackB from Near to InCrossing;
transition barrier from Up to Down;
state trackA.Main.InCrossing;
state trackB.Main.InCrossing;
state controller.Main.TrainPresent;
state barrier.Main.Down;
}
}
step {
act {
raise trackASensors.approach
raise trackASensors.leave
schedule component
}
assert {
transition trackA from InCrossing to Free;
raise trackA.controller.trainLeft;
state trackA.Main.Free;
state trackB.Main.InCrossing;
state controller.Main.TrainPresent;
state barrier.Main.Down;
}
}
step {
act {
raise trackASensors.approach
schedule component
}
assert {
transition trackA from Free to Approaching;
raise trackA.controller.trainApproaching;
transition controller from TrainPresent to Idle when trackA.trainLeft;
raise controller.barrier.lift;
state trackA.Main.Approaching;
state trackB.Main.InCrossing;
state controller.Main.Idle;
state barrier.Main.Down;
}
}
step {
act {
raise trackASensors.near
raise trackASensors.enter
raise trackASensors.leave
schedule component
}
assert {
transition trackA from Approaching to Near;
transition controller from Idle to TrainPresent when trackA.trainApproaching;
raise controller.barrier.lower;
transition barrier from Down to Up;
state trackA.Main.Near;
state trackB.Main.InCrossing;
state controller.Main.TrainPresent;
state barrier.Main.Up;
}
}
importnames the case's package, andtrace <name> of <case>names the traced case; every name resolves in the scope of the case's component.- Instances are named from the traced component down, nested ones as
outer->inner. - The first step is initialization: the
resetact, the outputs the entry actions raised, and the state reached. - A step's acts are what the environment did:
raise <port>.<event>raises an input event,elapse <milliseconds>is the time that passed before the step, andschedule componentruns the component for one step. - A step's asserts are what followed: the active
stateof every region, thevariablevalues, the output events an instance raised, and every firedtransition, withwhen <trigger>where another transition shares its source and target.
The trace differs from Gamma's own: its header names a verification case, where Gamma's names a component; the transition assert is Semantifyr's own; an elapse of a fraction of a millisecond is written over its denominator, as in elapse 2000/3, where Gamma's takes whole milliseconds; and it asserts nothing of an event that was not raised, where Gamma's back-annotation negates each. The values of event parameters are planned for the trace, and the assign act, schedule of an instance, and a final cycle are not supported.