1 | function [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 | |
---|
9 | TangoName = family2tangodev(Family, DeviceList); |
---|
10 | |
---|
11 | % 2. If Field = 'Setpoint', base on SP-AM tolerance |
---|
12 | if 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 | |
---|
50 | end |
---|