function [Xpos Zpos Xangle Zangle] = getIDbpm_stat
% getIDbpm_stat - Show angle and position of beam at center of straight sections

%
%  Written by Laurent S. Nadolski

DisplayFlag = 1;

deviceList = { ...
    'ANS-C01/DG/CALC-SDL-POSITION-ANGLE', ...
    'ANS-C02/DG/CALC-SDc-POSITION-ANGLE', ...
    'ANS-C02/DG/CALC-SDM-POSITION-ANGLE', ...
    'ANS-C03/DG/CALC-SDC-POSITION-ANGLE', ...
    'ANS-C03/DG/CALC-SDM-POSITION-ANGLE', ...
    'ANS-C04/DG/CALC-SDM-POSITION-ANGLE', ...
    'ANS-C05/DG/CALC-SDL-POSITION-ANGLE', ...
    'ANS-C06/DG/CALC-SDC-POSITION-ANGLE', ...
    'ANS-C06/DG/CALC-SDM-POSITION-ANGLE', ...
    'ANS-C07/DG/CALC-SDC-POSITION-ANGLE', ...
    'ANS-C07/DG/CALC-SDM-POSITION-ANGLE', ...
    'ANS-C08/DG/CALC-SDM-POSITION-ANGLE', ...
    'ANS-C09/DG/CALC-SDL-POSITION-ANGLE', ...
    'ANS-C10/DG/CALC-SDC-POSITION-ANGLE', ...
    'ANS-C10/DG/CALC-SDM-POSITION-ANGLE', ...
    'ANS-C11/DG/CALC-SDC-POSITION-ANGLE', ...
    'ANS-C11/DG/CALC-SDM-POSITION-ANGLE', ...
    'ANS-C12/DG/CALC-SDM-POSITION-ANGLE', ...
    'ANS-C13/DG/CALC-SDL-POSITION-ANGLE', ...
    'ANS-C14/DG/CALC-SDC-POSITION-ANGLE', ...
    'ANS-C14/DG/CALC-SDM-POSITION-ANGLE', ...
    'ANS-C15/DG/CALC-SDC-POSITION-ANGLE', ...
    'ANS-C15/DG/CALC-SDM-POSITION-ANGLE', ...
    'ANS-C16/DG/CALC-SDM-POSITION-ANGLE'  ...
    };

Xpos = zeros(size(deviceList,2),1);
Zpos = Xpos;
Xangle = Xpos;
Zangle = Xpos;

for k = 1:size(deviceList,2),
    rep = tango_read_attributes2(deviceList{k},{'positionX','positionZ','angleX', 'angleZ'});
    Xpos(k)   = rep(1).value;
    Zpos(k)   = rep(2).value;
    Xangle(k) = rep(3).value;
    Zangle(k) = rep(4).value;
end

if DisplayFlag
    figure
    subplot(2,2,1)
    bar(Xpos)
    ylabel('x (µm)')

    subplot(2,2,2)
    bar(Xangle)
    ylabel('x'' (µrad)')

    subplot(2,2,3)
    bar(Zpos)
    ylabel('z (µm)')

    subplot(2,2,4)
    bar(Zangle)
    ylabel('z'' (µrad)')
    suptitle('Angle and position as a function of straigth section number')
end

% for k = 1:size(deviceList,2),
%     rep = tango_get_device_property(deviceList{k},'OutputNames');
%     fprintf('\n%s \n', deviceList{k});
%     for k=1:4, fprintf('%s \n', rep{1}{k}), end
% end