1 | function scanorbit(Family, DeviceList1, DeviceList2) |
---|
2 | %SCANORBIT - Scans 2 correctors 90 degrees out of phase |
---|
3 | % or 2 correctors of your choice |
---|
4 | % |
---|
5 | % If only one corrector is selected, then automatically find a BPM at 90 |
---|
6 | % degrees out of phase |
---|
7 | % |
---|
8 | % INPUTS |
---|
9 | % 1. Family - Family name |
---|
10 | % 2. DeviceList1 - First corrector devicelist |
---|
11 | % 3. DeviceList2 - Second corrector devicelist |
---|
12 | |
---|
13 | |
---|
14 | Amps = [-10 0 10]; |
---|
15 | |
---|
16 | HCMFamily = gethcmfamily; |
---|
17 | VCMFamily = getvcmfamily; |
---|
18 | |
---|
19 | % Inputs |
---|
20 | i = 0; |
---|
21 | if nargin < 1 |
---|
22 | i = menu('Select a corrector family:','1 HCOR corrector','1 VCOR corrector', ... |
---|
23 | 'All HCOR correctors','All VCOR correctors', 'Cancel'); |
---|
24 | switch i |
---|
25 | case 1 % HCM |
---|
26 | Family = HCMFamily; |
---|
27 | case 2 % VCM |
---|
28 | Family = VCMFamily; |
---|
29 | case 3 % All HCM |
---|
30 | Family = HCMFamily; |
---|
31 | DeviceList1 = family2dev(Family); |
---|
32 | case 4 % All VCM |
---|
33 | Family = VCMFamily; |
---|
34 | DeviceList1 = family2dev(Family); |
---|
35 | case 5 % Cancel |
---|
36 | return; |
---|
37 | end |
---|
38 | end |
---|
39 | |
---|
40 | if nargin < 2 & (i~=3 | i~=4) |
---|
41 | DeviceList1 = editlist(family2dev(Family), Family, 0); |
---|
42 | end |
---|
43 | |
---|
44 | if isempty(DeviceList1) |
---|
45 | DeviceList1 = family2dev(Family); |
---|
46 | end |
---|
47 | |
---|
48 | for i = 1:size(DeviceList1,1) |
---|
49 | Dev1 = DeviceList1(i,:); |
---|
50 | |
---|
51 | if nargin < 3 |
---|
52 | % Find a corrector 90 degrees out of phase with Dev1 |
---|
53 | DeviceList2 = family2dev(Family); |
---|
54 | [Phase1, PhaseAll] = modeltwiss('Phase', Family, Dev1, Family, DeviceList2); |
---|
55 | [PhaseDiffRad, j] = min(abs(rem(PhaseAll-Phase1, pi/2))-1); |
---|
56 | Dev2 = DeviceList2(j(1),:); |
---|
57 | else |
---|
58 | Dev2 = DeviceList2(i,:); |
---|
59 | end |
---|
60 | |
---|
61 | % Get both corrector values |
---|
62 | Amps10 = getsp(Family, Dev1); |
---|
63 | Amps20 = getsp(Family, Dev2); |
---|
64 | |
---|
65 | for Amp1 = Amps |
---|
66 | setsp(Family, Amp1, Dev1); |
---|
67 | pause(.2); |
---|
68 | for Amp2 = Amps |
---|
69 | setsp(Family, Amp2, Dev2); |
---|
70 | fprintf(' %s(%d,%d)=%f %s(%d,%d)=%f \n', Family, Dev1(1,1), Dev1(1,2), Amp1, Family, Dev2(1,1), Dev2(1,2), Amp2); |
---|
71 | fprintf(' Hit return to continue (Ctrl-C to exit)\n'); |
---|
72 | pause; |
---|
73 | fprintf(' \n'); |
---|
74 | end |
---|
75 | end |
---|
76 | |
---|
77 | % Reset to nominal value |
---|
78 | setsp(Family, Amps10, Dev1); |
---|
79 | pause(.2); |
---|
80 | setsp(Family, Amps20, Dev2); |
---|
81 | end |
---|
82 | |
---|
83 | |
---|