Code covered by the BSD License  

Highlights from
CO2gui - lab control and automation

CO2gui - lab control and automation

by

 

06 Jan 2010 (Updated )

Software used for controlling and data logging lab equipment.

rheodyneobjstop(rheodyneTimer)
function rheodyneobjstop(rheodyneTimer)
% RHEODYNEOBJSTOP stops the timer for Rheodyne controllers
% rheodyneobjstop(rheodyneTimer) stops the timer for Rheodyne control,
% given a valid timer object.

% e.g. rheodyneobjstop(rheodyneobj) stops the Rheodyne timer.


% checks the number of arguments
error(nargchk(1, 1, nargin))

% error handling
if length(rheodyneTimer) > 1 || ~isvalid(rheodyneTimer)
    % errors
    error('rheodyneTimer must be a valid scalar timer object.')
    
elseif ~strcmp(rheodyneTimer.Tag, 'rheodyne')
    % errors
    error('Incorrect timer - the timer must be generated from rheodyneobj.')
end

% gets the user data
userData = rheodyneTimer.UserData;

% more error handling
if ~isfield(userData, 'audioPlayerObject')
    % error
    error('audioPlayerObject is missing from the timer UserData.')
    
elseif ~isa(userData.audioPlayerObject, 'audioplayer')
    % error
    error('audioPlayerObject in timer UserData is not an audioplayer object.')
end

% stop it only if it was already running (stops annoying warnings coming up
if isrunning(rheodyneTimer)
    % stops the timer
    stop(rheodyneTimer)
end

% if the sound is playing...
if isplaying(userData.audioPlayerObject)
    % also stop the sound
    try
        % tries
        stop(userData.audioPlayerObject)

    catch
        % warning
        warning('rheodyneObjAudio:couldNotStopSound', 'Could not stop the audio from playing.')
    end
end

Contact us