source: MML/trunk/mml/links/tango/corgetrunflag.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: 1.4 KB
Line 
1function [RunFlag, Delta, Tol] = tangogetrunflag(Family, Field, DeviceList)
2% function TANGOGETRUNFLAG
3%
4%
5%  NOTES
6%  1. This function look at the tango state since if getpv, getam is too fast they return the samme value before the PS
7%  start moving!
8
9TangoName = family2tangodev(Family, DeviceList);
10
11% 2. If Field = 'Setpoint', base on SP-AM tolerance
12if strcmp(Field, 'Setpoint')
13    % Base runflag on abs(Setpoint-Monitor) > Tol
14    Tol = family2tol(Family, Field, DeviceList, 'Hardware');
15    if isempty(Tol)
16        return;
17    end
18
19    RunFlag = zeros(size(Tol));
20   
21    % Check for first power supply still in running state
22    for k=1:length(TangoName),
23        val = readattribute([TangoName{k} '/State']);
24        if val == 10 % running state
25            RunFlag(k) = 1;       
26        end
27    end
28   
29        % Use the "real" Setpoint value
30    SP  = getpv(Family, 'TangoSetpoint', DeviceList, 'Hardware');   
31   
32    if isempty(SP)
33        return;
34    end
35    %SP = raw2real(Family, 'Monitor', SP, DeviceList); % Laurent
36
37    % Use the "real" Monitor value
38    AM  = getpv(Family, 'Monitor', DeviceList, 'Hardware');
39    if isempty(AM)
40        return;
41    end
42    %AM = raw2real(Family, 'Monitor', AM, DeviceList); % Laurent
43   
44    % Condition is now Tango Step + Tolerance
45    RunFlag = RunFlag | abs(SP-AM) > Tol;
46
47    %fprintf('SP=%f AM=%f\n', SP,AM);
48    Delta = SP-AM;
49
50end
Note: See TracBrowser for help on using the repository browser.