Commit c102e116 authored by Simone Liuzzo's avatar Simone Liuzzo

SetOperationOptics teseted and corrected for EBS. sr/sources/all excluded (not working)

parent 6a05ac8f
function SetOperationOptics(machine)
% set the operation optics folder:
% - relink theory folder
% - relink theory folder
% - send optics parameters to diagnostics
% - Init Devices where needed.
% - set injection bump (call stand alone SetOpeationInjectionBump)
% - set simulator model (set propery and call reset_ebs_simu)
% - set d-orbit (beam position at ID) properties
%
%
%
% machine may be: 'ebs', 'sy', 'tl2'
%
%see also: ebs.CreateLatticeOpitcs, sy.CreateLatticeOptics,
......@@ -31,4 +36,98 @@ system(['ln -s ' newtheodir ' theory']);
% back to initial directory.
cd(curdir);
end
\ No newline at end of file
% load newly set model
at_pinhole_names = [];
switch machine
case 'ebs'
latticemodel = ebs.model;
% key names in ebs.model for poinhole cameras
at_pinhole_names = {'pinholeD01', 'pinholeD17', 'pinholeD27', 'pinholeID07', 'pinholeID25'};
case 'sy'
latticemodel = sy.model;
case 'tl2'
latticemodel = tl2.model;
otherwise
error('Input must be one of the ollowing: ''ebs'', ''sy'', ''tl2'',')
end
% redefine PINHOLE AND d-orbit property.
espread = latticemodel.energy_spread;
propstruct = struct(...
'beta_h',0.0, ... % at_code 3
'alpha_h',0.0, ... % at_code 4
'eta_h',0.0, ... % at_code 5
'etap_h',0.0, ... % at_code 6
'beta_v',0.0, ... % at_code 7
'alpha_v',0.0, ... % at_code 8
'eta_v',0.0, ... % at_code 9
'etap_v',0.0, ... % at_code 10
'sigmae_h',espread, ...% at_code 3
'sigmae_v',espread); % at_code 3
at_codes = [0, 3, 4, 6, 7, 8, 9, 11, 12];
% loop pinhole devices
for id = 1:length(at_pinhole_names)
% get optics.
d = latticemodel.get(at_codes, at_pinhole_names{id});
pinhole_devname = latticemodel.ring{d(1)}.Device;
p = tango.Device(pinhole_devname); % get pinhole device name from lattice model.
disp(['setting optics properties for: ' pinhole_devname]);
propstruct.beta_h = d(2);
propstruct.alpha_h = d(3);
propstruct.eta_h = d(4);
propstruct.etap_h = d(5);
propstruct.beta_v = d(6);
propstruct.alpha_v = d(7);
propstruct.eta_v = d(8);
propstruct.etap_v = d(9);
p.set_property(propstruct);
disp(['Send Init command to: ' pinhole_devname]);
p.Init();
end
disp('Properties of pinhole cameras are updated')
%% set property for device computing position and emittance growths at ID & BM
% get optics
[idx, iddata, bmdata] = latticemodel.get(0, 'id', [3, 4, 6, 7, 8, 9], 'id', 8, 'bm');
sl = 2.0 * latticemodel.getfieldvalue(idx, 'Length'); % get straigth sections length
% set properties of orbit device (computes angle and position at IDs)
devorb = tango.Device('sr/sources/all');
% data = zip(labels, [d for d in iddata.T] + [bmdata.flatten(), sr.emith, sr.emitv, sl])
devorb.id_Hbeta = iddata(:,1);
devorb.id_Halpha = iddata(:,2);
devorb.id_Heta = iddata(:,3);
devorb.id_HetaPrime = iddata(:,4);
devorb.id_Vbeta = iddata(:,5);
devorb.id_Valpha = iddata(:,6);
devorb.d_Vbeta = bmdata(:,1);
devorb.ref_H_emit = latticemodel.emith;
devorb.ref_V_emit = latticemodel.emitv;
devorb.straight_section_length = sl;
devorb.Init();
% set model in simulator.
end
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment