getTbTdata_EBS_SIMU.m 1.13 KB
Newer Older
Simone Liuzzo's avatar
Simone Liuzzo committed
1 2 3 4 5 6
function [h,v,s] = getTbTdata_EBS_SIMU(obj)
% read TbT data



% read BPM TbT buffer counter
7
data_counter = obj.bpm_trigger_counter();
Simone Liuzzo's avatar
Simone Liuzzo committed
8 9 10 11 12 13 14

pause(1.0) % necessary!! or later trigger counter re-reading will be already after KE shot!
% necessary!! or could read two identical buffers!

% wait for trigger couter to change
integralwaited = 0.0;
dt =0.2;
15
while obj.bpm_trigger_counter() == data_counter
Simone Liuzzo's avatar
Simone Liuzzo committed
16 17 18 19 20 21 22
    disp('waiting for fresh data');
    pause(dt);
    integralwaited = integralwaited + dt;
    if integralwaited>10
        warning('Waiting too long for new data, take what is available');
        break
    end
23
    disp(['next data ' num2str(obj.bpm_trigger_counter()) ' before Ke: ' num2str(data_counter)]);
Simone Liuzzo's avatar
Simone Liuzzo committed
24 25 26 27 28 29 30 31 32 33
end


try
    if (obj.noise)
        
        obj.initial_coordinates.set( [obj.injoff, 0,0,0,0,0]+randn(1,6).*obj.injectorRMSNoise);
    end
    pause(1);
    % read BPM Turn-by-Turn
34 35
    h = obj.hor_bpm_TBT();
    v = obj.ver_bpm_TBT();
Simone Liuzzo's avatar
Simone Liuzzo committed
36 37 38 39 40 41 42 43 44 45 46 47
    
    % warning('logic/scalar error && -> & !')
    s = ~isnan(h) & ~isnan(v) ;
catch err
    disp(err)
    error('ERROR RingControl.measuretrajectory: did you set BPM TbT?')
    return
end

            

end