source: MML/trunk/machine/SOLEIL/StorageRing/insertions/idGetUndParam.m @ 17

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

To have a stable version on the server.

  • Property svn:executable set to *
File size: 2.1 KB
Line 
1function param = idGetUndParam(idName, attrName)
2
3param = 0;
4DServName = '';
5StandByStr = ''; %String to search in the return of "Status" command of DServer
6useAppleIIDServerLevel1 = 0;
7
8[DServName, StandByStr] = idGetUndDServer(idName);
9
10if strcmp(DServName, '') ~= 0
11    fprintf('Device Server name can not be found\n');
12    param = -1;
13    return;
14end
15
16if 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
39end
40if strcmp(idName, 'HU52_DEIMOS')
41    useAppleIIDServerLevel1 = 1;
42end
43
44attr_name_list = {attrName};
45
46if 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   
55end
56
57attr_val_list = tango_read_attributes(DServName, attr_name_list);
58
59if (tango_error == -1) %handle error
60    tango_print_error_stack; param = -1; return;
61end
62param = attr_val_list(1).value(1); %check why (1)
63
64if 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
75end
Note: See TracBrowser for help on using the repository browser.