source: MML/trunk/machine/SOLEIL/StorageRing/insertions/IDStarter/idSetCurrentSync.m @ 4

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

Initial import--MML version from SOLEIL@2013

File size: 1.0 KB
Line 
1function res = idSetCurrentSync(idDevServ, currentToSet, currentAbsTol)
2
3maxDelay_s = 20; %to edit
4testTimePeriod_s = 1; %to edit
5res = -1;
6
7maxNumTests = round(maxDelay_s/testTimePeriod_s);
8
9on_or_off = tango_command_inout2(idDevServ, 'State');
10if(strcmp(on_or_off, 'ON') == 0)
11    tango_command_inout2(idDevServ, 'On');
12    for i = 1:maxNumTests
13        on_or_off = tango_command_inout2(idDevServ, 'State');
14        if(strcmp(on_or_off, 'ON'))
15            break;
16        end
17        pause(testTimePeriod_s);
18    end
19    if(strcmp(on_or_off, 'ON') == 0)
20        fprintf('Failed to set the device ON');
21        return;
22    end
23end
24
25attrCurrent = strcat(idDevServ, '/currentPM');
26writeattribute(attrCurrent, currentToSet);
27actCur = 0;
28for i = 1:maxNumTests
29        actCur = readattribute([idDevServ, '/current']);
30    if(abs(currentToSet - actCur) <= currentAbsTol)
31        res = 0;
32        return;
33    end
34        pause(testTimePeriod_s);
35end
36
37if(abs(currentToSet - actCur) > currentAbsTol)
38        res = -1;
39        fprintf('Failed to set the requested current\n');
40end
41
Note: See TracBrowser for help on using the repository browser.