Files
mocha/scripts/mcatimeout.m
2017-09-19 11:58:36 +02:00

65 lines
2.3 KiB
Matlab

function varargout = mcatimeout(varargin)
%MCATIMEOUT - set or display MCA timeout setings
%
% MCATIMEOUT('open', t1)
% 'open' option sets the internal variable MCA_SEARCH_TIMEOUT to t1 (sec)
%
% MCATIMEOUT('get', t1)
% 'get' option sets the internal variable MCA_GET_TIMEOUT to t1 (sec)
%
% MCATIMEOUT('put', t1)
% 'put' option sets the internal variable MCA_PUT_TIMEOUT to t1 (sec)
%
% MCATIMEOUT('default') sets the default values
% MCA_SEARCH_TIMEOUT = 1.0 (sec)
% MCA_GET_TIMEOUT = 5.0 (sec)
% MCA_PUT_TIMEOUT = 0.01 (sec)
%
% TIMEOUTS = MCATIMEOUT with no arguments returns a vector of currently set timeouts
% in the format [MCA_SEARCH_TIMEOUT MCA_GET_TIMEOUT MCA_PUT_TIMEOUT]
%
% Notes:
% See also: MCA.cpp
%
switch nargin
case 0
a=mocha('getTimeout');
%a(1) Put %a(2)Get
b=mocha('getOpenWaitTime');
AB=[b(1); a(2); a(1)]; %search, get, put
varargout{1} = AB(1:3); %mca(1000);
case 1
if strcmp(varargin{1}, 'default')
a=mocha('setTimeOutDefault');
b=mocha('openWaitWithTimeDefault');
AB=[b(1); a(2); a(1)]; %search, get, put
varargout{1} = AB(1:3); %mca(1004);
else
error ('Invalid command option.')
end
case 2
if strcmp(varargin{1}, 'open')
if ~isnumeric(varargin{2}) || varargin{2} <= 0
error('Second argument must be numeric, positive seconds');
end
mocha('openWaitWithTime',varargin{2});
%mca(1001,varargin{2});
elseif strcmp(varargin{1}, 'get')
if ~isnumeric(varargin{2}) || varargin{2} <= 0
error('Second argument must be numeric, positive seconds');
end
mocha('setTimeoutGet',varargin{2});
%mca(1002,varargin{2});
elseif strcmp(varargin{1}, 'put')
if ~isnumeric(varargin{2}) || varargin{2} <= 0
error('Second argument must be numeric, positive seconds');
end
mocha('setTimeoutPut',varargin{2});
%mca(1003,varargin{2});
else
error('Invalid command option.')
end
otherwise
error ('Invalid number of arguments.')
end