1 | function [new_tot_mCHE_with_arg, new_tot_mCVE_with_arg, new_tot_mCHS_with_arg, new_tot_mCVS_with_arg] = idUpdateFeedForwardCorTables2D(idName, tabNameDataCHE, tabNameDataCVE, tabNameDataCHS, tabNameDataCVS, vArgVert, vArgHor, updateMode, interpMeth) |
---|
2 | %Update FF Correction Tables, with interpolation, if necessary |
---|
3 | %tabNameDataCHE = {'parallelModeCHE', mCHE} |
---|
4 | %tabNameDataCVE = {'parallelModeCVE', mCVE} |
---|
5 | %vArgVert = [15.5,16,18,...] - gap values |
---|
6 | %vArgHor = [-40,-35,-30,...] - phase values |
---|
7 | %updateMode: |
---|
8 | % 0- set zero in all tables; 1- overwrite values in all tables; 2- add values of new tables to existing tables, keeping the mesh |
---|
9 | % of the existing tables |
---|
10 | |
---|
11 | %res = 0; |
---|
12 | |
---|
13 | numArgVert = length(vArgVert); |
---|
14 | numArgHor = length(vArgHor); |
---|
15 | |
---|
16 | testVar = 0; |
---|
17 | if(updateMode == 1) |
---|
18 | if((vArgVert ~= -1) && (vArgHor ~= -1)) |
---|
19 | testVar = 1; |
---|
20 | end |
---|
21 | else |
---|
22 | if((isempty(vArgVert) == 0) && (isempty(vArgHor) == 0)) |
---|
23 | testVar = 1; |
---|
24 | end |
---|
25 | end |
---|
26 | |
---|
27 | %if((numArgVert > 1) && (numArgHor > 1)) %assume tabNameDataCHE{2} etc. is without arguments |
---|
28 | %TO CORRECT!!!: make general§ |
---|
29 | %if((isempty(vArgVert) == 0) && (isempty(vArgHor) == 0)) %OC,FM1205008 |
---|
30 | %if((vArgVert ~= -1) && (vArgHor ~= -1)) %OC,FM1205008 |
---|
31 | if(testVar ~= 0) |
---|
32 | mCHE_with_arg = idAuxMergeCorTableWithArg2D(vArgVert, vArgHor, tabNameDataCHE{2}); |
---|
33 | mCVE_with_arg = idAuxMergeCorTableWithArg2D(vArgVert, vArgHor, tabNameDataCVE{2}); |
---|
34 | mCHS_with_arg = idAuxMergeCorTableWithArg2D(vArgVert, vArgHor, tabNameDataCHS{2}); |
---|
35 | mCVS_with_arg = idAuxMergeCorTableWithArg2D(vArgVert, vArgHor, tabNameDataCVS{2}); |
---|
36 | else %assume tabNameDataCHE{2} etc. is with arguments |
---|
37 | mCHE_with_arg = tabNameDataCHE{2}; |
---|
38 | mCVE_with_arg = tabNameDataCVE{2}; |
---|
39 | mCHS_with_arg = tabNameDataCHS{2}; |
---|
40 | mCVS_with_arg = tabNameDataCVS{2}; |
---|
41 | |
---|
42 | numArgVert = size(mCHE_with_arg, 1) - 1; |
---|
43 | for i = 1:numArgVert |
---|
44 | vArgVert(i) = mCHE_with_arg(i+1,1); |
---|
45 | end |
---|
46 | numArgHor = size(mCHE_with_arg, 2) - 1; |
---|
47 | for i = 1:numArgHor |
---|
48 | vArgHor(i) = mCHE_with_arg(1,i+1); |
---|
49 | end |
---|
50 | end |
---|
51 | |
---|
52 | minValArgVert = vArgVert(1); |
---|
53 | maxValArgVert = vArgVert(1); |
---|
54 | for i = 1:numArgVert |
---|
55 | curValArg = vArgVert(i); |
---|
56 | if(minValArgVert > curValArg) |
---|
57 | minValArgVert = curValArg; |
---|
58 | end |
---|
59 | if(maxValArgVert < curValArg) |
---|
60 | maxValArgVert = curValArg; |
---|
61 | end |
---|
62 | end |
---|
63 | minValArgHor = vArgHor(1); |
---|
64 | maxValArgHor = vArgHor(1); |
---|
65 | for i = 1:numArgHor |
---|
66 | curValArg = vArgHor(i); |
---|
67 | if(minValArgHor > curValArg) |
---|
68 | minValArgHor = curValArg; |
---|
69 | end |
---|
70 | if(maxValArgHor < curValArg) |
---|
71 | maxValArgHor = curValArg; |
---|
72 | end |
---|
73 | end |
---|
74 | |
---|
75 | [DServName] = idGetUndDServer(idName); |
---|
76 | |
---|
77 | %Reading previous cor. tables |
---|
78 | rep = tango_read_attribute2(DServName, tabNameDataCHE{1}); |
---|
79 | stOldTablesFF.mCHE_with_arg = rep.value; |
---|
80 | rep = tango_read_attribute2(DServName, tabNameDataCVE{1}); |
---|
81 | stOldTablesFF.mCVE_with_arg = rep.value; |
---|
82 | rep = tango_read_attribute2(DServName, tabNameDataCHS{1}); |
---|
83 | stOldTablesFF.mCHS_with_arg = rep.value; |
---|
84 | rep = tango_read_attribute2(DServName, tabNameDataCVS{1}); |
---|
85 | stOldTablesFF.mCVS_with_arg = rep.value; |
---|
86 | |
---|
87 | new_tot_mCHE_with_arg = stOldTablesFF.mCHE_with_arg; |
---|
88 | new_tot_mCVE_with_arg = stOldTablesFF.mCVE_with_arg; |
---|
89 | new_tot_mCHS_with_arg = stOldTablesFF.mCHS_with_arg; |
---|
90 | new_tot_mCVS_with_arg = stOldTablesFF.mCVS_with_arg; |
---|
91 | |
---|
92 | numArgVert_p_1 = numArgVert + 1; |
---|
93 | numArgHor_p_1 = numArgHor + 1; |
---|
94 | if(updateMode == 0) |
---|
95 | for i = 2:numArgVert_p_1 |
---|
96 | for j = 2:numArgHor_p_1 |
---|
97 | mCHE_with_arg(i,j) = 0; |
---|
98 | mCVE_with_arg(i,j) = 0; |
---|
99 | mCHS_with_arg(i,j) = 0; |
---|
100 | mCVS_with_arg(i,j) = 0; |
---|
101 | end |
---|
102 | end |
---|
103 | end |
---|
104 | |
---|
105 | if((updateMode == 0) || (updateMode == 1)) |
---|
106 | new_tot_mCHE_with_arg = mCHE_with_arg; |
---|
107 | new_tot_mCVE_with_arg = mCVE_with_arg; |
---|
108 | new_tot_mCHS_with_arg = mCHS_with_arg; |
---|
109 | new_tot_mCVS_with_arg = mCVS_with_arg; |
---|
110 | end |
---|
111 | |
---|
112 | if(updateMode == 2) |
---|
113 | %strIncompatSizes = 'Incompatible dimensions od mesh of existing and new tables. Incremental update can not be performed.'; |
---|
114 | %if((size(stOldTablesFF.mCHE_with_arg, 1) ~= numArgVert_p_1) || (size(stOldTablesFF.mCVE_with_arg, 1) ~= numArgVert_p_1) || (size(stOldTablesFF.mCHS_with_arg, 1) ~= numArgVert_p_1) || (size(stOldTablesFF.mCVS_with_arg, 1) ~= numArgVert_p_1)) |
---|
115 | % fprintf(strIncompatSizes); |
---|
116 | % return; |
---|
117 | %end |
---|
118 | %if((size(stOldTablesFF.mCHE_with_arg, 2) ~= numArgHor_p_1) || (size(stOldTablesFF.mCVE_with_arg, 2) ~= numArgHor_p_1) || (size(stOldTablesFF.mCHS_with_arg, 2) ~= numArgHor_p_1) || (size(stOldTablesFF.mCVS_with_arg, 2) ~= numArgHor_p_1)) |
---|
119 | % fprintf(strIncompatSizes); |
---|
120 | % return; |
---|
121 | %end |
---|
122 | |
---|
123 | %for i = 2:numArgVert_p_1 |
---|
124 | % if((mCHE_with_arg(i,1) ~= stOldTablesFF.mCHE_with_arg(i,1)) || (mCVE_with_arg(i,1) ~= stOldTablesFF.mCVE_with_arg(i,1)) || (mCHS_with_arg(i,1) ~= stOldTablesFF.mCHS_with_arg(i,1)) || (mCVS_with_arg(i,1) ~= stOldTablesFF.mCVS_with_arg(i,1))) |
---|
125 | % fprintf(strIncompatSizes); |
---|
126 | % return; |
---|
127 | % end |
---|
128 | %end |
---|
129 | %for j = 2:numArgHor_p_1 |
---|
130 | % if((mCHE_with_arg(1,j) ~= stOldTablesFF.mCHE_with_arg(1,j)) || (mCVE_with_arg(1,j) ~= stOldTablesFF.mCVE_with_arg(1,j)) || (mCHS_with_arg(1,j) ~= stOldTablesFF.mCHS_with_arg(1,j)) || (mCVS_with_arg(1,j) ~= stOldTablesFF.mCVS_with_arg(1,j))) |
---|
131 | % fprintf(strIncompatSizes); |
---|
132 | % return; |
---|
133 | % end |
---|
134 | %end |
---|
135 | |
---|
136 | %Interpolation of New Tables to the Mesh of Existing Tables |
---|
137 | numArgVertExist = size(stOldTablesFF.mCHE_with_arg, 1) - 1; |
---|
138 | argCountVert = 1; |
---|
139 | iVertStart = 1; |
---|
140 | for i = 1:numArgVertExist |
---|
141 | testArg = stOldTablesFF.mCHE_with_arg(i+1,1); |
---|
142 | if((testArg >= minValArgVert) && (testArg <= maxValArgVert)) |
---|
143 | vArgVertExist(argCountVert) = testArg; |
---|
144 | if(argCountVert == 1) |
---|
145 | iVertStart = i; |
---|
146 | end |
---|
147 | argCountVert = argCountVert + 1; |
---|
148 | end |
---|
149 | end |
---|
150 | iVertEnd = iVertStart + (argCountVert - 2); |
---|
151 | numArgVert_p_1 = argCountVert; |
---|
152 | |
---|
153 | numArgHorExist = size(stOldTablesFF.mCHE_with_arg, 2) - 1; |
---|
154 | argCountHor = 1; |
---|
155 | iHorStart = 1; |
---|
156 | for i = 1:numArgHorExist |
---|
157 | testArg = stOldTablesFF.mCHE_with_arg(1,i+1); |
---|
158 | if((testArg >= minValArgHor) && (testArg <= maxValArgHor)) |
---|
159 | vArgHorExist(argCountHor) = testArg; |
---|
160 | if(argCountHor == 1) |
---|
161 | iHorStart = i; |
---|
162 | end |
---|
163 | argCountHor = argCountHor + 1; |
---|
164 | end |
---|
165 | end |
---|
166 | iHorEnd = iHorStart + (argCountHor - 2); |
---|
167 | numArgHor_p_1 = argCountHor; |
---|
168 | |
---|
169 | [new_mCHE_with_arg, new_mCVE_with_arg, new_mCHS_with_arg, new_mCVS_with_arg] = idInterpolFeedForwardCorTables2D(mCHE_with_arg, mCVE_with_arg, mCHS_with_arg, mCVS_with_arg, vArgVertExist, vArgHorExist, interpMeth); |
---|
170 | |
---|
171 | %for i = 2:numArgVert_p_1 |
---|
172 | % for j = 2:numArgHor_p_1 |
---|
173 | % new_tot_mCHE_with_arg(i,j) = new_tot_mCHE_with_arg(i,j) + new_mCHE_with_arg(i,j); |
---|
174 | % new_tot_mCVE_with_arg(i,j) = new_tot_mCVE_with_arg(i,j) + new_mCVE_with_arg(i,j); |
---|
175 | % new_tot_mCHS_with_arg(i,j) = new_tot_mCHS_with_arg(i,j) + new_mCHS_with_arg(i,j); |
---|
176 | % new_tot_mCVS_with_arg(i,j) = new_tot_mCVS_with_arg(i,j) + new_mCVS_with_arg(i,j); |
---|
177 | % end |
---|
178 | %end |
---|
179 | for i = (iVertStart + 1):(iVertEnd + 1) |
---|
180 | iRel = i - iVertStart + 1; |
---|
181 | for j = (iHorStart + 1):(iHorEnd + 1) |
---|
182 | jRel = j - iHorStart + 1; |
---|
183 | new_tot_mCHE_with_arg(i,j) = new_tot_mCHE_with_arg(i,j) + new_mCHE_with_arg(iRel,jRel); |
---|
184 | new_tot_mCVE_with_arg(i,j) = new_tot_mCVE_with_arg(i,j) + new_mCVE_with_arg(iRel,jRel); |
---|
185 | new_tot_mCHS_with_arg(i,j) = new_tot_mCHS_with_arg(i,j) + new_mCHS_with_arg(iRel,jRel); |
---|
186 | new_tot_mCVS_with_arg(i,j) = new_tot_mCVS_with_arg(i,j) + new_mCVS_with_arg(iRel,jRel); |
---|
187 | end |
---|
188 | end |
---|
189 | |
---|
190 | end |
---|
191 | |
---|
192 | %Saving previous FF Tables |
---|
193 | fileNameCoreOldFF = 'old_ff_tab'; |
---|
194 | idSaveStruct(stOldTablesFF, fileNameCoreOldFF, idName, 1, 0); |
---|
195 | |
---|
196 | %return; |
---|
197 | |
---|
198 | %Updating FF Tables |
---|
199 | tango_write_attribute2(DServName, tabNameDataCHE{1}, new_tot_mCHE_with_arg); |
---|
200 | tango_write_attribute2(DServName, tabNameDataCVE{1}, new_tot_mCVE_with_arg); |
---|
201 | tango_write_attribute2(DServName, tabNameDataCHS{1}, new_tot_mCHS_with_arg); |
---|
202 | tango_write_attribute2(DServName, tabNameDataCVS{1}, new_tot_mCVS_with_arg); |
---|