1 | function [offsets_X,offsets_Z, DeviceList] = getbpmBBAoffsets(varargin) |
---|
2 | %GETBPMBBAOFFSETS- Reads the current BBA offset stored int the TANGO static database |
---|
3 | % |
---|
4 | % OUTPUTS |
---|
5 | % 1. offsets_X - Horizontal BPM BBA offsets |
---|
6 | % 2. offsets_Z - Vertical BPM BBA offsets |
---|
7 | |
---|
8 | % |
---|
9 | %% Written by N. Hubert |
---|
10 | % Modified June 2009, Add plot Laurent S. Nadolski |
---|
11 | |
---|
12 | % TODO |
---|
13 | % WARNING if BPM added not working. Need to define device list !!! |
---|
14 | |
---|
15 | |
---|
16 | DisplayFlag = 1; |
---|
17 | |
---|
18 | % Switchyard |
---|
19 | for i = length(varargin):-1:1 |
---|
20 | if strcmpi(varargin{i},'Display') |
---|
21 | DisplayFlag = 1; |
---|
22 | elseif strcmpi(varargin{i},'Display') |
---|
23 | DisplayFlag = 0; |
---|
24 | end |
---|
25 | end |
---|
26 | |
---|
27 | if ~isempty(varargin) |
---|
28 | AskedDevList = varargin{1}; |
---|
29 | DisplayFlag = 0; |
---|
30 | end |
---|
31 | |
---|
32 | X_offset_BBA=0; |
---|
33 | Z_offset_BBA=0; |
---|
34 | |
---|
35 | increment=1; |
---|
36 | Correspondance=tango_get_db_property('BPM','DeviceParameters'); |
---|
37 | block_table=tango_get_db_property('BPM','BlockParameters'); |
---|
38 | |
---|
39 | for i=1:1:size(Correspondance,2) |
---|
40 | index=regexpi(Correspondance{i},'ANS-C'); |
---|
41 | if ~isempty(index) |
---|
42 | BPM_name=Correspondance{i}(index:index+15); |
---|
43 | block_name=Correspondance{i}(index+17:index+24); |
---|
44 | for j=1:1:size(block_table,2) |
---|
45 | index3=regexpi(block_table{j},[block_name,':']); |
---|
46 | if ~isempty(index3) |
---|
47 | separator=regexpi(block_table{j},':'); |
---|
48 | X_offset_BBA(increment) = str2num(block_table{j}(separator(8)+1:separator(9)-1)); |
---|
49 | Z_offset_BBA(increment) = str2num(block_table{j}(separator(10)+1:separator(11)-1)); |
---|
50 | BPM(increment,:)=BPM_name; |
---|
51 | DeviceList(increment,:) = tangodev2dev(BPM_name); % Build up device list |
---|
52 | increment = increment+1; |
---|
53 | end |
---|
54 | end |
---|
55 | end |
---|
56 | end |
---|
57 | |
---|
58 | |
---|
59 | % 3 lines to be removes if calling programmes use the device list |
---|
60 | offsets_X = [X_offset_BBA(2:end) X_offset_BBA(1)]'; |
---|
61 | offsets_Z = [Z_offset_BBA(2:end) Z_offset_BBA(1)]'; |
---|
62 | DeviceList = [DeviceList(2:end,:); DeviceList(1,:)]; |
---|
63 | |
---|
64 | if exist('AskedDevList', 'var') |
---|
65 | Idx = findrowindex(AskedDevList, DeviceList); |
---|
66 | offsets_X = offsets_X(Idx); |
---|
67 | offsets_Z = offsets_Z(Idx); |
---|
68 | DeviceList = DeviceList(Idx,:); |
---|
69 | end |
---|
70 | |
---|
71 | |
---|
72 | if DisplayFlag |
---|
73 | figure |
---|
74 | spos = getspos('BPMx'); |
---|
75 | h1 = subplot(5,1,[1 2]); |
---|
76 | plot(spos, offsets_X, '.-') |
---|
77 | ylabel('X BBA Offsets (mm)') |
---|
78 | grid on; |
---|
79 | h2 = subplot(5,1,3); |
---|
80 | drawlattice |
---|
81 | h3 = subplot(5,1,[4 5]); |
---|
82 | plot(spos, offsets_Z, '.-') |
---|
83 | ylabel('Z BBA Offsets (mm)') |
---|
84 | grid on; |
---|
85 | linkaxes([h1 h2 h3], 'x') |
---|
86 | addlabel(1,0,sprintf('%s', datestr(clock,0))); |
---|
87 | end |
---|