...
 
Commits (2)
......@@ -22,7 +22,10 @@ obj.s12 = movable('');
obj.s3 = movable('');
obj.cv8 = movable('');
obj.cv9 = movable('');
obj.sh = movable([TANGO_HOST 'srmag/hst/all/Strengths'],'absolute',true,'limits',[-4e-4 4e-4]);
obj.sh = movable([TANGO_HOST 'srmag/hst/all/Strengths'],...
'get_fun',@(devname)tango.Attribute(devname).value,...
'set_fun',@(devname,val)setfield(tango.Attribute(devname),'set',val),...
'absolute',true,'limits',[-4e-4 4e-4]);
obj.sv = movable([TANGO_HOST 'srmag/vst/all/Strengths'],'absolute',true,'limits',[-4e-4 4e-4]);
% limits can be higher, but they depend on the strengths of the steerers
obj.skew = movable([TANGO_HOST 'srmag/sqp/all/CorrectionStrengths'],'absolute',true,'limits',[-1.5e-2 1.5e-2]);
......
......@@ -58,16 +58,20 @@ classdef movable < handle
addRequired(p,'name',@ischar);
addOptional(p,'absolute',true,@islogical);
addOptional(p,'limits',[],@isnumeric);
addOptional(p,'calibration',[],@isnumeric);
addOptional(p,'calibration',1,@isnumeric);
addOptional(p,'set_tolerance',[],@isnumeric);
addOptional(p,'get_fun',@(a)tango.Attribute(name).read,@(a)isa(a,'function_handle'));
addOptional(p,'set_fun',@(a)tango.Attribute(name).set ,@(a)isa(a,'function_handle'));
addOptional(p,'get_fun',@(devname)NaN(1),@(a)isa(a,'function_handle'));
addOptional(p,'set_fun',@(devname,val)setfield(obj.attribute,'set',NaN) ,@(a)isa(a,'function_handle'));
parse(p,name,varargin{:});
obj.attr_name = p.Results.name;
obj.get_fun = p.Results.get_fun;
obj.set_fun = p.Results.set_fun;
obj.calibration = p.Results.calibration;
obj.min = -Inf;
obj.max = Inf;
% deal with empty moovable
if isempty(obj.attr_name)
......@@ -94,15 +98,12 @@ classdef movable < handle
% define default calibration to 1.
if isempty(p.Results.calibration)
calib = ones(size(obj.attribute.value));
else
calib = p.Results.calibration;
if ~ (any(size(calib) == size(obj.attribute.value)) | any(size(calib) == [1 1]))
error('wrong size of calibration array');
end
if ~ (any(size(obj.calibration) == size(obj.get)) | any(size(obj.calibration) == [1 1]))
error('wrong size of calibration array');
end
obj.calibration = calib;
% get present value of variable
v0 = obj.get;
......@@ -149,7 +150,16 @@ classdef movable < handle
% read attribute value
function v = get(obj)
% read attribute value in calibrated units
v = obj.get_fun .* obj.calibration; % this should be .SET?
if ~isempty(obj.attr_name)
try
v = obj.get_fun(obj.attr_name) .* obj.calibration; % this should be .SET?
catch
disp([obj.attr_name ' not readable with ' func2str(obj.get_fun)]);
v = NaN;
end
else
v = NaN;
end
end
......@@ -178,7 +188,7 @@ classdef movable < handle
value_calib = value ./ obj.calibration;
% set value to attribute
obj.set_fun( value_calib );
obj.set_fun(obj.attr_name, value_calib );
% wait for set point reached
v=obj.get;
......