%% Example of Parallel Decomposition
% This example employs parallelism to implement an air controller that
% maintains air temperature at 120 degrees in a physical plant.

% Copyright 2009-2020 The MathWorks, Inc.

%%

% Set up charts with white background
set_param(0,'ExportBackgroundColorMode','white');

model = 'sf_aircontrol';
load_system(model)
open_system([model '/Air Controller']);

%%
% The controller operates two fans. The first fan turns on when the air
% temperature rises above 120 degrees. The second fan provides additional
% cooling when the air temperature rises above 150 degrees. The chart
% models these fans as parallel states |FAN1| and |FAN2|, both of which are
% active when the controller is turned on. Except for their operating
% thresholds, the fans have an identical configuration of states and
% transitions that reflects the two modes of fan operation (|On| and
% |Off|).

%%
% A third parallel state |SpeedValue| calculates the value of the output
% data |airflow| based on how many fans have cycled on at each time step.
% The Boolean expression |in(FAN1.On)| has a value of 1 when the |On| state
% of |FAN1| is active. Otherwise, |in(FAN1.On)| equals 0. Similarly, the
% value of |in(FAN2.On)| represents whether |FAN2| has cycled on or off.
% The sum of these expressions indicates the number of fans that are turned
% on during each time step.