0001 function R=ParseAtributesMADX_2_AT(R,elname,var,val)
0002
0003
0004
0005
0006
0007
0008
0009
0010 val0=val;
0011
0012 if ~isempty(val)
0013
0014 val=strrep(val,'=','');
0015 val=strrep(val,',','');
0016 val=strrep(val,' ','');
0017
0018 var=strrep(var,'=','');
0019 var=strrep(var,',','');
0020 var=strrep(var,' ','');
0021
0022 val=strrep(val,'&','0');
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 mstr={'rm11'
0033 'rm12'
0034 'rm13'
0035 'rm14'
0036 'rm15'
0037 'rm16'
0038 'rm21'
0039 'rm22'
0040 'rm23'
0041 'rm24'
0042 'rm25'
0043 'rm26'
0044 'rm31'
0045 'rm32'
0046 'rm33'
0047 'rm34'
0048 'rm35'
0049 'rm36'
0050 'rm41'
0051 'rm42'
0052 'rm43'
0053 'rm44'
0054 'rm45'
0055 'rm46'
0056 'rm51'
0057 'rm52'
0058 'rm53'
0059 'rm54'
0060 'rm55'
0061 'rm56'
0062 'rm61'
0063 'rm62'
0064 'rm63'
0065 'rm64'
0066 'rm65'
0067 'rm66'};
0068
0069 tmstr = {'tm111'
0070 'tm112'
0071 'tm113'
0072 'tm114'
0073 'tm115'
0074 'tm116'
0075 'tm211'
0076 'tm212'
0077 'tm213'
0078 'tm214'
0079 'tm215'
0080 'tm216'
0081 'tm311'
0082 'tm312'
0083 'tm313'
0084 'tm314'
0085 'tm315'
0086 'tm316'
0087 'tm411'
0088 'tm412'
0089 'tm413'
0090 'tm414'
0091 'tm415'
0092 'tm416'
0093 'tm511'
0094 'tm512'
0095 'tm513'
0096 'tm514'
0097 'tm515'
0098 'tm516'
0099 'tm611'
0100 'tm612'
0101 'tm613'
0102 'tm614'
0103 'tm615'
0104 'tm616'
0105 'tm121'
0106 'tm122'
0107 'tm123'
0108 'tm124'
0109 'tm125'
0110 'tm126'
0111 'tm221'
0112 'tm222'
0113 'tm223'
0114 'tm224'
0115 'tm225'
0116 'tm226'
0117 'tm321'
0118 'tm322'
0119 'tm323'
0120 'tm324'
0121 'tm325'
0122 'tm326'
0123 'tm421'
0124 'tm422'
0125 'tm423'
0126 'tm424'
0127 'tm425'
0128 'tm426'
0129 'tm521'
0130 'tm522'
0131 'tm523'
0132 'tm524'
0133 'tm525'
0134 'tm526'
0135 'tm621'
0136 'tm622'
0137 'tm623'
0138 'tm624'
0139 'tm625'
0140 'tm626'
0141 'tm131'
0142 'tm132'
0143 'tm133'
0144 'tm134'
0145 'tm135'
0146 'tm136'
0147 'tm231'
0148 'tm232'
0149 'tm233'
0150 'tm234'
0151 'tm235'
0152 'tm236'
0153 'tm331'
0154 'tm332'
0155 'tm333'
0156 'tm334'
0157 'tm335'
0158 'tm336'
0159 'tm431'
0160 'tm432'
0161 'tm433'
0162 'tm434'
0163 'tm435'
0164 'tm436'
0165 'tm531'
0166 'tm532'
0167 'tm533'
0168 'tm534'
0169 'tm535'
0170 'tm536'
0171 'tm631'
0172 'tm632'
0173 'tm633'
0174 'tm634'
0175 'tm635'
0176 'tm636'
0177 'tm141'
0178 'tm142'
0179 'tm143'
0180 'tm144'
0181 'tm145'
0182 'tm146'
0183 'tm241'
0184 'tm242'
0185 'tm243'
0186 'tm244'
0187 'tm245'
0188 'tm246'
0189 'tm341'
0190 'tm342'
0191 'tm343'
0192 'tm344'
0193 'tm345'
0194 'tm346'
0195 'tm441'
0196 'tm442'
0197 'tm443'
0198 'tm444'
0199 'tm445'
0200 'tm446'
0201 'tm541'
0202 'tm542'
0203 'tm543'
0204 'tm544'
0205 'tm545'
0206 'tm546'
0207 'tm641'
0208 'tm642'
0209 'tm643'
0210 'tm644'
0211 'tm645'
0212 'tm646'
0213 'tm151'
0214 'tm152'
0215 'tm153'
0216 'tm154'
0217 'tm155'
0218 'tm156'
0219 'tm251'
0220 'tm252'
0221 'tm253'
0222 'tm254'
0223 'tm255'
0224 'tm256'
0225 'tm351'
0226 'tm352'
0227 'tm353'
0228 'tm354'
0229 'tm355'
0230 'tm356'
0231 'tm451'
0232 'tm452'
0233 'tm453'
0234 'tm454'
0235 'tm455'
0236 'tm456'
0237 'tm551'
0238 'tm552'
0239 'tm553'
0240 'tm554'
0241 'tm555'
0242 'tm556'
0243 'tm651'
0244 'tm652'
0245 'tm653'
0246 'tm654'
0247 'tm655'
0248 'tm656'
0249 'tm161'
0250 'tm162'
0251 'tm163'
0252 'tm164'
0253 'tm165'
0254 'tm166'
0255 'tm261'
0256 'tm262'
0257 'tm263'
0258 'tm264'
0259 'tm265'
0260 'tm266'
0261 'tm361'
0262 'tm362'
0263 'tm363'
0264 'tm364'
0265 'tm365'
0266 'tm366'
0267 'tm461'
0268 'tm462'
0269 'tm463'
0270 'tm464'
0271 'tm465'
0272 'tm466'
0273 'tm561'
0274 'tm562'
0275 'tm563'
0276 'tm564'
0277 'tm565'
0278 'tm566'
0279 'tm661'
0280 'tm662'
0281 'tm663'
0282 'tm664'
0283 'tm665'
0284 'tm666'};
0285
0286 switch var
0287 case {'l','L'}
0288 R=[R elname '.(''Length'')=' val '; \n'];
0289
0290 case {'angle','ANGLE'}
0291 R=[R elname '.(''BendingAngle'')=' val '; \n'];
0292 case {'K1','k1'}
0293 R=[R elname '.(''PolynomB'')(2)=' val '; \n'];
0294 case {'K1S',''}
0295 R=[R elname '.(''PolynomA'')(2)=' val '; \n'];
0296 case {'K2','k2'}
0297 R=[R elname '.(''PolynomB'')(3)=' val '; \n'];
0298 case {'K3','k3'}
0299 R=[R elname '.(''PolynomB'')(4)=' val '; \n'];
0300 case {'KS','ks'}
0301 R=[R elname '.(''K'')(1)=' val '; \n'];
0302 case {'E1','e1'}
0303 R=[R elname '.(''EntranceAngle'')=' val '; \n'];
0304 case {'E2','e2'}
0305 R=[R elname '.(''ExitAngle'')=' val '; \n'];
0306
0307
0308
0309
0310 case {'HGAP','hgap'}
0311 R=[R elname '.(''FullGap'')=2*' val '; \n'];
0312 case {'fint','FINT'}
0313 R=[R elname '.(''FringeInt1'')=' val '; \n'];
0314 case {'fintx','FINTX'}
0315 R=[R elname '.(''FringeInt2'')=' val '; \n'];
0316 case {'K1L','k1l'}
0317 R=[R elname '.(''PolynomB'')(1)=' val '; \n'];
0318 case {'K2L','k2l'}
0319 R=[R elname '.(''PolynomB'')(2)=' val '; \n'];
0320 case {'K3L','k3l'}
0321 R=[R elname '.(''PolynomB'')(3)=' val '; \n'];
0322 case {'K4L','k4l'}
0323 R=[R elname '.(''PolynomB'')(4)=' val '; \n'];
0324 case {'K5L','k5l'}
0325 R=[R elname '.(''PolynomB'')(5)=' val '; \n'];
0326 case {'K6L','k6l'}
0327 R=[R elname '.(''PolynomB'')(6)=' val '; \n'];
0328 case {'K1SL','k1sl'}
0329 R=[R elname '.(''PolynomA'')(1)=' val '; \n'];
0330 case {'K2SL','k2sl'}
0331 R=[R elname '.(''PolynomA'')(2)=' val '; \n'];
0332 case {'K3SL','k3sl'}
0333 R=[R elname '.(''PolynomA'')(3)=' val '; \n'];
0334 case {'K4SL','k4sl'}
0335 R=[R elname '.(''PolynomA'')(4)=' val '; \n'];
0336 case {'K5SL','k5sl'}
0337 R=[R elname '.(''PolynomA'')(5)=' val '; \n'];
0338 case {'K6SL','k6sl'}
0339 R=[R elname '.(''PolynomA'')(6)=' val '; \n'];
0340 case {'KNL','knl'}
0341 R=[R elname '.(''PolynomB'')=' val0 '; \n'];
0342 case {'KSL','ksl'}
0343 R=[R elname '.(''PolynomA'')=' val0 '; \n'];
0344 case tmstr
0345 if strcmp(var(3),'5')
0346 var(3)='6';
0347 elseif strcmp(var(3),'6')
0348 var(3)='5';
0349 end
0350 if strcmp(var(4),'5')
0351 var(4)='6';
0352 elseif strcmp(var(4),'6')
0353 var(4)='5';
0354 end
0355 if strcmp(var(5),'5')
0356 var(5)='6';
0357 elseif strcmp(var(5),'6')
0358 var(5)='5';
0359 end
0360 R=[R elname '.Tijk(' var(3) ',' var(4) ',' var(5) ')=' strrep(val0,',','') '; \n'];
0361 case mstr
0362 if strcmp(var(3),'5')
0363 var(3)='6';
0364 elseif strcmp(var(3),'6')
0365 var(3)='5';
0366 end
0367 if strcmp(var(4),'5')
0368 var(4)='6';
0369 elseif strcmp(var(4),'6')
0370 var(4)='5';
0371 end
0372
0373
0374
0375
0376
0377
0378
0379 R=[R elname '.M66(' var(3) ',' var(4) ')=' strrep(val0,',','') '; \n'];
0380 case {'VOLT','volt'}
0381 R=[R elname '.(''Voltage'')=abs(' val ')*1e6; %% convert to MV \n'];
0382 case {'FREQ','freq'}
0383 R=[R elname '.(''Frequency'')=' val '*1e6; %% convert to MHz \n'];
0384 case {'tilt','TILT','Tilt'}
0385 R=[R elname '.(''Tilt'')(1)=' val '; \n'];
0386 case {'type','Type','TYPE'}
0387 R=[R elname '.(''Type'')=' val '; \n'];
0388 case {'HARMON','harmon'}
0389 R=[R elname '.(''HarmNumber'')=' val '; \n'];
0390
0391
0392
0393
0394 otherwise
0395
0396 end
0397 end
0398
0399
0400