Code covered by the BSD License  

Highlights from
MATLAB-WaveMaster XDEV Demos

from MATLAB-WaveMaster XDEV Demos by Adarsh Narasimhamurthy
LeCroy WaveMaster DSO demo files.

Horizontal(varargin)
function varargout = Horizontal(varargin)
%HORIZONTAL Set/Get Horizontal settings
%
% Usage:  
%   To get current values and structure used for setting values use:
%   h=auxout; 
%   To set the values of the AuxOut pass the structure in with the
%   appropriate values you want to set.
%   auxout(h); 
%
% Example:
%   h=auxout;
%   h.Amplitude = 0.2;
%   auxout(h);

%Proplist = {'AcquisitionDuration','ActiveChannels','ExternalClockRate','HorOffset','HorOffsetOrigin','HorScale','HorScaleDown','HorScaleUp','HorUnits','MaxSamples','MaxSamplesDown','MaxSamplesUp','NumOfAdcs','NumPoints','NumSegments','ReferenceClock','RISType','SampleClock','SampleMode','SampleRate','SamplingRate','SamplingRateDown','SamplingRateUp','SequenceTimeout','SequencyTimeoutEnable','SetupSmartMemory','SmartMemory','TimePerPoint','ZeroDelay'};
Proplist = {'AcquisitionDuration','ActiveChannels','ExternalClockRate','HorOffset','HorOffsetOrigin','HorScale','HorUnits','MaxSamples','NumOfAdcs','NumPoints','NumSegments','ReferenceClock','RISType','SampleClock','SampleMode','SampleRate','SamplingRate','SequenceTimeout','SmartMemory','TimePerPoint'};
switch nargin
    case 0
        % User wants the current settings.
        h=actxserver('Lecroy.WaveMasterApplication');
        u=h.Object.Item('Acquisition').Object.Item('Horizontal');
        values = getValues(u,Proplist);
        ranges = getRanges(u,Proplist);
        varargout{1} = values;
        varargout{2} = ranges;
    case 1
        % User wants to set the current settings to what they passed.
        setValue(varargin{1});
end;


function x = getValues(h,Proplist)
%
x.handle = h;
for idx=1:length(Proplist)
    try
        hprop = get(h,Proplist{idx});
        value = get(hprop,'Value');
        x=setfield(x,Proplist{idx},value);
    catch
        Proplist{idx}
    end;
end;

function x = getRanges(h,Proplist)
%
x.handle = h;
for idx=1:length(Proplist)
    hprop = get(h,Proplist{idx});
    range = parseRange(get(hprop,'RangeStringAutomation'));
    x=setfield(x,Proplist{idx},range);
end;


function cellarray = parseRange(str)
%
%
%
token = strfind(str,',');
if ~isempty(token)
    cellarray{1}=parseVector(str(1:token(1)-1));
    if length(token)>1
        for idx=2:length(token)
            cellarray{idx}= parseVector(str(token(idx-1)+1:token(idx)-1));
        end;
    end;
    cellarray{end+1}= parseVector(str(token(end)+1:end));
else
    cellarray = parseVector(str);
end;

function str = parseVector(str)
%
if strfind(str,'From')
    if strfind(str,'to')
        if strfind(str,'step')
            
            str = strrep(str,'From ','[');
            str = strrep(str,' to ','::');
            str = strrep(str,' step ',']');
            idx = strfind(str,']');
            incr = str(idx+1:end);
            str = str(1:idx);
            str = strrep(str,'::',[':',incr,':']);
        end;
    end;
end;


function setValue(hstr)
%
h=hstr.handle;
hstr = rmfield(hstr,'handle');

Proplist = fields(hstr);
for idx=1:length(Proplist)
    try
        hprop = get(h,Proplist{idx});
        set(hprop,'Value',hstr.(Proplist{idx}));
    catch
        disp(['Property: ',Proplist{idx},' is not setable']);
    end;
end;

Contact us at files@mathworks.com