source: MML/trunk/machine/SOLEIL/StorageRing/bpm/getbpmBBAoffsets.m @ 4

Last change on this file since 4 was 4, checked in by zhangj, 11 years ago

Initial import--MML version from SOLEIL@2013

File size: 2.4 KB
Line 
1function [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
16DisplayFlag = 1;
17
18% Switchyard
19for 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
25end
26
27if ~isempty(varargin)
28    AskedDevList = varargin{1};
29    DisplayFlag = 0;
30end
31
32X_offset_BBA=0;
33Z_offset_BBA=0;
34
35increment=1;
36Correspondance=tango_get_db_property('BPM','DeviceParameters');
37block_table=tango_get_db_property('BPM','BlockParameters');
38
39for 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
56end
57
58
59% 3 lines to be removes if calling programmes use the device list
60offsets_X = [X_offset_BBA(2:end) X_offset_BBA(1)]';
61offsets_Z = [Z_offset_BBA(2:end) Z_offset_BBA(1)]';
62DeviceList = [DeviceList(2:end,:); DeviceList(1,:)];
63
64if exist('AskedDevList', 'var')
65   Idx = findrowindex(AskedDevList, DeviceList);
66   offsets_X  = offsets_X(Idx);
67   offsets_Z  = offsets_Z(Idx);
68   DeviceList = DeviceList(Idx,:);
69end
70
71
72if 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)));
87end
Note: See TracBrowser for help on using the repository browser.