Commit b41d4023 authored by Simone Liuzzo's avatar Simone Liuzzo Committed by Nicola Carmignani

Moovable

parent d7f67e3f
......@@ -95,20 +95,20 @@ ModelRM.TrajVCor{1} = [];
ModelRM.TrajVCor{3} = [];
if h
hs0 = obj.getHSteerers;
hs0 = obj.sh.get;
for ik = 1:length(hs0) %
if enabledcorH(ik) % only if eneabled corrector
disp(['H steerer' num2str(ik)])
hs = hs0;
hs(ik) = hs(ik) + deltak;
obj.setHSteerers(hs);
obj.sh.set(hs);
pause(waitPStime);
t = obj.measuretrajectory;
obj.setHSteerers(hs0);
obj.sh.set(hs0);
rmh(:,ik) = (t(1,:) - t0(1,:))./deltak; % m/rad
rmv(:,ik) = (t(2,:) - t0(2,:))./deltak;
......@@ -130,16 +130,16 @@ obj.ModelRM = ModelRM; %temporary store of ModelRM
if measrf
% RF RM
disp('RF RM');
rf0 = obj.getRFFrequency;
rf0 = obj.rf.get;
rf = rf0 + deltarf;
obj.setRFFrequency(rf);
obj.rf.get(rf);
pause(waitPStime);
t = obj.measuretrajectory;
obj.setRFFrequency(rf0);
obj.rf.set(rf0);
ModelRM.TrajHDPP = (t(1,:) - t0(1,:))./deltarf;
ModelRM.TrajVDPP = (t(2,:) - t0(2,:))./deltarf;
......@@ -152,7 +152,7 @@ obj.ModelRM = ModelRM; %temporary store of ModelRM
% V steerers RM
if v
vs0 = obj.getVSteerers;
vs0 = obj.sv.get;
for ik = 1:length(vs0) %1:2%
if enabledcorV(ik) % only if eneabled corrector
......@@ -160,13 +160,13 @@ if v
vs = vs0;
vs(ik) = vs(ik) + deltak;
obj.setVSteerers(vs);
obj.sv.set(vs);
pause(waitPStime);
t = obj.measuretrajectory;
obj.setVSteerers(vs0);
obj.sv.set(vs0);
rmh(:,ik) = (t(1,:) - t0(1,:))./deltak;
rmv(:,ik) = (t(2,:) - t0(2,:))./deltak;
......@@ -186,19 +186,21 @@ obj.ModelRM = ModelRM; %temporary store of ModelRM
% septa
disp('septa RM')
if sp
hs0 = obj.getSepta;
hs0 = [obj.s12.get obj.s3.get];
for ik = 1:length(hs0)
hs = hs0;
hs(ik) = hs(ik) + deltak;
obj.setSepta(hs);
obj.s12.set(hs(1));
obj.s3.set(hs(2));
pause(waitPStime);
t = obj.measuretrajectory;
obj.setSepta(hs0);
obj.s12.set(hs0(1));
obj.s3.set(hs0(2));
ModelRM.RMSP(ik,:) = (t(1,:) - t0(1,:))./deltak;
......@@ -210,19 +212,21 @@ obj.ModelRM = ModelRM; %temporary store of ModelRM
% CV TL2 steerers RM
disp('CV RM')
if cv
vs0 = obj.getTL2CV;
vs0 = [obj.cv8.get obj.cv9.get];
for ik = 1:length(vs0)
vs = vs0;
vs(ik) = vs(ik) + deltak;
obj.setTL2CV(vs);
obj.cv8.set(vs(1));
obj.cv9.get(vs(2));
pause(waitPStime);
t = obj.measuretrajectory;
obj.setTL2CV(vs0);
obj.cv8.set(vs0(1));
obj.cv9.get(vs0(2));
ModelRM.RMCV(ik,:) = (t(2,:) - t0(2,:))./deltak;
......
......@@ -110,7 +110,7 @@ addOptional(p,'ask_to_continue',true,@islogical); % if cell compute, if struct R
parse(p,obj,varargin{:});
alpha = mcf(r0);
f0 = obj.getRFFrequency;% atgetfieldvalues(r0,find(atgetcells(r0,'Frequency'),1,'first'),'Frequency');
f0 = obj.rf.get;% atgetfieldvalues(r0,find(atgetcells(r0,'Frequency'),1,'first'),'Frequency');
inCOD = zeros(6,1);
indBPM = p.Results.indBPM;
......@@ -396,7 +396,7 @@ while (nbpmu<=length(indBPM)*corropt.maxturns) && ~stopped
end
% get initial corrector values
corh0=obj.getHSteerers;
corh0=obj.sh.get;
% restrict RM to usable correctors
......@@ -422,7 +422,7 @@ while (nbpmu<=length(indBPM)*corropt.maxturns) && ~stopped
RespH = [RMSP(:,usebpm)',RespH];
steermeanlist = [zeros(1,size(RMSP,1)), steermeanlist];
Septas = obj.getSepta;
Septas = [obj.s12.get obj.s3.get];
S120 = Septas(1);
S30 = Septas(2);
......@@ -532,14 +532,6 @@ while (nbpmu<=length(indBPM)*corropt.maxturns) && ~stopped
cc(usecorH) = dch;
tothcor=corh0-cc;
if ~isempty(corropt.steererlimit)
if abs(tothcor)>corropt.steererlimit(1)
disp('Steerers above limit!')
end
tothcor(tothcor>corropt.steererlimit(1))=corropt.steererlimit(1);
tothcor(tothcor<-corropt.steererlimit(1))=-corropt.steererlimit(1);
end
end
......@@ -549,7 +541,7 @@ while (nbpmu<=length(indBPM)*corropt.maxturns) && ~stopped
end
% get current correctors values
corv0=obj.getVSteerers;
corv0=obj.sv.get;
% restrict RM
RespV=RMV(usebpm,usecorV);
......@@ -572,7 +564,7 @@ while (nbpmu<=length(indBPM)*corropt.maxturns) && ~stopped
RespV = [RMCV(:,usebpm)',RespV];
steermeanlist = [zeros(1,size(RMCV,1)), steermeanlist];
TL2CV = obj.getTL2CV;
TL2CV = [obj.cv8.get obj.cv9.get];
CV80 = TL2CV(1);
CV90 = TL2CV(2);
......@@ -668,44 +660,39 @@ while (nbpmu<=length(indBPM)*corropt.maxturns) && ~stopped
cc = corv0*0;
cc(usecorV) = dcv;
totvcor=corv0-cc;
if ~isempty(corropt.steererlimit)
if abs(totvcor)>corropt.steererlimit(2)
disp('Steerers above limit!')
end
totvcor(totvcor>corropt.steererlimit(2))=corropt.steererlimit(2);
totvcor(totvcor<-corropt.steererlimit(2))=-corropt.steererlimit(2);
end
end
%% APPLY CORRECTION
if corropt.corTL2
obj.setSepta([S12 S3])
obj.s12.set(S12)
obj.s3.set(S3)
end
if corropt.corH
obj.setHSteerers(tothcor);
obj.sh.set(tothcor);
end
if corropt.corRF
obj.setRFFrequency(f0-alpha*(deltacor)*f0);
obj.rf.set(f0-alpha*(deltacor)*f0);
end
if corropt.corTL2
obj.setTL2CV([CV8 CV9]);
obj.cv8.set(CV8)
obj.cv9.set(CV9);
end
if corropt.corV
obj.setVSteerers(totvcor);
obj.sv.set(totvcor);
end
......@@ -767,7 +754,7 @@ while (nbpmu<=length(indBPM)*corropt.maxturns) && ~stopped
end
ax2=subplot(2,2,2);
bar(scorh,repmat(obj.getHSteerers,1,1));
bar(scorh,repmat(obj.sh.get,1,1));
ylabel('hor [rad]');
%xlabel('s [m]');
ax2.XTick=scorh;
......@@ -798,7 +785,7 @@ while (nbpmu<=length(indBPM)*corropt.maxturns) && ~stopped
end
ax4=subplot(2,2,4);
bar(scorv,repmat(obj.getVSteerers,1,1));
bar(scorv,repmat(obj.sv.get,1,1));
ylabel('ver [rad]');
xlabel('s [m]');
linkaxes([ax1 ax3],'x');
......@@ -927,22 +914,22 @@ end
% read final steerer settings
if corropt.corH
hs = obj.getHSteerers;
hs = obj.sh.get;
else
disp('wished h steerers values, not set')
hs = corh0-dch;
end
if corropt.corV
vs = obj.getVSteerers;
vs = obj.sv.get;
else
disp('wished h steerers values, not set')
vs = corv0-dcv;
end
if corropt.corTL2
sp = obj.getSepta;
cv = obj.getTL2CV;
sp = [obj.s12.get obj.s3.get];
cv = [obj.cv8.get obj.cv9.get];
else
disp('wished septa and CV89 values, not set')
sp = [NaN NaN];
......@@ -951,7 +938,7 @@ end
if corropt.corRF
freq = obj.getRFFrequency;
freq = obj.rf.get;
else
disp('wished frequency change')
freq = f0-alpha*(deltacor)*f0;
......@@ -979,6 +966,11 @@ corropt.number_of_acquisitions = inputcor('# of trajectories to average',
obj.n_acquisitions = corropt.number_of_acquisitions;
corropt.steererlimit(1) = inputcor('Maximum hor. steerer strength', corropt.steererlimit(1));
corropt.steererlimit(2) = inputcor('Maximum ver. steerer strength', corropt.steererlimit(2));
obj.sh.min= - corropt.steererlimit(1);
obj.sh.max= + corropt.steererlimit(1);
obj.sv.min= - corropt.steererlimit(2);
obj.sv.max= + corropt.steererlimit(2);
corropt.maxturns = inputcor('accepted number of turns to end correction',corropt.maxturns);
corropt.correctturns = inputcor(['number of turns to correct (change RM size, max ' num2str(corropt.max_turns_RM) ')'],corropt.correctturns);
if corropt.correctturns > corropt.max_turns_RM
......
......@@ -7,17 +7,11 @@ classdef InjBumpClosure < RingControl %& GridScan
properties
attr_bump
attr_K1
attr_K2
attr_K3
attr_K4
calibK1
calibK2
calibK3
calibK4
calibbump
bump
K1
K2
K3
K4
ModelRM
......@@ -43,18 +37,12 @@ classdef InjBumpClosure < RingControl %& GridScan
case 'esrf-sr'
obj.attr_bump = 'sr/ps-bump/inj/Amplitude';
obj.attr_K1 = 'sr/ps-k1/1/Current';
obj.attr_K2 = 'sr/ps-k1/1/Current';
obj.attr_K3 = 'sr/ps-k1/1/Current';
obj.attr_K4 = 'sr/ps-k1/1/Current';
obj.bump = moovable('sr/ps-bump/inj/Amplitude','calibration',1e-3);
obj.K1 = moovable('sr/ps-k1/1/Current','calibration',obj.kick(5,1)/1775);
obj.K2 = moovable('sr/ps-k1/1/Current','calibration',obj.kick(5,2)/1518);
obj.K3 = moovable('sr/ps-k1/1/Current','calibration',obj.kick(5,3)/1512);
obj.K4 = moovable('sr/ps-k1/1/Current','calibration',obj.kick(5,4)/1769);
obj.calibK1 = obj.kick(5,1)/1775 ;% [rad]/A
obj.calibK2 = obj.kick(5,2)/1518 ;% [rad]/A
obj.calibK3 = obj.kick(5,3)/1512 ;% [rad]/A
obj.calibK4 = obj.kick(5,4)/1769 ;% [rad]/A
obj.calibbump = 1e-3; %
b = load('/users/beamdyn/dev/commissioningtools/@InjBumpClosure/InjBumpESRF-SR_RM.mat');
obj.ModelRM = b.ModelRM;
......
......@@ -41,7 +41,7 @@ if ~simulator
deltak = 1e-4; % rad
deltabump = 1e-3;
else
deltak = 1e-4; % A
deltak = 1e-4; % rad
deltabump = 1e-3; % m
end
......@@ -54,66 +54,60 @@ ModelRM.TrajK3{1} = [];
ModelRM.TrajBump{1} = [];
% K1
ik = 1;
s = tango.Attribute(obj.K1);
s0 = s.value; % initial value
s.set = s0 + deltak./obj.calibK1;
%K1
ik = 1;
s0 = obj.K1.value; % initial value
obj.K1.set(s0 + deltak);
pause(waitPStime);
t = obj.measuretrajectory;
s.set = s0 ;
obj.K1.set(s0);
rmh(:,ik) = (t(1,:) - t0(1,:))./deltak; % m/rad
rmv(:,ik) = (t(2,:) - t0(2,:))./deltak;
% K2
ik = 2;
s = tango.Attribute(obj.K2);
s0 = s.value; % initial value
s.set = s0 + deltak./obj.calibK2;
s0 = obj.K2.value; % initial value
obj.K2.set(s0 + deltak);
pause(waitPStime);
t = obj.measuretrajectory;
s.set = s0 ;
obj.K2.set(s0);
rmh(:,ik) = (t(1,:) - t0(1,:))./deltak; % m/rad
rmv(:,ik) = (t(2,:) - t0(2,:))./deltak;
% K3
ik = 3;
s = tango.Attribute(obj.K3);
s0 = s.value; % initial value
s.set = s0 + deltak./obj.calibK3;
s0 = obj.K3.value; % initial value
obj.K3.set(s0 + deltak);
pause(waitPStime);
t = obj.measuretrajectory;
s.set = s0 ;
obj.K3.set(s0);
rmh(:,ik) = (t(1,:) - t0(1,:))./deltak; % m/rad
rmv(:,ik) = (t(2,:) - t0(2,:))./deltak;
% K4
ik = 4;
s = tango.Attribute(obj.K4);
s0 = s.value; % initial value
s.set = s0 + deltak./obj.calibK4;
s0 = obj.K4.value; % initial value
obj.K4.set(s0 + deltak);
pause(waitPStime);
t = obj.measuretrajectory;
s.set = s0 ;
obj.K4.set(s0);
rmh(:,ik) = (t(1,:) - t0(1,:))./deltak; % m/rad
rmv(:,ik) = (t(2,:) - t0(2,:))./deltak;
......@@ -127,15 +121,14 @@ obj.ModelRM = ModelRM; %temporary store of ModelRM
% bump
s = tango.Attribute(obj.bump);
s0 = s.value; % initial value
s.set = s0 + deltabump./obj.calibbump;
s0 = obj.bump.value; % initial value
obj.bump.set(s0 + deltabump);
pause(waitPStime);
t = obj.measuretrajectory;
s.set = s0 ;
obj.bump.set(s0);
rmh(:,ik) = (t(1,:) - t0(1,:))./deltabump; % m/mm
rmv(:,ik) = (t(2,:) - t0(2,:))./deltabump;
......
......@@ -205,14 +205,6 @@ if response == 'y'
end
% initilize attributes.
k1 = tango.Attribute(obj.attr_K1);
k2 = tango.Attribute(obj.attr_K2);
k3 = tango.Attribute(obj.attr_K3);
k4 = tango.Attribute(obj.attr_K4);
bump = tango.Attribute(obj.attr_bump);
%% loop until stopped
while ~stopped
......@@ -329,12 +321,12 @@ while ~stopped
end
% get initial corrector values (rad)
K0 = [k1.set*obj.calibK1;...
k2.set*obj.calibK2;...
k3.set*obj.calibK3;....
k4.set*obj.calibK4;];
K0 = [obj.k1.get;...
obj.k2.get;...
obj.k3.get;....
obj.k4.get;];
bump0 = bump.set*obj.calibbump;
bump0 = obj.bump.get;
% restrict RM to usable correctors
RespH=[RMK(usebpm,:);RMbump(usebpm,:)];
......@@ -414,11 +406,11 @@ while ~stopped
disp(dch);
disp('CORRECTION UNSET')
% disp('set correction in A');
% k1.set = dch(1)./obj.calibK1;
% k2.set = dch(2)./obj.calibK2;
% k3.set = dch(3)./obj.calibK3;
% k4.set = dch(4)./obj.calibK4;
% bump.set = dch(5)./obj.calibbump;
% obj.k1.set(dch(1));
% obj.k2.set(dch(2));
% obj.k3.set(dch(3));
% obj.k4.set(dch(4));
% obj.bump.set(dch(5));
if printouttext
disp('correcting trajectory'); end
......@@ -605,6 +597,15 @@ corropt.number_of_acquisitions = inputcor('# of trajectories to average',
obj.n_acquisitions = corropt.number_of_acquisitions;
corropt.steererlimit(1) = inputcor('Minimum hor. kickers strength', corropt.steererlimit(1));
corropt.steererlimit(2) = inputcor('Maximum hor. kickers strength', corropt.steererlimit(2));
obj.k1.min= - corropt.steererlimit(1);
obj.k1.max= + corropt.steererlimit(2);
obj.k2.min= - corropt.steererlimit(1);
obj.k2.max= + corropt.steererlimit(2);
obj.k3.min= - corropt.steererlimit(1);
obj.k3.max= + corropt.steererlimit(2);
obj.k4.min= - corropt.steererlimit(1);
obj.k4.max= + corropt.steererlimit(2);
corropt.correctturns = inputcor(['number of turns to correct (change RM size, max ' num2str(corropt.max_turns_RM) ')'],corropt.correctturns);
if corropt.correctturns > corropt.max_turns_RM
......
function ModelRM = MeasureTrajectoryRM(obj,varargin)
function ModelRM = MeasureOrbitRM(obj,varargin)
% measure trajectory RM (single sided)
% optional inputs:
% 'h',true
......@@ -83,20 +83,20 @@ ModelRM.TrajVCor{1} = [];
ModelRM.TrajVCor{3} = [];
if h
hs0 = obj.getHSteerers;
hs0 = obj.sh.get;
for ik = 1:length(hs0) %
if enabledcorH(ik) % only if eneabled corrector
disp(['H steerer' num2str(ik)])
hs = hs0;
hs(ik) = hs(ik) + deltak;
obj.setHSteerers(hs);
obj.sh.set(hs);
pause(waitPStime);
t = obj.measuretrajectory;
obj.setHSteerers(hs0);
obj.sh.set(hs0);
rmh(:,ik) = (t(1,:) - t0(1,:))./deltak; % m/rad
rmv(:,ik) = (t(2,:) - t0(2,:))./deltak;
......@@ -113,16 +113,16 @@ if h
if measrf
% RF RM
disp('RF RM');
rf0 = obj.getRFFrequency;
rf0 = obj.rf.get;
rf = rf0 + deltarf;
obj.setRFFrequency(rf);
obj.rf.set(rf);
pause(waitPStime);
t = obj.measuretrajectory;
obj.setRFFrequency(rf0);
obj.rf.set(rf0);
ModelRM.TrajHDPP = (t(1,:) - t0(1,:))./deltak;
ModelRM.TrajVDPP = (t(2,:) - t0(2,:))./deltak;
......@@ -136,7 +136,7 @@ obj.ModelRM = ModelRM; %temporary store of ModelRM
% V steerers RM
if v
vs0 = obj.getVSteerers;
vs0 = obj.sv.get;
for ik = 1:length(vs0) %1:2%
if enabledcorV(ik) % only if eneabled corrector
......@@ -144,13 +144,13 @@ if v
vs = vs0;
vs(ik) = vs(ik) + deltak;
obj.setVSteerers(vs);
obj.sv.set(vs);
pause(waitPStime);
t = obj.measuretrajectory;
obj.setVSteerers(vs0);
obj.sv.set(vs0);
rmh(:,ik) = (t(1,:) - t0(1,:))./deltak;
rmv(:,ik) = (t(2,:) - t0(2,:))./deltak;
......@@ -170,19 +170,21 @@ obj.ModelRM = ModelRM; %temporary store of ModelRM
% septa
disp('septa RM')
if sp
hs0 = obj.getSepta;
hs0 = [obj.s12.get obj.s3.get];
for ik = 1:length(hs0)
hs = hs0;
hs(ik) = hs(ik) + deltak;
obj.setSepta(hs);
obj.s12.set(hs(1));
obj.s3.set(hs(2));
pause(waitPStime);
t = obj.measuretrajectory;
obj.setSepta(hs0);
obj.s12.set(hs0(1));
obj.s3.set(hs0(2));
ModelRM.RMSP(ik,:) = (t(1,:) - t0(1,:))./deltak;
......@@ -194,19 +196,22 @@ obj.ModelRM = ModelRM; %temporary store of ModelRM
% CV TL2 steerers RM
disp('CV RM')
if cv
vs0 = obj.getTL2CV;
vs0 = [obj.cv8.get obj.cv9.get];
for ik = 1:length(vs0)
vs = vs0;
vs(ik) = vs(ik) + deltak;
obj.setTL2CV(vs);
obj.cv8.set(vs(1));
obj.cv9.set(vs(2));
pause(waitPStime);
t = obj.measuretrajectory;
obj.setTL2CV(vs0);
obj.cv8.set(vs0(1));
obj.cv9.set(vs0(2));
ModelRM.RMCV(ik,:) = (t(2,:) - t0(2,:))./deltak;
......
......@@ -105,7 +105,7 @@ addOptional(p,'ask_to_continue',true,@islogical); % if cell compute, if struct R
parse(p,obj,varargin{:});
alpha = mcf(r0);
f0 = obj.getRFFrequency;% atgetfieldvalues(r0,find(atgetcells(r0,'Frequency'),1,'first'),'Frequency');
f0 = obj.rf.get;% atgetfieldvalues(r0,find(atgetcells(r0,'Frequency'),1,'first'),'Frequency');
inCOD = zeros(6,1);
indBPM = p.Results.indBPM;
......@@ -303,7 +303,7 @@ while ~stopped
end
% get initial corrector values
corh0=obj.getHSteerers;
corh0=obj.sh.get;
% restrict RM to usable correctors
......@@ -432,7 +432,7 @@ while ~stopped
end
% get current correctors values
corv0=obj.getVSteerers;
corv0=obj.sv.get;
% restrict RM
RespV=RMV(usebpm,usecorV);
......@@ -563,7 +563,7 @@ while ~stopped
ax2=subplot(2,2,2);
bar(scorh,[repmat(obj.getHSteerers,1,1); tothcor]','BarWidth',10);
bar(scorh,[repmat(obj.sh.get,1,1); tothcor]','BarWidth',10);
ylabel('hor [rad]');
%xlabel('s [m]');
ax2.XTick=scorh;%1:length(scorh);
......@@ -589,7 +589,7 @@ while ~stopped
ax4=subplot(2,2,4);
bar(scorv,[repmat(obj.getVSteerers,1,1); totvcor]');
bar(scorv,[repmat(obj.sv.get,1,1); totvcor]');
ylabel('ver [rad]');
xlabel('s [m]');
linkaxes([ax1 ax3],'x');
......@@ -619,18 +619,18 @@ while ~stopped
if corropt.corH
obj.setHSteerers(tothcor);
obj.sh.set(tothcor);
end
if corropt.corRF
obj.setRFFrequency(f0-alpha*(deltacor)*f0);
obj.rf.set(f0-alpha*(deltacor)*f0);
end
if corropt.corV
obj.setVSteerers(totvcor);
obj.sv.set(totvcor);
end
elseif response=='n'
......@@ -649,8 +649,8 @@ while ~stopped
% measure and use orbit RM
[t] = obj.measureorbit;
tothcorc = obj.getHSteerers;
totvcorc = obj.getVSteerers;
tothcorc = obj.sh.get;
totvcorc = obj.sv.get;