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 | |
---|
1 | function res = idSetCurrentSync(idDevServ, currentToSet, currentAbsTol) |
---|
2 | |
---|
3 | maxDelay_s = 20; %to edit |
---|
4 | testTimePeriod_s = 1; %to edit |
---|
5 | res = -1; |
---|
6 | |
---|
7 | maxNumTests = round(maxDelay_s/testTimePeriod_s); |
---|
8 | |
---|
9 | on_or_off = tango_command_inout2(idDevServ, 'State'); |
---|
10 | if(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 |
---|
23 | end |
---|
24 | |
---|
25 | attrCurrent = strcat(idDevServ, '/currentPM'); |
---|
26 | writeattribute(attrCurrent, currentToSet); |
---|
27 | actCur = 0; |
---|
28 | for 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); |
---|
35 | end |
---|
36 | |
---|
37 | if(abs(currentToSet - actCur) > currentAbsTol) |
---|
38 | res = -1; |
---|
39 | fprintf('Failed to set the requested current\n'); |
---|
40 | end |
---|
41 | |
---|
Note: See
TracBrowser
for help on using the repository browser.