00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include <stdio.h>
00012 #include <string.h>
00013 #include <ctype.h>
00014 #include <stdlib.h>
00015
00016
00017
00018
00019 #include "config.h"
00020
00021
00022
00023
00024 #define STRING 0
00025 #define INTEGER 1
00026 #define FLOAT 2
00027
00028
00029
00030
00031 extern int InputType();
00032 extern void WrongType();
00033 extern void RemoveBlanks();
00034
00035 extern char str[1024];
00036 extern int status_interval;
00037
00038
00039
00040
00041 CONFIG GetConfig(FILE *);
00042 CONFIG SetConfig(void);
00043 void PutConfig(CONFIG);
00044
00045
00046
00047
00048 CONFIG
00049 GetConfig(FILE *fp)
00050 {
00051 CONFIG h;
00052 int i,j,k, size, ntok=0, nmode=0;
00053 char buf[128], *key, *token[20];
00054 extern int input_priority;
00055 extern float stat_wavelength;
00056
00057
00058 h = SetConfig();
00059
00060 fseek( fp, 0, SEEK_SET );
00061
00062
00063
00064
00065
00066 while( fgets(buf,128,fp)!= NULL){
00067 if ( strlen(buf) < 2 ) continue;
00068
00069
00070 if( buf[0] == '#' || buf[0]=='!' ) continue;
00071
00072
00073
00074 ntok = -1;
00075
00076 for(i=0;i<128;i++) {
00077
00078 if( buf[i] == '\t') buf[i] = ' ';
00079 if( buf[i] == '\f') buf[i] = ' ';
00080 if( buf[i] == '\n') buf[i] = '\0';
00081 if( buf[i] == '\r') buf[i] = '\0';
00082 if( buf[i] == '\0') break;
00083 }
00084
00085 for(i=0;i<strlen(buf);i++) {
00086 if( buf[i] == ' ' ) continue;
00087 ntok++;
00088 for (j=i;j<strlen(buf);j++)
00089 if( buf[j] == ' ') break;
00090 i=j;
00091 }
00092 if (strlen(buf) < 3 ) continue;
00093
00094 key = strtok( buf, " ");
00095
00096
00097 for ( i=0; i<strlen(key); i++ )
00098 if ( isalnum( key[i] ) ) key[i] = toupper( key[i] );
00099
00100 for(i=0;i<ntok;i++) {
00101 token[i] = strtok( NULL, " ");
00102 strcpy( str, token[i] );
00103
00104 if ( !strstr( key, "NET" ) )
00105 for ( j=0; j<strlen( str ); j++ )
00106 if ( isalnum( str[j] ) ) str[j] = toupper( str[j] );
00107 strcpy( token[i] , str );
00108 RemoveBlanks( token[i] );
00109 }
00110
00111
00112 if(!strncmp(key,"GAIN",4) && ntok >= 0 )
00113 if ( InputType( token[0] ) >= INTEGER )
00114 h.gain = atof( token[0] );
00115 else
00116 WrongType( FLOAT, key, token[0] );
00117
00118 else if( !strncmp(key,"MONO",4) && ntok >=0 ) {
00119 for ( i=0; i<ntok; i++ ) {
00120 if ( strstr(token[i],"POLA" ) ) {
00121 i++;
00122 if ( InputType( token[i] ) >= INTEGER )
00123 h.polar = atof( token[i] );
00124 else
00125 WrongType( FLOAT, key, token[i] );
00126 }
00127 else {
00128 strcat( h.filter, token[i] );
00129 }
00130 }
00131 }
00132
00133
00134 else if(!strncmp(key,"SHUT",4) && ntok >= 0 )
00135 if ( InputType( token[0] ) == INTEGER )
00136 h.shutter_delay = atoi( token[0] );
00137 else
00138 WrongType( INTEGER, key, token[0] );
00139
00140
00141 else if(!strncmp(key,"SETS",4) && ntok >= 0 )
00142 if ( InputType( token[0] ) == INTEGER )
00143 h.sets = (unsigned char)atoi( token[0] );
00144 else
00145 WrongType( INTEGER, key, token[0] );
00146
00147
00148
00149 else if( !strncmp(key,"GENE",4) && ntok >= 0 ) {
00150 for(i=0;i<ntok;i++) {
00151 if ( strstr( token[i], "MA" ) ) {
00152 i++;
00153 if ( InputType( token[i] ) >= INTEGER ) {
00154 h.mA = atof( token[i] );
00155 }
00156 else
00157 WrongType( FLOAT, key, token[i] );
00158 }
00159 else if ( strstr( token[i], "KV" ) ) {
00160 i++;
00161 if ( InputType( token[i] ) >= INTEGER ) {
00162 h.kV = atof( token[i] );
00163 }
00164 else
00165 WrongType( FLOAT, key, token[i] );
00166 }
00167 else
00168 strcat( h.source, token[i] );
00169 }
00170 }
00171
00172
00173 else if(!strncmp(key,"COLO",4) && ntok >= 0 )
00174 if ( InputType( token[0] ) == INTEGER )
00175 h.colors = (unsigned char)atoi( token[0] );
00176 else
00177 WrongType( INTEGER, key, token[0] );
00178
00179
00180 else if(!strncmp(key,"PRIO",4) && ntok >= 0 && input_priority < 0 )
00181 if ( InputType( token[0] ) == INTEGER )
00182 input_priority = atoi( token[0] );
00183 else
00184 WrongType( INTEGER, key, token[0] );
00185
00186
00187 else if(!strncmp(key,"FLAG",4) && ntok >= 0 )
00188 if ( InputType( token[0] ) == INTEGER )
00189 h.flags = atoi( token[0] );
00190 else
00191 WrongType( INTEGER, key, token[0] );
00192
00193
00194 else if(!strncmp(key,"SPIR",4) && ntok >= 0 )
00195 for(i=0;i<ntok;i++) {
00196 if ( strstr( token[i], "MAX" ) ) {
00197 i++;
00198 if ( InputType( token[i] ) == INTEGER ) {
00199 h.spiral_max = atoi( token[i] );
00200 }
00201 else
00202 WrongType( INTEGER, key, token[i] );
00203 }
00204 else if ( strstr( token[i], "SCA" ) ) {
00205 i++;
00206 if ( InputType( token[i] ) >= INTEGER ) {
00207 h.spiral_scale = atof( token[i] );
00208 }
00209 else
00210 WrongType( FLOAT, key, token[i] );
00211 }
00212 }
00213
00214
00215 else if(!strncmp(key,"INTE",4) && ntok >= 0 ) {
00216 for(i=0;i<ntok;i++) {
00217 if ( strstr( token[i], "MIN" ) ) {
00218 i++;
00219 if ( InputType( token[i] ) >= INTEGER )
00220 h.intensmin = atof( token[i] );
00221 else
00222 WrongType( FLOAT, key, token[i] );
00223 }
00224 else if ( strstr( token[i], "WAR" ) ) {
00225 i++;
00226 if ( InputType( token[i] ) >= INTEGER )
00227 h.intenswarn = atof( token[i] );
00228 else
00229 WrongType( FLOAT, key, token[i] );
00230 }
00231 else if ( strstr( token[i], "DOS" ) ) {
00232 i++;
00233 if ( InputType( token[i] ) >= INTEGER )
00234 h.dosemin = (float)atof( token[i] );
00235 else
00236 WrongType( FLOAT, key, token[i] );
00237 }
00238 }
00239 }
00240
00241
00242 else if( !strncmp(key,"COLL",4) && ntok >= 1 ) {
00243 for(i=0;i<ntok;i++) {
00244 if ( strstr( token[i], "WID" ) ) {
00245 i++;
00246 if ( InputType( token[i] ) >= INTEGER ) {
00247 h.slitx= atof( token[i] );
00248 }
00249 else
00250 WrongType( FLOAT, key, token[i] );
00251 }
00252 else if ( strstr( token[i], "HEI" ) ) {
00253 i++;
00254 if ( InputType( token[i] ) >= INTEGER ) {
00255 h.slity = atof( token[i] );
00256 }
00257 else
00258 WrongType( FLOAT, key, token[i] );
00259 }
00260 }
00261 }
00262
00263 else if(!strncmp(key,"PHI",3) && ntok >= 0 ) {
00264 for(i=0;i<ntok;i++) {
00265 if ( strstr( token[i], "SPE" ) ) {
00266 i++;
00267 if ( InputType( token[i] ) == INTEGER ) {
00268 h.phi_speed = atoi( token[i] );
00269 }
00270 else
00271 WrongType( INTEGER, key, token[i] );
00272 }
00273 else if ( strstr( token[i], "STE" ) ) {
00274 i++;
00275 if ( InputType( token[i] ) == INTEGER ) {
00276 h.phi_steps = atoi( token[i] );
00277 }
00278 else
00279 WrongType( INTEGER, key, token[i] );
00280 }
00281 else if ( strstr( token[i], "DEF" ) ) {
00282 i++;
00283 if ( InputType( token[i] ) >= INTEGER ) {
00284 h.phi_def = atof( token[i] );
00285 }
00286 else
00287 WrongType( FLOAT, key, token[i] );
00288 }
00289 }
00290 }
00291
00292 else if(!strncmp(key,"OME",3) && ntok >= 0 ) {
00293 for(i=0;i<ntok;i++) {
00294 if ( strstr( token[i], "SPE" ) ) {
00295 i++;
00296 if ( InputType( token[i] ) == INTEGER ) {
00297 h.ome_speed = atoi( token[i] );
00298 }
00299 else
00300 WrongType( INTEGER, key, token[i] );
00301 }
00302 else if ( strstr( token[i], "STE" ) ) {
00303 i++;
00304 if ( InputType( token[i] ) == INTEGER ) {
00305 h.ome_steps = atoi( token[i] );
00306 }
00307 else
00308 WrongType( INTEGER, key, token[i] );
00309 }
00310 else if ( strstr( token[i], "MIN" ) ) {
00311 i++;
00312 if ( InputType( token[i] ) >= INTEGER ) {
00313 h.ome_min = atof( token[i] );
00314 }
00315 else
00316 WrongType( FLOAT, key, token[i] );
00317 }
00318 else if ( strstr( token[i], "MAX" ) ) {
00319 i++;
00320 if ( InputType( token[i] ) >= INTEGER ) {
00321 h.ome_max = atof( token[i] );
00322 }
00323 else
00324 WrongType( FLOAT, key, token[i] );
00325 }
00326 else if ( strstr( token[i], "DEF" ) ) {
00327 i++;
00328 if ( InputType( token[i] ) >= INTEGER ) {
00329 h.ome_def = atof( token[i] );
00330 }
00331 else
00332 WrongType( FLOAT, key, token[i] );
00333 }
00334 }
00335 }
00336
00337 else if(!strncmp(key,"CHI",3) && ntok >= 0 ) {
00338 for(i=0;i<ntok;i++) {
00339 if ( strstr( token[i], "SPE" ) ) {
00340 i++;
00341 if ( InputType( token[i] ) == INTEGER ) {
00342 h.chi_speed = atoi( token[i] );
00343 }
00344 else
00345 WrongType( INTEGER, key, token[i] );
00346 }
00347 else if ( strstr( token[i], "STE" ) ) {
00348 i++;
00349 if ( InputType( token[i] ) == INTEGER ) {
00350 h.chi_steps = atoi( token[i] );
00351 }
00352 else
00353 WrongType( INTEGER, key, token[i] );
00354 }
00355 else if ( strstr( token[i], "MIN" ) ) {
00356 i++;
00357 if ( InputType( token[i] ) >= INTEGER ) {
00358 h.chi_min = atof( token[i] );
00359 }
00360 else
00361 WrongType( FLOAT, key, token[i] );
00362 }
00363 else if ( strstr( token[i], "MAX" ) ) {
00364 i++;
00365 if ( InputType( token[i] ) >= INTEGER ) {
00366 h.chi_max = atof( token[i] );
00367 }
00368 else
00369 WrongType( FLOAT, key, token[i] );
00370 }
00371 else if ( strstr( token[i], "DEF" ) ) {
00372 i++;
00373 if ( InputType( token[i] ) >= INTEGER ) {
00374 h.chi_def = atof( token[i] );
00375 }
00376 else
00377 WrongType( FLOAT, key, token[i] );
00378 }
00379 }
00380 }
00381
00382 else if(!strncmp(key,"THET",4) && ntok >= 0 ) {
00383 for(i=0;i<ntok;i++) {
00384 if ( strstr( token[i], "SPE" ) ) {
00385 i++;
00386 if ( InputType( token[i] ) == INTEGER ) {
00387 h.thet_speed = atoi( token[i] );
00388 }
00389 else
00390 WrongType( INTEGER, key, token[i] );
00391 }
00392 else if ( strstr( token[i], "STE" ) ) {
00393 i++;
00394 if ( InputType( token[i] ) == INTEGER ) {
00395 h.thet_steps = atoi( token[i] );
00396 }
00397 else
00398 WrongType( INTEGER, key, token[i] );
00399 }
00400 else if ( strstr( token[i], "MIN" ) ) {
00401 i++;
00402 if ( InputType( token[i] ) >= INTEGER ) {
00403 h.thet_min = atof( token[i] );
00404 }
00405 else
00406 WrongType( FLOAT, key, token[i] );
00407 }
00408 else if ( strstr( token[i], "MAX" ) ) {
00409 i++;
00410 if ( InputType( token[i] ) >= INTEGER ) {
00411 h.thet_max = atof( token[i] );
00412 }
00413 else
00414 WrongType( FLOAT, key, token[i] );
00415 }
00416 else if ( strstr( token[i], "DEF" ) ) {
00417 i++;
00418 if ( InputType( token[i] ) >= INTEGER ) {
00419 h.thet_def = atof( token[i] );
00420 }
00421 else
00422 WrongType( FLOAT, key, token[i] );
00423 }
00424 }
00425 }
00426
00427 else if(!strncmp(key,"DIST",4) && ntok >= 0 )
00428 for(i=0;i<ntok;i++) {
00429 if ( strstr( token[i], "SPE" ) ) {
00430 i++;
00431 if ( InputType( token[i] ) == INTEGER ) {
00432 h.dist_speed = atoi( token[i] );
00433 }
00434 else
00435 WrongType( INTEGER, key, token[i] );
00436 }
00437 else if ( strstr( token[i], "STE" ) ) {
00438 i++;
00439 if ( InputType( token[i] ) == INTEGER ) {
00440 h.dist_steps = atoi( token[i] );
00441 }
00442 else
00443 WrongType( INTEGER, key, token[i] );
00444 }
00445 else if ( strstr( token[i], "DEF" ) ) {
00446 i++;
00447 if ( InputType( token[i] ) >= INTEGER ) {
00448 h.dist_def = atof( token[i] );
00449 }
00450 else
00451 WrongType( FLOAT, key, token[i] );
00452 }
00453 else if ( strstr( token[i], "USEMIN" ) )
00454 h.use_distmin = 1;
00455 else if ( strstr( token[i], "USEMAX" ) )
00456 h.use_distmax = 1;
00457 else if ( strstr( token[i], "MIN" ) ) {
00458 i++;
00459 if ( InputType( token[i] ) >= INTEGER ) {
00460 h.dist_min = atof( token[i] );
00461 }
00462 else
00463 WrongType( FLOAT, key, token[i] );
00464 }
00465 else if ( strstr( token[i], "MAX" ) ) {
00466 i++;
00467 if ( InputType( token[i] ) >= INTEGER ) {
00468 h.dist_max = atof( token[i] );
00469 }
00470 else
00471 WrongType( FLOAT, key, token[i] );
00472 }
00473 }
00474
00475 else if(!strncmp(key,"LOCK",4) && ntok >= 0 ) {
00476 for(i=0;i<ntok;i++) {
00477 if ( strstr( token[i], "PRE" ) ) {
00478 i++;
00479 if ( InputType( token[i] ) == INTEGER ) {
00480 h.prelock_speed = atoi( token[i] );
00481 }
00482 else
00483 WrongType( INTEGER, key, token[i] );
00484 }
00485 else if ( strstr( token[i], "LOC" ) ) {
00486 i++;
00487 if ( InputType( token[i] ) == INTEGER ) {
00488 h.lock_speed = atoi( token[i] );
00489 }
00490 else
00491 WrongType( INTEGER, key, token[i] );
00492 }
00493 }
00494 }
00495
00496 else if(!strncmp(key,"WAVE",4) && ntok >= 0 ) {
00497 if ( strstr( token[0], "VAR" ) )
00498 h.lambda_var = 1;
00499 else {
00500 h.lambda_var = 0;
00501 if ( InputType( token[0] ) >= INTEGER )
00502 h.wavelength = stat_wavelength = atof( token[0] );
00503 else
00504 WrongType( FLOAT, key, token[0] );
00505 }
00506 }
00507
00508
00509 else if(!strncmp(key,"MODE",4) && ntok >= 0 ) {
00510 for ( i=nmode=0; i<ntok; i++ ) {
00511 if ( strstr( token[i], "SCAN" ) ) {
00512 i++;
00513 if ( InputType( token[i] ) >= INTEGER )
00514 h.scantime[nmode] = atof( token[i] );
00515 else
00516 WrongType( FLOAT, key, token[i] );
00517 }
00518 else if ( strstr( token[i], "ERAS" ) ) {
00519 i++;
00520 if ( InputType( token[i] ) >= INTEGER )
00521 h.erasetime[nmode] = atof( token[i] );
00522 else
00523 WrongType( FLOAT, key, token[i] );
00524 }
00525 else if ( strstr( token[i], "ROFF" ) ) {
00526 i++;
00527 if ( InputType( token[i] ) >= INTEGER)
00528 h.roff[nmode] = atof( token[i] );
00529 else
00530 WrongType( FLOAT, key, token[i] );
00531 }
00532 else if ( strstr( token[i], "TOFF" ) ) {
00533 i++;
00534 if ( InputType( token[i] ) >= INTEGER)
00535 h.toff[nmode] = atof( token[i] );
00536 else
00537 WrongType( FLOAT, key, token[i] );
00538 }
00539 else if ( strstr( token[i], "XC" ) ) {
00540 i++;
00541 if ( InputType( token[i] ) >= INTEGER)
00542 h.xcen = atof( token[i] );
00543 else
00544 WrongType( FLOAT, key, token[i] );
00545 }
00546 else if ( strstr( token[i], "YC" ) ) {
00547 i++;
00548 if ( InputType( token[i] ) >= INTEGER)
00549 h.ycen = atof( token[i] );
00550 else
00551 WrongType( FLOAT, key, token[i] );
00552 }
00553 else if ( strstr( token[i], "ADC" ) ) {
00554 i++;
00555 if ( InputType( token[i] ) == INTEGER)
00556 h.adcoff[nmode] = atoi( token[i] );
00557 else
00558 WrongType( INTEGER, key, token[i] );
00559 }
00560 else if ( strstr( token[i], "AADD" ) ) {
00561 i++;
00562 if ( InputType( token[i] ) == INTEGER)
00563 h.adcadd_A[nmode] = atoi( token[i] );
00564 else
00565 WrongType( INTEGER, key, token[i] );
00566 }
00567 else if ( strstr( token[i], "BADD" ) ) {
00568 i++;
00569 if ( InputType( token[i] ) == INTEGER)
00570 h.adcadd_B[nmode] = atoi( token[i] );
00571 else
00572 WrongType( INTEGER, key, token[i] );
00573 }
00574 else if ( strstr( token[i], "ADD" ) ) {
00575 i++;
00576 if ( InputType( token[i] ) == INTEGER)
00577 h.adcadd[nmode] = atoi( token[i] );
00578 else
00579 WrongType( INTEGER, key, token[i] );
00580 }
00581 else {
00582 if ( InputType( token[i] ) == INTEGER ){
00583 size = atoi( token[i] );
00584 for ( nmode=0; nmode<MAX_SCANMODE; nmode++ ) {
00585 if ( size == h.size[nmode] ) break;
00586 }
00587 }
00588 else {
00589 WrongType( INTEGER, key, token[i] );
00590 break;
00591 }
00592 }
00593 }
00594 }
00595
00596
00597 else if(!strncmp(key,"UNIT",4) && ntok >= 0 )
00598 for(i=0;i<ntok;i++) {
00599 if ( strstr( token[i], "TIME" ) ) {
00600 i++;
00601 if ( InputType( token[i] ) == INTEGER ) {
00602 h.units_time = atoi( token[i] );
00603 }
00604 else
00605 WrongType( INTEGER, key, token[i] );
00606 }
00607 else if ( strstr( token[i], "DOS" ) ) {
00608 i++;
00609 if ( InputType( token[i] ) == INTEGER ) {
00610 h.units_dose = atoi( token[i] );
00611 }
00612 else
00613 WrongType( INTEGER, key, token[i] );
00614 }
00615 }
00616
00617
00618 else if(!strncmp(key,"INIT",4) && ntok >= 0 )
00619 for(i=0;i<ntok;i++) {
00620 if ( strstr( token[i], "MIN" ) ) {
00621 h.init_maxdist=0;
00622 }
00623 else if ( strstr( token[i], "MAX" ) ) {
00624 h.init_maxdist=1;
00625 }
00626 }
00627
00628
00629 else if(!strncmp(key,"IGNO",4) && ntok >= 0 )
00630 for(i=0;i<ntok;i++) {
00631 if ( strstr( token[i], "PHI" ) )
00632 h.use_phi = 0;
00633 else if ( strstr( token[i], "OME" ) )
00634 h.use_ome = 0;
00635 else if ( strstr( token[i], "CHI" ) )
00636 h.use_chi = 0;
00637 else if ( strstr( token[i], "THE" ) )
00638 h.use_thet = 0;
00639 else if ( strstr( token[i], "DIS" ) )
00640 h.use_dist = 0;
00641 else if ( strstr( token[i], "ERA" ) )
00642 h.use_erase = 0;
00643 else if ( strstr( token[i], "XRA" ) )
00644 h.use_xray = 0;
00645 else if ( strstr( token[i], "SOU" ) )
00646 h.use_sound = 0;
00647 else if ( strstr( token[i], "BAS" ) )
00648 h.use_base = 0;
00649 else if ( strstr( token[i], "IMA" ) )
00650 h.use_image = 0;
00651 else if ( strstr( token[i], "DOS" ) )
00652 h.use_dose = 0;
00653 else if ( strstr( token[i], "RUN" ) )
00654 h.use_run = 0;
00655 else if ( strstr( token[i], "STA" ) )
00656 h.use_stats = 0;
00657 else if ( strstr( token[i], "Z-A" ) )
00658 h.use_zaxis = 0;
00659 else if ( strstr( token[i], "WAV" ) )
00660 h.use_wave = 0;
00661 else if ( strstr( token[i], "SHE" ) )
00662 h.use_shell= 0;
00663 else if ( strstr( token[i], "ERR" ) )
00664 h.use_error[0] = 1;
00665 else if ( h.use_error[0] > 0 ) {
00666 strcpy( str, token[i] );
00667 for ( j=k=0; k<strlen(str); k++ ) {
00668 if ( !isdigit( str[k] ) ) {
00669 j=1;
00670 break;
00671 }
00672 }
00673 if ( j==0 && h.use_error[0] < MAX_IGNORE_ERR ) {
00674 j = atoi(str);
00675 h.use_error[h.use_error[0]] = atoi(str);
00676 h.use_error[0] ++;
00677 }
00678 }
00679 else if ( strstr( token[i], "SPY" ) )
00680 h.use_msg = 0;
00681 else if ( strstr( token[i], "ADC" ) )
00682 h.use_adc = 0;
00683 else if ( strstr( token[i], "HTM" ) )
00684 h.use_html = 0;
00685 else if ( strstr( token[i], "SUM" ) )
00686 h.use_txt = 0;
00687 }
00688
00689
00690 else if(!strncmp(key,"USE",3) && ntok >= 0 )
00691 for(i=0;i<ntok;i++) {
00692 if ( strstr( token[i], "PHI" ) )
00693 h.use_phi = 1;
00694 else if ( strstr( token[i], "OME" ) )
00695 h.use_ome = 1;
00696 else if ( strstr( token[i], "CHI" ) )
00697 h.use_chi = 1;
00698 else if ( strstr( token[i], "THE" ) )
00699 h.use_thet = 1;
00700 else if ( strstr( token[i], "DIS" ) )
00701 h.use_dist = 1;
00702 else if ( strstr( token[i], "ERA" ) )
00703 h.use_erase = 1;
00704 else if ( strstr( token[i], "XRA" ) )
00705 h.use_xray = 1;
00706 else if ( strstr( token[i], "SOU" ) )
00707 h.use_sound = 1;
00708 else if ( strstr( token[i], "BAS" ) )
00709 h.use_base = 1;
00710 else if ( strstr( token[i], "IMA" ) )
00711 h.use_image = 1;
00712 else if ( strstr( token[i], "DOS" ) )
00713 h.use_dose = 1;
00714 else if ( strstr( token[i], "SPI" ) )
00715 h.use_image = 2;
00716 else if ( strstr( token[i], "SPK" ) )
00717 h.use_image = 3;
00718 else if ( strstr( token[i], "RUN" ) )
00719 h.use_run = 1;
00720 else if ( strstr( token[i], "STATS" ) )
00721 h.use_stats = 1;
00722 else if ( strstr( token[i], "STATUS" ) )
00723 status_interval = 1;
00724 else if ( strstr( token[i], "Z-A" ) )
00725 h.use_zaxis = 1;
00726 else if ( strstr( token[i], "WAV" ) )
00727 h.use_wave = 1;
00728 else if ( strstr( token[i], "SHE" ) )
00729 h.use_shell= 1;
00730 else if ( strstr( token[i], "SPY" ) )
00731 h.use_msg = 1;
00732 else if ( strstr( token[i], "ADC" ) )
00733 h.use_adc = 1;
00734 else if ( strstr( token[i], "HTM" ) )
00735 h.use_html = 1;
00736 else if ( strstr( token[i], "SUM" ) )
00737 h.use_txt = 1;
00738 }
00739
00740
00741 else if(!strncmp(key,"NET",3) && ntok >= 1 )
00742 for(i=0;i<ntok;i++) {
00743 if ( strstr( token[i], "PORT" ) || strstr( token[i], "port") ) {
00744 i++;
00745 if ( InputType( token[i] ) == INTEGER ) {
00746 h.port = atoi( token[i] );
00747 }
00748 else
00749 WrongType( INTEGER, key, token[i] );
00750 }
00751 else if ( strstr( token[i], "HOST" ) || strstr( token[i], "host") ) {
00752 i++;
00753 strcpy( h.host, token[i] );
00754 }
00755 else if ( strstr( token[i], "TIMEOUT") || strstr( token[i], "timeout") ) {
00756 double tmo;
00757 i++;
00758 tmo = atof( token[i] );
00759 }
00760
00761 else {
00762 strcpy( h.host, token[i] );
00763 }
00764 }
00765
00766
00767 else if(!strncmp(key,"MEMO",4) && ntok >= 0 )
00768 if ( strstr( token[0], "SMA" ) )
00769 h.memory = 0;
00770
00771 }
00772
00773
00774
00775
00776
00777
00778 if ( h.use_base == 0 ) {
00779 h.use_phi = 0;
00780 h.use_chi = 0;
00781 h.use_ome = 0;
00782 h.use_thet = 0;
00783 h.use_dist = 0;
00784 h.use_xray = 0;
00785 }
00786
00787 if ( h.use_wave ) h.lambda_var = 1;
00788
00789 return( h );
00790
00791 }
00792
00793
00794
00795
00796 CONFIG
00797 SetConfig()
00798 {
00799 CONFIG h;
00800 int i;
00801
00802 memset( &h, 0, sizeof( CONFIG ) );
00803
00804 h.phi_speed = 2000;
00805 h.ome_speed = 2000;
00806 h.chi_speed = 2000;
00807 h.thet_speed = 2000;
00808 h.dist_speed = 1000;
00809
00810 h.phi_steps = 500;
00811 h.chi_steps = 500;
00812 h.ome_steps = 500;
00813 h.thet_steps = 500;
00814 h.dist_steps = 100;
00815
00816 h.dist_min = 80.0;
00817 h.thet_min = -360.0;
00818 h.chi_min = -360.0;
00819 h.ome_min = -360.0;
00820 h.dist_max = 2000.0;
00821 h.thet_max = 360.0;
00822 h.chi_max = 360.0;
00823 h.ome_max = 360.0;
00824 h.chi_def = 0.0;
00825 h.phi_def = 0.0;
00826 h.ome_def = 0.0;
00827 h.thet_def = 0.0;
00828 h.dist_def = 100.0;
00829
00830 h.use_phi = 1;
00831 h.use_chi = 0;
00832 h.use_ome = 0;
00833 h.use_thet = 0;
00834 h.use_dist = 1;
00835 h.use_xray = 1;
00836 h.use_base = 1;
00837 h.use_erase = 1;
00838 h.use_sound = 0;
00839 h.use_image = 0;
00840 h.use_dose = 1;
00841 h.use_distmin = 0;
00842 h.use_distmax = 0;
00843 h.use_msg = 1;
00844 h.use_adc = 0;
00845 h.use_run = 1;
00846 h.use_stats = 0;
00847 h.use_zaxis = 0;
00848 h.use_wave = 0;
00849 h.use_shell = 0;
00850
00851 h.init_maxdist = 1;
00852
00853 h.units_time = 4000;
00854 h.units_dose = 1000;
00855 h.dosemin = 1.0;
00856
00857 h.spiral_max = 65500;
00858 h.spiral_scale = 1.0;
00859
00860 h.intensmin = -999.;
00861 h.intenswarn = 20.0;
00862 h.gain = -1.0;
00863
00864 h.mA = 20;
00865 h.kV = 10;
00866 h.polar = 0.0;
00867 h.slitx = 0.3;
00868 h.slity = 0.3;
00869
00870 h.wavelength = 1.541789;
00871 h.lambda_var = 0;
00872 h.memory = 1;
00873 h.colors = 32;
00874 h.flags = 0;
00875 h.lock_speed = 10;
00876 h.prelock_speed = 20;
00877 h.shutter_delay = 0;
00878 h.xcen = 0.0;
00879 h.ycen = 0.0;
00880
00881
00882
00883
00884
00885 h.scantime[0] = 80;
00886 h.scantime[1] = 66;
00887 h.scantime[2] = 48;
00888 h.scantime[3] = 34;
00889 h.scantime[4] =108;
00890 h.scantime[5] = 87;
00891 h.scantime[6] = 62;
00892 h.scantime[7] = 42;
00893
00894 h.erasetime[0] = 20;
00895 h.erasetime[1] = 20;
00896 h.erasetime[2] = 20;
00897 h.erasetime[3] = 20;
00898 h.erasetime[4] = 20;
00899 h.erasetime[5] = 20;
00900 h.erasetime[6] = 20;
00901 h.erasetime[7] = 20;
00902
00903 h.diameter[0] = h.diameter[4] = 345;
00904 h.diameter[1] = h.diameter[5] = 300;
00905 h.diameter[2] = h.diameter[6] = 240;
00906 h.diameter[3] = h.diameter[7] = 180;
00907
00908 for( i=0; i<4; i++ ) {
00909 h.pixelsize[i] = 0.15;
00910 h.pixelsize[i+4] = 0.10;
00911 h.size[i] = (short)(h.diameter[i ] / h.pixelsize[i ] + 0.99);
00912 h.size[i+4] = (short)(h.diameter[i+4] / h.pixelsize[i+4] + 0.99);
00913 h.roff[i] = h.roff[i+4] = 0;
00914 }
00915
00916 for( i=0; i<8; i++ ) {
00917 h.roff[i] = 0;
00918 h.toff[i] = 0;
00919 h.adcoff[i] = 100;
00920 h.adcadd[i] = 0;
00921 h.adcadd_A[i] = 0;
00922 h.adcadd_B[i] = 0;
00923 }
00924
00925 for ( i=0; i<MAX_IGNORE_ERR; i++ ) h.use_error[i] = 0;
00926
00927 strcpy( h.source, "" );
00928 strcpy( h.filter, "" );
00929 return( h );
00930 }
00931
00932
00933
00934
00935 void
00936 PutConfig(CONFIG h)
00937 {
00938 int i,j;
00939 char num[10];
00940
00941 extern int verbose;
00942
00943 status_interval = 0;
00944
00945 for ( i=0; i<MAX_SCANMODE; i++ ) {
00946 if ( h.adcadd[i] != 0 )
00947 h.adcadd_A[i] = h.adcadd_B[i] = h.adcadd[i];
00948 }
00949
00950 for ( i=0; i<MAX_SCANMODE; i++ ) {
00951 sprintf( str, "scan345: MODE %d SCAN %1.1f ERAS %1.1f\n",h.size[i],h.scantime[i],h.erasetime[i]);
00952 if ( verbose > 2 ) fprintf( stdout, str );
00953 sprintf( str, "scan345: MODE %d ROFF %1.1f TOFF %1.1f ADC %d AADD %d BADD %d\n",h.size[i],h.roff[i],h.toff[i],h.adcoff[i],h.adcadd_A[i],h.adcadd_B[i]);
00954 if ( verbose > 2 ) fprintf( stdout, str );
00955 }
00956
00957 if ( h.use_phi ) {
00958 sprintf( str, "scan345: PHI SPEED %d STEPS %d\n",h.phi_speed,h.phi_steps);
00959 if ( verbose > 2 ) fprintf( stdout, str );
00960 }
00961 else {
00962 sprintf( str, "scan345: PHI DEFAULT %1.3f\n",h.phi_def);
00963 if ( verbose > 2 ) fprintf( stdout, str );
00964 }
00965
00966 if ( h.use_ome ) {
00967 sprintf( str, "scan345: OMEGA SPEED %d STEPS %d MIN %1.3f MAX %1.3f\n",h.ome_speed,h.ome_steps,h.ome_min,h.ome_max);
00968 if ( verbose > 2 ) fprintf( stdout, str );
00969 }
00970 else {
00971 sprintf( str, "scan345: OMEGA DEFAULT %1.3f\n",h.ome_def);
00972 if ( verbose > 2 ) fprintf( stdout, str );
00973 }
00974
00975
00976 if ( h.use_chi ) {
00977 sprintf( str, "scan345: CHI SPEED %d STEPS %d MIN %1.3f MAX %1.3f\n",h.chi_speed,h.chi_steps,h.chi_min,h.chi_max);
00978 if ( verbose > 2 ) fprintf( stdout, str );
00979
00980 }
00981 else {
00982 sprintf( str, "scan345: CHI DEFAULT %1.3f\n",h.chi_def);
00983 if ( verbose > 2 ) fprintf( stdout, str );
00984 }
00985
00986 if ( h.use_thet ) {
00987 sprintf( str, "scan345: THETA SPEED %d STEPS %d MIN %1.3f MAX %1.3f\n",h.thet_speed,h.thet_steps,h.thet_min,h.thet_max);
00988 if ( verbose > 2 ) fprintf( stdout, str );
00989 }
00990 else {
00991 sprintf( str, "scan345: THETA DEFAULT %1.3f\n",h.thet_def);
00992 if ( verbose > 2 ) fprintf( stdout, str );
00993 }
00994
00995 if ( h.use_dist ) {
00996 sprintf( str, "scan345: DISTANCE SPEED %d STEPS %d MIN %1.3f MAX %1.3f",h.dist_speed,h.dist_steps,h.dist_min,h.dist_max);
00997 if ( h.use_distmin ) strcat( str, " USEMIN " );
00998 if ( h.use_distmax ) strcat( str, " USEMAX " );
00999 strcat( str, "\n");
01000 if ( verbose > 2 ) fprintf( stdout, str );
01001 }
01002 else {
01003 sprintf( str, "scan345: DISTANCE DEFAULT %1.3f\n",h.dist_def);
01004 if ( verbose > 2 ) fprintf( stdout, str );
01005 }
01006
01007 sprintf( str, "scan345: UNITS TIME %d DOSE %d\n",h.units_time,h.units_dose);
01008 if ( verbose > 2 ) fprintf( stdout, str );
01009
01010 sprintf( str, "scan345: IGNORE ");
01011 if ( h.use_phi ==0 ) strcat(str, "PHI ");
01012 if ( h.use_ome ==0 ) strcat(str, "OMEGA ");
01013 if ( h.use_chi ==0 ) strcat(str, "CHI ");
01014 if ( h.use_thet ==0 ) strcat(str, "THETA ");
01015 if ( h.use_zaxis==0 ) strcat(str, "Z-AXIS ");
01016 if ( h.use_dist ==0 ) strcat(str, "DISTANCE");
01017 strcat( str, "\n");
01018 if ( strlen( str ) > 20 ) {
01019 if ( verbose > 2 ) fprintf( stdout, str );
01020 }
01021
01022 sprintf( str, "scan345: IGNORE ");
01023 if ( h.use_xray ==0 ) strcat(str, "XRAY ");
01024 if ( h.use_erase==0 ) strcat(str, "ERASE ");
01025 if ( h.use_adc ==0 ) strcat(str, "ADC ");
01026 if ( h.use_sound==0 ) strcat(str, "SOUND ");
01027 if ( h.use_shell==0 ) strcat(str, "SHELL ");
01028 strcat( str, "\n");
01029 if ( strlen( str ) > 20 ) {
01030 if ( verbose > 2 ) fprintf( stdout, str );
01031 }
01032
01033 sprintf( str, "scan345: IGNORE ");
01034 if ( h.use_msg ==0 ) strcat(str, "SPY ");
01035 if ( h.use_wave ==0 ) strcat(str, "WAVE ");
01036 if ( h.use_run ==0 ) strcat(str, "RUN ");
01037 if ( h.use_html ==0 ) strcat(str, "HTML ");
01038 if ( h.use_txt ==0 ) strcat(str, "SUMMARY ");
01039 strcat( str, "\n");
01040 if ( strlen( str ) > 20 ) {
01041 if ( verbose > 2 ) fprintf( stdout, str );
01042 }
01043
01044 if ( h.use_error[0] > 1 ) {
01045 sprintf( str, "scan345: IGNORE ERROR");
01046 for ( j=1; j<h.use_error[0]; j++ ) {
01047 sprintf( num, " %d", h.use_error[j] );
01048 strcat ( str, num );
01049 }
01050 strcat( str, "\n");
01051 if ( verbose > 2 ) fprintf( stdout, str );
01052 }
01053
01054 sprintf( str, "scan345: USE ");
01055 if ( h.use_phi ==1 ) strcat(str, "PHI ");
01056 if ( h.use_ome ==1 ) strcat(str, "OMEGA ");
01057 if ( h.use_chi ==1 ) strcat(str, "CHI ");
01058 if ( h.use_thet ==1 ) strcat(str, "THETA ");
01059 if ( h.use_zaxis==1 ) strcat(str, "Z-AXIS ");
01060 if ( h.use_dist ==1 ) strcat(str, "DISTANCE ");
01061 strcat( str, "\n");
01062 if ( strlen( str ) > 20 ) {
01063 if ( verbose > 2 ) fprintf( stdout, str );
01064 }
01065
01066 sprintf( str, "scan345: USE ");
01067 if ( h.use_xray ==1 ) strcat(str, "XRAY ");
01068 if ( h.use_erase==1 ) strcat(str, "ERASE ");
01069 if ( h.use_sound==1 ) strcat(str, "SOUND ");
01070 if ( h.use_shell==1 ) strcat(str, "SHELL ");
01071 if ( h.use_adc ==1 ) strcat(str, "ADC ");
01072 if ( status_interval) strcat(str, "STATUS ");
01073 strcat( str, "\n");
01074 if ( strlen( str ) > 20 ) {
01075 if ( verbose > 2 ) fprintf( stdout, str );
01076 }
01077
01078
01079 sprintf( str, "scan345: USE ");
01080 if ( h.use_wave ==1 ) strcat(str, "WAVE ");
01081 if ( h.use_msg ==1 ) strcat(str, "SPY ");
01082 if ( h.use_run ==1 ) strcat(str, "RUN ");
01083 if ( h.use_html ==1 ) strcat(str, "HTML ");
01084 if ( h.use_txt ==1 ) strcat(str, "SUMMARY ");
01085 if ( h.use_image==1 ) strcat(str, "IMAGE ");
01086 if ( h.use_image==2 ) strcat(str, "SPIRAL ");
01087 if ( h.use_image==3 ) strcat(str, "SPK ");
01088 strcat( str, "\n");
01089 if ( strlen( str ) > 20 ) {
01090 if ( verbose > 2 ) fprintf( stdout, str );
01091 }
01092
01093 if ( h.init_maxdist )
01094 sprintf( str, "scan345: INITIAL MAXDIST\n");
01095 else
01096 sprintf( str, "scan345: INITIAL MINDIST\n");
01097 if ( verbose > 2 ) fprintf( stdout, str );
01098
01099 sprintf( str, "scan345: NETWORK HOST %s PORT %d\n",h.host,h.port);
01100 if ( verbose > 2 ) fprintf( stdout, str );
01101
01102 sprintf( str, "scan345: SPIRAL SCALE %1.3f MAX %d\n",h.spiral_scale, h.spiral_max);
01103 if ( verbose > 2 ) fprintf( stdout, str );
01104
01105 sprintf( str, "scan345: FLAGS %d\n",h.flags);
01106 if ( verbose > 2 ) fprintf( stdout, str );
01107
01108 sprintf( str, "scan345: COLORS %d\n",h.colors);
01109 if ( verbose > 2 ) fprintf( stdout, str );
01110
01111 if ( h.sets < 4 ) h.sets = 4;
01112 if ( h.sets > 4 ) h.sets = 8;
01113 sprintf( str, "scan345: SETS %d\n",h.sets);
01114 if ( verbose > 2 ) fprintf( stdout, str );
01115
01116 if ( h.memory )
01117 sprintf( str, "scan345: MEMORY LARGE\n");
01118 else
01119 sprintf( str, "scan345: MEMORY SMALL\n");
01120 if ( verbose > 2 ) fprintf( stdout, str );
01121
01122 if ( h.gain != 1.0 ) {
01123 sprintf( str, "scan345: GAIN %1.0f\n",h.gain);
01124 if ( verbose > 2 ) fprintf( stdout, str );
01125 }
01126
01127 sprintf( str, "scan345: INTENSITY MIN %1.3f WARNING %1.1f DOSE %1.3f\n",h.intensmin,h.intenswarn,h.dosemin);
01128 if ( verbose > 2 ) fprintf( stdout, str );
01129
01130 sprintf( str, "scan345: WAVELENGTH %1.5f\n",h.wavelength);
01131 if ( verbose > 2 ) fprintf( stdout, str );
01132
01133 sprintf( str, "scan345: MONOCHROM %s POLAR %1.3f\n",h.filter, h.polar);
01134 if ( verbose > 2 ) fprintf( stdout, str );
01135
01136 sprintf( str, "scan345: COLLIMATOR WIDTH %1.3f HEIGHT %1.3f\n",h.slitx,h.slity);
01137 if ( verbose > 2 ) fprintf( stdout, str );
01138
01139 sprintf( str, "scan345: GENERATOR %s mA %1.1f kV %1.1f\n",h.source, h.mA,h.kV);
01140 if ( verbose > 2 ) fprintf( stdout, str );
01141
01142 if ( status_interval ) {
01143 sprintf( str, "scan345: STATUS %d\n",status_interval);
01144 if ( verbose > 2 ) fprintf( stdout, str );
01145 }
01146
01147 if ( h.use_zaxis ) h.use_ome=1;
01148
01149 }