/*--------------------------------------------------------------------- PWS16MAIN written by L. Granroth 08-24-88 last modified by Bob Baines 11-17-90 Versions - Two versions of program (now combined into one program) Client: to utilize DECnet-DOS Transparent Task-to-Task (TTT) capabilities and function as a "PWS16" client which displays Voyager PWS data requested from the PWS16_SERVER at IOWASP::. Processor Client: to process Voyager PWS data files directly. * IN DEVELOPMENT * 08-26-88 converted to "Unix-like" i/o (necessary for TTT) -ljg 09-11-88 converted server and client to exchange 2-byte integers instead of "VAX R*2" -ljg 10-14-88 Client now requests device-specific number of time bins. Graphics routines in separate module. -ljg 07-26-89 Snapshot Feature Installed. Peaks and Averages data plotted. Functions in several separate modules. External text file containing help added (keep with executable). -bb 11-01-90 Change from client only program to one full version that includes client version and a complete version (PC requires only data files). Uses config file to set various defaults. Complete version reads in normal data files or compressed data files (set-up in config file). Uses colors for plotting normal plots (scaling mode still uses only b/w shades). Uses external BGI driver. ---------------------------------------------------------------------*/ #define MAIN #include #include #include #include #include "pwstruct.h" #include "proto.h" #include "pwsglobl.h" /* Global Vars shared with PWS16FNC module*/ kmd_type *kmd; boolean setchan; boolean more; boolean Snapshot = FALSE; char *tp[MAXTOK]; /* token pointer */ int ki[MAXTOK]; /* keyword idx */ int idx; /* Internal Function Prototypes (functions specific only to this module) */ void init(void); void process_params(int, char**); void snap_prep(void); int pws16_control (void); /* user interface and control routine */ void pws16_help (void); /* Display Help Menu */ void cleanup(void); /* Internal Global Vars */ char output_dev[9] = "UNKNOWN"; char node_loc[LLEN] = "\\\\t\\IOWASP\\PWSERVER\\PASSWORD\\\\#133"; void main (int argc, char *argv[]) /* PWS16MAIN */ { /* init vars, read config file, etc..... */ define_commands(); init(); process_params(argc, argv); /* open communication - file pointer dependent on type of communication */ pws16_begin(); /* LOOP - process each command until done */ while (pws16_control()) { /* request data and if goes okay get data and plot channel by channel */ if (pws16_command()) { label(); while (pws16_data()) plot(); } else printf ("No data found for interval beginning: %2i %03i %02i%02i\n", Cmd.year,Cmd.day,Cmd.hour,Cmd.minute); } /* close communication */ pws16_end(); /* do any cleaning up as is neccesary */ cleanup(); } /* PWS16PC - PWS16 client */ /*--------------------------------------------------------------------- INIT written by R. Baines 6/90. to handle various settings required for customizing the setup of combined version of program. Also allows aliases, setting of screen colors and external bgi declarations. ---------------------------------------------------------------------*/ void init(void) { FILE *fp; char line[LLEN], *command, *parameter, *p1, *p2; int i; /* create arrays dynamically because it static would make executable BIG */ for (i=0; i 1) if (strcmp(strlwr(param[1]),"-v")==0) strcpy(output_dev, param[2]); else if (strcmp(strlwr(param[1]), "-n") == 0) strcpy(node_loc, param[2]); /* if there is a second parameter process it */ if (count > 3) if (strcmp(strlwr(param[3]), "-v") == 0) strcpy(output_dev, param[4]); else if (strcmp(strlwr(param[3]), "-n") == 0) strcpy(node_loc, param[4]); } /*--------------------------------------------------------------------- PWS16_CONTROL written by L. Granroth 08-26-88 to handle the user interface, set up the network command structure, and pass the data request to the network routine servicing the PWS16PC program. Nonzero is returned for normal status and zero is returned when program termination is requested. Forget survey and fp options for now. ---------------------------------------------------------------------*/ int pws16_control (void) { static struct old_params old = {0,0,0,0,0,0,0,0,0L,0L}; /* keep track of previous parameters*/ static char *delim="\t =,:/"; /* input token delimiters */ static char *endtok="endtok"; char card[LLEN]; /* input command "card" */ int i,j,numtok; char *p; /* reset variables */ setchan=FALSE; Cmin=Cmd.chan[0]; Cmax=Cmd.chan[Cmd.nchan-1]; /* read data cards */ do { more = FALSE; printf ("> "); if (!gets(card)) { if (feof(stdin)) return(FALSE); strcpy (card,"HELP"); } /* semicolon is a line terminator */ if (p=strchr(card,';')) p[0]='\0'; strupr (card); printf ("> %s\n",card); /* Copy Card so can display on graphic screen later */ strcpy(Cmdline, card); /* tokenize data card */ i=0; tp[i]=strtok(card,delim); while ((i=0;idx--) /* check against keyword table */ { ki[idx] = 0; for (j=1;j