1 | function param = idGetUndParam(idName, attrName) |
---|
2 | |
---|
3 | param = 0; |
---|
4 | DServName = ''; |
---|
5 | StandByStr = ''; %String to search in the return of "Status" command of DServer |
---|
6 | useAppleIIDServerLevel1 = 0; |
---|
7 | |
---|
8 | [DServName, StandByStr] = idGetUndDServer(idName); |
---|
9 | |
---|
10 | if strcmp(DServName, '') ~= 0 |
---|
11 | fprintf('Device Server name can not be found\n'); |
---|
12 | param = -1; |
---|
13 | return; |
---|
14 | end |
---|
15 | |
---|
16 | if strcmpi(attrName, 'Mode') |
---|
17 | TempStruct=tango_read_attribute2(DServName, 'phaseCtrlMode'); |
---|
18 | if tango_error==-1 |
---|
19 | fprintf('Problem while checking mode\n') |
---|
20 | param = -1; |
---|
21 | return; |
---|
22 | else |
---|
23 | TempValue=TempStruct.value; |
---|
24 | TempValue=TempValue(1); |
---|
25 | if TempValue==0 |
---|
26 | param='ii'; |
---|
27 | elseif TempValue==1 |
---|
28 | param='x'; |
---|
29 | elseif TempValue==2 |
---|
30 | param='i2'; |
---|
31 | elseif TempValue==3 |
---|
32 | param='x2'; |
---|
33 | else |
---|
34 | fprintf 'Wrong mode number\n') |
---|
35 | return |
---|
36 | end |
---|
37 | return |
---|
38 | end |
---|
39 | end |
---|
40 | if strcmp(idName, 'HU52_DEIMOS') |
---|
41 | useAppleIIDServerLevel1 = 1; |
---|
42 | end |
---|
43 | |
---|
44 | attr_name_list = {attrName}; |
---|
45 | |
---|
46 | if useAppleIIDServerLevel1 |
---|
47 | %special case: controlling via DServer of Level 1 |
---|
48 | |
---|
49 | if (strcmpi(attrName, 'gap')) |
---|
50 | attr_name_list = {'encoder1Position','encoder2Position','encoder3Position','encoder4Position'}; |
---|
51 | elseif (strcmpi(attrName, 'phase')) |
---|
52 | attr_name_list = {'encoder5Position','encoder6Position'}; |
---|
53 | end |
---|
54 | |
---|
55 | end |
---|
56 | |
---|
57 | attr_val_list = tango_read_attributes(DServName, attr_name_list); |
---|
58 | |
---|
59 | if (tango_error == -1) %handle error |
---|
60 | tango_print_error_stack; param = -1; return; |
---|
61 | end |
---|
62 | param = attr_val_list(1).value(1); %check why (1) |
---|
63 | |
---|
64 | if useAppleIIDServerLevel1 |
---|
65 | %special case: controlling via DServer of Level 1 |
---|
66 | |
---|
67 | if (strcmp(attrName, 'gap') || strcmp(attrName, 'GAP')) |
---|
68 | param = 0.5*(attr_val_list(1).value + attr_val_list(2).value + attr_val_list(3).value + attr_val_list(4).value); |
---|
69 | elseif (strcmp(attrName, 'phase') || strcmp(attrName, 'PHASE')) |
---|
70 | param = 0.5*(abs(attr_val_list(1).value) + abs(attr_val_list(2).value))*sign(attr_val_list(1).value); |
---|
71 | if(sign(attr_val_list(1).value) ~= sign(attr_val_list(2).value)) |
---|
72 | param = param + i; |
---|
73 | end |
---|
74 | end |
---|
75 | end |
---|