77 lines
2.8 KiB
Matlab
77 lines
2.8 KiB
Matlab
function varargout = mcagets(varargin)
|
|
%MCAGETS - read values from PV's, with string output for ENUMs
|
|
%
|
|
% VALUE = MCAGETS(HANDLE) returns a value of a PV specified by integer HANDLE.
|
|
% Type of return value depends on the native type and the number of elements
|
|
% in the EPICS record:
|
|
%
|
|
% EPICS strings are returned as MATLAB strings
|
|
% EPICS array of strings - MATLAB cell array of strings
|
|
% All numeric EPICS types are returned as MATLAB double arrays
|
|
% This routine returns the string value of ENUM types, when the input
|
|
% parameter is a single handle. Otherwise this routine behaves
|
|
% identically to MCAGET
|
|
%
|
|
% VALUES = MCAGETS(HANDLES) an easy get for a group of scalar numeric PV's
|
|
% HANDLES - array of handles
|
|
% VALUES - numeric array of values.
|
|
% If any of the PVs is a waveform,
|
|
% only the first element is returned
|
|
%
|
|
% [VALUE1, ... VALUEN] = MCAGETS(HANDLE1, ... , HANDLEN)
|
|
% returns values of multiple PV's of any type and length
|
|
% Number of outputs must match the number of inputs
|
|
%
|
|
% Error handling:
|
|
% A matlab exception will be thrown when any of the PVs are invalid,
|
|
% i.e. not the result of a successful MCAOPEN.
|
|
% Furthermore, an error can result from a 'get' timeout,
|
|
% configurable via MCATIMEOUT.
|
|
% In addition, an error can result from a network disconnect.
|
|
% In principle, one can check beforehand via MCASTATE, but since
|
|
% a disconnect might happen just between the sucessful MCASTATE call
|
|
% and the following MCAGET, the only safe thing might be to surround
|
|
% MCAGET calls with TRY....CATCH.
|
|
%
|
|
% See also TRY, CATCH, MCASTATE, MCATIMEOUT, MCAPUT
|
|
if nargin<1
|
|
error('No arguments were specified in mcaget')
|
|
elseif nargin==1
|
|
if length(varargin{1})>1
|
|
[a, isallOK]=mocha('getScalarArray', varargin{1}, 'double');
|
|
varargout{1} = [a]; %mca(51,varargin{1});
|
|
else
|
|
|
|
varargout{1} = mocha('get', varargin{1});
|
|
|
|
%if(strcmp(mca(43,varargin{1}),'ENUM'))
|
|
% enumvalues=mca(40,varargin{1});
|
|
% varargout{1}= enumvalues{mca(50,varargin{1})+1};
|
|
% else
|
|
% varargout{1} =mca(50,varargin{1});
|
|
% end
|
|
end
|
|
elseif nargin>1
|
|
if nargin ~= nargout
|
|
error('Number of outputs must match the number of inputs')
|
|
end
|
|
[a, isallOK]=mocha('getStructArray', [varargin{:}]);
|
|
for k=1:length(a)
|
|
chInfo=mocha('getInfo', varargin{k});
|
|
if( length(a(k).val) ==1 && strcmp(chInfo.dataType,'DBR_ENUM') )
|
|
varargout{k}=mocha('getCache', varargin{k}, 'double');
|
|
|
|
else
|
|
if (length(a(k).val)==1 && iscell(a(k).val))
|
|
varargout{k}=a(k).val{1};
|
|
else
|
|
varargout{k}=a(k).val;
|
|
end
|
|
end
|
|
end
|
|
%[varargout{1:nargin}] mca(50,varargin{:})
|
|
|
|
end
|
|
|
|
|