%% Effects of Communication Delays on a Flight Control System

% Copyright 2008-2011 The MathWorks, Inc.

%% Overview
% This example shows how to modify the time-based F-14 flight control example by adding a
% network between the controller and the plant that models the aircraft
% dynamics.

  modelname = 'sedemo_f14_control_over_network';
  open_system(modelname);
  close_system([modelname '/Pilot G force Scope']);
  close_system([modelname '/Angle of  Attack']);
  close_system([modelname '/Instrumentation/Number in  Output Buffer Queues']);
  close_system([modelname '/Instrumentation/Average wait time  in Output Buffer Queues']);
  close_system([modelname '/Instrumentation/Utilization']);
  close_system([modelname '/Instrumentation/Number of  Dropped Packets']);
  open_system([modelname '/Shared Access Network Double-click to view network']);
  
%% Structure
% The network model is similar to the one in the Shared Access
% Communications Media example.
%
% In the subsystem (Shared Access Network Double-click to view network),
% double-click the Average Arrival Rate block (red) and use the slider to
% change the background traffic level. You can examine the impact of
% background traffic on the accuracy of the flight control loop. At low
% traffic volume, the delays have little effect. However, at moderate
% volume, the increased delay causes the control loop to oscillate when the
% control stick is moved quickly. At higher volume, the delays are
% sufficient to render the control loop ineffective.

%% Results And Displays
  open_system([modelname '/Pilot G force Scope']);
  open_system([modelname '/Angle of  Attack']);
  open_system([modelname '/Instrumentation/Number in  Output Buffer Queues']);
  open_system([modelname '/Instrumentation/Average wait time  in Output Buffer Queues']);
  open_system([modelname '/Instrumentation/Utilization']);
  open_system([modelname '/Instrumentation/Number of  Dropped Packets']);
  sim(modelname);
  
%% Related Examples
% * <matlab:helpview(fullfile(docroot,'toolbox','simevents','helptargets.map'),'doc_gateways'); Converting Between Time-Based and Event-Based Signals>

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