function MPlayTutorFcn(action)
%MPlayTutorFcn Helper function for MPlay tutorials.

% Copyright 2004-2005 The MathWorks, Inc.
% $Date: 2010/11/01 23:13:47 $ $Revision: 1.1.6.2 $

switch action
    case 'ModelStart'
        vipmplaytut;  % verify model is open
        set_param('vipmplaytut','SimulationCommand','start')
    case 'ModelStop'
        vipmplaytut;  % verify model is open
        set_param('vipmplaytut','SimulationCommand','stop')
    case 'DisconnectSig'
        m=mplayfind;
        if isempty(m), m=mplay; end % skipped steps?
        m(1).releaseData;
    case 'SelectRGBVideoBlock'
        vipmplaytut; % skipped steps?
        s=slmgr.SignalSelectMgr({'vipmplaytut/RGB Video',1},true);
        s.unselect('all');
        % Need "select block only" method - workaround for now:
        s=get_param('vipmplaytut/RGB Video','object');
        s.select='on';
    case 'ConnectSig'
        m=mplayfind;
        if isempty(m), m=mplay; end % skipped steps?
        m(1).connectToDataSource(m(1).getExtInst('Sources', 'Simulink'));
    case 'SelectSig1'
        vipmplaytut; % skipped steps?
        s=slmgr.SignalSelectMgr({'vipmplaytut/Rotate',1}, true);
        s.unselect('all'); s.select; s.flash;
    case 'SelectSig2' 
        vipmplaytut; % skipped steps? 
        s=slmgr.SignalSelectMgr({'vipmplaytut/Bus Selector',2},true); 
        s.unselect('all'); s.select; s.flash; 
    case 'SelectSig3'
        vipmplaytut; % skipped steps?
        s=slmgr.SignalSelectMgr({'vipmplaytut/RGB Video',1:3}, true);
        s.unselect('all'); s.select; s.flash;
    case 'BeginTutorial'
        helpview(fullfile(docroot, 'toolbox', 'vision', 'vision.map'), 'mplaytutorial');
    otherwise
        error('vipblks:MPlayTutorFcn:unrecognizedAction', ...
            'Unrecognized action: %s', action)
end

% [EOF]
