9.Rules and rule editor - larics/Petri.Net GitHub Wiki

Rules are an important part in Petri net simulation. A Petri net can be controlled by control places. These places control the flow of tokens in critical sections of system (if there is a danger of deadlock or conflict). In every sampling interval rules are calculated and based on result control places receive particular number of tokens determined by the rules.

As it was mentioned in section 3, main application window has a dockable window called Rules Editor (Figure 9.1). It contains a set of rules for particular Petri net.

Figure 9.1. The Rules Editor window.

Rules Editor window shows collection of items associated with current document. In front of every rule there is an icon that shows if that rule currently evaluates to true or false. This is very useful in step-by-step simulation (explained later in this manual) so control algorithm can be easily validated and debugged. In Rules Editor new rule can be added, or existing rule can be edited by double-clicking that rule. A new window called Rule Editor is opened (Figure 9.2).

In this window you type a new rule by entering a Rule Expression and (optionally) a Rule Description.

Figure 9.2. The Rule Editor window.

Every rule has the following syntax:

IF (Expr1 AND Expr2 AND … AND ExprN) THEN (Assign1 AND Assign2 AND … AND AssignN)

where: Expr : NameID1/const1 op NameID2/const2 op … op NameIDN/constN RELOP NameID1/const1 op NameID2/const2 op … op NameIDN/constN

`op – arithmetical operator. It can be '+' or '-' character`
`RELOP – relational operator. It can be ==, !=, <, <=, >, >=`

Assign : NameID = const

Examples of rules:

  • IF (MA == 1 AND IA != 0) THEN (UD2 = 0)
  • IF (RA == 1 AND RP == 1 AND MP == 0) THEN (UD2 = 1 AND UD4 = 0)
  • IF (RA == 1 AND PI1 > 0) THEN (UD1 = 1 AND UD3 = 0)
  • IF (OA >= 2) THEN (UD3 = 0)
  • IF (RA + OA - 3 >= OB – IA + 10) THEN (UD3 = 0)
⚠️ **GitHub.com Fallback** ⚠️