www.gusucode.com > rtwdemos 工具箱matlab源码程序 > rtwdemos/rtwdemo_async_mdlreftop_script.m
function rtwdemo_async_mdlreftop_script(action) % rtwdemo_async_mdlreftop_script: Helper script for the example model % rtwdemo_async_mdlreftop to perform the specified activities for % examples to the user % Inputs: % action: the type of the action to be performed % The user may direct the following actions to be performed % 1. BuildGRT : build the model in the GRT Mode % 2. BuildERT : build the model in the ERT Mode % 3. TsDisplay: display the sample time colors of the model % Copyright 2011-2012 The MathWorks, Inc. switch action case 'BuildGRT' localBuildTheModelInGRTMode(); case 'BuildERT' localBuildTheModelInERTMode(); case 'TsDisplay' localDisplaySampleTimeColors(); otherwise fprintf(['Invalid option: valid options are ''BuildGRT'', ', ... '''BuildGRT'', or ''TsDisplay''\n']); end % ------------------------------------------------------------------------- % LOCAL HELPER FUNCTIONS % ------------------------------------------------------------------------- function localBuildTheModelInGRTMode() % localBuildTheModelInGRTMode: Local helper function to set-up the model % and build in the GRT Mode % Check if the base variable for configuration set reference exists if ~exist('demoConfigSet', 'var') load('rtwdemo_async_mdlreftop_data'); end % Example model topMdl = 'rtwdemo_async_mdlreftop'; try evalin('base', ... 'set_param(demoConfigSet, ''SystemTargetFile'', ''tornado.tlc'');'); evalin('base', ... 'set_param(demoConfigSet, ''TemplateMakefile'', ''tornado.tmf'');'); rtwbuilddemomodel(topMdl); catch BuildFailure rethrow(BuildFailure); end % Clean-up evalin('base', 'clear topMdl;'); % ------------------------------------------------------------------------- function localBuildTheModelInERTMode() % localBuildTheModelInGRTMode: Local helper function to set-up the model % and build in the GRT Mode % BUILD FOR ERT TARGET % Check if the base variable for configuration set reference exists if ~exist('demoConfigSet', 'var') load('rtwdemo_async_mdlreftop_data'); end % Example model topMdl = 'rtwdemo_async_mdlreftop'; try evalin('base', ... 'set_param(demoConfigSet, ''SystemTargetFile'', ''ert.tlc'');'); evalin('base', ... 'setProp(demoConfigSet, ''TargetOS'', ''VxWorksExample'');'); evalin('base', ... 'setProp(demoConfigSet, ''CombineOutputUpdateFcns'', ''off'');'); rtwbuilddemomodel(topMdl); catch BuildFailure rethrow(BuildFailure); end % Clean-up evalin('base', 'clear topMdl;'); % ------------------------------------------------------------------------- function localDisplaySampleTimeColors() % localDisplaySampleTimeColors: Displays the sample times for the model % SCRIPT TO DISPLAY THE SAMPLE TIME COLORS model = 'rtwdemo_async_mdlreftop'; % Set the SampleTimeColors parameter to 'on' and update the model set_param(model, 'SampleTimeColors', 'on'); feval(model, [], [], [], 'compile'); feval(model, [], [], [], 'term'); % Clean-up: evalin('base', 'clear model;'); % -------------------------------------------------------------------------