%% Modeling System Architecture of Small UAV

%% Overview
% This example shows how to set up the architecture for a small unmanned
% aerial vehicle, composed of six top-level systems. You also learn how to
% refine your architecture design by authorizing interfaces, linking to
% requirements, defining profiles and stereotypes, and running analysis on
% such an architecture model.
%
% Open the project:
[projectFolder,~]=matlab.internal.project.example.projectDemoSetUp(...
    fullfile(matlabroot,'toolbox','systemcomposer','examples','SmallUAV.zip'),[],true);
openProject(projectFolder);

%%
% Each system is decomposed into its components.
% Navigate through the hierarchy to view the composition for each
% component. 
% The root component, SmallUAV, has input and output ports that represent
% data exchange between the system and its environment.

%% Authorize Interfaces
% You define interfaces in a local data dictionary. Turn on the *Interface
% Editor* to view the interfaces. Click the *GS Commands* port on
% the architecture model to highlight the *architecture_gsCommands* interface
% and indicate the assignment.

%% Inspect Requirements
% Components in the architecture model link to system requirements defined
% in |smallUAVReqs.slreqx| . Open the Requirements Perspective for the model.
% Select components to see the requirement they link to, or, conversely, 
% select items in the *Requirements* view to see which components
% implement them.

%% Define Profiles and Stereotypes
% To complete specifications and enable analysis later in the design
% process, stereotypes add custom metadata to architecture model
% elements. This model has stereotypes for these elements:

%%
% * On-board element, applicable to components
% * RF connector, applicable to ports
% * RF wiring, applicable to connectors

%%
% Stereotypes are defined in XML files called Profiles. The profile
% |UAVComponent.xml| is attached to this model. You can edit a profile using
% the Profile Editor.

%% Analyze the Model
% An analysis model can be produced from this specification model for the
% purpose of running static analyses on this system. An analysis model is
% is a tree of instances generated from the elements of the specification
% model in which all referenced models are flatted out, and all variants
% are resolved.
%
% Run a mass rollup on this model. From the toolstrip, click *Analysis Model*,
% and then *Analysis Model* again. Select the stereotypes that you want to
% include in your analysis. Clear the *Strict Mode* checkbox. Select the
% analysis function by browsing to |utilities/massRollUp.m|. Set the model
% iteration mode to *Bottom-up* and click *Instantiate*.
%
% The analysis function iterates through model elements bottom up,
% assigning the *Mass* property of each component as a sum of the
% *Mass* properties of its subcomponents. The overall weight of the
% system is assigned to the *Mass* property of the top level component,
% SmallUAV.

%%
displayEndOfDemoMessage(mfilename)
