function varargout = Channels(varargin)
%CHANNELS Set/Get Channels settings
%
% Usage:
% To get current values and structure used for setting values use:
% h=channels;
% To set the values of the Channel pass the structure in with the
% appropriate values you want to set.
% channels(h);
%
% Example:
% h=channels('C1');
% h.Samples = 5002;
% channels(h);
%Proplist = {'DataArray','ExtendedStatus','FirstEventTime','HorizontalFrameStart','HorizontalFrameStop','HorizontalOffset','HorizontalPerStep','HorizontalResolution','HorizontalUnits','HorizontalVariances','IndexOfFirstSampleInFrame','LastEventTime','NumSamplesInFrame','Samples','Status','StatusDescription','Sweeps','UpdateTime','VerticalFrameStart','VerticalFrameStop','VerticalOffset','VerticalPerStep','VerticalResolution','VerticalUnits'};
if nargin==1
if ischar(varargin{1})
% User wants the current settings.
h=actxserver('Lecroy.WaveMasterApplication');
u=h.Object.Item('Acquisition').Object.Item(varargin{1});
values = get(u.Out.Result);
values.handle = u.Out.Result;
varargout{1} = values;
else
% User wants to set the current settings to what they passed.
setValue(varargin{1});
end;
else
help channels
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;