Each one of the breakpoint monitors has two monitoring functions:
- a predicate function and
- an action function.
The predicate function is called after simulation steps. When the predicate function returns true, the action function will set a flag in the simulator to indicate that a simulation breakpoint – that is, a simulation stop criterion – has been fulfilled.
Accessibility of the monitoring functions for the different kinds of breakpoint monitors:
Predicate | Action | |
---|---|---|
Place contents | hidden | hidden |
Transition enabled | hidden | hidden |
Generic breakpoint | accessible | hidden |
Generic breakpoint monitors
Function types for the accessible functions:
pred : subnet -> bool
For more information about the subnet
data type, see Data types for monitored subnets.
Examples of monitoring functions
All of the following examples are examples of monitoring functions for the Simple protocol net. Additional examples of breakpoint monitoring functions can be found in the example net for the Queue system example.
Example 1
The following predicate function is for a monitor that is associated with no places and no transitions. The monitor will stop a simulation when the model time is greater than 200.
fun pred () =
IntInf.toInt(time()) > 200
Example 2
The following predicate function is for a monitor that is associated with one place and two transitions. The monitor will stop a simulation when either the Transmit_Ack
or the Transmit_Packet
transition on the page Top
occurs. The variables associated with the transitions and the marking of the place B
are ignored in this function.
fun pred (bindelem,
Top’B_1_mark : INTxDATA ms) =
let
fun predBindElem (Top’Transmit_Packet (1, {n,p,r,s})) = true
| predBindElem _ = false
in
predBindElem bindelem
end
Example 3
The following predicate function is for a monitor for the Simple protocol net, and the monitor is associated with one place and one transition. The monitor will stop a simulation when the following conditions are fulfilled:
- the
Transmit_Packet
transition occurs; - the packet is discarded, as indicated by
not (Ok(s,r))
; and - there are at least two tokens on place
B
, as indicated by(size Top'B_1_mark >= 2)
.
The size
function is a function for multisets.
fun pred (bindelem,
Top’B_1_mark : INTxDATA ms) =
let
fun predBindElem (Top’Transmit_Packet (1, {n,p,r,s})) =
not (Ok(s,r)) andalso
(size Top’B_1_mark >= 2)
| predBindElem _ = false
in
predBindElem bindelem
end
You must be logged in to post a comment.