%% Map Input Events for an Atomic Subchart
% This model contains a Mux block that supplies input events to a chart.

% Copyright 2019-2020 The MathWorks, Inc.

%%

model = 'sf_yoyo';

load_system(model)

% Delete all annotations at the top level of the model
ah = find_system(model, 'FindAll', 'on', 'type', 'annotation');
for i = 1:length(ah)
   ao = get_param(ah(i), 'Object');
   ao.delete;
end

open_system(model);
close_system([model '/Energy scope']);
close_system([model '/Length scope']);
close_system([model '/Theta scope']);

%% 
% The chart contains two superstates: |Active| and |Inactive|. The |Active|
% state uses input events to guard transitions between different substates.
%
% <<../sf_yoyo_chart.png>>

% g2074387
% open_system([model '/Chart']);

%%
% To convert the |Active| state to an atomic subchart:
%
% # Right-click the |Active| state and select *Group & Subchart* > *Atomic
% Subchart*.
% # Right-click the atomic subchart and select *Subchart Mappings*.
% # Under *Input Event Mapping*, map each atomic subchart symbol to the
% corresponding input event in the main chart.
% # Click *OK*.
% 
% <<../mapping_for_input_event.png>>

%% Disable Input Events for Atomic Subcharts
% Not every input event in an atomic subchart has to correspond to an
% event in the main chart. For example, you can create a linked atomic
% subchart that does not use the entire set of events that are defined in
% the library chart. To disable an input event in an atomic subchart:
%
% # Right-click the atomic subchart and select *Subchart Mappings*.
% # Under *Input Event Mapping*, in the *Main chart symbol* drop-down list,
% select |&lt;disabled&gt;|.
% # Click *OK*.
% 
% <<../disable_mapping_for_input_event.png>>