%% Routing Entities Using Switches

% Copyright 2008-2011 The MathWorks, Inc.

%% Overview
% This example shows how the routing of entities can be achieved via 
% *Input Switch* and *Output Switch*

modelname = 'sedemo_inputoutputswitch';
open_system(modelname);

%% Working
% In this example, the Input Switch block determines from which input port 
% to accept entities by reading values from the p input port. The Entity
% Departure Counter block sets the OutputPort attribute for the Output 
% Switch to use to determine the path for the entities. The values used by
% the Input Switch and Output Switch appear in the plots. The markers on 
% the lines in these plots indicate times at which entities pass through 
% the switch blocks. 
    
sim(modelname);

%% Related Examples
% * <matlab:helpview(fullfile(docroot,'toolbox','simevents','helptargets.map'),'doc_roundrobin'); Round-robin approach via
% Input Switch>
% * <matlab:helpview(fullfile(docroot,'toolbox','simevents','helptargets.map'),'doc_race_conditions_switch'); Race condition 
% for simultaneous events with varying event priorities using Input Switch>
% * <matlab:helpview(fullfile(docroot,'toolbox','simevents','helptargets.map'),'doc_switch_nostorage'); Signal-based output 
% switching>
% * <matlab:helpview(fullfile(docroot,'toolbox','simevents','helptargets.map'),'doc_packet_switch'); Packet switch in a 
% communication network>

%% 
%cleanup
bdclose(modelname);
clear modelname;
displayEndOfDemoMessage(mfilename)
