1 | |
---|
2 | /* file mfexec.c |
---|
3 | * ======== |
---|
4 | * |
---|
5 | * version 63, 21-Nov-2007 |
---|
6 | * |
---|
7 | * execution of SH commands |
---|
8 | * K. Stammler, 25-Feb-93 |
---|
9 | */ |
---|
10 | |
---|
11 | |
---|
12 | /* |
---|
13 | * |
---|
14 | * SeismicHandler, seismic analysis software |
---|
15 | * Copyright (C) 1996, Klaus Stammler, Federal Institute for Geosciences |
---|
16 | * and Natural Resources (BGR), Germany |
---|
17 | * |
---|
18 | * This program is free software; you can redistribute it and/or modify |
---|
19 | * it under the terms of the GNU General Public License as published by |
---|
20 | * the Free Software Foundation; either version 2 of the License, or |
---|
21 | * (at your option) any later version. |
---|
22 | * |
---|
23 | * This program is distributed in the hope that it will be useful, |
---|
24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
26 | * GNU General Public License for more details. |
---|
27 | * |
---|
28 | * You should have received a copy of the GNU General Public License |
---|
29 | * along with this program; if not, write to the Free Software |
---|
30 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
---|
31 | * |
---|
32 | */ |
---|
33 | |
---|
34 | |
---|
35 | |
---|
36 | #include <stdio.h> |
---|
37 | #include <string.h> |
---|
38 | #include "basecnst.h" |
---|
39 | #undef BC_DEFINE_TRUE_FALSE |
---|
40 | #ifdef BC_INC_STDLIB |
---|
41 | #include BC_INC_STDLIB |
---|
42 | #endif |
---|
43 | #include <Xm/Xm.h> |
---|
44 | #include <Xm/ToggleB.h> |
---|
45 | #include <Xm/Text.h> |
---|
46 | #include BC_SYSBASE |
---|
47 | #include "erusrdef.h" |
---|
48 | #include "motifgraph.h" |
---|
49 | #include "station_no.h" |
---|
50 | #include "cbutil.h" |
---|
51 | #include "mfexec.h" |
---|
52 | #include "cblib.h" |
---|
53 | #include "cblib3.h" |
---|
54 | #include "callsh.h" |
---|
55 | #include "infoidx.h" |
---|
56 | #include "utusrdef.h" |
---|
57 | #include "shvars.h" |
---|
58 | #include "glusrdef.h" |
---|
59 | #include "phaseinf.h" |
---|
60 | #include "phasemgr.h" |
---|
61 | #include "trcselect.h" |
---|
62 | #include "shm_widgets.h" |
---|
63 | #include "sysext.h" |
---|
64 | #include "seismics.h" |
---|
65 | #include "globalparams.h" |
---|
66 | |
---|
67 | |
---|
68 | /* |
---|
69 | * the following definitions must match the 'entry define shm_...' commands |
---|
70 | * in SHM_CMD_STARTUP.SHC |
---|
71 | */ |
---|
72 | #define MXC_NUM_VIEW 0 |
---|
73 | #define MXC_NUM_HIDE 1 |
---|
74 | #define MXC_NUM_FILTER 2 |
---|
75 | #define MXC_NUM_ROT 3 |
---|
76 | #define MXC_EF_VIEW (MXC_NUM_VIEW|EF_TYPE) |
---|
77 | #define MXC_EF_HIDE (MXC_NUM_HIDE|EF_TYPE) |
---|
78 | #define MXC_EF_FILTER (MXC_NUM_FILTER|EF_TYPE) |
---|
79 | #define MXC_EF_ROT (MXC_NUM_ROT|EF_TYPE) |
---|
80 | #define MXC_FLAG_VIEW (1<<MXC_NUM_VIEW) |
---|
81 | #define MXC_FLAG_HIDE (1<<MXC_NUM_HIDE) |
---|
82 | #define MXC_FLAG_FILTER (1<<MXC_NUM_FILTER) |
---|
83 | #define MXC_FLAG_ROT (1<<MXC_NUM_ROT) |
---|
84 | |
---|
85 | |
---|
86 | /* imported variables */ |
---|
87 | extern Widget xmv_w[]; /* widget array */ |
---|
88 | extern MX_CMD_READG xmv_cmd_readg; /* to write on it in external_routine */ |
---|
89 | |
---|
90 | |
---|
91 | static int mxv_display_state=0; /* display status */ |
---|
92 | |
---|
93 | |
---|
94 | |
---|
95 | /* prototypes of local routines */ |
---|
96 | static void mxh_read_file_list( Widget w, MGT_DSPCTRL *ctrl, char filenames[], |
---|
97 | int format, STATUS *status ); |
---|
98 | static void mx_prepare_display( void ); |
---|
99 | static void mxh_filter_separately( Widget w, MGT_DSPCTRL *ctrl, char filter[], |
---|
100 | float autocut, STATUS *status ); |
---|
101 | static BOOLEAN mxh_rotation_is_possible( void ); |
---|
102 | static void mxh_get_vax_grflist( MX_CMD_READG *rg, char liststr[] ); |
---|
103 | static void mxh_read_statlist( char fname[], Widget w[], MX_STATLIST *sl, |
---|
104 | STATUS *status ); |
---|
105 | static void mxh_mount_cdrom( MX_CMD_READG *par, STATUS *status ); |
---|
106 | static void mxh_set_entry_name( Widget ew, char text[] ); |
---|
107 | void mx_remove_double_elements( char *str ); |
---|
108 | void mxh_compute_azimuth( char cstation[], float lat, float lon, |
---|
109 | float *azim, TSyStatus *status ); |
---|
110 | static void mxh_read_stations_from_evt( char autoevt[], char addlist[] ); |
---|
111 | static void mxh_read_location_from_evt( char autoevt[], float *lat, float *lon, |
---|
112 | TSyBoolean *found ); |
---|
113 | static void mxh_translate_button_name( char code[], char autoevt[], |
---|
114 | char addlist[], TSyStatus *status ); |
---|
115 | |
---|
116 | |
---|
117 | |
---|
118 | /*--------------------------------------------------------------------------*/ |
---|
119 | |
---|
120 | |
---|
121 | |
---|
122 | void mx_readg( MX_CMD_READG *par, Widget wm, Widget ws, MGT_DSPCTRL *ctrl, |
---|
123 | BOOLEAN keep_phases, char autoevt[], STATUS *status ) |
---|
124 | |
---|
125 | /* executes readg command |
---|
126 | * |
---|
127 | * parameters of routine |
---|
128 | * XM_CMD_READG *par; input; command parameters |
---|
129 | * Widget wm; input; main DrawingArea Widget |
---|
130 | * Widget ws; input; single trace window |
---|
131 | * MGT_DSPCTRL *ctrl; input; display control parameters |
---|
132 | * TSyBoolean keep_phases; input; keep phases in memory |
---|
133 | * char *autoevt input; name of evt file for retrieving stat. names |
---|
134 | * TSyStatus *status; output; return status |
---|
135 | */ |
---|
136 | { |
---|
137 | /* local variables */ |
---|
138 | static int gse_cnt=0; /* GSE counter */ |
---|
139 | char line[cBcVeryLongStrLth+1]; /* command line */ |
---|
140 | char statlist[cBcVeryLongStrLth+1]; /* station list */ |
---|
141 | char addlist[cBcLongStrLth+1]; /* parsed station string */ |
---|
142 | int i; /* bit count */ |
---|
143 | char *eptr; /* pointer to char for getenv */ |
---|
144 | TSyBoolean redraw; /* dummy */ |
---|
145 | TSyStatus locstat; /* local status */ |
---|
146 | char gsename[cBcFileLth+1]; /* name of GSE file */ |
---|
147 | |
---|
148 | /* executable code */ |
---|
149 | |
---|
150 | if (par->channum == 0 && par->format == MXC_FORMAT_SEED) { |
---|
151 | *status = MXE_NOCHANNELS; |
---|
152 | return; |
---|
153 | } /*endif*/ |
---|
154 | |
---|
155 | mg_do_drag( wm, MGC_DRAG_CLEAR, 0, 0 ); |
---|
156 | mg_plot_drag_window( ws, ctrl->show_phase_acc, status ); |
---|
157 | if (Severe(status)) return; |
---|
158 | |
---|
159 | /* translate device name if possible */ |
---|
160 | if (strcmp(par->device,"CD") == 0) { |
---|
161 | mxh_mount_cdrom( par, status ); |
---|
162 | if (Severe(status)) return; |
---|
163 | } else { |
---|
164 | eptr = getenv( par->device ); |
---|
165 | if (eptr != NULL) { |
---|
166 | if (strlen(eptr) >= BC_FILELTH) { |
---|
167 | *status = MXE_STROVFL; |
---|
168 | return; |
---|
169 | } /*endif*/ |
---|
170 | strcpy( par->device, eptr ); |
---|
171 | strcat( par->device, "/" ); |
---|
172 | } /*endif*/ |
---|
173 | } /*endif*/ |
---|
174 | |
---|
175 | if (par->keep) { |
---|
176 | mx_exec_sh( wm, ctrl, "nr" ); |
---|
177 | mx_exec_sh( wm, ctrl, "display all_dh" ); |
---|
178 | mx_exec_sh( wm, ctrl, "del _shm_filter(y)" ); |
---|
179 | mx_exec_sh( wm, ctrl, "del _shm_rot(y)" ); |
---|
180 | mx_exec_sh( wm, ctrl, "rd" ); |
---|
181 | } else { |
---|
182 | mx_exec_sh( wm, ctrl, "del all_dh" ); |
---|
183 | } /*endif*/ |
---|
184 | if (Severe(status)) return; |
---|
185 | mx_exec_sh( wm, ctrl, "dtw" ); |
---|
186 | /* mx_exec_sh( wm, ctrl, "rd" ); */ |
---|
187 | /* mx_exec_sh( wm, ctrl, "nr" ); */ |
---|
188 | |
---|
189 | /* create station list and component list */ |
---|
190 | *statlist = '\0'; |
---|
191 | for (i=0; i<MXC_STATLIST_LTH; i++) { |
---|
192 | if ((1<<i) & par->stations) { |
---|
193 | if (*statlist != '\0') strcat( statlist, "," ); |
---|
194 | mxh_translate_button_name( par->sl.code[i], autoevt, addlist, status ); |
---|
195 | if (strlen(statlist)+strlen(addlist) < cBcVeryLongStrLth) { |
---|
196 | strcat( statlist, addlist ); |
---|
197 | } else { |
---|
198 | *status = MXE_STROVFL; |
---|
199 | return; |
---|
200 | } /*endif*/ |
---|
201 | } /*endif*/ |
---|
202 | } /*endfor*/ |
---|
203 | if (strlen(statlist) > cBcVeryLongStrLth-55) { |
---|
204 | printf( "*SHM: mx_readg: station list too long\n" ); |
---|
205 | printf( " field length exceeded, abort program\n" ); |
---|
206 | exit( 1 ); |
---|
207 | } /*endif*/ |
---|
208 | if (*statlist != '\0') |
---|
209 | mx_remove_double_elements( statlist ); |
---|
210 | |
---|
211 | switch (par->format) { |
---|
212 | case MXC_FORMAT_SEED: |
---|
213 | if (par->use_readk) { |
---|
214 | |
---|
215 | /* read from VAX WORMS: (completely outdated code, no more k-files) */ |
---|
216 | /* check whether GRF or GRSN data are requested */ |
---|
217 | if (strncmp(statlist,"GRA",3) == 0 |
---|
218 | || strncmp(statlist,"GRB",3) == 0 |
---|
219 | || strncmp(statlist,"GRC",3) == 0) { |
---|
220 | /* these are GRF data ... */ |
---|
221 | ; |
---|
222 | } else { |
---|
223 | /* these are GRSN data ... */ |
---|
224 | if (par->channum > 1) |
---|
225 | printf( "*SHM: take only first channel selected\n" ); |
---|
226 | /* generate filename */ |
---|
227 | sprintf( gsename, "grn2gse_%02d.gse", ++gse_cnt ); |
---|
228 | strcpy( line, GpGetString(cGpS_defpath_extprog) ); |
---|
229 | sprintf( line+strlen(line), |
---|
230 | "grn2gse %s %s %f %s %s %s %s", |
---|
231 | par->device, par->start, par->seclth, statlist, |
---|
232 | par->comp, par->chanstr[0], gsename ); |
---|
233 | } /*endif*/ |
---|
234 | if (GpGetInt(cGpI_debug_level) > 1) |
---|
235 | printf( "SHM-dbg2: exec: %s\n", line ); |
---|
236 | system( line ); |
---|
237 | sprintf( line, "@READGSE %s ALL", gsename ); |
---|
238 | if (GpGetInt(cGpI_debug_level) > 1) |
---|
239 | printf( "SHM-dbg2: sh exec: %s\n", line ); |
---|
240 | mx_exec_sh( wm, ctrl, line ); |
---|
241 | /* now delete input GSE file */ |
---|
242 | /* sy_fdelete( gsename ); */ |
---|
243 | |
---|
244 | } else { |
---|
245 | |
---|
246 | /* read from Mini-SEED files */ |
---|
247 | /* to be added: check length of line */ |
---|
248 | |
---|
249 | /* make backslashes out of slashes */ |
---|
250 | eptr = par->device - 1; |
---|
251 | while (*(++eptr) != '\0') |
---|
252 | if (*eptr == '/') *eptr = '\\'; |
---|
253 | /* loop all channels */ |
---|
254 | for (i=0; i<(par->channum); i++) { |
---|
255 | #ifdef SH_SETUP_LINUX |
---|
256 | if (par->reads_invhdr) { |
---|
257 | sprintf( line, "@READS/NOSWAP/INVHDR/SFD=%s %s %s %f %s %s %s", |
---|
258 | par->sfdfile, par->device, par->start, par->seclth, |
---|
259 | statlist, par->comp, par->chanstr[i] ); |
---|
260 | } else { |
---|
261 | sprintf( line, "@READS/NOSWAP/SFD=%s %s %s %f %s %s %s", |
---|
262 | par->sfdfile, par->device, par->start, par->seclth, |
---|
263 | statlist, par->comp, par->chanstr[i] ); |
---|
264 | } /*endif*/ |
---|
265 | #else |
---|
266 | if (par->reads_invhdr) { |
---|
267 | sprintf( line, "@READS/INVHDR/SFD=%s %s %s %f %s %s %s", |
---|
268 | par->sfdfile, par->device, par->start, par->seclth, |
---|
269 | statlist, par->comp, par->chanstr[i] ); |
---|
270 | } else { |
---|
271 | sprintf( line, "@READS/SFD=%s %s %s %f %s %s %s", |
---|
272 | par->sfdfile, par->device, par->start, par->seclth, |
---|
273 | statlist, par->comp, par->chanstr[i] ); |
---|
274 | } /*endif*/ |
---|
275 | #endif |
---|
276 | if (GpGetInt(cGpI_debug_level) > 1) |
---|
277 | printf( "SHM-dbg2: execute: >%s< length %d\n", line, strlen(line) ); |
---|
278 | mx_exec_sh( wm, ctrl, line ); |
---|
279 | } /*endfor*/ |
---|
280 | |
---|
281 | } /*endif*/ |
---|
282 | break; |
---|
283 | |
---|
284 | case MXC_FORMAT_GSE: |
---|
285 | case MXC_FORMAT_GSE2: |
---|
286 | case MXC_FORMAT_AH: |
---|
287 | case MXC_FORMAT_Q: |
---|
288 | mxh_read_file_list( wm, ctrl, par->filename, par->format, status ); |
---|
289 | if (Severe(status)) return; |
---|
290 | break; |
---|
291 | |
---|
292 | default: |
---|
293 | |
---|
294 | printf( "*SHM: mx_readg: program error\n" ); |
---|
295 | *status = MXE_PROG_BUG; |
---|
296 | return; |
---|
297 | |
---|
298 | } /*endswitch*/ |
---|
299 | |
---|
300 | cl_set_autofilters(); |
---|
301 | |
---|
302 | mx_exec_sh( wm, ctrl, "SHM_CMD_TIMEAL" ); |
---|
303 | |
---|
304 | if (keep_phases) { |
---|
305 | mg_plot_phases( wm, ctrl->show_phase_acc, status ); |
---|
306 | } /*endif*/ |
---|
307 | cl3_uppercase_names(); |
---|
308 | |
---|
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 | } /*endif*/ |
---|
369 | } else if (*autoevt == '\0' || strcmp(autoevt,"None") == 0) { |
---|
370 | /* same as above */ |
---|
371 | GpReadParameter( "v$loc", cBcLongStrLth, addlist, &ok ); |
---|
372 | if (!ok) { |
---|
373 | printf( "*SHM: cannot translate :LOC, autoevt is NULL and no v$loc found\n" ); |
---|
374 | *status = MXE_CONFIG_SETUP; |
---|
375 | err_setcontext( " ## variable: V$LOC not found" ); |
---|
376 | } /*endif*/ |
---|
377 | } else { |
---|
378 | /* get location from evt file */ |
---|
379 | mxh_read_location_from_evt( autoevt, &epilat, &epilon, &epifound ); |
---|
380 | if (!epifound) { |
---|
381 | /* no epicentre in evt file, behave like :AE */ |
---|
382 | printf( "*SHM: cannot translate :LOC, no epicentre found -> :AE\n" ); |
---|
383 | mxh_translate_button_name( ":AE", autoevt, addlist, status ); |
---|
384 | return; |
---|
385 | } /*endif*/ |
---|
386 | if (GpGetInt(cGpI_debug_level) > 2) |
---|
387 | printf( "SHM-dbg3: :LOC found epi %f,%f\n", epilat, epilon ); |
---|
388 | epifound = FALSE; |
---|
389 | locvarcnt = 1; |
---|
390 | FOREVER { |
---|
391 | /* read through all v$loc* variables and compare with curr. location */ |
---|
392 | sprintf( varname, "v$loc%d", locvarcnt ); |
---|
393 | GpReadParameter( varname, cBcLongStrLth, vstr, &ok ); |
---|
394 | if (!ok) break; |
---|
395 | if (GpGetInt(cGpI_debug_level) > 3) |
---|
396 | printf( "SHM-dbg4: %s translated to %s\n", varname, vstr ); |
---|
397 | if (sscanf(vstr,"%f,%f,%f,%f %s", |
---|
398 | &vlat1,&vlon1,&vlat2,&vlon2,addlist) != 5) |
---|
399 | continue; |
---|
400 | if (vlat1 <= epilat && epilat <= vlat2 && vlon1 <= epilon |
---|
401 | && epilon <= vlon2) { |
---|
402 | epifound = TRUE; |
---|
403 | break; |
---|
404 | } /*endif*/ |
---|
405 | locvarcnt++; |
---|
406 | } /*endfor*/ |
---|
407 | if (!epifound) { |
---|
408 | GpReadParameter("v$loc", cBcLongStrLth, addlist, &ok ); |
---|
409 | if (!ok) { |
---|
410 | printf( "*SHM: no v$loc definition\n" ); |
---|
411 | *status = MXE_CONFIG_SETUP; |
---|
412 | err_setcontext( " ## variable: V$LOC not found" ); |
---|
413 | return; |
---|
414 | } /*endif*/ |
---|
415 | } /*endif*/ |
---|
416 | } /*endif*/ |
---|
417 | } else { |
---|
418 | strcpy( addlist, code ); |
---|
419 | } /*endif*/ |
---|
420 | |
---|
421 | /* if addlist is a variable, translate it */ |
---|
422 | if (addlist[0] == '$') { |
---|
423 | vstr[0] = 'v'; |
---|
424 | strcpy( vstr+1, addlist ); |
---|
425 | GpReadParameter( vstr, cBcLongStrLth, addlist, &ok ); |
---|
426 | if (!ok) { |
---|
427 | printf( "*SHM: no %s definition\n", vstr ); |
---|
428 | *status = MXE_CONFIG_SETUP; |
---|
429 | err_setcontext( " ## variable: not found: " ); |
---|
430 | err_setcontext( vstr ); |
---|
431 | return; |
---|
432 | } /*endif*/ |
---|
433 | } /*endif*/ |
---|
434 | if (GpGetInt(cGpI_debug_level) > 3) |
---|
435 | printf( "SHM-dbg4: :LOC addlist: %s\n", addlist ); |
---|
436 | |
---|
437 | } /* end of mxh_translate_button_name */ |
---|
438 | |
---|
439 | |
---|
440 | |
---|
441 | /*--------------------------------------------------------------------------*/ |
---|
442 | |
---|
443 | |
---|
444 | |
---|
445 | void mx_filter( MX_CMD_FILTER *filter, Widget w, MGT_DSPCTRL *ctrl, |
---|
446 | STATUS *status ) |
---|
447 | |
---|
448 | /* performs filtering |
---|
449 | * |
---|
450 | * parameters of routine |
---|
451 | * MX_CMD_FILTER *filter; input; filter command parameters |
---|
452 | * Widget w; input; DrawingArea Widget |
---|
453 | * MGT_DSPCTRL *ctrl; input; display control parameters |
---|
454 | * TSyStatus *status; output; return status |
---|
455 | */ |
---|
456 | { |
---|
457 | /* local variables */ |
---|
458 | char str[BC_LINELTH+1]; /* scratch string */ |
---|
459 | char filprefix[BC_SHORTSTRLTH+1]; /* filter prefix */ |
---|
460 | char filter_typ; /* recursive or FFT, 'R' or 'F' */ |
---|
461 | TSyBoolean same_filter; /* same filter for all traces */ |
---|
462 | unsigned filent; /* filter info entry */ |
---|
463 | int trcnum; /* trace number */ |
---|
464 | void *trc; /* trace pointer */ |
---|
465 | |
---|
466 | /* executable code */ |
---|
467 | |
---|
468 | /* if no traces on display return error status */ |
---|
469 | if (mg_dsptrcs() == 0) { |
---|
470 | *status = MXE_NO_TRACES; |
---|
471 | return; |
---|
472 | } /*endif*/ |
---|
473 | |
---|
474 | /* get filter type */ |
---|
475 | #ifdef XXX |
---|
476 | filter_typ = (shv_global.use_rec_filters) ? 'R' : 'F'; |
---|
477 | if (shv_global.filter_type != ' ') filter_typ = shv_global.filter_type; |
---|
478 | #endif |
---|
479 | filter_typ = GpGetChar( cGpC_filter_type ); |
---|
480 | |
---|
481 | /* if filtering is switched off it's quick and easy */ |
---|
482 | if (filter->name[0] == '\0') { |
---|
483 | /* delete filter entry on selected traces */ |
---|
484 | if (ts_some_trace_selected()) { |
---|
485 | /* get index number of filter entry */ |
---|
486 | db_ident( "FILTER", &filent, status ); |
---|
487 | if (SySevere(status)) return; |
---|
488 | /* loop all traces and delete filter entry */ |
---|
489 | trc = NULL; |
---|
490 | trcnum = 0; |
---|
491 | FOREVER { |
---|
492 | trc = db_getp( trc, EP_NEXT, NULL ); |
---|
493 | if (trc == NULL) break; |
---|
494 | trcnum++; |
---|
495 | if (ts_is_selected(trcnum)) |
---|
496 | db_sets( trc, filent, "", status ); |
---|
497 | } /*endfor*/ |
---|
498 | ts_clear_selections(); |
---|
499 | } /*endif*/ |
---|
500 | /* remove the filter */ |
---|
501 | mxv_display_state &= ~MXC_FLAG_FILTER; |
---|
502 | sprintf( str, "shm_cmd_filter %c ;; NONE %f %d", |
---|
503 | filter_typ, filter->autocut, |
---|
504 | (GpGetInt(cGpI_trace_normalisation)==cGp_NORM_CONST) ); |
---|
505 | mx_exec_sh( w, ctrl, str ); |
---|
506 | return; |
---|
507 | } /*endif*/ |
---|
508 | |
---|
509 | /* filtering is switched on */ |
---|
510 | mxv_display_state |= MXC_FLAG_FILTER; |
---|
511 | |
---|
512 | /* now let's check which filter(s) must be used */ |
---|
513 | cl3_check_filter( filter->name, (filter_typ == 'R'), |
---|
514 | filprefix, &same_filter, status ); |
---|
515 | if (Severe(status)) return; |
---|
516 | |
---|
517 | /* if all traces need the same filter do it with the old SH-cp and quit */ |
---|
518 | if (same_filter && !ts_some_trace_selected()) { |
---|
519 | if (filter_typ == 'R') { |
---|
520 | sprintf( str, "shm_cmd_filter r;%s;%s %f %d", |
---|
521 | filprefix, filter->name, filter->autocut, |
---|
522 | (GpGetInt(cGpI_trace_normalisation)==cGp_NORM_CONST) ); |
---|
523 | } else { |
---|
524 | sprintf( str, "shm_cmd_filter %c;%s;%s %f %d", |
---|
525 | filter_typ, filprefix, filter->name, filter->autocut, |
---|
526 | (GpGetInt(cGpI_trace_normalisation)==cGp_NORM_CONST) ); |
---|
527 | } /*endif*/ |
---|
528 | if (GpGetInt(cGpI_debug_level) > 1) |
---|
529 | printf( "SHM-dbg2: execute >%s<\n", str ); |
---|
530 | mx_exec_sh( w, ctrl, str ); |
---|
531 | return; |
---|
532 | } /*endif*/ |
---|
533 | |
---|
534 | /* now this is the hard way */ |
---|
535 | mxh_filter_separately( w, ctrl, filter->name, filter->autocut, status ); |
---|
536 | |
---|
537 | } /* end of mx_filter */ |
---|
538 | |
---|
539 | |
---|
540 | |
---|
541 | /*--------------------------------------------------------------------------*/ |
---|
542 | |
---|
543 | |
---|
544 | |
---|
545 | void mx_exec_sh( Widget w, MGT_DSPCTRL *ctrl, char line[] ) |
---|
546 | |
---|
547 | /* executes command line |
---|
548 | * |
---|
549 | * parameters of routine |
---|
550 | * Widget w; input; widget of drawing area |
---|
551 | * MGT_DSPCTRL *ctrl; input; display control parameters |
---|
552 | * char line[]; input; command line |
---|
553 | */ |
---|
554 | { |
---|
555 | /* local variables */ |
---|
556 | TSyStatus status; /* return status */ |
---|
557 | TSyBoolean redraw; /* redraw flag */ |
---|
558 | |
---|
559 | /* executable code */ |
---|
560 | |
---|
561 | status = BC_NOERROR; |
---|
562 | callsh( line, &redraw, &status ); |
---|
563 | if (Severe(&status)) { |
---|
564 | cu_alert( status ); |
---|
565 | } else { |
---|
566 | if (redraw) |
---|
567 | mg_tracedisplay( w, ctrl, &status ); |
---|
568 | if (Severe(&status)) { |
---|
569 | cu_alert( status ); |
---|
570 | } /*endif*/ |
---|
571 | } /*endif*/ |
---|
572 | |
---|
573 | } /* end of mx_exec_sh */ |
---|
574 | |
---|
575 | |
---|
576 | |
---|
577 | /*--------------------------------------------------------------------------*/ |
---|
578 | |
---|
579 | |
---|
580 | |
---|
581 | void mx_stw( Widget wm, Widget ws, MGT_DSPCTRL *ctrl ) |
---|
582 | |
---|
583 | /* executes stw command |
---|
584 | * |
---|
585 | * parameters of routine |
---|
586 | * Widget wm; input; widget ID of main DrawingArea |
---|
587 | * Widget ws; input; widget ID of single trace DrawingArea |
---|
588 | * MGT_DSPCTRL *ctrl; input; display control parameters |
---|
589 | */ |
---|
590 | { |
---|
591 | /* local variables */ |
---|
592 | char cmd[BC_LINELTH+1]; /* command line */ |
---|
593 | float start, end; /* time window */ |
---|
594 | TSyBoolean set; /* time window set */ |
---|
595 | TSyStatus locstat=BC_NOERROR; /* local status */ |
---|
596 | |
---|
597 | /* executable code */ |
---|
598 | |
---|
599 | mg_get_drag_window( &start, &end, &set ); |
---|
600 | if (!set) return; |
---|
601 | sprintf( cmd, "stw %e %e", start, end ); |
---|
602 | mx_exec_sh( wm, ctrl, cmd ); |
---|
603 | mg_do_drag( wm, MGC_DRAG_CLEAR, 0, 0 ); |
---|
604 | mg_plot_drag_window( ws, ctrl->show_phase_acc, &locstat ); |
---|
605 | |
---|
606 | } /* end of mx_stw */ |
---|
607 | |
---|
608 | |
---|
609 | |
---|
610 | /*---------------------------------------------------------------------------*/ |
---|
611 | |
---|
612 | |
---|
613 | |
---|
614 | void mx_handle_beam( Widget wm, Widget ws, BOOLEAN do_beam, MGT_DSPCTRL *ctrl, |
---|
615 | CUT_PARAMS *par, char alignphase[], STATUS *status ) |
---|
616 | |
---|
617 | /* creates or deletes beam trace (toggle routine) |
---|
618 | * |
---|
619 | * parameters of routine |
---|
620 | * Widget wm; input; Widget ID of main window |
---|
621 | * Widget ws; input; Widget ID of single trace window |
---|
622 | * TSyBoolean do_beam; input; do beam (not align) |
---|
623 | * MGT_DSPCTRL *ctrl; input; display control |
---|
624 | * CUT_PARAMS *par; input; analysis parameters |
---|
625 | * char alignphase[]; input; name of phase to be aligned |
---|
626 | * TSyStatus *status; output; return status |
---|
627 | */ |
---|
628 | { |
---|
629 | /* local variables */ |
---|
630 | int t; /* trace counter */ |
---|
631 | TSyStatus locstat; /* local status */ |
---|
632 | char str[BC_LINELTH+1]; /* scratch */ |
---|
633 | char trcstr[BC_LINELTH+1]; /* trace list string */ |
---|
634 | TSyBoolean create_beam; /* create or delete beam */ |
---|
635 | |
---|
636 | /* executable code */ |
---|
637 | |
---|
638 | /* look for BEAM trace */ |
---|
639 | create_beam = TRUE; |
---|
640 | for (t=1; t<=mg_dsptrcs(); t++) { |
---|
641 | locstat = BC_NOERROR; |
---|
642 | db_gets( mg_trcptr(t), ES_STATION, BC_LINELTH, str, &locstat ); |
---|
643 | if (locstat == BC_NOERROR && strcmp(str,"BEAM") == 0) { |
---|
644 | create_beam = FALSE; |
---|
645 | break; |
---|
646 | } else if (locstat == BC_NOERROR && strcmp(str,"ALIGN") == 0) { |
---|
647 | create_beam = FALSE; |
---|
648 | break; |
---|
649 | } /*endif*/ |
---|
650 | } /*endfor*/ |
---|
651 | |
---|
652 | mg_do_drag( wm, MGC_DRAG_CLEAR, 0, 0 ); |
---|
653 | locstat = BC_NOERROR; |
---|
654 | mg_plot_drag_window( ws, ctrl->show_phase_acc, &locstat ); |
---|
655 | if (create_beam) { |
---|
656 | if (do_beam) { |
---|
657 | sprintf( str, "shm_cmd_make_beam %e %e %s", |
---|
658 | par->b_azimuth, par->b_slowness, GpGetString(cGpS_refstation) ); |
---|
659 | if (cu_get_exec_flag(CUC_F_EXEC_RESIDCORR)) strcat( str, " P" ); |
---|
660 | mx_exec_sh( wm, ctrl, str ); |
---|
661 | } else { |
---|
662 | cl_calc_align_times( alignphase, BC_LINELTH-19, trcstr, status ); |
---|
663 | /* this is the textlength in the sprintf cmd ^ */ |
---|
664 | if (Severe(status)) return; |
---|
665 | if (*trcstr == '\0') { |
---|
666 | *status = MXE_NO_TRACES; |
---|
667 | return; |
---|
668 | } /*endif*/ |
---|
669 | sprintf( str, "shm_cmd_make_align %s", trcstr ); |
---|
670 | mx_exec_sh( wm, ctrl, str ); |
---|
671 | } /*endif*/ |
---|
672 | } else { |
---|
673 | mx_exec_sh( wm, ctrl, "shm_cmd_delete_beam" ); |
---|
674 | } /*endif*/ |
---|
675 | |
---|
676 | } /* end of mx_handle_beam */ |
---|
677 | |
---|
678 | |
---|
679 | |
---|
680 | /*---------------------------------------------------------------------------*/ |
---|
681 | |
---|
682 | |
---|
683 | #define MAX_NEW_TRC 3 |
---|
684 | #define NEW_TRC_R 0 |
---|
685 | #define NEW_TRC_T 1 |
---|
686 | #define NEW_TRC_Z 2 |
---|
687 | |
---|
688 | |
---|
689 | |
---|
690 | void mx_rotation( Widget wm, MGT_DSPCTRL *ctrl, float azimuth, |
---|
691 | float lat, float lon, TSyStatus *status ) |
---|
692 | |
---|
693 | /* Performs rotation of traces with given azimuth of, if 0.0, computing |
---|
694 | * azimuth by given location |
---|
695 | * |
---|
696 | * parameters of routine |
---|
697 | * Widget wm; input; widget ID of main window |
---|
698 | * MGT_DSPCTRL *ctrl; input; display control |
---|
699 | * float azimuth; input; rotation angle |
---|
700 | * float lat, lon; input; event location |
---|
701 | * STATUS *status; output; return status |
---|
702 | */ |
---|
703 | { |
---|
704 | /* local variables */ |
---|
705 | void *trc; /* running index */ |
---|
706 | void *trc_z, *trc_n, *trc_e; /* trace pointers */ |
---|
707 | char comp; /* component */ |
---|
708 | char station[BC_SHORTSTRLTH+1]; /* station name */ |
---|
709 | char cstation[BC_SHORTSTRLTH+1]; /* current station name */ |
---|
710 | TSyBoolean flush; /* do rotation */ |
---|
711 | TSyStatus locstat; /* local status */ |
---|
712 | char cmd[BC_LINELTH+1]; /* command line for SH */ |
---|
713 | void *newtrc[MAX_NEW_TRC]; /* new created traces */ |
---|
714 | int newtrclth; /* number of new traces */ |
---|
715 | float xazim; /* local copy of azimuth */ |
---|
716 | TSyBoolean dmy; /* dummy */ |
---|
717 | |
---|
718 | /* executable code */ |
---|
719 | |
---|
720 | /* check whether rotated traces are there */ |
---|
721 | locstat = BC_NOERROR; |
---|
722 | trc = NULL; |
---|
723 | FOREVER { |
---|
724 | /* get next trace */ |
---|
725 | trc = db_getp( trc, EP_NEXT, NULL ); |
---|
726 | if (trc == NULL) break; |
---|
727 | if (db_getf(trc,MXC_EF_ROT,&locstat)) { |
---|
728 | mxv_display_state &= ~MXC_FLAG_ROT; |
---|
729 | mx_exec_sh( wm, ctrl, "shm_cmd_rotate unrotate" ); |
---|
730 | return; |
---|
731 | } /*endif*/ |
---|
732 | } /*endfor*/ |
---|
733 | /* no rotated traces there -> continue and make them */ |
---|
734 | |
---|
735 | /* initialize */ |
---|
736 | mxv_display_state |= MXC_FLAG_ROT; |
---|
737 | trc_z = trc_n = trc_e = NULL; |
---|
738 | *station = '\0'; |
---|
739 | mx_exec_sh( wm, ctrl, "shm_cmd_rotate begin" ); |
---|
740 | |
---|
741 | /* loop all traces in memory */ |
---|
742 | flush = FALSE; |
---|
743 | trc = NULL; |
---|
744 | do { |
---|
745 | /* get next trace */ |
---|
746 | trc = db_getp( trc, EP_NEXT, NULL ); |
---|
747 | /* get station and component */ |
---|
748 | locstat = BC_NOERROR; |
---|
749 | flush = (trc == NULL); |
---|
750 | if (!flush) { |
---|
751 | db_gets( trc, ES_STATION, BC_SHORTSTRLTH, cstation, &locstat ); |
---|
752 | if (Severe(&locstat)) {*cstation = '\0'; locstat = BC_NOERROR;} |
---|
753 | comp = db_getc( trc, EC_COMP, &locstat ); |
---|
754 | if (Severe(&locstat)) {comp = ' '; locstat = BC_NOERROR;} |
---|
755 | flush = (strcmp(station,cstation) != 0); |
---|
756 | } /*endif*/ |
---|
757 | if (flush) { |
---|
758 | /* rotate if traces are there */ |
---|
759 | if (trc_n != NULL && trc_e != NULL) { |
---|
760 | /* compute azimuth if equal to 0.0 */ |
---|
761 | if (azimuth == 0.0) { |
---|
762 | mxh_compute_azimuth( cstation, lat, lon, &xazim, status ); |
---|
763 | if (SySevere(status)) return; |
---|
764 | if (GpGetInt(cGpI_debug_level) > 3) |
---|
765 | printf( "SHM-dbg5: rotate: azimuth %f for %s\n", |
---|
766 | xazim, cstation ); |
---|
767 | } else { |
---|
768 | xazim = azimuth; |
---|
769 | if (GpGetInt(cGpI_debug_level) > 3) |
---|
770 | printf( "SHM-dbg5: rotate: constant azimuth %f for %s\n", |
---|
771 | xazim, cstation ); |
---|
772 | } /*endif*/ |
---|
773 | /* generate SH command line and execute it */ |
---|
774 | if (trc_z == NULL) { |
---|
775 | sprintf( cmd, "shm_cmd_rotate ;; a:%lx a:%lx %g", |
---|
776 | trc_n, trc_e, xazim ); |
---|
777 | } else { |
---|
778 | sprintf( cmd, "shm_cmd_rotate a:%lx a:%lx a:%lx %g", |
---|
779 | trc_z, trc_n, trc_e, xazim ); |
---|
780 | } /*endif*/ |
---|
781 | callsh( cmd, &dmy, status ); |
---|
782 | if (Severe(status)) return; |
---|
783 | /* get trace pointers of new traces */ |
---|
784 | db_createdlist( NULL, &newtrclth ); |
---|
785 | if (newtrclth != 2) { |
---|
786 | printf( "*SHM: mx_rotation: this cannot happen (1)\n" ); |
---|
787 | *status = MXE_PROG_BUG; |
---|
788 | return; |
---|
789 | } /*endif*/ |
---|
790 | db_createdlist( newtrc, &newtrclth ); |
---|
791 | newtrc[NEW_TRC_Z] = (trc_z == NULL) |
---|
792 | ? NULL : db_getp(newtrc[NEW_TRC_R],EP_PREV,NULL); |
---|
793 | # ifdef XPHASE |
---|
794 | /* copy phases to output traces */ |
---|
795 | if (trc_z != NULL) |
---|
796 | db_setp( newtrc[NEW_TRC_Z], EP_USRX, |
---|
797 | pi_copy_phaselist(db_getp(trc_z,EP_USRX,NULL),status),status); |
---|
798 | if (Severe(status)) return; |
---|
799 | db_setp( newtrc[NEW_TRC_R], EP_USR2, |
---|
800 | pi_copy_phaselist(db_getp(trc_n,EP_USRX,NULL),status), status ); |
---|
801 | if (Severe(status)) return; |
---|
802 | db_setp( newtrc[NEW_TRC_T], EP_USR2, |
---|
803 | pi_copy_phaselist(db_getp(trc_e,EP_USRX,NULL),status), status ); |
---|
804 | if (Severe(status)) return; |
---|
805 | # endif |
---|
806 | } /*endif*/ |
---|
807 | /* reset variables for next rotation */ |
---|
808 | strcpy( station, cstation ); |
---|
809 | trc_z = trc_n = trc_e = NULL; |
---|
810 | } /*endif*/ |
---|
811 | if (Cap(comp) == 'Z') trc_z = trc; |
---|
812 | else if (Cap(comp) == 'N') trc_n = trc; |
---|
813 | else if (Cap(comp) == 'E') trc_e = trc; |
---|
814 | } while (trc != NULL); |
---|
815 | |
---|
816 | /* cleanup */ |
---|
817 | mx_exec_sh( wm, ctrl, "shm_cmd_rotate finish" ); |
---|
818 | |
---|
819 | } /* end of mx_rotation */ |
---|
820 | |
---|
821 | |
---|
822 | #undef MAX_NEW_TRC |
---|
823 | #undef NEW_TRC_R |
---|
824 | #undef NEW_TRC_T |
---|
825 | #undef NEW_TRC_Z |
---|
826 | |
---|
827 | |
---|
828 | |
---|
829 | /*---------------------------------------------------------------------------*/ |
---|
830 | |
---|
831 | |
---|
832 | |
---|
833 | BOOLEAN mx_need_rotation( void ) |
---|
834 | |
---|
835 | /* Returns whether rotation mode is switched on. If no rotation is possible |
---|
836 | * it switches off rotation mode. |
---|
837 | * |
---|
838 | * no input parameters |
---|
839 | */ |
---|
840 | { |
---|
841 | /* local variables */ |
---|
842 | TSyBoolean redraw; /* redraw display (not used) */ |
---|
843 | TSyStatus locstat; /* local status */ |
---|
844 | |
---|
845 | /* executable code */ |
---|
846 | |
---|
847 | if (MXC_FLAG_ROT & mxv_display_state) { |
---|
848 | if (mxh_rotation_is_possible()) { |
---|
849 | return TRUE; |
---|
850 | } else { |
---|
851 | mx_clear_rotation(); |
---|
852 | locstat = BC_NOERROR; |
---|
853 | callsh( "external_routine prepare_display", &redraw, &locstat ); |
---|
854 | callsh( "hide all", &redraw, &locstat ); |
---|
855 | callsh( "display _shm_view(y)", &redraw, &locstat ); |
---|
856 | callsh( "rd r", &redraw, &locstat ); |
---|
857 | if (GpGetInt(cGpI_debug_level) > 1) |
---|
858 | printf( "SHM-dbg2: rotation mode switched off by mx_need_rotation\n" ); |
---|
859 | return FALSE; |
---|
860 | } /*endif*/ |
---|
861 | } else { |
---|
862 | return FALSE; |
---|
863 | } /*endif*/ |
---|
864 | |
---|
865 | } /* end of mx_need_rotation */ |
---|
866 | |
---|
867 | |
---|
868 | |
---|
869 | /*---------------------------------------------------------------------------*/ |
---|
870 | |
---|
871 | |
---|
872 | |
---|
873 | static BOOLEAN mxh_rotation_is_possible( void ) |
---|
874 | |
---|
875 | /* checks whether a rotation is possible on the traces in memory |
---|
876 | * |
---|
877 | * no parameters |
---|
878 | */ |
---|
879 | { |
---|
880 | /* local variables */ |
---|
881 | TPmTrace *trc; /* pointer to current trace */ |
---|
882 | int t; /* trace counter */ |
---|
883 | TSyStatus locstat; /* local status */ |
---|
884 | char station[BC_SHORTSTRLTH+1]; /* station name */ |
---|
885 | char c_station[BC_SHORTSTRLTH+1]; /* current station */ |
---|
886 | char c_comp; /* current component */ |
---|
887 | TSyBoolean z_found, n_found, e_found; /* components found */ |
---|
888 | |
---|
889 | /* executable code */ |
---|
890 | |
---|
891 | /* loop over all traces in memory */ |
---|
892 | trc = NULL; |
---|
893 | station[0] = '\0'; |
---|
894 | z_found = n_found = e_found = FALSE; |
---|
895 | for (t=0; t<db_lstlth(); t++) { |
---|
896 | /* get next trace pointer */ |
---|
897 | locstat = BC_NOERROR; |
---|
898 | trc = db_getp( trc, EP_NEXT, &locstat ); |
---|
899 | if (Severe(&locstat)) {printf("*SHM: mx-error(10) ***\n"); continue;} |
---|
900 | /* get current station and component */ |
---|
901 | db_gets( trc, ES_STATION, BC_SHORTSTRLTH, c_station, &locstat ); |
---|
902 | if (Severe(&locstat)) continue; |
---|
903 | c_comp = db_getc( trc, EC_COMP, &locstat ); |
---|
904 | if (Severe(&locstat)) continue; |
---|
905 | if (strcmp(station,c_station) != 0) { |
---|
906 | z_found = n_found = e_found = FALSE; |
---|
907 | strcpy( station, c_station ); |
---|
908 | } /*endif*/ |
---|
909 | switch (c_comp) { |
---|
910 | case 'z': case 'Z': z_found = TRUE; break; |
---|
911 | case 'n': case 'N': n_found = TRUE; break; |
---|
912 | case 'e': case 'E': e_found = TRUE; break; |
---|
913 | } /*endswitch*/ |
---|
914 | if (z_found && n_found && e_found) return TRUE; |
---|
915 | } /*endfor*/ |
---|
916 | |
---|
917 | return FALSE; |
---|
918 | |
---|
919 | } /* end of mxh_rotation_is_possible */ |
---|
920 | |
---|
921 | |
---|
922 | |
---|
923 | /*---------------------------------------------------------------------------*/ |
---|
924 | |
---|
925 | |
---|
926 | |
---|
927 | void mx_trclist_command( Widget wm, Widget ws, MGT_DSPCTRL *ctrl, char cmd[], |
---|
928 | STATUS *status ) |
---|
929 | |
---|
930 | /* executes SH command on trace list |
---|
931 | * |
---|
932 | * parameters of routine |
---|
933 | * Widget wm, ws; input; widget ID's of drawing areas |
---|
934 | * MGT_DSPCTRL *ctrl; input; display control |
---|
935 | * char cmd[]; input; command to be executed |
---|
936 | * TSyStatus *status; output; return status |
---|
937 | */ |
---|
938 | { |
---|
939 | /* local variables */ |
---|
940 | char str[BC_LINELTH+1]; /* scratch string */ |
---|
941 | char cmdline[BC_LINELTH+1]; /* command string */ |
---|
942 | |
---|
943 | /* executable code */ |
---|
944 | |
---|
945 | ts_get_selection_string( BC_LINELTH, str ); |
---|
946 | if (*str == '\0' && *cmd >= 'a' && *cmd <= 'z') return; |
---|
947 | if (*str == '\0') strcpy( str, "all" ); |
---|
948 | |
---|
949 | if (strlen(cmd)+strlen(str) > BC_LINELTH-1) { |
---|
950 | *status = MXE_STROVFL; |
---|
951 | return; |
---|
952 | } /*endif*/ |
---|
953 | sprintf( cmdline, cmd, str ); |
---|
954 | |
---|
955 | if (GpGetInt(cGpI_debug_level) > 3) |
---|
956 | printf( "SHM-dbg4: executing: >%s<\n", cmdline ); |
---|
957 | mx_exec_sh( wm, ctrl, cmdline ); |
---|
958 | |
---|
959 | ts_clear_selections(); |
---|
960 | |
---|
961 | mg_do_drag( wm, MGC_DRAG_CLEAR, 0, 0 ); |
---|
962 | mg_plot_drag_window( ws, ctrl->show_phase_acc, status ); |
---|
963 | |
---|
964 | } /* end of mx_trclist_command */ |
---|
965 | |
---|
966 | |
---|
967 | |
---|
968 | /*----------------------------------------------------------------------------*/ |
---|
969 | |
---|
970 | |
---|
971 | |
---|
972 | void mx_trclist_refml( STATUS *status ) |
---|
973 | |
---|
974 | /* stores reference ml in parameter list |
---|
975 | * |
---|
976 | * parameters of routine |
---|
977 | * TSyStatus *status; output; return status |
---|
978 | */ |
---|
979 | { |
---|
980 | /* local variables */ |
---|
981 | char selstr[BC_LINELTH+1]; /* selection string */ |
---|
982 | int trcnum; /* trace number */ |
---|
983 | TPmTrace *trc; /* pointer to trace */ |
---|
984 | char station[BC_SHORTSTRLTH+1]; /* station name of ref ml */ |
---|
985 | char c_station[BC_SHORTSTRLTH+1]; /* current station */ |
---|
986 | TPiPhaseRoot *proot; /* poiner to phase root */ |
---|
987 | TPiPhaseList *plist; /* phase list */ |
---|
988 | TPiPhase *phase; /* pointer to phase info */ |
---|
989 | int p; /* phase counter */ |
---|
990 | TSyStatus locstat; /* local status */ |
---|
991 | TSyBoolean ml_done; /* found ml entry on ref. station */ |
---|
992 | TSyBoolean is_ml_station; /* curr. station is ml ref station */ |
---|
993 | |
---|
994 | /* executable code */ |
---|
995 | |
---|
996 | ts_get_selection_string( BC_LINELTH, selstr ); |
---|
997 | /* ts_clear_selections(); */ /* clear selection done in shm.c */ |
---|
998 | if (*selstr == '\0') { |
---|
999 | *status = MXE_NONE_SELECT; |
---|
1000 | return; |
---|
1001 | } else if (strchr(selstr,',') != NULL) { |
---|
1002 | *status = MXE_MANY_SELECT; |
---|
1003 | err_setcontext( " ## too many traces selected: " ); |
---|
1004 | err_setcontext( selstr ); |
---|
1005 | return; |
---|
1006 | } /*endif*/ |
---|
1007 | |
---|
1008 | /* get station name of selected trace */ |
---|
1009 | trcnum = 0; |
---|
1010 | sscanf( selstr, "%d", &trcnum ); |
---|
1011 | trc = mg_trcptr( trcnum ); |
---|
1012 | if (trc == NULL) { |
---|
1013 | *status = MXE_PROG_BUG; |
---|
1014 | err_setcontext( " ## selected trace resulted in NULL pointer" ); |
---|
1015 | return; |
---|
1016 | } /*endif*/ |
---|
1017 | db_gets( trc, ES_STATION, BC_SHORTSTRLTH, station, status ); |
---|
1018 | if (Severe(status)) return; |
---|
1019 | |
---|
1020 | /* loop all phases and look for ml entries */ |
---|
1021 | ml_done = FALSE; |
---|
1022 | proot = NULL; |
---|
1023 | FOREVER { |
---|
1024 | /* get next phase root pointer */ |
---|
1025 | proot = PiNextPhaseRoot( proot ); |
---|
1026 | if (proot == NULL) break; |
---|
1027 | /* get phase list and station name */ |
---|
1028 | plist = PiPhaseListOfRoot( proot ); |
---|
1029 | if (plist == NULL) continue; |
---|
1030 | strcpy( c_station, PiStationOfRoot(proot) ); |
---|
1031 | is_ml_station = (strcmp(c_station,station) == 0); |
---|
1032 | /* loop all phases of trace */ |
---|
1033 | for (p=0; p<PiPhaseListLength(plist); p++) { |
---|
1034 | phase = PiGetPhase( plist, p, status ); |
---|
1035 | if (Severe(status)) return; |
---|
1036 | if (phase->magn_source == cPiMagnMl) { |
---|
1037 | /* found an ml entry */ |
---|
1038 | if (is_ml_station) { |
---|
1039 | /* set magnitude flag */ |
---|
1040 | phase->flags |= fPiAttribMagn; |
---|
1041 | ml_done = TRUE; |
---|
1042 | } else { |
---|
1043 | /* clear magnitude flag */ |
---|
1044 | phase->flags &= ~fPiAttribMagn; |
---|
1045 | } /*endif*/ |
---|
1046 | } /*endif*/ |
---|
1047 | } /*endfor*/ |
---|
1048 | } /*endfor*/ |
---|
1049 | |
---|
1050 | /* no ml entry found */ |
---|
1051 | if (!ml_done) |
---|
1052 | *status = MXE_NO_MLENTRY; |
---|
1053 | |
---|
1054 | } /* end of mx_trclist_refml */ |
---|
1055 | |
---|
1056 | |
---|
1057 | |
---|
1058 | /*----------------------------------------------------------------------------*/ |
---|
1059 | |
---|
1060 | |
---|
1061 | |
---|
1062 | void mx_analyst_name( Widget w[], MGT_DSPCTRL *ctrl, STATUS *status ) |
---|
1063 | |
---|
1064 | /* Reads analyst's initials from dialog box checks it and closes dialog |
---|
1065 | * box if everything is ok. |
---|
1066 | * |
---|
1067 | * parameters of routine |
---|
1068 | * Widget w[]; input; widget array |
---|
1069 | * TSyStatus *status; output; return status |
---|
1070 | */ |
---|
1071 | { |
---|
1072 | /* local variables */ |
---|
1073 | char *initials; /* pointer to initials */ |
---|
1074 | char analyst[BC_SHORTSTRLTH+1]; /* copy of initials */ |
---|
1075 | TSyBoolean found; /* name found */ |
---|
1076 | TGpTextList txtlst; /* text list with analysts initals */ |
---|
1077 | int i; /* counter */ |
---|
1078 | |
---|
1079 | /* executable code */ |
---|
1080 | |
---|
1081 | initials = cu_get_string( w[k_widget_analyst_name_text] ); |
---|
1082 | if (initials == NULL) {*status = MXE_ILL_ANALYST; return;} |
---|
1083 | if (*initials == '\0') {*status = MXE_ILL_ANALYST; return;} |
---|
1084 | if (strlen(initials) > 4) {*status = MXE_ILL_ANALYST; return;} |
---|
1085 | strcpy( analyst, initials ); |
---|
1086 | /*ut_cap( analyst );*/ |
---|
1087 | |
---|
1088 | /* get list of analysts from setup file */ |
---|
1089 | GpParseTextList( GpGetString(cGpS_list_of_analysts), &txtlst ); |
---|
1090 | |
---|
1091 | found = FALSE; |
---|
1092 | for (i=0; i<txtlst.numelem; i++) { |
---|
1093 | found = (strcmp(txtlst.elem[i],analyst) == 0); |
---|
1094 | if (found) break; |
---|
1095 | } /*endwhile*/ |
---|
1096 | |
---|
1097 | GpFreeTextList( &txtlst ); |
---|
1098 | |
---|
1099 | if (found) { |
---|
1100 | XtUnmanageChild( w[k_widget_analyst_box] ); |
---|
1101 | GpSetString( cGpS_analyst, analyst, NULL ); |
---|
1102 | } else { |
---|
1103 | *status = MXE_ILL_ANALYST; |
---|
1104 | } /*endif*/ |
---|
1105 | |
---|
1106 | } /* end of mx_analyst_name */ |
---|
1107 | |
---|
1108 | |
---|
1109 | |
---|
1110 | /*--------------------------------------------------------------------------*/ |
---|
1111 | |
---|
1112 | |
---|
1113 | |
---|
1114 | void mx_filter_box_defaults( Widget w[], MX_CMD_FILTER *fil ) |
---|
1115 | |
---|
1116 | /* resets filter box |
---|
1117 | * |
---|
1118 | * parameters of routine |
---|
1119 | * Widget w[]; input; widget array |
---|
1120 | * MX_CMD_FILTER *fil; input; filter parameters |
---|
1121 | */ |
---|
1122 | { |
---|
1123 | /* local variables */ |
---|
1124 | Arg al[1]; /* argument list */ |
---|
1125 | int cut_w_no; /* widget number of cutoff time */ |
---|
1126 | int i; /* counter */ |
---|
1127 | |
---|
1128 | /* executable code */ |
---|
1129 | |
---|
1130 | if (fil->autocut >= 600.0) cut_w_no = k_widget_filter_autocut_10min; |
---|
1131 | else if (fil->autocut >= 300.0) cut_w_no = k_widget_filter_autocut_5min; |
---|
1132 | else if (fil->autocut >= 180.0) cut_w_no = k_widget_filter_autocut_3min; |
---|
1133 | else if (fil->autocut >= 60.0) cut_w_no = k_widget_filter_autocut_1min; |
---|
1134 | else if (fil->autocut >= 20.0) cut_w_no = k_widget_filter_autocut_20sec; |
---|
1135 | else if (fil->autocut >= 5.0) cut_w_no = k_widget_filter_autocut_5sec; |
---|
1136 | else cut_w_no = k_widget_filter_autocut_0; |
---|
1137 | XtSetArg( al[0], XmNmenuHistory, w[cut_w_no] ); |
---|
1138 | XtSetValues( w[k_widget_filter_autocut_option], al, 1 ); |
---|
1139 | |
---|
1140 | for (i=k_widget_filter_none; i<=k_widget_filter_sro_lp; i++) |
---|
1141 | if (i != k_widget_filter_lrsm_lp) |
---|
1142 | XmToggleButtonSetState( w[i], FALSE, FALSE ); |
---|
1143 | if (strcmp(fil->name,"GRF_STANDARD_BP") == 0) |
---|
1144 | XmToggleButtonSetState( w[k_widget_filter_standard_bp], TRUE, FALSE ); |
---|
1145 | else if (strcmp(fil->name,"WWSSN_SP") == 0) |
---|
1146 | XmToggleButtonSetState( w[k_widget_filter_wwssn_sp], TRUE, FALSE ); |
---|
1147 | else if (strcmp(fil->name,"WWSSN_LP") == 0) |
---|
1148 | XmToggleButtonSetState( w[k_widget_filter_wwssn_lp], TRUE, FALSE ); |
---|
1149 | else if (strcmp(fil->name,"LRSM_SP") == 0) |
---|
1150 | XmToggleButtonSetState( w[k_widget_filter_lrsm_sp], TRUE, FALSE ); |
---|
1151 | else if (strcmp(fil->name,"LRSM_LP") == 0) |
---|
1152 | XmToggleButtonSetState( w[k_widget_filter_lrsm_lp], TRUE, FALSE ); |
---|
1153 | else if (strcmp(fil->name,"KIRNOS") == 0) |
---|
1154 | XmToggleButtonSetState( w[k_widget_filter_kirnos], TRUE, FALSE ); |
---|
1155 | else if (strcmp(fil->name,"WOODAND") == 0) |
---|
1156 | XmToggleButtonSetState( w[k_widget_filter_woodand], TRUE, FALSE ); |
---|
1157 | else if (strcmp(fil->name,"SRO_LP") == 0) |
---|
1158 | XmToggleButtonSetState( w[k_widget_filter_sro_lp], TRUE, FALSE ); |
---|
1159 | |
---|
1160 | cu_set_string( w[k_widget_filter_edit_text], fil->name ); |
---|
1161 | |
---|
1162 | } /* end of mx_filter_box_defaults */ |
---|
1163 | |
---|
1164 | |
---|
1165 | |
---|
1166 | /*----------------------------------------------------------------------------*/ |
---|
1167 | |
---|
1168 | |
---|
1169 | |
---|
1170 | void mx_sh_external_routine( char cmd[], STATUS *status ) |
---|
1171 | |
---|
1172 | /* external routine for SH |
---|
1173 | * |
---|
1174 | * parameters of routine |
---|
1175 | * char cmd[]; input; switch to subcommands |
---|
1176 | * TSyStatus *status; output; return status |
---|
1177 | */ |
---|
1178 | { |
---|
1179 | /* local variables */ |
---|
1180 | |
---|
1181 | /* executable code */ |
---|
1182 | |
---|
1183 | if (strcmp(cmd,"PREPARE_DISPLAY") == 0) { |
---|
1184 | mx_prepare_display(); |
---|
1185 | } else if (strcmp(cmd,"SAVE_DSP_PHASES") == 0) { |
---|
1186 | /*cl3_save_phase_display( status );*/ |
---|
1187 | if (GpGetInt(cGpI_debug_level) > 2) |
---|
1188 | printf( "SHM-dbg3: external_routine: SAVE_DSP_PHASES disabled\n" ); |
---|
1189 | } else if (strcmp(cmd,"RESTORE_DSP_PHASES") == 0) { |
---|
1190 | if (GpGetInt(cGpI_debug_level) > 2) |
---|
1191 | printf( "SHM-dbg3: external_routine: RESTORE_DSP_PHASES disabled\n" ); |
---|
1192 | } else if (strcmp(cmd,"RESET_DISPLAY_FLAGS") == 0) { |
---|
1193 | mxv_display_state = 0; |
---|
1194 | } else if (strcmp(cmd,"PHASE_CHECK") == 0) { |
---|
1195 | PiPhaseDump(); |
---|
1196 | } else if (strncmp(cmd,"BTN_READS",9) == 0) { |
---|
1197 | if (GpGetInt(cGpI_debug_level) > 2) |
---|
1198 | printf( "SHM-dbg3: external_routine: btn_reads ignored\n" ); |
---|
1199 | } else if (strncmp(cmd,"READ_DIALOG:",12) == 0) { |
---|
1200 | mxh_read_statlist( cmd+12, xmv_w, &xmv_cmd_readg.sl, status ); |
---|
1201 | } else if (strncmp(cmd,"LOC_EXTERNAL:",13) == 0) { |
---|
1202 | mxh_set_entry_name( xmv_w[k_widget_param_hypoloc], cmd+13 ); |
---|
1203 | } else if (strncmp(cmd,"TABLE_ML_SIGMA:",15) == 0) { |
---|
1204 | si_read_table( cmd+15, "ml-sigma", status ); |
---|
1205 | } else if (strcmp(cmd,"DUMP_GLOBALS") == 0) { |
---|
1206 | GpDumpParams(); |
---|
1207 | } else if (strncmp(cmd,"MINMAXFMT:",10) == 0) { |
---|
1208 | /* disabled */ |
---|
1209 | if (GpGetInt(cGpI_debug_level) > 0) |
---|
1210 | printf( "SHM-dbg1: function minmaxfmt obsolete\n" ); |
---|
1211 | } else { |
---|
1212 | *status = MXE_ILL_EXTROUT; |
---|
1213 | return; |
---|
1214 | } /*endif*/ |
---|
1215 | |
---|
1216 | } /* end of mx_sh_external_routine */ |
---|
1217 | |
---|
1218 | |
---|
1219 | |
---|
1220 | /*----------------------------------------------------------------------------*/ |
---|
1221 | |
---|
1222 | |
---|
1223 | |
---|
1224 | static void mx_prepare_display( void ) |
---|
1225 | |
---|
1226 | /* selects traces to be displayed on next redraw (sets EF_VIEW flag). |
---|
1227 | * |
---|
1228 | */ |
---|
1229 | { |
---|
1230 | /* local variables */ |
---|
1231 | int t; /* trace counter */ |
---|
1232 | TPmTrace *trc; /* pointer to trace info */ |
---|
1233 | TSyStatus locstat; /* local status */ |
---|
1234 | TSyBoolean dsp; /* do display trace */ |
---|
1235 | TSyBoolean dsp_filtered; /* display filtered traces */ |
---|
1236 | TSyBoolean dsp_rotated; /* display rotated traces */ |
---|
1237 | |
---|
1238 | /* executable code */ |
---|
1239 | |
---|
1240 | dsp_filtered = (MXC_FLAG_FILTER & mxv_display_state); |
---|
1241 | dsp_rotated = (MXC_FLAG_ROT & mxv_display_state); |
---|
1242 | |
---|
1243 | /* loop over all traces in memory */ |
---|
1244 | trc = NULL; |
---|
1245 | for (t=0; t<db_lstlth(); t++) { |
---|
1246 | /* get next trace pointer */ |
---|
1247 | locstat = BC_NOERROR; |
---|
1248 | trc = db_getp( trc, EP_NEXT, &locstat ); |
---|
1249 | if (Severe(&locstat)) {printf("*SHM: mx-error(1) ***\n"); continue;} |
---|
1250 | dsp = ( |
---|
1251 | !db_getf(trc,MXC_EF_HIDE,&locstat) |
---|
1252 | && db_getf(trc,MXC_EF_FILTER,&locstat) == dsp_filtered |
---|
1253 | && db_getf(trc,MXC_EF_ROT,&locstat) == dsp_rotated |
---|
1254 | ); |
---|
1255 | db_setf( trc, MXC_EF_VIEW, dsp, &locstat ); |
---|
1256 | if (Severe(&locstat)) {printf("*SHM: mx-error(2) ***\n"); continue;} |
---|
1257 | } /*endfor*/ |
---|
1258 | |
---|
1259 | } /* end of mx_prepare_display */ |
---|
1260 | |
---|
1261 | |
---|
1262 | |
---|
1263 | /*----------------------------------------------------------------------------*/ |
---|
1264 | |
---|
1265 | |
---|
1266 | |
---|
1267 | void mx_clear_rotation( void ) |
---|
1268 | |
---|
1269 | /* resets rotation state |
---|
1270 | * |
---|
1271 | * no parameters |
---|
1272 | */ |
---|
1273 | { |
---|
1274 | /* executable code */ |
---|
1275 | |
---|
1276 | mxv_display_state &= ~MXC_FLAG_ROT; |
---|
1277 | |
---|
1278 | } /* end of mx_clear_rotation */ |
---|
1279 | |
---|
1280 | |
---|
1281 | |
---|
1282 | /*----------------------------------------------------------------------------*/ |
---|
1283 | |
---|
1284 | |
---|
1285 | |
---|
1286 | void mx_get_chanlist( Widget w[], MX_CMD_READG *rg ) |
---|
1287 | |
---|
1288 | |
---|
1289 | /* reads list of channels from dialog box into channel array |
---|
1290 | * |
---|
1291 | * parameters of routine |
---|
1292 | * Widget w[]; input; widget array |
---|
1293 | * MX_CMD_READG *rg; output; channel array (chanstr) |
---|
1294 | */ |
---|
1295 | { |
---|
1296 | /* local variables */ |
---|
1297 | int i; /* channel counter */ |
---|
1298 | int cwno[MXC_MAXCHAN]; /* channel widget numbers */ |
---|
1299 | char *str; /* pointer to string */ |
---|
1300 | |
---|
1301 | /* executable code */ |
---|
1302 | |
---|
1303 | cwno[0] = k_widget_read_grsn_1hz; |
---|
1304 | cwno[1] = k_widget_read_grsn_20hz; |
---|
1305 | cwno[2] = k_widget_read_grsn_80hz; |
---|
1306 | cwno[3] = k_widget_read_grsn_edit_hz; |
---|
1307 | |
---|
1308 | /* reset channel counter */ |
---|
1309 | rg->channum = 0; |
---|
1310 | |
---|
1311 | for (i=0; i<MXC_MAXCHAN; i++) { |
---|
1312 | if (XmToggleButtonGetState(w[cwno[i]])) { |
---|
1313 | strcpy( rg->chanstr[rg->channum], rg->sl.channel[i] ); |
---|
1314 | if (strcmp(rg->chanstr[rg->channum],"ed") == 0) { |
---|
1315 | str = cu_get_string( w[k_widget_read_grsn_hz_text] ); |
---|
1316 | if (strlen(str) <= MXC_CHANLTH && strlen(str) > 0) { |
---|
1317 | strcpy( rg->chanstr[rg->channum], str ); |
---|
1318 | } else { |
---|
1319 | printf( "*SHM: illegal channel string %s\n", str ); |
---|
1320 | } /*endif*/ |
---|
1321 | } /*endif*/ |
---|
1322 | (rg->channum)++; |
---|
1323 | } /*endif*/ |
---|
1324 | } /*endfor*/ |
---|
1325 | |
---|
1326 | #ifdef XXX |
---|
1327 | /* check buttons */ |
---|
1328 | if (XmToggleButtonGetState(w[k_widget_read_grsn_1hz])) { |
---|
1329 | strcpy( rg->chanstr[rg->channum], "LH" ); |
---|
1330 | (rg->channum)++; |
---|
1331 | } /*endif*/ |
---|
1332 | if (XmToggleButtonGetState(w[k_widget_read_grsn_20hz])) { |
---|
1333 | strcpy( rg->chanstr[rg->channum], "BH" ); |
---|
1334 | (rg->channum)++; |
---|
1335 | } /*endif*/ |
---|
1336 | if (XmToggleButtonGetState(w[k_widget_read_grsn_80hz])) { |
---|
1337 | strcpy( rg->chanstr[rg->channum], "HH" ); |
---|
1338 | (rg->channum)++; |
---|
1339 | } /*endif*/ |
---|
1340 | if (XmToggleButtonGetState(w[k_widget_read_grsn_edit_hz])) { |
---|
1341 | str = cu_get_string( w[k_widget_read_grsn_hz_text] ); |
---|
1342 | if (strlen(str) <= MXC_CHANLTH && strlen(str) > 0) { |
---|
1343 | strcpy( rg->chanstr[rg->channum], str ); |
---|
1344 | } else { |
---|
1345 | printf( "*SHM: illegal channel string %s\n", str ); |
---|
1346 | } /*endif*/ |
---|
1347 | (rg->channum)++; |
---|
1348 | } /*endif*/ |
---|
1349 | #endif |
---|
1350 | |
---|
1351 | } /* end of mx_get_chanlist */ |
---|
1352 | |
---|
1353 | |
---|
1354 | |
---|
1355 | /*----------------------------------------------------------------------------*/ |
---|
1356 | |
---|
1357 | |
---|
1358 | |
---|
1359 | static void mxh_read_statlist( char fname[], Widget w[], MX_STATLIST *sl, |
---|
1360 | STATUS *status ) |
---|
1361 | |
---|
1362 | /* reads in station list from file 'fname' |
---|
1363 | * |
---|
1364 | * parameters of routine |
---|
1365 | * char fname[]; input; name of input file |
---|
1366 | * Widget w[]; input; widget array (widgets will be modified) |
---|
1367 | * MX_STATLIST *sl; output; station list for dialog box |
---|
1368 | * TSyStatus *status; output; return status |
---|
1369 | */ |
---|
1370 | { |
---|
1371 | /* local variables */ |
---|
1372 | FILE *fp; /* pointer to input file */ |
---|
1373 | char line[BC_LINELTH+1]; /* current line */ |
---|
1374 | int s; /* station counter */ |
---|
1375 | int c; /* channel counter */ |
---|
1376 | int cwno[MXC_MAXCHAN]; /* channel widget numbers */ |
---|
1377 | int slen; /* string length */ |
---|
1378 | char *ch; /* char pointer */ |
---|
1379 | Arg args[2]; /* argument list */ |
---|
1380 | int n; /* argument counter */ |
---|
1381 | XmString xmstr; /* Xm string */ |
---|
1382 | |
---|
1383 | /* executable code */ |
---|
1384 | |
---|
1385 | fp = sy_fopen( fname, "r" ); |
---|
1386 | if (fp == NULL) { |
---|
1387 | *status = MXE_OPENREAD; |
---|
1388 | err_setcontext( " ## file " ); err_setcontext( fname ); |
---|
1389 | return; |
---|
1390 | } /*endif*/ |
---|
1391 | |
---|
1392 | /* initialize output record */ |
---|
1393 | for (s=0; s<MXC_STATLIST_LTH; s++) strcpy( sl->code[s], "---" ); |
---|
1394 | strcpy( sl->set1code, "---" ); |
---|
1395 | strcpy( sl->set2code, "---" ); |
---|
1396 | sl->set1start = sl->set1end = sl->set2start = sl->set2end = 0; |
---|
1397 | strcpy( sl->channel[0], "LH" ); |
---|
1398 | strcpy( sl->channel[1], "BH" ); |
---|
1399 | strcpy( sl->channel[2], "HH" ); |
---|
1400 | strcpy( sl->channel[3], "ed" ); |
---|
1401 | |
---|
1402 | s = c = 0; |
---|
1403 | while (fgets(line,BC_LINELTH,fp) != NULL) { |
---|
1404 | if (*line == '!' || *line == '\n') continue; |
---|
1405 | slen = strlen( line ) - 1; |
---|
1406 | if (line[slen] == '\n') line[slen] = '\0'; |
---|
1407 | if (strncmp(line,"set1:",5) == 0) { |
---|
1408 | if (sscanf(line+5,"%d %d %s", |
---|
1409 | &(sl->set1start),&(sl->set1end),sl->set1code) != 3) |
---|
1410 | fprintf( stderr, |
---|
1411 | "*SHM: mx_read_statlist: error reading subset 1\n" ); |
---|
1412 | } else if (strncmp(line,"set2:",5) == 0) { |
---|
1413 | if (sscanf(line+5,"%d %d %s", |
---|
1414 | &(sl->set2start),&(sl->set2end),sl->set2code) != 3) |
---|
1415 | fprintf( stderr, |
---|
1416 | "*SHM: mx_read_statlist: error reading subset 2\n" ); |
---|
1417 | } else if (*line == '*') { |
---|
1418 | if (s == MXC_STATLIST_LTH) { |
---|
1419 | fprintf( stderr, "*SHM: mx_read_statlist: too many stations\n" ); |
---|
1420 | } else { |
---|
1421 | ch = line + 1; |
---|
1422 | while (*ch == ' ' && *ch != '\0') ch++; |
---|
1423 | if (strlen(ch) > MXC_STATSTR_LTH) { |
---|
1424 | fprintf( stderr, |
---|
1425 | "*SHM: mx_read_statlist: station name %s too long\n", ch ); |
---|
1426 | } else { |
---|
1427 | strcpy( sl->code[s++], ch ); |
---|
1428 | } /*endif*/ |
---|
1429 | } /*endif*/ |
---|
1430 | } else if (*line == 'c') { |
---|
1431 | if (c < MXC_MAXCHAN) { |
---|
1432 | sl->channel[c][0] = line[2]; |
---|
1433 | sl->channel[c][1] = line[3]; |
---|
1434 | sl->channel[c][2] = '\0'; |
---|
1435 | c++; |
---|
1436 | } else { |
---|
1437 | fprintf( stderr, "*SHM: mx_read_statlist: too many channels\n" ); |
---|
1438 | } /*endif*/ |
---|
1439 | } else { |
---|
1440 | fprintf( stderr, "*SHM: mx_read_statlist: illegal line:\n%s", line ); |
---|
1441 | } /*endif*/ |
---|
1442 | } /*endwhile*/ |
---|
1443 | |
---|
1444 | sy_fclose( fp ); |
---|
1445 | |
---|
1446 | /* set dialog box */ |
---|
1447 | for (s=0; s<MXC_STATLIST_LTH; s++) { |
---|
1448 | xmstr = XmStringCreateLtoR( sl->code[s], "" ); |
---|
1449 | n = 0; |
---|
1450 | XtSetArg( args[n], XmNlabelString, xmstr ); n++; |
---|
1451 | XtSetValues( w[k_widget_read_grsn_station+s], args, n ); |
---|
1452 | XtSetSensitive( w[k_widget_read_grsn_station+s], (sl->code[s][0] != '-')); |
---|
1453 | } /*endfor*/ |
---|
1454 | |
---|
1455 | xmstr = XmStringCreateLtoR( sl->set1code, "" ); |
---|
1456 | n = 0; |
---|
1457 | XtSetArg( args[n], XmNlabelString, xmstr ); n++; |
---|
1458 | XtSetValues( w[k_widget_read_grsn_grf], args, n ); |
---|
1459 | XtSetSensitive( w[k_widget_read_grsn_grf], (sl->set1code[0] != '-') ); |
---|
1460 | xmstr = XmStringCreateLtoR( sl->set2code, "" ); |
---|
1461 | n = 0; |
---|
1462 | XtSetArg( args[n], XmNlabelString, xmstr ); n++; |
---|
1463 | XtSetValues( w[k_widget_read_grsn_grsn], args, n ); |
---|
1464 | XtSetSensitive( w[k_widget_read_grsn_grsn], (sl->set2code[0] != '-') ); |
---|
1465 | |
---|
1466 | cwno[0] = k_widget_read_grsn_1hz; |
---|
1467 | cwno[1] = k_widget_read_grsn_20hz; |
---|
1468 | cwno[2] = k_widget_read_grsn_80hz; |
---|
1469 | cwno[3] = k_widget_read_grsn_edit_hz; |
---|
1470 | for (c=0; c<MXC_MAXCHAN; c++) { |
---|
1471 | xmstr = XmStringCreateLtoR( sl->channel[c], "" ); |
---|
1472 | n = 0; |
---|
1473 | XtSetArg( args[n], XmNlabelString, xmstr ); n++; |
---|
1474 | XtSetValues( w[cwno[c]], args, n ); |
---|
1475 | XtSetSensitive( w[cwno[c]], (sl->channel[c][0] != '-')); |
---|
1476 | } /*endfor*/ |
---|
1477 | |
---|
1478 | } /* end of mxh_read_statlist */ |
---|
1479 | |
---|
1480 | |
---|
1481 | |
---|
1482 | /*----------------------------------------------------------------------------*/ |
---|
1483 | |
---|
1484 | |
---|
1485 | |
---|
1486 | void mx_name_read_buttons( Widget w[], int dialbox_num, TSyStatus *status ) |
---|
1487 | |
---|
1488 | /* reads in station list from parameter file. Original from mxh_read_statlist. |
---|
1489 | * |
---|
1490 | * parameters of routine |
---|
1491 | * Widget w[]; input; widget array (widgets will be modified) |
---|
1492 | * int dialbox_num; input; number of dialog box to be modified |
---|
1493 | * MX_STATLIST *sl; output; station list for dialog box |
---|
1494 | * TSyStatus *status; output; return status |
---|
1495 | */ |
---|
1496 | { |
---|
1497 | /* local variables */ |
---|
1498 | char parname[cBcLineLth+1]; /* name of parameter (dialog box number) */ |
---|
1499 | char parval[cBcLongStrLth+1]; /* list of stations */ |
---|
1500 | int ok; /* parameter ok? */ |
---|
1501 | TGpTextList slist; /* parsed station list */ |
---|
1502 | int s; /* station counter */ |
---|
1503 | int setcnt; /* set counter */ |
---|
1504 | int c; /* channel counter */ |
---|
1505 | int cwno[MXC_MAXCHAN]; /* channel widget numbers */ |
---|
1506 | Arg args[2]; /* argument list */ |
---|
1507 | int n; /* argument counter */ |
---|
1508 | XmString xmstr; /* Xm string */ |
---|
1509 | MX_STATLIST *sl; /* station list for dialog box */ |
---|
1510 | int slen; /* string length */ |
---|
1511 | |
---|
1512 | /* executable code */ |
---|
1513 | |
---|
1514 | sl = &(xmv_cmd_readg.sl); |
---|
1515 | |
---|
1516 | /* get station parameter from parameter file */ |
---|
1517 | sprintf( parname, "v$read_dialog_stations_%02d", dialbox_num ); |
---|
1518 | GpReadParameter( parname, cBcLongStrLth, parval, &ok ); |
---|
1519 | if (!ok) {*status = MXE_NOT_FOUND;return;} |
---|
1520 | GpParseTextList( parval, &slist ); |
---|
1521 | |
---|
1522 | /* initialize output record */ |
---|
1523 | for (s=0; s<MXC_STATLIST_LTH; s++) strcpy( sl->code[s], "---" ); |
---|
1524 | strcpy( sl->set1code, "---" ); |
---|
1525 | strcpy( sl->set2code, "---" ); |
---|
1526 | sl->set1start = sl->set1end = sl->set2start = sl->set2end = 0; |
---|
1527 | strcpy( sl->channel[0], "LH" ); |
---|
1528 | strcpy( sl->channel[1], "BH" ); |
---|
1529 | strcpy( sl->channel[2], "HH" ); |
---|
1530 | strcpy( sl->channel[3], "ed" ); |
---|
1531 | |
---|
1532 | setcnt = 0; |
---|
1533 | for (s=0; s<slist.numelem; s++) { |
---|
1534 | slen = strlen( slist.elem[s] ); |
---|
1535 | if (slen > MXC_STATSTR_LTH) { |
---|
1536 | fprintf( stderr, |
---|
1537 | "*SHM: mx_name_read_buttons: station name %s too long\n", |
---|
1538 | slist.elem[s] ); |
---|
1539 | continue; |
---|
1540 | } /*endif*/ |
---|
1541 | if (s == MXC_STATLIST_LTH) { |
---|
1542 | strcpy( sl->set1code, slist.elem[s] ); |
---|
1543 | } else if (s == MXC_STATLIST_LTH+1) { |
---|
1544 | strcpy( sl->set2code, slist.elem[s] ); |
---|
1545 | } else if (s < MXC_STATLIST_LTH) { |
---|
1546 | if (slist.elem[s][0] == '[') { |
---|
1547 | setcnt++; |
---|
1548 | if (setcnt == 1) { |
---|
1549 | sl->set1start = s; |
---|
1550 | } else if (setcnt == 2) { |
---|
1551 | sl->set2start = s; |
---|
1552 | } /*endif*/ |
---|
1553 | strcpy( sl->code[s], slist.elem[s]+1 ); |
---|
1554 | } else if (slist.elem[s][slen-1] == ']') { |
---|
1555 | if (setcnt == 1) { |
---|
1556 | sl->set1end = s; |
---|
1557 | } else if (setcnt == 2) { |
---|
1558 | sl->set2end = s; |
---|
1559 | } /*endif*/ |
---|
1560 | strcpy( sl->code[s], slist.elem[s] ); |
---|
1561 | sl->code[s][slen-1] = '\0'; |
---|
1562 | } else { |
---|
1563 | strcpy( sl->code[s], slist.elem[s] ); |
---|
1564 | } /*endif*/ |
---|
1565 | } /*endif*/ |
---|
1566 | } /*endfor*/ |
---|
1567 | if (setcnt > 0 && sl->set1code[0] == '-') strcpy( sl->set1code, "SET1" ); |
---|
1568 | if (setcnt > 1 && sl->set2code[0] == '-') strcpy( sl->set2code, "SET2" ); |
---|
1569 | |
---|
1570 | GpFreeTextList( &slist ); |
---|
1571 | |
---|
1572 | /* get channel parameter from parameter file */ |
---|
1573 | sprintf( parname, "v$read_dialog_channels_%02d", dialbox_num ); |
---|
1574 | GpReadParameter( parname, cBcLongStrLth, parval, &ok ); |
---|
1575 | if (ok) { |
---|
1576 | GpParseTextList( parval, &slist ); |
---|
1577 | c = 0; |
---|
1578 | for (s=0; s<slist.numelem; s++) |
---|
1579 | if (s < MXC_MAXCHAN && strlen(slist.elem[s]) <= MXC_CHANLTH) |
---|
1580 | strcpy( sl->channel[c++], slist.elem[s] ); |
---|
1581 | GpFreeTextList( &slist ); |
---|
1582 | } /*endif*/ |
---|
1583 | |
---|
1584 | /* set dialog box */ |
---|
1585 | for (s=0; s<MXC_STATLIST_LTH; s++) { |
---|
1586 | xmstr = XmStringCreateLtoR( sl->code[s], "" ); |
---|
1587 | n = 0; |
---|
1588 | XtSetArg( args[n], XmNlabelString, xmstr ); n++; |
---|
1589 | XtSetValues( w[k_widget_read_grsn_station+s], args, n ); |
---|
1590 | XtSetSensitive( w[k_widget_read_grsn_station+s], (sl->code[s][0] != '-')); |
---|
1591 | XmToggleButtonSetState( w[k_widget_read_grsn_station+s], FALSE, TRUE ); |
---|
1592 | } /*endfor*/ |
---|
1593 | |
---|
1594 | xmstr = XmStringCreateLtoR( sl->set1code, "" ); |
---|
1595 | n = 0; |
---|
1596 | XtSetArg( args[n], XmNlabelString, xmstr ); n++; |
---|
1597 | XtSetValues( w[k_widget_read_grsn_grf], args, n ); |
---|
1598 | XtSetSensitive( w[k_widget_read_grsn_grf], (sl->set1code[0] != '-') ); |
---|
1599 | xmstr = XmStringCreateLtoR( sl->set2code, "" ); |
---|
1600 | n = 0; |
---|
1601 | XtSetArg( args[n], XmNlabelString, xmstr ); n++; |
---|
1602 | XtSetValues( w[k_widget_read_grsn_grsn], args, n ); |
---|
1603 | XtSetSensitive( w[k_widget_read_grsn_grsn], (sl->set2code[0] != '-') ); |
---|
1604 | |
---|
1605 | cwno[0] = k_widget_read_grsn_1hz; |
---|
1606 | cwno[1] = k_widget_read_grsn_20hz; |
---|
1607 | cwno[2] = k_widget_read_grsn_80hz; |
---|
1608 | cwno[3] = k_widget_read_grsn_edit_hz; |
---|
1609 | for (c=0; c<MXC_MAXCHAN; c++) { |
---|
1610 | xmstr = XmStringCreateLtoR( sl->channel[c], "" ); |
---|
1611 | n = 0; |
---|
1612 | XtSetArg( args[n], XmNlabelString, xmstr ); n++; |
---|
1613 | XtSetValues( w[cwno[c]], args, n ); |
---|
1614 | XtSetSensitive( w[cwno[c]], (sl->channel[c][0] != '-')); |
---|
1615 | } /*endfor*/ |
---|
1616 | |
---|
1617 | } /* end of mx_name_read_buttons */ |
---|
1618 | |
---|
1619 | |
---|
1620 | |
---|
1621 | /*----------------------------------------------------------------------------*/ |
---|
1622 | |
---|
1623 | |
---|
1624 | |
---|
1625 | static void mxh_read_file_list( Widget w, MGT_DSPCTRL *ctrl, char filenames[], |
---|
1626 | int format, STATUS *status ) |
---|
1627 | |
---|
1628 | /* reads in all GSE files matching the wildcard string "filenames" |
---|
1629 | * |
---|
1630 | * parameters of routine |
---|
1631 | * Widget w; input; widget ID of drawing area |
---|
1632 | * MGT_DSPCTRL *ctrl; input; display control params |
---|
1633 | * char filenames[]; input; wild card string for filenames |
---|
1634 | * int format; input; format code |
---|
1635 | * TSyStatus *status; output; return status |
---|
1636 | */ |
---|
1637 | { |
---|
1638 | /* local variables */ |
---|
1639 | char currfile[BC_FILELTH+1]; /* current file */ |
---|
1640 | char altfile[cBcFileLth+1]; /* another filename */ |
---|
1641 | int filecnt; /* file counter */ |
---|
1642 | char cmd[BC_LINELTH+1]; /* comand line */ |
---|
1643 | char *cp; /* moving pointer */ |
---|
1644 | TSyBoolean redraw; /* dummy */ |
---|
1645 | int i; /* counter */ |
---|
1646 | |
---|
1647 | /* executable code */ |
---|
1648 | |
---|
1649 | mx_exec_sh( w, ctrl, "nr" ); |
---|
1650 | filecnt = 0; |
---|
1651 | FOREVER { |
---|
1652 | |
---|
1653 | /* try to find next matching file */ |
---|
1654 | sy_findfile( SYC_FF_NAME|SYC_FF_DIR|SYC_FF_EXT, filenames, currfile ); |
---|
1655 | if (*currfile == '\0') { |
---|
1656 | if (filecnt == 0) { |
---|
1657 | *status = MXE_NO_GSE_MATCH; |
---|
1658 | break; |
---|
1659 | } /*endif*/ |
---|
1660 | break; |
---|
1661 | } /*endif*/ |
---|
1662 | |
---|
1663 | /* put backslashes instead if slashes because of SH command line */ |
---|
1664 | cp = currfile - 1; |
---|
1665 | while (*(++cp) != '\0') |
---|
1666 | if (*cp == '/') |
---|
1667 | *cp = '\\'; |
---|
1668 | |
---|
1669 | /* process file currfile */ |
---|
1670 | if (strlen(currfile)+12 > BC_LINELTH) { |
---|
1671 | *status = MXE_STROVFL; |
---|
1672 | break; |
---|
1673 | } /*endif*/ |
---|
1674 | switch (format) { |
---|
1675 | case MXC_FORMAT_GSE: sprintf( cmd, "@READGSE_MERGE %s ALL", currfile ); break; |
---|
1676 | case MXC_FORMAT_GSE2: sprintf( cmd, "@READGSE_MERGE %s ALL", currfile ); break; |
---|
1677 | case MXC_FORMAT_AH: sprintf( cmd, "@READAH %s ALL", currfile ); break; |
---|
1678 | case MXC_FORMAT_Q: |
---|
1679 | strcpy( altfile, currfile ); |
---|
1680 | i = strlen( altfile ) - 4; |
---|
1681 | if (i > 1 && strcmp(altfile+i,".QBN") == 0) { |
---|
1682 | altfile[i] = '\0'; |
---|
1683 | sprintf( cmd, "@READ %s ALL", altfile ); |
---|
1684 | } else { |
---|
1685 | sprintf( cmd, "! @READ %s ALL", altfile ); |
---|
1686 | } /*endif*/ |
---|
1687 | break; |
---|
1688 | default: |
---|
1689 | printf( "*SHM: mxh_read_file_list: this should not happen\n" ); |
---|
1690 | break; |
---|
1691 | } /*endswitch*/ |
---|
1692 | if (GpGetInt(cGpI_debug_level) > 1) |
---|
1693 | printf( "SHM-dbg2: executing command: %s\n", cmd ); |
---|
1694 | callsh( cmd, &redraw, status ); |
---|
1695 | if (Severe(status)) { |
---|
1696 | /* should print out error in a more elaborate way */ |
---|
1697 | printf( "*SHM: readgse error %d\n", *status ); |
---|
1698 | *status = BC_NOERROR; |
---|
1699 | } /*endif*/ |
---|
1700 | /* mx_exec_sh( w, ctrl, cmd ); */ |
---|
1701 | |
---|
1702 | /* increment file counter */ |
---|
1703 | filecnt++; |
---|
1704 | |
---|
1705 | } /*endfor*/ |
---|
1706 | mx_exec_sh( w, ctrl, "rd" ); |
---|
1707 | |
---|
1708 | } /* end of mxh_read_file_list */ |
---|
1709 | |
---|
1710 | |
---|
1711 | |
---|
1712 | /*----------------------------------------------------------------------------*/ |
---|
1713 | |
---|
1714 | |
---|
1715 | #define MAX_S_LTH 8 |
---|
1716 | |
---|
1717 | |
---|
1718 | static void mxh_filter_separately( Widget w, MGT_DSPCTRL *ctrl, char filter[], |
---|
1719 | float autocut, STATUS *status ) |
---|
1720 | |
---|
1721 | /* Filters traces on display separately. |
---|
1722 | * |
---|
1723 | * parameters of routine |
---|
1724 | * Widget w; input; widget ID of drawing window |
---|
1725 | * MGT_DSPCTRL *ctrl; input; display control |
---|
1726 | * char filter[]; input; name of filter (without prefix) |
---|
1727 | * float autocut; input; autocut of traces in sec |
---|
1728 | * TSyStatus *status; output; return status |
---|
1729 | */ |
---|
1730 | { |
---|
1731 | /* local variables */ |
---|
1732 | void *trc; /* trace pointer */ |
---|
1733 | int trcnum; /* trace number on display */ |
---|
1734 | char complete_name[BC_FILELTH+1]; /* complete filter name */ |
---|
1735 | char tfname[BC_FILELTH+1]; /* transfer function name */ |
---|
1736 | char last_name[BC_FILELTH+1]; /* last filter */ |
---|
1737 | BOOLEAN simulation; /* is simulation filter */ |
---|
1738 | char station[BC_SHORTSTRLTH+1]; /* station name */ |
---|
1739 | char cmd[BC_LINELTH+1]; /* SH command */ |
---|
1740 | char filter_typ, filter_typ_save; /* filter type */ |
---|
1741 | void *newtrc; /* pointer to new trace */ |
---|
1742 | void *tmp; /* scratch pointer */ |
---|
1743 | void *lasttrc; /* last trace at beginning */ |
---|
1744 | TIME ttime; /* start time of trace */ |
---|
1745 | char strtime[cBcTimeLth+1]; /* converted start time */ |
---|
1746 | int trcflags; /* trace flags for filtered traces */ |
---|
1747 | TSyStatus locstat; /* local status */ |
---|
1748 | BOOLEAN dmy; /* dummy */ |
---|
1749 | unsigned filent; /* filter entry */ |
---|
1750 | char singfilt[BC_FILELTH+1]; /* single filter name */ |
---|
1751 | char filprefix[BC_FILELTH+1]; /* filter prefix on rec. filters */ |
---|
1752 | |
---|
1753 | /* executable code */ |
---|
1754 | |
---|
1755 | if (GpGetInt(cGpI_debug_level) > 1) |
---|
1756 | printf( "SHM-dbg2: mx_filter: different filters used\n" ); |
---|
1757 | |
---|
1758 | #ifdef XXX |
---|
1759 | filter_typ = (shv_global.use_rec_filters) ? 'R' : 'F'; |
---|
1760 | if (shv_global.filter_type != ' ') filter_typ = shv_global.filter_type; |
---|
1761 | #endif |
---|
1762 | filter_typ = GpGetChar(cGpC_filter_type); |
---|
1763 | filter_typ_save = filter_typ; |
---|
1764 | simulation = (strchr(filter,'+') != NULL); |
---|
1765 | if (strlen(filter) > BC_FILELTH-2*MAX_S_LTH) { |
---|
1766 | *status = MXE_STROVFL; |
---|
1767 | return; |
---|
1768 | } /*endif*/ |
---|
1769 | |
---|
1770 | /* get index number of filter entry */ |
---|
1771 | db_ident( "FILTER", &filent, status ); |
---|
1772 | if (SySevere(status)) return; |
---|
1773 | |
---|
1774 | /* prepare traces */ |
---|
1775 | mx_exec_sh( w, ctrl, "shm_cmd_sepfil_begin" ); |
---|
1776 | |
---|
1777 | /* set newtrc to last trace in memory */ |
---|
1778 | newtrc = NULL; |
---|
1779 | FOREVER { |
---|
1780 | tmp = db_getp( newtrc, EP_NEXT, NULL ); |
---|
1781 | if (tmp == NULL) break; |
---|
1782 | newtrc = tmp; |
---|
1783 | } /*endfor*/ |
---|
1784 | if (newtrc == NULL) { |
---|
1785 | printf( "*SHM: mx_filter: no traces\n" ); |
---|
1786 | *status = MXE_PROG_BUG; |
---|
1787 | return; |
---|
1788 | } /*endif*/ |
---|
1789 | lasttrc = newtrc; |
---|
1790 | |
---|
1791 | /* loop all traces on display */ |
---|
1792 | trcnum = 0; |
---|
1793 | *last_name = '\0'; |
---|
1794 | trc = NULL; |
---|
1795 | do { |
---|
1796 | filter_typ = filter_typ_save; /* in case it has been changed by FORCE_T */ |
---|
1797 | trcnum++; |
---|
1798 | trcflags = 0; |
---|
1799 | trc = db_getp( trc, EP_NEXT, NULL ); |
---|
1800 | if (trc == NULL) { |
---|
1801 | printf( "*SHM: mx_filter: this is impossible (10)\n" ); |
---|
1802 | *status = MXE_PROG_BUG; |
---|
1803 | return; |
---|
1804 | } /*endif*/ |
---|
1805 | if (!ts_some_trace_selected() || ts_is_selected(trcnum)) { |
---|
1806 | *complete_name = '\0'; |
---|
1807 | if (filter_typ == 'R') { |
---|
1808 | cl_filter_prefix( trc, MAX_S_LTH, complete_name ); |
---|
1809 | strcpy( filprefix, complete_name ); |
---|
1810 | } /*endif*/ |
---|
1811 | if (simulation) { |
---|
1812 | /*db_gets( trc, ES_STATION, BC_SHORTSTRLTH, station, status );*/ |
---|
1813 | /*if (Severe(status)) return;*/ |
---|
1814 | locstat = cBcNoError; |
---|
1815 | db_gett( trc, ET_START, &ttime, &locstat ); |
---|
1816 | tc_a2t( &ttime, strtime, &locstat ); |
---|
1817 | cu_get_stream_string( trc, station, NULL ); |
---|
1818 | cu_lookup_filter( station, strtime, tfname, &trcflags, status ); |
---|
1819 | if (Severe(status)) return; |
---|
1820 | if (trcflags & CUC_F_TRC_FORCE_F) { |
---|
1821 | strcpy( complete_name, tfname ); |
---|
1822 | filter_typ = 'F'; |
---|
1823 | } else if (trcflags & CUC_F_TRC_FORCE_T) { |
---|
1824 | strcpy( complete_name, tfname ); |
---|
1825 | filter_typ = 'T'; |
---|
1826 | } else { |
---|
1827 | strcat( complete_name, tfname ); |
---|
1828 | } /*endif*/ |
---|
1829 | strcat( complete_name, "_" ); |
---|
1830 | } /*endif*/ |
---|
1831 | strcat( complete_name, filter ); |
---|
1832 | if (ts_is_selected(trcnum)) { |
---|
1833 | /* take filter from dialog box into filter info entry */ |
---|
1834 | if (GpGetInt(cGpI_debug_level) > 3) |
---|
1835 | printf( "shm-dbg4: set single filter %s on trace %d\n", |
---|
1836 | filter, trcnum ); |
---|
1837 | if (filter_typ == 'R') { |
---|
1838 | strcpy( singfilt, filprefix ); |
---|
1839 | strcat( singfilt, filter ); |
---|
1840 | } else { |
---|
1841 | strcpy( singfilt, filter ); |
---|
1842 | } /*endif*/ |
---|
1843 | db_sets( trc, filent, singfilt, status ); |
---|
1844 | if (Severe(status)) return; |
---|
1845 | } else { |
---|
1846 | locstat = cBcNoError; |
---|
1847 | db_gets( trc, filent, BC_FILELTH, singfilt, &locstat ); |
---|
1848 | if (locstat == cBcNoError && *singfilt != '\0') { |
---|
1849 | strcat( complete_name, ";" ); |
---|
1850 | strcat( complete_name, singfilt ); |
---|
1851 | } /*endif*/ |
---|
1852 | } /*endif*/ |
---|
1853 | if (strcmp(complete_name,last_name) != 0) { |
---|
1854 | sprintf( cmd, "fili %c %s", filter_typ, complete_name ); |
---|
1855 | callsh( cmd, &dmy, status ); |
---|
1856 | if (Severe(status)) { |
---|
1857 | *status = BC_NOERROR; |
---|
1858 | if (GpGetInt(cGpI_debug_level) > 1) |
---|
1859 | printf( "SHM-dbg2: filter, %s not available, use dummy filter\n", |
---|
1860 | complete_name ); |
---|
1861 | sprintf( cmd, "fili %c dummy", filter_typ ); |
---|
1862 | callsh( cmd, &dmy, status ); |
---|
1863 | if (Severe(status)) return; |
---|
1864 | } /*endif*/ |
---|
1865 | strcpy( last_name, complete_name ); |
---|
1866 | } /*endif*/ |
---|
1867 | sprintf( cmd, "filter %c a:%lx", filter_typ, trc ); |
---|
1868 | callsh( cmd, &dmy, status ); |
---|
1869 | if (Severe(status)) return; |
---|
1870 | newtrc = db_getp( newtrc, EP_NEXT, NULL ); |
---|
1871 | if (newtrc == NULL) { |
---|
1872 | *status = MXE_PROG_BUG; |
---|
1873 | printf( "*SHM: mx_filter: no trace created\n" ); |
---|
1874 | return; |
---|
1875 | } /*endif*/ |
---|
1876 | sprintf( cmd, "flt:%s", filter ); |
---|
1877 | db_sets( newtrc, ES_COMMENT, cmd, status ); |
---|
1878 | if (Severe(status)) return; |
---|
1879 | db_setf( newtrc, MXC_EF_FILTER, TRUE, status ); |
---|
1880 | if (Severe(status)) return; |
---|
1881 | } else { |
---|
1882 | sprintf( cmd, "copy a:%lx", trc ); |
---|
1883 | callsh( cmd, &dmy, status ); |
---|
1884 | if (Severe(status)) return; |
---|
1885 | newtrc = db_getp( newtrc, EP_NEXT, NULL ); |
---|
1886 | if (newtrc == NULL) { |
---|
1887 | *status = MXE_PROG_BUG; |
---|
1888 | printf( "*SHM: mx_filter: no trace created\n" ); |
---|
1889 | return; |
---|
1890 | } /*endif*/ |
---|
1891 | sprintf( cmd, "flt:NONE" ); |
---|
1892 | db_sets( newtrc, ES_COMMENT, cmd, status ); |
---|
1893 | if (Severe(status)) return; |
---|
1894 | db_setf( newtrc, MXC_EF_FILTER, TRUE, status ); |
---|
1895 | if (Severe(status)) return; |
---|
1896 | } /*endif*/ |
---|
1897 | |
---|
1898 | /* make trace red on alert flag */ |
---|
1899 | if (CUC_F_TRC_ALERT & trcflags) |
---|
1900 | mg_make_alert_trace( w, newtrc, status ); |
---|
1901 | |
---|
1902 | } while (trc != lasttrc); |
---|
1903 | |
---|
1904 | /* cleanup */ |
---|
1905 | sprintf( cmd, "shm_cmd_sepfil_finish %s %f %d", |
---|
1906 | filter, autocut, (GpGetInt(cGpI_trace_normalisation)==cGp_NORM_CONST) ); |
---|
1907 | mx_exec_sh( w, ctrl, cmd ); |
---|
1908 | |
---|
1909 | ts_clear_selections(); |
---|
1910 | |
---|
1911 | } /* end of mxh_filter_separately */ |
---|
1912 | |
---|
1913 | |
---|
1914 | #undef MAX_S_LTH |
---|
1915 | |
---|
1916 | |
---|
1917 | |
---|
1918 | /*----------------------------------------------------------------------------*/ |
---|
1919 | |
---|
1920 | |
---|
1921 | #ifdef XXX |
---|
1922 | |
---|
1923 | #define GRFNUM 19 |
---|
1924 | |
---|
1925 | |
---|
1926 | |
---|
1927 | static void mxh_get_vax_grflist( MX_CMD_READG *rg, char liststr[] ) |
---|
1928 | |
---|
1929 | /* returns list string for readk command |
---|
1930 | * |
---|
1931 | * parameters of routine |
---|
1932 | * MX_CMD_READG *rg; input; read parameters |
---|
1933 | * char liststr[]; output; list string |
---|
1934 | */ |
---|
1935 | { |
---|
1936 | /* local variables */ |
---|
1937 | long statmap; /* station map */ |
---|
1938 | int compmap; /* component map */ |
---|
1939 | int idx[GRFNUM]; /* list of GRF numbers */ |
---|
1940 | int cnt; /* number of stations */ |
---|
1941 | int i; /* counter */ |
---|
1942 | |
---|
1943 | /* executable code */ |
---|
1944 | |
---|
1945 | if (strcmp(rg->sl.code[0],"GRA1") != 0) { |
---|
1946 | strcpy( liststr, "NONE" ); |
---|
1947 | return; |
---|
1948 | } /*endif*/ |
---|
1949 | |
---|
1950 | statmap = 0; |
---|
1951 | compmap = rg->comp; |
---|
1952 | |
---|
1953 | /* make own station map */ |
---|
1954 | for (i=0; i<MXC_STATLIST_LTH; i++) { |
---|
1955 | if ((1<<i) & rg->stations) { |
---|
1956 | if (strncmp(rg->sl.code[i],"GR",2) != 0) continue; |
---|
1957 | if (strcmp(rg->sl.code[i],"GRA1") == 0) statmap |= (1<<STC_GRA1); |
---|
1958 | else if (strcmp(rg->sl.code[i],"GRA2") == 0) statmap |= (1<<STC_GRA2); |
---|
1959 | else if (strcmp(rg->sl.code[i],"GRA3") == 0) statmap |= (1<<STC_GRA3); |
---|
1960 | else if (strcmp(rg->sl.code[i],"GRA4") == 0) statmap |= (1<<STC_GRA4); |
---|
1961 | else if (strcmp(rg->sl.code[i],"GRB1") == 0) statmap |= (1<<STC_GRB1); |
---|
1962 | else if (strcmp(rg->sl.code[i],"GRB2") == 0) statmap |= (1<<STC_GRB2); |
---|
1963 | else if (strcmp(rg->sl.code[i],"GRB3") == 0) statmap |= (1<<STC_GRB3); |
---|
1964 | else if (strcmp(rg->sl.code[i],"GRB4") == 0) statmap |= (1<<STC_GRB4); |
---|
1965 | else if (strcmp(rg->sl.code[i],"GRB5") == 0) statmap |= (1<<STC_GRB5); |
---|
1966 | else if (strcmp(rg->sl.code[i],"GRC1") == 0) statmap |= (1<<STC_GRC1); |
---|
1967 | else if (strcmp(rg->sl.code[i],"GRC2") == 0) statmap |= (1<<STC_GRC2); |
---|
1968 | else if (strcmp(rg->sl.code[i],"GRC3") == 0) statmap |= (1<<STC_GRC3); |
---|
1969 | else if (strcmp(rg->sl.code[i],"GRC4") == 0) statmap |= (1<<STC_GRC4); |
---|
1970 | } /*endif*/ |
---|
1971 | } /*endfor*/ |
---|
1972 | |
---|
1973 | /* create list of GRF numbers */ |
---|
1974 | cnt = 0; |
---|
1975 | if ((1<<STC_GRA1) & statmap && (1<<STC_COMP_Z) & compmap) idx[cnt++] = 1; |
---|
1976 | if ((1<<STC_GRA1) & statmap && (1<<STC_COMP_N) & compmap) idx[cnt++] = 2; |
---|
1977 | if ((1<<STC_GRA1) & statmap && (1<<STC_COMP_E) & compmap) idx[cnt++] = 3; |
---|
1978 | if ((1<<STC_GRA2) & statmap && (1<<STC_COMP_Z) & compmap) idx[cnt++] = 4; |
---|
1979 | if ((1<<STC_GRA3) & statmap && (1<<STC_COMP_Z) & compmap) idx[cnt++] = 5; |
---|
1980 | if ((1<<STC_GRA4) & statmap && (1<<STC_COMP_Z) & compmap) idx[cnt++] = 6; |
---|
1981 | if ((1<<STC_GRB1) & statmap && (1<<STC_COMP_Z) & compmap) idx[cnt++] = 7; |
---|
1982 | if ((1<<STC_GRB1) & statmap && (1<<STC_COMP_N) & compmap) idx[cnt++] = 8; |
---|
1983 | if ((1<<STC_GRB1) & statmap && (1<<STC_COMP_E) & compmap) idx[cnt++] = 9; |
---|
1984 | if ((1<<STC_GRB2) & statmap && (1<<STC_COMP_Z) & compmap) idx[cnt++] = 10; |
---|
1985 | if ((1<<STC_GRB3) & statmap && (1<<STC_COMP_Z) & compmap) idx[cnt++] = 11; |
---|
1986 | if ((1<<STC_GRB4) & statmap && (1<<STC_COMP_Z) & compmap) idx[cnt++] = 12; |
---|
1987 | if ((1<<STC_GRB5) & statmap && (1<<STC_COMP_Z) & compmap) idx[cnt++] = 13; |
---|
1988 | if ((1<<STC_GRC1) & statmap && (1<<STC_COMP_Z) & compmap) idx[cnt++] = 14; |
---|
1989 | if ((1<<STC_GRC1) & statmap && (1<<STC_COMP_N) & compmap) idx[cnt++] = 15; |
---|
1990 | if ((1<<STC_GRC1) & statmap && (1<<STC_COMP_E) & compmap) idx[cnt++] = 16; |
---|
1991 | if ((1<<STC_GRC2) & statmap && (1<<STC_COMP_Z) & compmap) idx[cnt++] = 17; |
---|
1992 | if ((1<<STC_GRC3) & statmap && (1<<STC_COMP_Z) & compmap) idx[cnt++] = 18; |
---|
1993 | if ((1<<STC_GRC4) & statmap && (1<<STC_COMP_Z) & compmap) idx[cnt++] = 19; |
---|
1994 | |
---|
1995 | /* put this list into a string */ |
---|
1996 | if (cnt == 0) { strcpy( liststr, "NONE" ); return; } |
---|
1997 | sprintf( liststr, "%d", idx[0] ); |
---|
1998 | for (i=1; i<cnt; i++) |
---|
1999 | sprintf( liststr+strlen(liststr), ",%d", idx[i] ); |
---|
2000 | |
---|
2001 | } /* end of mxh_get_vax_grflist */ |
---|
2002 | |
---|
2003 | #endif |
---|
2004 | |
---|
2005 | /*----------------------------------------------------------------------------*/ |
---|
2006 | |
---|
2007 | |
---|
2008 | |
---|
2009 | static void mxh_mount_cdrom( MX_CMD_READG *par, STATUS *status ) |
---|
2010 | |
---|
2011 | /* mounts cdrom for reading |
---|
2012 | * |
---|
2013 | * parameters of routine |
---|
2014 | * MX_CMD_READG *par; input/modify; read command parameters |
---|
2015 | * STATUS *status; output; return status |
---|
2016 | */ |
---|
2017 | { |
---|
2018 | /* local variables */ |
---|
2019 | int i; /* counter */ |
---|
2020 | char stream[BC_LINELTH+1]; /* stream string */ |
---|
2021 | char cmdline[BC_LONGSTRLTH+1]; /* command line */ |
---|
2022 | char *env; /* pointer to environment */ |
---|
2023 | TSyBoolean redraw; /* not used */ |
---|
2024 | TSyStatus locstat; /* not used */ |
---|
2025 | TSyBoolean is_sol2; /* is Solaris 2 machine */ |
---|
2026 | |
---|
2027 | /* executable code */ |
---|
2028 | |
---|
2029 | if (par->channum == 0) { |
---|
2030 | *status = MXE_NOCHANNELS; |
---|
2031 | return; |
---|
2032 | } else if (par->channum > 1) { |
---|
2033 | printf( "*SHM: take only first channel selected\n" ); |
---|
2034 | } /*endif*/ |
---|
2035 | |
---|
2036 | /* find first station in list */ |
---|
2037 | for (i=0; i<MXC_STATLIST_LTH; i++) |
---|
2038 | if ((1<<i) & par->stations) break; |
---|
2039 | |
---|
2040 | /* if no station selected return */ |
---|
2041 | if (i == MXC_STATLIST_LTH) { |
---|
2042 | *status = MXE_NOSTATIONS; |
---|
2043 | return; |
---|
2044 | } /*endif*/ |
---|
2045 | |
---|
2046 | /* build stream name from first station */ |
---|
2047 | strcpy( stream, par->sl.code[i] ); |
---|
2048 | strcat( stream, "-" ); |
---|
2049 | strcat( stream, par->chanstr[0] ); |
---|
2050 | strcat( stream, "-z" ); |
---|
2051 | ut_uncap( stream ); |
---|
2052 | |
---|
2053 | is_sol2 = cl_is_solaris_2(); |
---|
2054 | |
---|
2055 | /* close SEED files */ |
---|
2056 | locstat = BC_NOERROR; |
---|
2057 | callsh( "reads/close", &redraw, &locstat ); |
---|
2058 | |
---|
2059 | /* build and execute command line */ |
---|
2060 | if (is_sol2) { |
---|
2061 | /* *cmdline = '\0'; */ |
---|
2062 | strcpy( cmdline, "cmdtool " ); |
---|
2063 | } else { |
---|
2064 | strcpy( cmdline, "cmdtool " ); |
---|
2065 | } /*endif*/ |
---|
2066 | env = getenv( "SEED_PROG" ); |
---|
2067 | if (env != NULL) { |
---|
2068 | strcat( cmdline, env ); |
---|
2069 | strcat( cmdline, "/" ); |
---|
2070 | } /*endif*/ |
---|
2071 | sprintf( cmdline+strlen(cmdline), "szgrf_cd_mount.csh %s %s", |
---|
2072 | stream, par->start ); |
---|
2073 | system( cmdline ); |
---|
2074 | |
---|
2075 | if (is_sol2) { |
---|
2076 | strcpy( par->device, "/cdrom/cdrom0" ); |
---|
2077 | } else { |
---|
2078 | strcpy( par->device, "/cdrom" ); |
---|
2079 | } /*endif*/ |
---|
2080 | |
---|
2081 | } /* end of mxh_mount_cdrom */ |
---|
2082 | |
---|
2083 | |
---|
2084 | |
---|
2085 | /*----------------------------------------------------------------------------*/ |
---|
2086 | |
---|
2087 | |
---|
2088 | |
---|
2089 | static void mxh_set_entry_name( Widget ew, char text[] ) |
---|
2090 | |
---|
2091 | /* Sets menu entry text |
---|
2092 | * |
---|
2093 | * parameters of routine |
---|
2094 | * Widget ew; input; menu entry widget |
---|
2095 | * char text[]; input; new text for widget |
---|
2096 | */ |
---|
2097 | { |
---|
2098 | /* local variables */ |
---|
2099 | char ltext[cBcLineLth+1]; /* local copy of text to remove '_' */ |
---|
2100 | Arg args[2]; /* argument list */ |
---|
2101 | int n; /* argument counter */ |
---|
2102 | XmString xmstr; /* Xm string */ |
---|
2103 | |
---|
2104 | /* executable code */ |
---|
2105 | |
---|
2106 | if (strlen(text) >= cBcLineLth) { |
---|
2107 | fprintf( stderr, "*SHM: mxh_set_entry_name: name too long\n" ); |
---|
2108 | return; |
---|
2109 | } /*endif*/ |
---|
2110 | strcpy( ltext, text ); |
---|
2111 | for (n=0; n<strlen(ltext); n++) |
---|
2112 | if (ltext[n] == '_') ltext[n] = ' '; |
---|
2113 | |
---|
2114 | xmstr = XmStringCreateLtoR( ltext, "" ); |
---|
2115 | n = 0; |
---|
2116 | XtSetArg( args[n], XmNlabelString, xmstr ); n++; |
---|
2117 | XtSetValues( ew, args, n ); |
---|
2118 | |
---|
2119 | } /* end of mxh_set_entry_name */ |
---|
2120 | |
---|
2121 | |
---|
2122 | |
---|
2123 | /*----------------------------------------------------------------------------*/ |
---|
2124 | |
---|
2125 | |
---|
2126 | |
---|
2127 | void mx_remove_double_elements( char str[] ) |
---|
2128 | |
---|
2129 | /* removes double elements from comma separated list |
---|
2130 | * |
---|
2131 | * parameters of routine |
---|
2132 | * char str[]; modify; list |
---|
2133 | */ |
---|
2134 | { |
---|
2135 | /* local variables */ |
---|
2136 | TGpTextList tl; /* text list */ |
---|
2137 | int i, j; /* counters */ |
---|
2138 | |
---|
2139 | /* executable code */ |
---|
2140 | |
---|
2141 | GpParseTextList( str, &tl ); |
---|
2142 | |
---|
2143 | for (i=0; i<tl.numelem; i++) |
---|
2144 | for (j=(i+1); j<tl.numelem; j++) |
---|
2145 | if (strcmp(tl.elem[i],tl.elem[j]) == 0) |
---|
2146 | tl.elem[j][0] = '\0'; |
---|
2147 | |
---|
2148 | strcpy( str, tl.elem[0] ); |
---|
2149 | for (i=1; i<tl.numelem; i++) { |
---|
2150 | if (tl.elem[i][0] != '\0') { |
---|
2151 | strcat( str, "," ); |
---|
2152 | strcat( str, tl.elem[i] ); |
---|
2153 | } /*endif*/ |
---|
2154 | } /*endfor*/ |
---|
2155 | |
---|
2156 | GpFreeTextList( &tl ); |
---|
2157 | |
---|
2158 | } /* end of mx_remove_double_elements */ |
---|
2159 | |
---|
2160 | |
---|
2161 | |
---|
2162 | /*----------------------------------------------------------------------------*/ |
---|
2163 | |
---|
2164 | |
---|
2165 | |
---|
2166 | void mxh_compute_azimuth( char station[], float lat, float lon, |
---|
2167 | float *azim, TSyStatus *status ) |
---|
2168 | |
---|
2169 | /* Computes azimuth from station and epicentre location |
---|
2170 | * |
---|
2171 | * parameters of routine |
---|
2172 | * char cstation[]; input; name of station |
---|
2173 | * float lat, lon; input; epicentre location |
---|
2174 | * float *azim; output; azimuth computed |
---|
2175 | * TSyStatus *status; output; return status |
---|
2176 | */ |
---|
2177 | { |
---|
2178 | /* local variables */ |
---|
2179 | GLT_STATINF *statinf; /* station info */ |
---|
2180 | double d_dist, d_azim, d_bazim; |
---|
2181 | |
---|
2182 | /* executable code */ |
---|
2183 | |
---|
2184 | statinf = gl_store_station( station, TRUE, status ); |
---|
2185 | if (Severe(status)) return; |
---|
2186 | mb_locdiff( statinf->lat, statinf->lon, lat, lon, |
---|
2187 | &d_dist, &d_azim, &d_bazim ); |
---|
2188 | *azim = d_bazim; |
---|
2189 | |
---|
2190 | } /* end of mxh_compute_azimuth */ |
---|
2191 | |
---|
2192 | |
---|
2193 | |
---|
2194 | /*----------------------------------------------------------------------------*/ |
---|
2195 | |
---|
2196 | |
---|
2197 | static void mxh_read_stations_from_evt( char autoevt[], char addlist[] ) |
---|
2198 | |
---|
2199 | /* Reads station list from evtfile |
---|
2200 | * |
---|
2201 | * parameters of routine |
---|
2202 | * char autoevt[]; input: name of evt file |
---|
2203 | * char addlist[]; output; list of station names |
---|
2204 | */ |
---|
2205 | { |
---|
2206 | /* local variables */ |
---|
2207 | FILE *fp; /* pointer to file */ |
---|
2208 | char tmpfile[cBcFileLth+1]; /* temporary file */ |
---|
2209 | static int fcnt=1; /* temp file counter */ |
---|
2210 | char shellcmd[cBcLongStrLth+1]; /* shell command */ |
---|
2211 | char line[cBcLineLth+1]; /* current line in file */ |
---|
2212 | int i; /* counter */ |
---|
2213 | |
---|
2214 | /* executable code */ |
---|
2215 | |
---|
2216 | *addlist = '\0'; |
---|
2217 | sprintf( tmpfile, "/tmp/ae_stations_%d.000", fcnt++ ); |
---|
2218 | sprintf( shellcmd, |
---|
2219 | "grep 'Station code :' %s | awk '{print $4}' | sort -u >%s", |
---|
2220 | autoevt, tmpfile ); |
---|
2221 | printf( "executing: %s\n", shellcmd ); |
---|
2222 | system( shellcmd ); |
---|
2223 | fp = fopen( tmpfile, "r" ); |
---|
2224 | while (fgets(line,cBcLineLth,fp) != NULL) { |
---|
2225 | i = strlen( line ); |
---|
2226 | if (line[i-1] == '\n') line[i-1] = '\0'; |
---|
2227 | if (strlen(addlist) > cBcLongStrLth-2) { |
---|
2228 | fclose( fp ); |
---|
2229 | printf( "*SHM: evt station list truncated\n" ); |
---|
2230 | return; |
---|
2231 | } /*endif*/ |
---|
2232 | if (*addlist != '\0') strcat( addlist, "," ); |
---|
2233 | strcat( addlist, line ); |
---|
2234 | } /*endwhile*/ |
---|
2235 | fclose( fp ); |
---|
2236 | } |
---|
2237 | |
---|
2238 | |
---|
2239 | /*----------------------------------------------------------------------------*/ |
---|
2240 | |
---|
2241 | |
---|
2242 | |
---|
2243 | static void mxh_read_location_from_evt( char autoevt[], float *lat, float *lon, |
---|
2244 | TSyBoolean *found ) |
---|
2245 | |
---|
2246 | /* Reads latitude and longitude from evt file |
---|
2247 | * |
---|
2248 | * parameters of routine |
---|
2249 | * char autoevt[]; input; name of evt file |
---|
2250 | * float *lat, *lon; output; location read from above file |
---|
2251 | * TSyBoolean *found; output; TRUE if location is found |
---|
2252 | */ |
---|
2253 | { |
---|
2254 | /* local variables */ |
---|
2255 | FILE *fp; /* pointer to file */ |
---|
2256 | char line[cBcLineLth+1]; /* current line of file */ |
---|
2257 | TSyBoolean latfound, lonfound; /* latitude and longitude found */ |
---|
2258 | int i; /* counter */ |
---|
2259 | |
---|
2260 | /* executable code */ |
---|
2261 | |
---|
2262 | /* open evt file */ |
---|
2263 | *found = TRUE; |
---|
2264 | fp = fopen( autoevt, "r" ); |
---|
2265 | if (fp == NULL) { |
---|
2266 | *found = FALSE; |
---|
2267 | return; |
---|
2268 | } /*endif*/ |
---|
2269 | |
---|
2270 | /* read through file */ |
---|
2271 | latfound = lonfound = FALSE; |
---|
2272 | while (fgets(line,cBcLineLth,fp) != NULL) { |
---|
2273 | if (strncmp(line,"Latitude ",9) == 0) { |
---|
2274 | i = 9; /* length of Latitude string */ |
---|
2275 | while (line[i] == ' ' || line[i] == ':') |
---|
2276 | i++; |
---|
2277 | if (sscanf(line+i,"%f",lat) == 1) |
---|
2278 | latfound = TRUE; |
---|
2279 | } /*endif*/ |
---|
2280 | if (strncmp(line,"Longitude ",10) == 0) { |
---|
2281 | i = 10; /* length of Latitude string */ |
---|
2282 | while (line[i] == ' ' || line[i] == ':') |
---|
2283 | i++; |
---|
2284 | if (sscanf(line+i,"%f",lon) == 1) |
---|
2285 | lonfound = TRUE; |
---|
2286 | } /*endif*/ |
---|
2287 | if (latfound && lonfound) |
---|
2288 | break; |
---|
2289 | } /*endwhile*/ |
---|
2290 | |
---|
2291 | if (!latfound || !lonfound) { |
---|
2292 | *found = FALSE; |
---|
2293 | return; |
---|
2294 | } /*endif*/ |
---|
2295 | |
---|
2296 | fclose( fp ); |
---|
2297 | |
---|
2298 | } /* end of mxh_read_location_from_evt */ |
---|
2299 | |
---|
2300 | |
---|
2301 | |
---|
2302 | /*----------------------------------------------------------------------------*/ |
---|