Modeling a Security System
This example shows how to model a home alarm system including motion sensors. Like in modern alarm systems, if the system detects an intrusion, it allows a certain (small) time for the alarm to be disabled, otherwise it calls the police.
This model shows how to use directed event broadcasts to coordinate between parallel states, how to use output events to drive external blocks, and how to use the function call trigger to simulate a system which needs to be periodically triggered.
Inputs to the system include three anti-intrusion sensors (window, door, and motion) and corresponding on/off modes for each sensor. Another input signal indicates if the alarm is enabled. The chart outputs signals to sound a warning and call the police.
The chart models the logic of the alarm controller; It can be itself turned on or off. It consists in four parallel states: One for each sensor, and a fourth one which handles an intrusion detection. Whenever the chart wakes up, all these parallel states are evaluated in a sequence as indicated in their top-right corners.
See the chart annotations for more details on their behaviors.