Changeset 58
- Timestamp:
- 10/30/2008 11:04:47 PM (14 years ago)
- Location:
- SH_SHM/trunk/source/motif
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
SH_SHM/trunk/source/motif/mfexec.c
r57 r58 111 111 static void mxh_read_location_from_evt( char autoevt[], float *lat, float *lon, 112 112 TSyBoolean *found ); 113 static void mxh_translate_button_name( char code[], char autoevt[], 114 char addlist[], TSyStatus *status ); 113 115 114 116 … … 137 139 char line[cBcVeryLongStrLth+1]; /* command line */ 138 140 char statlist[cBcVeryLongStrLth+1]; /* station list */ 139 char varname[MXC_STATSTR_LTH+2]; /* variable name */140 141 char addlist[cBcLongStrLth+1]; /* parsed station string */ 141 142 int i; /* bit count */ 142 143 char *eptr; /* pointer to char for getenv */ 143 144 TSyBoolean redraw; /* dummy */ 144 TSyBoolean ok; /* return code */145 145 TSyStatus locstat; /* local status */ 146 146 char gsename[cBcFileLth+1]; /* name of GSE file */ 147 float epilat, epilon; /* epicentre location rea from evt */148 float vlat1, vlat2, vlon1, vlon2;/* lat and lon area */149 TSyBoolean epifound; /* epicentre found in evt */150 int locvarcnt; /* location variable counter */151 147 152 148 /* executable code */ … … 196 192 if ((1<<i) & par->stations) { 197 193 if (*statlist != '\0') strcat( statlist, "," ); 198 if (par->sl.code[i][0] == '$') { 199 varname[0] = 'v'; 200 strcpy( varname+1, par->sl.code[i] ); 201 GpReadParameter( varname, cBcLongStrLth, addlist, &ok ); 202 if (!ok) { 203 *status = MXE_ILL_SUBSET; 204 err_setcontext( " ## variable: " ); 205 err_setcontext( varname ); 206 return; 207 } /*endif*/ 208 if (strlen(statlist)+strlen(addlist) < cBcVeryLongStrLth) { 209 strcat( statlist, addlist ); 210 } else { 211 *status = MXE_STROVFL; 212 return; 213 } /*endif*/ 214 } else if (strcmp(par->sl.code[i],":AE") == 0) { 215 if (autoevt == NULL) { 216 printf( "*SHM: cannot translate :AE, autoevt is NULL\n" ); 217 } else if (*autoevt == '\0') { 218 printf( "*SHM: cannot translate :AE, autoevt is empty\n" ); 219 } else { 220 printf( "get statlist\n" ); 221 mxh_read_stations_from_evt( autoevt, addlist ); 222 if (strlen(statlist)+strlen(addlist) < cBcVeryLongStrLth) { 223 strcat( statlist, addlist ); 224 } else { 225 *status = MXE_STROVFL; 226 return; 227 } /*endif*/ 228 printf( "statlist: %s\n", statlist ); 229 } /*endif*/ 230 } else if (strcmp(par->sl.code[i],":LOC") == 0) { 231 if (autoevt == NULL) { 232 printf( "*SHM: cannot translate :LOC, autoevt is NULL\n" ); 233 } else if (*autoevt == '\0') { 234 printf( "*SHM: cannot translate :LOC, autoevt is empty\n" ); 235 } else { 236 mxh_read_location_from_evt( autoevt, &epilat, &epilon, 237 &epifound ); 238 if (!epifound) { 239 printf( "*SHM: cannot translate :LOC, no epicentre found\n" ); 240 return; 241 } /*endif*/ 242 if (GpGetInt(cGpI_debug_level) > 2) 243 printf( "SHM-dbg3: :LOC found epi %f,%f\n", epilat, epilon ); 244 } /*endif*/ 245 epifound = FALSE; 246 locvarcnt = 1; 247 FOREVER { 248 /* read through all v$loc* variables */ 249 sprintf( varname, "v$loc%d", locvarcnt ); 250 GpReadParameter( varname, cBcLongStrLth, addlist, &ok ); 251 if (!ok) break; 252 if (GpGetInt(cGpI_debug_level) > 4) 253 printf( "SHM-dbg4: %s translated to %s\n", varname, addlist ); 254 if (sscanf(addlist,"%f,%f,%f,%f %s", 255 &vlat1,&vlon1,&vlat2,&vlon2,statlist) != 5) 256 continue; 257 if (vlat1 <= epilat && epilat <= vlat2 && vlon1 <= epilon 258 && epilon <= vlon2) { 259 epifound = TRUE; 260 break; 261 } /*endif*/ 262 locvarcnt++; 263 } /*endfor*/ 264 if (!epifound) { 265 GpReadParameter("v$loc", cBcLongStrLth, statlist, &ok ); 266 if (!ok) { 267 printf( "*SHM: no v$loc definition\n" ); 268 return; 269 } /*endif*/ 270 } /*endif*/ 194 mxh_translate_button_name( par->sl.code[i], autoevt, addlist, status ); 195 if (strlen(statlist)+strlen(addlist) < cBcVeryLongStrLth) { 196 strcat( statlist, addlist ); 271 197 } else { 272 if (strlen(statlist)+strlen(par->sl.code[i]) < cBcVeryLongStrLth) { 273 strcat( statlist, par->sl.code[i] ); 274 } else { 275 *status = MXE_STROVFL; 276 return; 277 } /*endif*/ 198 *status = MXE_STROVFL; 199 return; 278 200 } /*endif*/ 279 201 } /*endif*/ … … 386 308 387 309 } /* end of mx_readg */ 310 311 312 313 /*--------------------------------------------------------------------------*/ 314 315 316 static void mxh_translate_button_name( char code[], char autoevt[], 317 char addlist[], TSyStatus *status ) 318 319 /* Translates button name into a list of stations, returned by addlist 320 * 321 * parameters of routine 322 * char code[]; input; button name (station code or list abbrev) 323 * char autoevt[]; input; name of evt file with automatic picks and loc 324 * char addlist[]; output; resulting station list; max lth cBcLongStrLth 325 * TSyStatus *status; output; return status 326 */ 327 { 328 /* local variables */ 329 char varname[MXC_STATSTR_LTH+2]; /* variable name */ 330 TSyBoolean ok; /* worked ok? */ 331 float epilat, epilon; /* epicentre location rea from evt */ 332 float vlat1, vlat2, vlon1, vlon2;/* lat and lon area */ 333 TSyBoolean epifound; /* epicentre found in evt */ 334 int locvarcnt; /* location variable counter */ 335 char vstr[cBcLongStrLth+1]; /* scratch for variable evaluation */ 336 337 /* executable code */ 338 339 *addlist = '\0'; 340 if (code[0] == '$') { 341 /* find list of stations in config file */ 342 varname[0] = 'v'; 343 strcpy( varname+1, code ); 344 GpReadParameter( varname, cBcLongStrLth, addlist, &ok ); 345 if (!ok) { 346 *status = MXE_ILL_SUBSET; 347 err_setcontext( " ## variable: " ); 348 err_setcontext( varname ); 349 *addlist = '\0'; 350 return; 351 } /*endif*/ 352 } else if (strcmp(code,":AE") == 0) { 353 if (autoevt == NULL) { 354 printf( "*SHM: cannot translate :AE, autoevt is NULL\n" ); 355 } else if (*autoevt == '\0') { 356 printf( "*SHM: cannot translate :AE, autoevt is empty\n" ); 357 } else { 358 mxh_read_stations_from_evt( autoevt, addlist ); 359 } /*endif*/ 360 } else if (strcmp(code,":LOC") == 0) { 361 if (autoevt == NULL) { 362 /* if no autoevt file there, then use v$loc setting */ 363 GpReadParameter( "v$loc", cBcLongStrLth, addlist, &ok ); 364 if (!ok) { 365 printf( "*SHM: cannot translate :LOC, autoevt is NULL and no v$loc found\n" ); 366 *status = MXE_CONFIG_SETUP; 367 err_setcontext( " ## variable: V$LOC not found" ); 368 return; 369 } /*endif*/ 370 } else if (*autoevt == '\0') { 371 /* same as above */ 372 GpReadParameter( "v$loc", cBcLongStrLth, addlist, &ok ); 373 if (!ok) { 374 printf( "*SHM: cannot translate :LOC, autoevt is NULL and no v$loc found\n" ); 375 *status = MXE_CONFIG_SETUP; 376 err_setcontext( " ## variable: V$LOC not found" ); 377 return; 378 } /*endif*/ 379 } /*endif*/ 380 /* get location from evt file */ 381 mxh_read_location_from_evt( autoevt, &epilat, &epilon, &epifound ); 382 if (!epifound) { 383 /* no epicentre in evt file, behave like :AE */ 384 printf( "*SHM: cannot translate :LOC, no epicentre found -> :AE\n" ); 385 mxh_translate_button_name( ":AE", autoevt, addlist, status ); 386 return; 387 } /*endif*/ 388 if (GpGetInt(cGpI_debug_level) > 2) 389 printf( "SHM-dbg3: :LOC found epi %f,%f\n", epilat, epilon ); 390 epifound = FALSE; 391 locvarcnt = 1; 392 FOREVER { 393 /* read through all v$loc* variables and compare with curr. location */ 394 sprintf( varname, "v$loc%d", locvarcnt ); 395 GpReadParameter( varname, cBcLongStrLth, vstr, &ok ); 396 if (!ok) break; 397 if (GpGetInt(cGpI_debug_level) > 3) 398 printf( "SHM-dbg4: %s translated to %s\n", varname, vstr ); 399 if (sscanf(vstr,"%f,%f,%f,%f %s", 400 &vlat1,&vlon1,&vlat2,&vlon2,addlist) != 5) 401 continue; 402 if (vlat1 <= epilat && epilat <= vlat2 && vlon1 <= epilon 403 && epilon <= vlon2) { 404 epifound = TRUE; 405 break; 406 } /*endif*/ 407 locvarcnt++; 408 } /*endfor*/ 409 if (!epifound) { 410 GpReadParameter("v$loc", cBcLongStrLth, addlist, &ok ); 411 if (!ok) { 412 printf( "*SHM: no v$loc definition\n" ); 413 *status = MXE_CONFIG_SETUP; 414 err_setcontext( " ## variable: V$LOC not found" ); 415 return; 416 } /*endif*/ 417 } /*endif*/ 418 /* if addlist is a variable, translate it */ 419 if (addlist[0] == '$') { 420 strcpy( vstr, addlist ); 421 GpReadParameter( vstr, cBcLongStrLth, addlist, &ok ); 422 if (!ok) { 423 printf( "*SHM: no %s definition\n", vstr ); 424 *status = MXE_CONFIG_SETUP; 425 err_setcontext( " ## variable: not found: " ); 426 err_setcontext( vstr ); 427 return; 428 } /*endif*/ 429 } /*endif*/ 430 if (GpGetInt(cGpI_debug_level) > 3) 431 printf( "SHM-dbg4: :LOC addlist: %s\n", addlist ); 432 } else { 433 strcpy( addlist, code ); 434 } /*endif*/ 435 436 } /* end of mxh_translate_button_name */ 388 437 389 438 -
SH_SHM/trunk/source/motif/mfexec.h
r16 r58 50 50 #define MXE_NOT_FOUND (MXE_OFFSET+15) /* not found */ 51 51 #define MXE_ILL_SUBSET (MXE_OFFSET+16) /* undefined station subset */ 52 #define MXE_CONFIG_SETUP (MXE_OFFSET+17) /* conig file setup error */ 52 53 53 54
Note: See TracChangeset
for help on using the changeset viewer.