...
 
Commits (4)
......@@ -13,7 +13,7 @@ TANGO_HOST=['tango://' getenv('TANGO_HOST') '/'];
obj.MeasurementFolder = pwd;
obj.first_turn_index = 1;
%% movable objects
%% movable objects (the movable class takes care of max-min limits, calibration, set point reached)
obj.ke = movable(''); % movable('sy/ps-ke/1');
obj.gun = movable(''); % 'elin/beam/run';%% missing
obj.rips = movable('');
......@@ -22,47 +22,62 @@ obj.s12 = movable('');
obj.s3 = movable('');
obj.cv8 = movable('');
obj.cv9 = movable('');
getfunction = @(devname)tango.Attribute(devname).value;
setfunction = @(devname,val)setfield(tango.Attribute(devname),'set',val);
obj.sh = movable([TANGO_HOST 'srmag/hst/all/Strengths'],...
'get_fun',getfunction,'set_fun',setfunction,...
'absolute',true,'limits',[-4e-4 4e-4]);
obj.sv = movable([TANGO_HOST 'srmag/vst/all/Strengths'],...
'get_fun',getfunction,'set_fun',setfunction,...
'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'],...
'get_fun',getfunction,'set_fun',setfunction,...
'absolute',true,'limits',[-1.5e-2 1.5e-2]);
obj.rf = movable([TANGO_HOST 'srrf/master-oscillator/1/Frequency'],...
'get_fun',getfunction,'set_fun',setfunction,...
'absolute',false,'limits',[0.99 1.01]);
obj.quad = movable([TANGO_HOST 'srmag/m-q/all/CorrectionStrengths'],...
'get_fun',getfunction,'set_fun',setfunction);
obj.sext = movable([TANGO_HOST 'srmag/m-s/all/CorrectionStrengths'],...
'get_fun',getfunction,'set_fun',setfunction);
obj.octu = movable([TANGO_HOST 'srmag/m-o/all/CorrectionStrengths'],...
'get_fun',getfunction,'set_fun',setfunction);
obj.initial_coordinates = movable([TANGO_HOST 'sys/ringsimulator/ebs/TbT_InCoord'],...
'get_fun',getfunction,'set_fun',setfunction);
%% diagnostics, read only attributes
obj.stored_current = @()tango.Attribute([TANGO_HOST 'srdiag/beam-current/total/Current']).value;
% function to measure trajectory, takes as input the class instance.
%% function to measure trajectory, takes as input the class instance.
obj.getTbTdata = @(obj)getTbTdata_EBS_SIMU(obj);
% inputs to function getTbTdata
obj.hor_bpm_TBT = @()tango.Attribute([TANGO_HOST 'srdiag/beam-position/all/TBT_HPositions']).value;
obj.ver_bpm_TBT = @()tango.Attribute([TANGO_HOST 'srdiag/beam-position/all/TBT_VPositions']).value;
obj.sum_bpm_TBT = @()tango.Attribute([]).value;
% bpm fresh data counter
obj.bpm_trigger_counter = @()tango.Attribute('sys/ringsimulator/ebs/Counter').value;
% load reference sum signal
obj.sum_signal_beam = ones(1,320); % sum signal with beam (sensitivity of each BPM)
obj.sum_signal_background = zeros(1,320);
obj.sum_signal_threshold = 0.5e-6; % sum signal below this value is considered not good
%% function to measure COD, takes as input the class instance.
obj.getSAdata = @(obj)getSAdata_EBS_SIMU(obj);
% inputs to function getTbTdata
obj.hor_bpm_SA = @()tango.Attribute([TANGO_HOST 'srdiag/beam-position/all/SA_HPositions']).value;
obj.ver_bpm_SA = @()tango.Attribute([TANGO_HOST 'srdiag/beam-position/all/SA_VPositions']).value;
obj.sum_bpm_SA = @()tango.Attribute([]).value;
obj.bpm_trigger_counter = @()tango.Attribute('sys/ringsimulator/ebs/Counter').value;
%% state and enabled disabled for RingControl
% mask of correctors to exclude
obj.status_bpm =@()(tango.Attribute([TANGO_HOST 'srdiag/beam-position/all/All_Status']).value==0); % BPM status (0 means no error, so ok)
obj.state_hst =@()(strcmp(tango.Attribute([TANGO_HOST 'srmag/hst/all/CorrectorStates']).value,'Disabled')==0); % H steerer status (ON OFF FAULT,...)
......@@ -75,10 +90,9 @@ obj.orbit_cor_disabled_vst =@()(tango.Attribute([TANGO_HOST 'sr/beam-orbitcor/sv
obj.autocor =@()(tango.Attribute([TANGO_HOST 'sr/beam-orbitcor/svd-auto']).state);
%load reference sum signal
obj.sum_signal_beam = ones(1,320); % sum signal with beam (sensitivity of each BPM)
obj.sum_signal_background = zeros(1,320);
obj.sum_signal_threshold = 0.5e6; % sum signal below this value is considered not good
%% diagnostics, read only attributes
obj.stored_current = @()tango.Attribute([TANGO_HOST 'srdiag/beam-current/total/Current']).value;
obj.KillBeamAtGivenCurrent = @(obj)KillBeamAtGivenCurrentESRF(obj);
obj.h_tune = @()tango.Attribute([TANGO_HOST 'srdiag/beam-tune/1/Tune_h']).value;
obj.v_tune = @()tango.Attribute([TANGO_HOST 'srdiag/beam-tune/1/Tune_v']).value;
......
......@@ -102,6 +102,9 @@ classdef RingControl < handle
last_measured_orbit % store last measured closed orbit
OrbitFileName % label to append to measurements
% kill beam if above current limit
KillBeamAtGivenCurrent% @(obj,varargin)fun;
indHst % indexes of horizontal steerers in AT rmodel
indVst % indexes of vertical steerers in AT rmodel
indBPM % indexes of BPM in AT rmodel
......@@ -303,9 +306,6 @@ classdef RingControl < handle
%trajectory simulation method
[t] = SimulateTrajectoryKick(obj,indSt,kick,plane);
% kill beam if above current limit
KillBeamAtGivenCurrent(obj,varargin);
% generic SVD to chose among different options
dq = svd(obj,svd_mode,varargin);
......
......@@ -120,12 +120,12 @@ end
for i=1:average
% wait for trigger and then read TbT data
[hor,ver,s]=obj.getTbTdata;
[hor,ver,sig]=obj.getTbTdata(obj);
% select only data where signal is above threshold
bpm_with_beam = ones(size(s));
bpm_with_beam = ones(size(sig));
bpm_with_beam(s < obj.sum_signal_threshold) = 0 ;
bpm_with_beam(sig < obj.sum_signal_threshold) = 0 ;
indlastBPM = find(bpm_with_beam>0.15,1,'last');
......
function KillBeamAtGivenCurrentESRF(obj,varargin)
%KILLBEAMATGIVENCURRENT kills beam with scraper if current > limit
%
% optional inptus:
% 'maxstorecurrent' scalar, value of maximum allowed stored current. if
% above, beam is killed with obj.dev_scraper scraper
% (default 1e-6 A)
%
%
%see also: RingControl
storecurrent_def=obj.max_stored_current();%1e-6;
p = inputParser();
addRequired(p,'obj');
addOptional(p,'maxstorecurrent',storecurrent_def,@isnumeric);
parse(p,obj,varargin{:});
storecurrent = p.Results.maxstorecurrent;
% in simulator scrapers do no exist at the moment.
simulator = strcmp(obj.machine,'ebs-simu');
if ~simulator
c4ext = tango.Device(obj.scraper.attr_name);
initpos=c4ext.Position.set;
% check current limit
Cur=obj.stored_current();
if Cur>storecurrent
disp('Maximum stored current is reached. closing C4 ext to -5 mm')
% shot vertical kicker to kill beam
c4ext.Position=-1;
pause(2);
try
while strcmp(c4ext.State,'Moving')
pause(1);
disp('wait scraper');
end
catch
pause(10)
end
c4ext.Position=initpos;
pause(2);
try
while strcmp(c4ext.State,'Moving')
pause(1);
disp('wait scraper');
end
catch
pause(10)
end
end
end
end