%% Monitoring Ink Status on a Shared Printer Using Simulink Functions
% This example shows how clients, in this case three computers, can send
% jobs to a server, a printer, and receive status from that server. This
% example highlights how Simulink functions can be called from different
% subsystems and interact in both Simulink(R) and Stateflow(R). (Note that
% when you simulate the example, Stateflow might generate code in the
% current working folder.)
%
% The computers each generate randomly sized print jobs at
% regular intervals. The printer interacts with the computers through
% two Simulink functions on the Simulink canvas and one exported
% graphical function in Stateflow.
%
% The clients use
% <docid:simulink_ref#mw_e8ac3ca8-33a8-4624-a902-096b2ba47d4d> blocks to
% invoke the |addPrintJob| interface of the printer. The client-server
% interaction modeled by this call may have a negative return value if the
% printer has run out of ink.
%
% The example also shows how to interface Simulink and Stateflow using
% functions. 
%
% The implementation of |addPrintJob| uses a Function Caller block to
% invoke |queuePrintJob|, a Stateflow exported graphical function. The
% |queuePrintJob| function interacts with other content in the chart using
% a local chart variable |work|.
%
% The implementation of the chart makes a call to |printerInk|, a
% Simulink function, which uses the graphical input and outputs to
% interact with the |addPrintJob| function.
%
% You can also visualize and debug Simulink functions.
%
% To enable the visualization lines connecting functions and their
% respective callers, in the Simulink Editor, on the *Debug* tab, under
% *Information Overlays*, click *Function Connectors*.
%
% The <docid:simulink_ref#buc4bm_-1> block shows where calls to functions
% are generated and which functions are called at different times. This
% information allows you to understand the flow of calls with respect to
% time and analyze the arguments sent during these calls to functions.
%
% Copyright 2014 The MathWorks, Inc.
%

mdl = 'slexPrinterExample';
open_system(mdl);
curDir = pwd;
cd(tempdir);
