├── old_ads ├── hdrcvt852 ├── hdrdump_all ├── fldump.c ├── oldhdr.h ├── Makefile ├── ohdump.c ├── hdrdump_all.c ├── telford.c ├── hdrdump.c ├── hd.c └── hdrcvt852.c ├── dup.ads ├── Makefile └── dup.ads.cc ├── edADShdr ├── define.h ├── Makefile ├── init.c ├── edADShdr.c ├── fbr.h ├── ccb.c └── Xwin.c ├── rtplot_motif ├── misc1.c ├── misc1.cc ├── error.cc ├── Colors.h ├── CanvasWindow.h ├── misc.cc ├── init.cc ├── global.cc ├── Makefile ├── rtplot.cc ├── memalloc.cc ├── amlibfn.cc ├── rtplot.1 ├── define.h ├── extern.h ├── rtloop.cc ├── autoscale.cc ├── rec_decode.cc ├── Colors.cc ├── ccb.cc ├── dataIO.cc ├── CanvasWindow.cc ├── fbr.h ├── Xwin.cc ├── Xplot.cc └── hdr_decode.cc ├── dup2d ├── Makefile └── dup2d.c ├── dnload ├── Makefile ├── tpfix.c ├── tppn.c ├── tps.c ├── dnload.c └── dnload.cc ├── dmptime ├── Makefile └── dmptime.cc ├── dump1d └── dump1d.cc ├── strip2d └── strip2d.cc ├── sppSim └── sppSim.c ├── mcr └── mcr_cut.cc ├── gpsChk.c └── LICENSE /old_ads/hdrcvt852: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NCAR/aircraft_ads2_utils/master/old_ads/hdrcvt852 -------------------------------------------------------------------------------- /old_ads/hdrdump_all: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NCAR/aircraft_ads2_utils/master/old_ads/hdrdump_all -------------------------------------------------------------------------------- /dup.ads/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for dup.ads program 3 | # 4 | CC= g++ 5 | BINDIR= ${JLOCAL}/bin 6 | INCLUDES= -I${JLOCAL}/include 7 | CXXFLAGS= ${INCLUDES} 8 | 9 | LIBS= -L${JLOCAL}/lib -lraf -lz 10 | 11 | SRCS= dup.ads.cc 12 | OBJS= dup.ads.o 13 | PROG= dup.ads 14 | 15 | ${PROG}: ${OBJS} 16 | ${CC} ${CXXFLAGS} ${OBJS} ${LIBS} -o $@ 17 | 18 | install: ${PROG} 19 | cp ${PROG} ${BINDIR} 20 | 21 | clean: 22 | rm -f ${OBJS} ${PROG} 23 | -------------------------------------------------------------------------------- /edADShdr/define.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | Widget CreateMainWindow(Widget Shell000); 6 | 7 | 8 | void Initialize(int argc, char *argv[]), 9 | OpenNewFile(Widget w, XtPointer client, XtPointer call), 10 | OpenNewFile_OK(Widget w, XtPointer client, XmFileSelectionBoxCallbackStruct *call), 11 | SaveFile(Widget w, XtPointer client, XtPointer call), 12 | Quit(Widget w, XtPointer client, XtPointer call); 13 | 14 | -------------------------------------------------------------------------------- /rtplot_motif/misc1.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* --------------------------------------------------------------------- */ 4 | void LogMessage(char msg[]) 5 | { 6 | fprintf(stderr, "%s", msg); 7 | 8 | } 9 | 10 | /* --------------------------------------------------------------------- */ 11 | float angcr(float angle2, float angle1, float syncro_range, float amin) 12 | { 13 | return(angle2); 14 | } 15 | 16 | /* --------------------------------------------------------------------- */ 17 | float GetDefaultsValue() 18 | { 19 | return(0.0); 20 | } 21 | -------------------------------------------------------------------------------- /dup2d/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for dnload 3 | # 4 | DESTDIR= /home/local 5 | BINDIR= ${DESTDIR}/bin 6 | MANDIR= ${DESTDIR}/man/manl 7 | INCDIR= ${DESTDIR}/include 8 | 9 | LIBS= -lraf 10 | INCLUDES= -I$(INCDIR) 11 | 12 | CC= gcc 13 | CFLAGS= ${INCLUDES} 14 | 15 | SRCS= dup2d.c 16 | PROG= dup2d 17 | 18 | .c.o: 19 | ${CC} ${CFLAGS} -c $*.c 20 | 21 | ${PROG}: dup2d.c 22 | ${CC} ${CFLAGS} dup2d.c ${LIBS} -o $@ 23 | 24 | install: ${PROG} 25 | cp ${PROG} ${BINDIR} 26 | 27 | clean: 28 | rm -f core ${PROGS} 29 | 30 | print: 31 | enscript -2Gr -bHdrUtils ${HDRS} ${SRCS} 32 | -------------------------------------------------------------------------------- /dnload/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for dnload 3 | # 4 | DESTDIR= ${JLOCAL} 5 | BINDIR= ${DESTDIR}/bin 6 | MANDIR= ${DESTDIR}/man/manl 7 | INCDIR= ${DESTDIR}/include/raf 8 | 9 | LIBS= -L${JLOCAL}/lib -lraf -lz 10 | INCLUDES= -I$(INCDIR) 11 | 12 | CC= g++ 13 | CFLAGS= ${INCLUDES} 14 | 15 | SRCS= dnload.cc 16 | PROG= dnload 17 | 18 | .c.o: 19 | ${CC} ${CFLAGS} -c $*.c 20 | 21 | ${PROG}: dnload.cc ${JLOCAL}/lib/libraf.a 22 | ${CC} ${CFLAGS} dnload.cc ${LIBS} -o $@ 23 | 24 | install: ${PROG} 25 | cp ${PROG} ${BINDIR} 26 | 27 | clean: 28 | rm -f core ${PROG} 29 | 30 | print: 31 | enscript -2Gr -bdnload ${HDRS} ${SRCS} 32 | -------------------------------------------------------------------------------- /dmptime/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for dmptime 3 | # 4 | DESTDIR= ${JLOCAL} 5 | BINDIR= ${DESTDIR}/bin 6 | MANDIR= ${DESTDIR}/man/manl 7 | INCDIR= ${DESTDIR}/include/raf 8 | 9 | LIBS= -L${JLOCAL}/lib -lraf -lz 10 | INCLUDES= -I$(INCDIR) 11 | 12 | CC= g++ 13 | CFLAGS= ${INCLUDES} 14 | 15 | SRCS= dmptime.cc 16 | PROG= dmptime 17 | 18 | .c.o: 19 | ${CC} ${CFLAGS} -c $*.c 20 | 21 | ${PROG}: dmptime.cc ${JLOCAL}/lib/libraf.a 22 | ${CC} ${CFLAGS} dmptime.cc ${LIBS} -o $@ 23 | 24 | install: ${PROG} 25 | cp ${PROG} ${BINDIR} 26 | 27 | clean: 28 | rm -f core ${PROG} 29 | 30 | print: 31 | enscript -2Gr -bdmptime ${HDRS} ${SRCS} 32 | -------------------------------------------------------------------------------- /rtplot_motif/misc1.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "raf/header.h" 3 | 4 | /* --------------------------------------------------------------------- */ 5 | void LogMessage(char msg[]) 6 | { 7 | fprintf(stderr, "%s", msg); 8 | 9 | } 10 | 11 | /* --------------------------------------------------------------------- */ 12 | float angcr(float angle2, float angle1, float syncro_range, float amin) 13 | { 14 | return(angle2); 15 | } 16 | 17 | /* --------------------------------------------------------------------- */ 18 | float GetDefaultsValue(char *s1, char *s2) 19 | { 20 | return(0.0); 21 | } 22 | 23 | /* --------------------------------------------------------------------- */ 24 | int Next2dRecord(P2d_rec *record, int probeCnt, short id) 25 | { 26 | return(0); 27 | } 28 | -------------------------------------------------------------------------------- /rtplot_motif/error.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: error.c 4 | 5 | FULL NAME: Handle Errors 6 | 7 | DESCRIPTION: This procudures displays errors based on wether we are in 8 | interactive mode or not. For interactive mode it displays 9 | an X window, otherwise a fprintf to stderr. The second 10 | parameter tells the procedure wether to return or do an 11 | exit. 12 | 13 | INPUT: Message, Weather to exit or return. 14 | 15 | OUTPUT: Error message. 16 | 17 | AUTHOR: websterc@ncar 18 | ------------------------------------------------------------------------- 19 | */ 20 | 21 | #include "define.h" 22 | 23 | void HandleError(char s[]) 24 | { 25 | fprintf(stderr, "%s\n", s); 26 | exit(1); 27 | 28 | } /* END HANDLERROR */ 29 | 30 | /* END ERROR.C */ 31 | -------------------------------------------------------------------------------- /edADShdr/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for edADShdr program 3 | # 4 | CC= gcc 5 | BINDIR= ${JLOCAL}/bin 6 | MANDIR= ${JLOCAL}/man/manl 7 | LINTLIBS= ${LIBS} 8 | INCLUDES= -I${JLOCAL}/include 9 | CFLAGS= -O2 ${INCLUDES} 10 | 11 | # Solaris 12 | LIBS= -lraf -lXm -lXt -lX11 13 | 14 | #Linux 15 | LIBS= -L${JLOCAL}/lib -lraf -lXm -lXt -lX11 -lXp -lXext 16 | 17 | SRCS= edADShdr.c init.c Xwin.c ccb.c 18 | HDRS= define.h 19 | OBJS= edADShdr.o init.o Xwin.o ccb.o 20 | PROG= edADShdr 21 | 22 | .c.o: 23 | ${CC} ${CFLAGS} -c $*.c 24 | 25 | ${PROG}: ${OBJS} 26 | ${CC} ${CFLAGS} ${OBJS} ${LIBS} -o $@ 27 | 28 | install: ${PROG} 29 | cp ${PROG} ${BINDIR} 30 | # install -m 444 ${PROG}.l ${MANDIR} 31 | 32 | clean: 33 | rm -f ${OBJS} ${PROG} 34 | 35 | lint: 36 | lint ${INCLUDES} ${SRCS} ${LINTLIBS} 37 | 38 | print: 39 | enscript -2Gr -b${PROG} ${HDRS} ${SRCS} 40 | 41 | #${OBJS}: ${HDRS} 42 | -------------------------------------------------------------------------------- /dump1d/dump1d.cc: -------------------------------------------------------------------------------- 1 | #include "raf/adsIO.h" 2 | 3 | char buffer[MX_PHYS]; 4 | 5 | main(int argc, char *argv[]) 6 | { 7 | int i, j; 8 | Hdr_blk *h = (Hdr_blk *)buffer; 9 | Pms1v2 *pp; 10 | P16v2_blk *dp; 11 | 12 | ADS_DataFile file("/home/data/101tf01.ads"); 13 | 14 | 15 | file.FirstSyncRecord(buffer); 16 | 17 | 18 | do 19 | { 20 | printf("%02d:%02d:%02d -----------\n", h->hour, h->minute, h->second); 21 | 22 | for (pp = file.hdr->GetFirst("PMS1V2"); pp; pp = file.hdr->GetNext("PMS1V2")) 23 | { 24 | dp = (P16v2_blk*)(&buffer[file.hdr->Start(pp)]); 25 | printf("%s\n", file.hdr->VariableName(pp)); 26 | 27 | for (i = 0; i < file.hdr->SampleRate(pp); ++i) 28 | { 29 | for (j = 0; j < 8; ++j) 30 | printf("%5d ", dp[i].aux[j]); 31 | 32 | printf("\n"); 33 | } 34 | } 35 | } 36 | while (file.NextSyncRecord(buffer)); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /old_ads/fldump.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "raf/header.h" 3 | 4 | main(int argc, char *argv[]) 5 | { 6 | FILE *fp; 7 | Fl flInfo; 8 | 9 | if (argc < 2) 10 | { 11 | fprintf(stderr, "Usage: fldump header_file_name.\n"); 12 | return(1); 13 | } 14 | 15 | if ((fp = fopen(argv[1], "rb")) == NULL) 16 | { 17 | fprintf(stderr, "Can't open %s.\n", argv[1]); 18 | return(1); 19 | } 20 | 21 | fread((char *)&flInfo, sizeof(Fl), 1, fp); 22 | fclose(fp); 23 | 24 | printf("Fl.thdr\t\t%s\n", flInfo.thdr); 25 | printf("Fl.item_len\t%d\n", flInfo.item_len); 26 | printf("Fl.version\t%s\n", flInfo.version); 27 | printf("Fl.prnum\t%s\n", flInfo.prnum); 28 | printf("Fl.acraft\t%s\n", flInfo.acraft); 29 | printf("Fl.n_items\t%d\n", flInfo.n_items); 30 | printf("Fl.lrlen\t%d\n", flInfo.lrlen); 31 | printf("Fl.lrppr\t%d\n", flInfo.lrppr); 32 | printf("Fl.thdrlen\t%d\n", flInfo.thdrlen); 33 | printf("Fl.ads_type\t%s\n", flInfo.ads_type); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /strip2d/strip2d.cc: -------------------------------------------------------------------------------- 1 | /* strip 2d records from an ADS file and produce a 2d file (including headers). 2 | */ 3 | #include 4 | #include 5 | #include 6 | 7 | char buffer[0x8000]; 8 | 9 | main() 10 | { 11 | int i, len; 12 | char sourceFile[512], destFile[512]; 13 | FILE *outFP; 14 | P2d_rec rec; 15 | 16 | printf("Enter source ADS file : "); 17 | gets(sourceFile); 18 | 19 | printf("Enter destination 2D file : "); 20 | gets(destFile); 21 | 22 | 23 | ADS_DataFile source(sourceFile); 24 | 25 | if ((outFP = fopen(destFile, "w+b")) == NULL) 26 | { 27 | fprintf(stderr, "Can't open output file %s, errno=%d\n", destFile); 28 | exit(1); 29 | } 30 | 31 | 32 | for (i = 0; i < 3; ++i) 33 | { 34 | len = source.NextPhysicalRecord(buffer); 35 | fwrite(buffer, len, 1, outFP); 36 | } 37 | 38 | while (source.NextPMS2dRecord(&rec)) 39 | fwrite(&rec, sizeof(P2d_rec), 1, outFP); 40 | 41 | fclose(outFP); 42 | 43 | } 44 | -------------------------------------------------------------------------------- /edADShdr/init.c: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: init.c 4 | 5 | FULL NAME: Initialize Global Variables 6 | 7 | ENTRY POINTS: Initialize() 8 | 9 | STATIC FNS: none 10 | 11 | DESCRIPTION: 12 | 13 | INPUT: none 14 | 15 | OUTPUT: none 16 | 17 | REFERENCES: none 18 | 19 | REFERENCED BY: setup.c 20 | 21 | COPYRIGHT: University Corporation for Atmospheric Research, 2000 22 | ------------------------------------------------------------------------- 23 | */ 24 | 25 | #include "define.h" 26 | 27 | char buffer[1024], FileName[1024], *DataDirectory; 28 | Fl flInfo; 29 | 30 | char *getenv(); 31 | 32 | 33 | /* -------------------------------------------------------------------- */ 34 | void Initialize(int argc, char *argv[]) 35 | { 36 | DataDirectory = (char *)getenv("DATA_DIR"); 37 | 38 | if (argc > 1) 39 | { 40 | strcpy(FileName, argv[1]); 41 | OpenNewFile_OK(NULL, NULL, NULL); 42 | } 43 | 44 | } /* END INITIALIZE */ 45 | 46 | /* END INIT.C */ 47 | -------------------------------------------------------------------------------- /rtplot_motif/Colors.h: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: Colors.h 4 | 5 | FULL NAME: Colors 6 | 7 | TYPE: 8 | 9 | DESCRIPTION: Provide a series of Colors that are always the same for 10 | both X & PostScript. 11 | 12 | NOTES: 13 | 14 | COPYRIGHT: University Corporation for Atmospheric Research, 1997-8 15 | ------------------------------------------------------------------------- 16 | */ 17 | 18 | #ifndef COLORS_H 19 | #define COLORS_H 20 | 21 | #include "define.h" 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | 28 | /* -------------------------------------------------------------------- */ 29 | class Colors { 30 | 31 | public: 32 | Colors(const Widget w); 33 | 34 | void ResetColors(); 35 | ulong GetColor(int indx); 36 | ulong NextColor(); 37 | ulong CurrentColor(); 38 | 39 | float *GetColorPS(int indx); 40 | float *NextColorPS(); 41 | float *CurrentColorPS(); 42 | 43 | private: 44 | int colorIndex; 45 | bool Color; 46 | 47 | }; /* END COLORS.H */ 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /rtplot_motif/CanvasWindow.h: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: CanvasWindow.h 4 | 5 | FULL NAME: Create Main Canvas Window 6 | 7 | TYPE: 8 | 9 | DESCRIPTION: 10 | 11 | NOTES: 12 | 13 | COPYRIGHT: University Corporation for Atmospheric Research, 1997-9 14 | ------------------------------------------------------------------------- 15 | */ 16 | 17 | #ifndef CANWINDOW_H 18 | #define CANWINDOW_H 19 | 20 | #include "define.h" 21 | 22 | #include "Window.h" 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | 34 | /* -------------------------------------------------------------------- */ 35 | class CanvasWindow : public WinForm { 36 | 37 | public: 38 | CanvasWindow(const Widget parent); 39 | 40 | Widget DrawingArea() { return(drawA); } 41 | Widget List() { return(varList); } 42 | 43 | 44 | private: 45 | Widget drawA, varList; 46 | 47 | }; /* END CANVASWINDOW.H */ 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /rtplot_motif/misc.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: misc.c 4 | 5 | FULL NAME: Calculate Spacing & Bar Width 6 | 7 | DESCRIPTION: 8 | 9 | INPUT: 10 | 11 | OUTPUT: 12 | ------------------------------------------------------------------------- 13 | */ 14 | 15 | #include "define.h" 16 | #include 17 | 18 | /* -------------------------------------------------------------------- */ 19 | void MakeTicLabel(char buffer[], double diff, double value) 20 | { 21 | long i_diff = (long)diff; 22 | 23 | if (diff < 0.01) 24 | sprintf(buffer, "%f", value); 25 | else 26 | if (diff < 0.1) 27 | sprintf(buffer, "%.4f", value); 28 | else 29 | if (diff < 1.0) 30 | sprintf(buffer, "%.3f", value); 31 | else 32 | if (i_diff % 10 == 0) 33 | sprintf(buffer, "%ld", (long)value); 34 | else 35 | if (diff < 10.0) 36 | sprintf(buffer, "%.2f", value); 37 | else 38 | if (diff < 40.0) 39 | sprintf(buffer, "%.1f", value); 40 | else 41 | sprintf(buffer, "%ld", (long)value); 42 | 43 | } /* MakeTicLabel */ 44 | 45 | char *GetComputeHost() 46 | { 47 | return(NULL); 48 | } 49 | 50 | /* MISC.C */ 51 | -------------------------------------------------------------------------------- /old_ads/oldhdr.h: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: oldhdr.h 4 | 5 | FULL NAME: HP hdr struct 6 | 7 | COPYRIGHT: University Corporation for Atmospheric Research, 1993 8 | ------------------------------------------------------------------------- 9 | */ 10 | 11 | struct old_hdr 12 | { 13 | short flag; /* = -1 */ 14 | short tapenum; 15 | short flightnum; 16 | short yymm; 17 | short ddhh; 18 | short mmss; 19 | char aircraft[4]; 20 | char projname[4]; 21 | short hdr_len; /* = 1655 */ 22 | short lrppr; 23 | short lrlen; 24 | char unused1[14]; 25 | 26 | char blkName[8][4]; 27 | short blkSiz[8]; 28 | short startWord[8]; 29 | short lastWord[8]; 30 | short maxPhysChannel; /* = 120 */ 31 | short locate[120][2]; 32 | short maxBuff; /* = 10 */ 33 | short buffOffset[10]; 34 | short maxSDI; /* = 120 */ 35 | short sampleRate[120]; 36 | char SDIname[120][6]; 37 | short maxAnalogChannel; /* = 120 */ 38 | float cals[3][120]; 39 | short nFull; 40 | char type[120][2]; /* "DI" or "AN" */ 41 | char pmsName[4][4]; 42 | short probeSize[4]; 43 | short pmsRate[4]; 44 | short pmsStart[4]; 45 | }; 46 | 47 | -------------------------------------------------------------------------------- /old_ads/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for hdrdump & ADScvt 3 | # 4 | DESTDIR= 5 | BINDIR= /opt/local/bin 6 | MANDIR= /usr/local/man/manl 7 | INCDIR= /opt/local/include 8 | LIBS= -L/opt/local/lib -lhdr_api 9 | LINTLIBS= /usr/local/lib/lint/llib-lhdr_api.ln 10 | INCLUDES= -I$(INCDIR) 11 | CC= gcc 12 | CFLAGS= -g ${INCLUDES} 13 | 14 | SRCS= hdrdump.c ADScvt.c ohdump.c hd.c 15 | PROGS= hdrdump ADScvt ohdump hd 16 | 17 | .c.o: 18 | ${CC} ${CFLAGS} -c $*.c 19 | 20 | all: hdrdump ADScvt ohdump hd 21 | 22 | hdrdump: hdrdump.c 23 | ${CC} ${CFLAGS} hdrdump.c ${LIBS} -o $@ 24 | 25 | hd: hd.c 26 | ${CC} ${CFLAGS} hd.c ${LIBS} -o $@ 27 | 28 | ohdump: ohdump.c 29 | ${CC} ${CFLAGS} ohdump.c -o $@ 30 | 31 | ADScvt: ADScvt.c 32 | ${CC} ${CFLAGS} ADScvt.c -o $@ 33 | 34 | hdrcvt852: hdrcvt852.c 35 | ${CC} ${CFLAGS} hdrcvt852.c -lhdr_api1 -o $@ 36 | 37 | install: ${PROG} 38 | cp hdrdump ${DESTDIR}${BINDIR} 39 | cp ADScvt ${DESTDIR}${BINDIR} 40 | cp ohdump ${DESTDIR}${BINDIR} 41 | 42 | clean: 43 | rm -f ${OBJS} ${PROGS} 44 | 45 | lint: 46 | lint ${INCLUDES} ${SRCS} ${LINTLIBS} 47 | 48 | print: 49 | enscript -2Gr -bHdrUtils ${HDRS} ${SRCS} 50 | 51 | hdrdump.o: $(INCDIR)/ctape.h $(INCDIR)/header.h 52 | ohdump.o: ./oldhdr.h 53 | hdrcvt852.o: $(INCDIR)/ctape.h $(INCDIR)/header.h 54 | ADScvt.o: $(INCDIR)/header.h 55 | -------------------------------------------------------------------------------- /rtplot_motif/init.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: init.c 4 | 5 | FULL NAME: Initialize Procedures 6 | 7 | TYPE: X11/R5 application, motif 8 | 9 | DESCRIPTION: Inializiation routines run once at the beginning of main 10 | Initialize is used to set all global variables. 11 | Process_args does just that. 12 | 13 | AUTHOR: websterc@ncar.ucar.edu 14 | ------------------------------------------------------------------------- 15 | */ 16 | 17 | #include "define.h" 18 | #include 19 | 20 | //extern "C" { int gethostname(char *name, int namelen); } 21 | 22 | 23 | /* --------------------------------------------------------------------- */ 24 | void Initialize() 25 | { 26 | xlabel = "Time"; 27 | 28 | numtics = NUMTICMARKS; 29 | FlashMode = Grid = Frozen = FALSE; 30 | NumberSeconds = 10; 31 | 32 | } /* END INITIALIZE */ 33 | 34 | /* --------------------------------------------------------------------- */ 35 | void process_args(char **argv) 36 | { 37 | while (*++argv) 38 | if ((*argv)[0] == '-') 39 | switch ((*argv)[1]) 40 | { 41 | case 's': /* Number of seconds */ 42 | if (*++argv == NULL) 43 | return; 44 | 45 | NumberSeconds = atoi(*argv); 46 | break; 47 | 48 | default: 49 | fprintf(stderr, "Invalid option, Usage:\n"); 50 | fprintf(stderr, " rtplot [-s Seconds]\n"); 51 | } 52 | 53 | } /* END PROCESS_ARGS */ 54 | 55 | /* END INIT.CC */ 56 | -------------------------------------------------------------------------------- /rtplot_motif/global.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: global.c 4 | 5 | FULL NAME: Global Variable Definitions 6 | 7 | DESCRIPTION: extern.h should look just like this. 8 | ------------------------------------------------------------------------- 9 | */ 10 | 11 | #include "define.h" 12 | 13 | bool Grid, /* Overlay grid on graph? */ 14 | Frozen, 15 | FlashMode; 16 | 17 | char buffer[BUFFSIZE], DataPath[1024], *ProjectName, FlightNumber[32]; 18 | 19 | SDITBL *sdi[MAX_SDI]; /* SDI (aka raw) variable list */ 20 | RAWTBL *raw[MAX_RAW]; /* Alphabeticly sorted pointers */ 21 | 22 | 23 | int nsdi, nraw, nVariables; 24 | VARTBL Variable[MAXDATASETS]; 25 | 26 | 27 | /* Vars related to data sets */ 28 | int NumberDataSets, NumberSeconds, NumberElements[MAXDATASETS], 29 | CurrentDataSet, Aircraft, Units; 30 | 31 | long nFloats; 32 | 33 | /* Data record pointers 34 | */ 35 | char *ADSrecord, *AVAPSrecord[4]; 36 | NR_TYPE *bits, *volts; 37 | NR_TYPE *SampledData, *AveragedData; 38 | NR_TYPE *plotData[MAXDATASETS]; 39 | 40 | float HDRversion; 41 | 42 | int FlightDate[3]; // Dummy. Here to shut linker up. 43 | 44 | /* Parameter File Variables */ 45 | string title, subtitle, xlabel, ylabel; 46 | 47 | /* Scaling & tic mark stuff */ 48 | NR_TYPE ymin, ymax, smallest_y, biggest_y; 49 | int numtics; 50 | 51 | /* Error messages */ 52 | char *o_mem = "Out of Memory."; 53 | 54 | /* X vars */ 55 | Widget varList; 56 | 57 | instanceRec iv; 58 | 59 | /* END GLOBAL.CC */ 60 | -------------------------------------------------------------------------------- /edADShdr/edADShdr.c: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: edADShdr.c 4 | 5 | FULL NAME: 6 | 7 | ENTRY POINTS: main() 8 | 9 | STATIC FNS: none 10 | 11 | DESCRIPTION: 12 | 13 | INPUT: 14 | 15 | OUTPUT: 16 | 17 | REFERENCES: Xwin.c, init.c then enters XtAppMainLoop() 18 | 19 | REFERENCED BY: user 20 | 21 | COPYRIGHT: University Corporation for Atmospheric Research, 2000 22 | ------------------------------------------------------------------------- 23 | */ 24 | 25 | #include "define.h" 26 | #include "fbr.h" 27 | 28 | 29 | Widget Shell000, MainWindow; 30 | 31 | 32 | /* -------------------------------------------------------------------- */ 33 | main(int argc, char **argv) 34 | { 35 | Widget AppShell; /* The Main Application Shell */ 36 | XtAppContext context; 37 | Arg args[8]; 38 | Cardinal n; 39 | 40 | n = 0; 41 | AppShell = XtAppInitialize(&context, "XmEdADShdr", NULL, 0, &argc, argv, 42 | fallback_resources, NULL, 0); 43 | 44 | n = 0; 45 | Shell000 = XtCreatePopupShell("topLevelShell", 46 | topLevelShellWidgetClass, AppShell, args, n); 47 | 48 | MainWindow = CreateMainWindow(Shell000); 49 | 50 | CreateErrorBox(AppShell); 51 | CreateWarningBox(AppShell); 52 | CreateFileSelectionBox(AppShell); 53 | 54 | Initialize(argc, argv); 55 | 56 | XtManageChild(MainWindow); 57 | XtPopup(XtParent(MainWindow), XtGrabNone); 58 | 59 | XtAppMainLoop(context); 60 | 61 | return(0); 62 | 63 | } /* END MAIN */ 64 | 65 | /* END EDADSHDR.C */ 66 | -------------------------------------------------------------------------------- /rtplot_motif/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for rtplot 3 | # 4 | CC = gcc 5 | BIN = ${JLOCAL}/bin 6 | RELEASE = ${JLOCAL}/rtplot 7 | NOBJ = ${NIMBUS}/src/filter/obj 8 | MAN1 = ${JLOCAL}/man/man1 9 | LIBS = -lraf -lXm -lXt -lX11 -lxlate -lm 10 | LINTLIBS= -lm 11 | INCLUDES= -I${JLOCAL}/include -I${NIMBUS}/include 12 | CXXFLAGS= -g ${INCLUDES} 13 | CFLAGS= -g ${INCLUDES} 14 | LIB_DIRS= -L${JLOCAL}/lib -L/usr/X11R6/lib 15 | 16 | SRCS= rtplot.cc global.cc init.cc autoscale.cc dataIO.cc CanvasWindow.cc\ 17 | hdr_decode.cc ccb.cc Xplot.cc misc.cc memalloc.cc Colors.cc\ 18 | amlibfn.cc rtloop.cc rec_decode.cc misc1.c 19 | 20 | OBJS= rtplot.o global.o init.o autoscale.o dataIO.o CanvasWindow.o\ 21 | hdr_decode.o ccb.o Xplot.o misc.o memalloc.o amlibfn.o Colors.o\ 22 | rtloop.o rec_decode.o misc1.o 23 | 24 | OOBJ= ${NOBJ}/calco.o ${NOBJ}/sort.o ${NOBJ}/search.o ${NOBJ}/textfile.o ${NOBJ}/popen.o 25 | 26 | HDRS= define.h extern.h 27 | PROG= rtplot 28 | 29 | ${PROG}: ${OBJS} 30 | ${CXX} ${CXXFLAGS} -L${NIMBUS}/lib ${LIB_DIRS} ${OBJS} ${OOBJ} ${LIBS} -o $@ 31 | 32 | release: 33 | tar cFFf - . | (cd ${RELEASE}; tar xfBp -) 34 | sed s/-g/-O2/g Makefile > ${RELEASE}/Makefile 35 | tar cFFf - . | (cd /home/linux/rtplot; tar xfBp -) 36 | sed s/-g/-O/g Makefile > /home/linux/rtplot/Makefile 37 | rm -f ${RELEASE}/LOCK.make 38 | 39 | install: ${PROG} 40 | cp ${PROG} ${BIN} 41 | cp ${PROG}.1 ${MAN1} 42 | 43 | clean: 44 | rm -f core ${OBJS} ${PROG} 45 | 46 | lint: 47 | lint ${INCLUDES} ${SRCS} ${LINTLIBS} 48 | 49 | print: 50 | enscript -2Gr -b${PROG} ${HDRS} ${SRCS} 51 | 52 | ${OBJS}: ${HDRS} 53 | amlibfn.o: ${NIMBUS}/include/xlatefns.h 54 | rtplot.o: ${HDRS} fbr.h 55 | -------------------------------------------------------------------------------- /rtplot_motif/rtplot.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: rtplot.c 4 | 5 | FULL NAME: Real Time Plot (Counts & Volts). 6 | 7 | TYPE: X11/R5 Motif 1.2 8 | 9 | DESCRIPTION: See man page 10 | 11 | INPUT: Command line options 12 | 13 | COPYRIGHT: University Corporation for Atmospheric Research, 1994-9 14 | ------------------------------------------------------------------------- 15 | */ 16 | 17 | #include "define.h" 18 | #include "decode.h" 19 | #include "fbr.h" 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | Application *application; 26 | Canvas *canvas; 27 | 28 | 29 | Widget CreateMainWindow(Widget); 30 | void Initialize(), process_args(char **argv), AllocateDataArrays(), 31 | RealTimeLoop(); 32 | 33 | bool RawData = true; 34 | 35 | 36 | /* --------------------------------------------------------------------- */ 37 | int main(int argc, char *argv[]) 38 | { 39 | int n; 40 | Arg args[6]; 41 | 42 | Initialize(); 43 | process_args(argv); 44 | 45 | DecodeHeader(NULL); 46 | AllocateDataArrays(); 47 | printf("Header decoded\n"); fflush(stdout); 48 | 49 | application = new Application("XmNCpp", &argc, argv, fallback_resources); 50 | 51 | CanvasWindow canvasWindow(application->Shell()); 52 | canvasWindow.PopUp(); 53 | 54 | canvas = new Canvas(canvasWindow.DrawingArea()); 55 | varList = canvasWindow.List(); 56 | 57 | PlotData((Widget)NULL, (XtPointer)NULL, (XmDrawingAreaCallbackStruct*)NULL); 58 | RealTimeLoop(); 59 | 60 | return(0); 61 | 62 | } /* END MAIN */ 63 | 64 | /* --------------------------------------------------------------------- */ 65 | void ErrorMsg(char msg[]) 66 | { 67 | new XmError(application->Shell(), msg); 68 | 69 | } /* END ERRORMSG */ 70 | 71 | /* END RTPLOT.CC */ 72 | -------------------------------------------------------------------------------- /rtplot_motif/memalloc.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: memalloc.c 4 | 5 | FULL NAME: Memory Allocation 6 | 7 | ENTRY POINTS: AllocateDataArrays() 8 | FreeDataArrays() 9 | 10 | STATIC FNS: none 11 | 12 | DESCRIPTION: Allocate storage for pointers & data array. This is 13 | analogous to shmem.c for winput.c 14 | 15 | INPUT: none 16 | 17 | OUTPUT: none 18 | 19 | REFERENCES: none 20 | 21 | REFERENCED BY: cb_main.c 22 | ------------------------------------------------------------------------- 23 | */ 24 | 25 | #include "define.h" 26 | #include "decode.h" 27 | #include "raf/adsIOrt.h" 28 | 29 | static bool ArraysInitialized = false; 30 | 31 | extern ADS_rtFile *file; 32 | 33 | 34 | /* -------------------------------------------------------------------- */ 35 | void AllocateDataArrays() 36 | { 37 | int i; 38 | 39 | ADSrecord = new char[file->hdr->lrLength()]; 40 | 41 | nFloats = 0; 42 | 43 | for (i = 0; i < nsdi; ++i) 44 | { 45 | sdi[i]->SRstart = nFloats; 46 | nFloats += sdi[i]->SampleRate; 47 | } 48 | 49 | for (i = 0; i < nraw; ++i) 50 | { 51 | raw[i]->SRstart = nFloats; 52 | nFloats += (raw[i]->SampleRate * raw[i]->Length); 53 | } 54 | 55 | 56 | bits = new float[nFloats]; 57 | volts = new float[nFloats]; 58 | SampledData = new float[nFloats]; 59 | 60 | memset((void *)bits, 0, sizeof(long) * nFloats); 61 | memset((void *)volts, 0, sizeof(NR_TYPE) * nFloats); 62 | 63 | ArraysInitialized = true; 64 | 65 | } /* END ALLOCATEDATAARRAYS */ 66 | 67 | /* -------------------------------------------------------------------- */ 68 | void FreeDataArrays() 69 | { 70 | if (ArraysInitialized) 71 | { 72 | delete [] ADSrecord; 73 | delete [] SampledData; 74 | } 75 | 76 | ArraysInitialized = false; 77 | 78 | } /* END FREEDATAARRAYS */ 79 | 80 | /* END MEMALLOC.C */ 81 | -------------------------------------------------------------------------------- /dup.ads/dup.ads.cc: -------------------------------------------------------------------------------- 1 | /* Duplicate an ADS image. Generally used to remove records at beginning 2 | * of file with bad time-stamps. 3 | * "if" tests can be placed in the main loop to remove specific problems. 4 | */ 5 | #include "raf/adsIO.h" 6 | #include 7 | 8 | char buffer[65999]; 9 | 10 | int main(int argc, char *argv[]) 11 | { 12 | int len; 13 | int skipNrecords = 0; 14 | char sourceFile[512], destFile[512]; 15 | FILE *outFP; 16 | Hdr_blk * h = (Hdr_blk *)buffer; 17 | /* 18 | printf("Enter input ADS file : "); 19 | fgets(sourceFile, 500, stdin); 20 | sourceFile[strlen(sourceFile)-1] = 0; 21 | 22 | printf("Enter output ADS file : "); 23 | fgets(destFile, 500, stdin); 24 | destFile[strlen(destFile)-1] = 0; 25 | 26 | printf("Enter number of records to skip : "); 27 | fgets(buffer, 10, stdin); 28 | skipNrecords = atoi(buffer); 29 | */ 30 | 31 | strcpy(sourceFile, argv[1]); 32 | strcpy(destFile, argv[2]); 33 | skipNrecords = 5; 34 | 35 | ADS_DataFile source(sourceFile); 36 | 37 | if ((outFP = fopen(destFile, "w+b")) == NULL) 38 | { 39 | fprintf(stderr, "Can't open output file %s, errno=%d\n", destFile); 40 | return(1); 41 | } 42 | 43 | /* Copy the header records. Required. 44 | */ 45 | for (int i = 0; i < 3; ++i) 46 | { 47 | len = source.NextPhysicalRecord(buffer); 48 | fwrite(buffer, len, 1, outFP); 49 | } 50 | 51 | /* Records to skip past. 52 | */ 53 | for (int i = 0; i < skipNrecords; ++i) 54 | source.NextPhysicalRecord(buffer); 55 | 56 | 57 | /* Let 'er rip. 58 | */ 59 | for (int cntr = 0; (len = source.NextPhysicalRecord(buffer)) > 0; ++cntr) 60 | { 61 | // Place your 'if' tests here to skip records. 62 | // if (cntr > 26000 && ntohs(h->hour) == 18) 63 | if (false) 64 | { 65 | printf("Disposing of record #%d\n", cntr); 66 | continue; 67 | } 68 | 69 | fwrite(buffer, len, 1, outFP); 70 | } 71 | 72 | fclose(outFP); 73 | return(0); 74 | } 75 | -------------------------------------------------------------------------------- /rtplot_motif/amlibfn.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: amlibfn.c 4 | 5 | FULL NAME: 6 | 7 | ENTRY POINTS: SearchDERIVEFTNS() 8 | SetLookupSuffix() 9 | RunAMLIBinitializers() 10 | 11 | STATIC FNS: none 12 | 13 | DESCRIPTION: This module performs all lookups into the list of variables 14 | that have xlate or compute functions (deriveftns[]). 15 | 16 | INPUT: target variable 17 | 18 | OUTPUT: index / ERR 19 | 20 | REFERENCES: none 21 | 22 | REFERENCED BY: hdr_decode.c 23 | 24 | COPYRIGHT: University Corporation for Atmospheric Research, 1992-9 25 | ------------------------------------------------------------------------- 26 | */ 27 | 28 | #include "define.h" 29 | #include "nimbus.h" 30 | #include "decode.h" 31 | #include "amlib.h" 32 | #include "xlatefns.h" 33 | 34 | static char *suffix; 35 | 36 | /* -------------------------------------------------------------------- */ 37 | void SetLookupSuffix(char *new_suffix) 38 | { 39 | suffix = new_suffix; 40 | } 41 | 42 | /* -------------------------------------------------------------------- */ 43 | int SearchDERIVEFTNS(char target[]) 44 | { 45 | int beg, mid, end, rc; 46 | char name[32]; 47 | static int n_variables = 0; 48 | static bool firstTime = true; 49 | 50 | if (firstTime) 51 | { 52 | firstTime = false; 53 | SetLookupSuffix((char *)NULL); 54 | 55 | while (deriveftns[n_variables].name) 56 | ++n_variables; 57 | } 58 | 59 | if (suffix) 60 | { 61 | strcpy(name, target); 62 | strcat(name, suffix); 63 | target = name; 64 | } 65 | 66 | beg = 0; 67 | end = n_variables; 68 | 69 | do 70 | { 71 | mid = (end + beg) >> 1; 72 | 73 | if ((rc = strcmp(target, deriveftns[mid].name)) == 0) 74 | return(mid); 75 | 76 | if (rc < 0) 77 | end = mid - 1; 78 | else 79 | beg = mid + 1; 80 | } 81 | while (beg <= end); 82 | 83 | return(-1); 84 | 85 | } /* END SEARCHDERIVEFTNS */ 86 | 87 | /* END AMLIBFN.C */ 88 | -------------------------------------------------------------------------------- /rtplot_motif/rtplot.1: -------------------------------------------------------------------------------- 1 | .na 2 | .nh 3 | .TH RTPLOT 1 "30 March 1995" "Local Command" 4 | .SH NAME 5 | rtplot \- RealTime Plotting 6 | .SH SYNOPSIS 7 | .B rtplot [-h ads_control_host] [-s NumSeconds] 8 | .SH DESCRIPTION 9 | .B rtplot 10 | performs realtime plotting of sample-rate ADS data. It can be run from any 11 | display station. If you are not running on the ADS control station, you 12 | must specify the "-h host" option. 13 | .B rtplot 14 | will give you the option to display up to 5 variables at once from a list. 15 | You only have the option of analog/digtial channels and variables from 16 | block-probes (IRS, GPS, PMS1D, OphirIII), there are no derived variables 17 | present. 18 | .SH PARAMETERS 19 | .TP 4 20 | \f4\-h\f2 ADS_control_host\f1 21 | Specify ads control host, so rtplot can locate the realtime ADS image. 22 | .SH OPTIONS 23 | .TP 4 24 | \f4\-s\f2 Seconds\f1 25 | Specify how many seconds to display across the X axis. This not changable 26 | once the program is running. The default is 10 seconds. 27 | .SH RUNTIME OPTIONS 28 | Through the 29 | .B Edit Menu 30 | there are several options: 31 | .TP 4 32 | \f4\Toggle Counts\f1 33 | This toggles between 34 | .B counts 35 | and 36 | .B engineering units. 37 | The default at start up is 38 | .B engineering units. 39 | .TP 4 40 | \f4\Toggle Snapshot Mode\f1 41 | This toggles between updating once per second, the default, and once per 42 | window size. If you have set the number of seconds to 5 at startup, then 43 | snapshot mode will show the previous 5 seconds worth of data for the next 44 | 5 seconds. 45 | .TP 4 46 | \f4\Toggle Grid\f1 47 | Toggle a background grid on the data window. 48 | .TP 4 49 | \f4\Autscale Axies\f1 50 | Autoscale axies. This shouldn't be necessary, as autoscaling is performed 51 | every screen update. 52 | .f 53 | .PP 54 | .SH EXAMPLE: 55 | .PP 56 | To change the number of seconds to display to 5, and attach to C-130 control: 57 | .PP 58 | 7% rtplot -h hercules -s 5 59 | .PP 60 | .SH AUTHOR 61 | Chris Webster, National Center for Atmospheric Research 62 | -------------------------------------------------------------------------------- /rtplot_motif/define.h: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: define.h 4 | 5 | FULL NAME: Include File to Include the Include Files 6 | 7 | DESCRIPTION: 8 | ------------------------------------------------------------------------- 9 | */ 10 | 11 | #ifndef DEFINE_H 12 | #define DEFINE_H 13 | 14 | #define _NO_PROTO 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #define CONSTANTS_H 27 | #define NAMLEN 13 28 | #include "nimbus.h" 29 | 30 | #define BUFFSIZE 2048 31 | #define PATH_LEN 1024 32 | 33 | #define SPACE ' ' 34 | 35 | #define MAX_VARIABLES 2048 36 | #define MAXDATASETS 5 37 | 38 | #define TITLESIZE 128 39 | #define LEGENDSIZE (TITLESIZE<<1) 40 | 41 | #define NUMTICMARKS 10 42 | 43 | /* Defines for 'Mode' */ 44 | #define COUNTS 0 45 | #define VOLTS 1 46 | #define ENGINEERING 2 47 | 48 | 49 | /* Values for "axies_to_scale" */ 50 | #define SCALE_XAXIS 0x01 51 | #define SCALE_YAXIS 0x02 52 | 53 | /* Values for "HandleError" */ 54 | #define RETURN 0 /* Continue after displaying error */ 55 | #define EXIT 1 /* Exit after displaying error */ 56 | #define IRET 2 /* if (interactive) return else exit(1) */ 57 | 58 | /* Values for reading Font Resources */ 59 | #define XtNtitleFont "titleFont" 60 | #define XtCTitleFont "Titlefont" 61 | #define XtNsubtitleFont "subtitleFont" 62 | #define XtCSubtitleFont "Subtitlefont" 63 | #define XtNticFont "ticFont" 64 | #define XtCTicFont "Ticfont" 65 | 66 | 67 | 68 | /* Struct for reading font resources from resource file */ 69 | typedef struct _insRec 70 | { 71 | char *titleFont; 72 | char *subtitleFont; 73 | char *ticFont; 74 | } instanceRec; 75 | 76 | typedef struct 77 | { 78 | char name[NAMLEN]; 79 | int SampleRate; 80 | int SRstart; 81 | int nPoints; 82 | XPoint *pts; 83 | int buffIndex; 84 | } VARTBL; 85 | 86 | 87 | #include "extern.h" 88 | 89 | #endif 90 | 91 | /* END DEFINE.H */ 92 | -------------------------------------------------------------------------------- /rtplot_motif/extern.h: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: extern.h 4 | 5 | FULL NAME: Global Variable External Declarations 6 | 7 | DESCRIPTION: 8 | 9 | AUTHOR: websterc@ncar 10 | ------------------------------------------------------------------------- 11 | */ 12 | 13 | #ifndef EXTERN_H 14 | #define EXTERN_H 15 | 16 | extern bool Grid, Frozen, FlashMode; 17 | 18 | extern char buffer[], DataPath[], *ProjectName, FlightNumber[]; 19 | 20 | extern SDITBL *sdi[]; /* SDI (aka raw) variable list */ 21 | extern RAWTBL *raw[]; /* Alphabeticly sorted pointers */ 22 | extern DEFAULT *Defaults[]; 23 | 24 | extern int nsdi, nraw, nVariables; 25 | extern VARTBL Variable[]; 26 | 27 | 28 | extern int NumberDataSets, NumberSeconds, NumberElements[], CurrentDataSet; 29 | extern int Aircraft, Units; 30 | 31 | extern char *ADSrecord; 32 | extern NR_TYPE *bits, *volts, *SampledData; 33 | 34 | extern NR_TYPE *plotData[]; 35 | 36 | extern NR_TYPE ymin, ymax, smallest_y, biggest_y; 37 | extern int numtics; 38 | 39 | /* Parameter File Variables */ 40 | extern string title, subtitle, xlabel, ylabel; 41 | 42 | /* Error messages */ 43 | extern char *o_mem; 44 | 45 | /* X vars */ 46 | extern Widget varList; 47 | 48 | extern instanceRec iv; 49 | 50 | 51 | /* Procedures */ 52 | char *get_legend(); 53 | void Quit(Widget, XtPointer, XtPointer), ErrorMsg(char msg[]), 54 | Freeze(Widget, XtPointer, XtPointer), DecodeRecord(), 55 | AddDataToBuffer(NR_TYPE *newData), 56 | ModifyActiveVars(Widget, XtPointer, XtPointer), 57 | ToggleUnits(Widget, XtPointer, XtPointer), 58 | DoAutoScale(Widget, XtPointer, XtPointer), 59 | ToggleGrid(Widget, XtPointer, XtPointer), 60 | ToggleFlash(Widget, XtPointer, XtPointer), 61 | ResizePlotWindow(Widget w, XtPointer client, XtPointer call), 62 | PlotData(Widget w, XtPointer client, XtPointer call), 63 | FindMinMax(), ResizePlotWindow(), AutoScale(char axis); 64 | 65 | void EditParms(), DismissParmsWindow(), ApplyParms(), AddVariable(), 66 | DeleteVariable(), ToggleGrid(), DoAutoScale(), Quit(), ToggleFlash(), 67 | PlotData(), AutoScale(), ToggleUnits(), ModifyActiveVars(); 68 | 69 | #endif 70 | 71 | /* END EXTERN.H */ 72 | -------------------------------------------------------------------------------- /rtplot_motif/rtloop.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: rtloop.c 4 | 5 | FULL NAME: RealTime Loop 6 | 7 | ENTRY POINTS: RealTimeLoop() 8 | 9 | STATIC FNS: WaitForNextLogicalRecord() 10 | OpenSocket() 11 | 12 | DESCRIPTION: 13 | 14 | REFERENCES: none 15 | 16 | REFERENCED BY: rtplot.c 17 | 18 | COPYRIGHT: University Corporation for Atmospheric Research, 1997-9 19 | ------------------------------------------------------------------------- 20 | */ 21 | 22 | #include "define.h" 23 | #include "decode.h" 24 | #include "raf/Application.h" 25 | #include "raf/adsIOrt.h" 26 | 27 | #include 28 | #include 29 | 30 | int Mode = REALTIME; 31 | 32 | extern Application *application; 33 | 34 | static void WaitForNextLogicalRecord(char dest[]); 35 | 36 | extern ADS_rtFile *file; 37 | 38 | //extern "C" { int usleep(unsigned int); } 39 | 40 | /* -------------------------------------------------------------------- */ 41 | void RealTimeLoop() 42 | { 43 | application->FlushEvents(); 44 | 45 | file = new ADS_rtFile(); 46 | file->LastSyncRecord(ADSrecord); 47 | 48 | while (1) 49 | { 50 | WaitForNextLogicalRecord(ADSrecord); 51 | DecodeRecord(); 52 | ApplyCalCoes(SampledData); 53 | 54 | switch (Units) 55 | { 56 | case COUNTS: 57 | AddDataToBuffer(bits); 58 | break; 59 | 60 | case VOLTS: 61 | AddDataToBuffer(volts); 62 | break; 63 | 64 | case ENGINEERING: 65 | AddDataToBuffer(SampledData); 66 | break; 67 | 68 | } 69 | 70 | AutoScale(SCALE_YAXIS); 71 | 72 | if (!Frozen) 73 | if (!FlashMode || Variable[0].buffIndex == 0) 74 | PlotData(NULL, NULL, NULL); 75 | 76 | application->FlushEvents(); 77 | } 78 | 79 | } /* END REALTIMELOOP */ 80 | 81 | /* -------------------------------------------------------------------- */ 82 | static void WaitForNextLogicalRecord(char dest[]) 83 | { 84 | Hdr_blk *hdr = (Hdr_blk *)dest; 85 | 86 | while (file->NextSyncRecord(dest) == false) 87 | { 88 | usleep(100000); 89 | 90 | application->FlushEvents(); 91 | } 92 | 93 | sprintf(buffer, "UTC (%02d:%02d:%02d)", ntohs(hdr->hour), 94 | ntohs(hdr->minute), ntohs(hdr->second)); 95 | xlabel = buffer; 96 | 97 | } /* END WAITFORNEXTLOGICALRECORD */ 98 | 99 | /* END RTLOOP.C */ 100 | -------------------------------------------------------------------------------- /dnload/tpfix.c: -------------------------------------------------------------------------------- 1 | /* 2 | :set tabstop=4 3 | ------------------------------------------------------------------------- 4 | OBJECT NAME: tptcp.c 5 | 6 | FULL NAME: Tape Tee Copy 7 | 8 | DESCRIPTION: Copy a tape from one tape to another and also dump a copy 9 | to disk sans 2d records 10 | 11 | INPUT: 12 | 13 | OUTPUT: 14 | 15 | NOTES: gcc tptcp.c -lraf -o tptcp 16 | 17 | COPYRIGHT: University Corporation for Atmospheric Research, 1992 18 | ------------------------------------------------------------------------- 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #include "/opt/local/include/raf/header.h" 26 | 27 | #define STDERR(msg) fprintf(stderr, msg) 28 | #define STDERRA(msg, arg) fprintf(stderr, msg, arg) 29 | 30 | #define ERR (-1) 31 | 32 | main(argc, argv) 33 | int argc; 34 | char *argv[]; 35 | { 36 | int outd, rc, nbytes, cnt = 0; 37 | char buffer[65000], date[32], fltnum[32]; 38 | 39 | if (argc < 3) 40 | { 41 | STDERR("usage: tptcp src dest disk_file\n"); 42 | STDERR(" example: tptcp /dev/rex0 /dev/rex1\n"); 43 | return(1); 44 | } 45 | 46 | 47 | if (TapeOpen(argv[1]) == ERR) 48 | { 49 | STDERRA("Can't open source tape %s\n", argv[1]); 50 | return(1); 51 | } 52 | 53 | if ((outd = open(argv[2], O_WRONLY)) == ERR) 54 | { 55 | STDERRA("Can't open destination tape %s\n", argv[2]); 56 | TapeClose(); 57 | return(1); 58 | } 59 | 60 | 61 | printf("Enter flight number : "); 62 | gets(fltnum); 63 | 64 | printf("Enter date [mm/dd/yyyy]: "); 65 | gets(date); 66 | 67 | rc = 0; /* Return Code */ 68 | 69 | while ((nbytes = TapeRead(buffer)) > 0) 70 | { 71 | if (*(unsigned short *)buffer == 0x5448) 72 | { 73 | struct Fl *p = (struct Fl *)buffer; 74 | 75 | strcpy(p->fltnum, fltnum); 76 | strcpy(p->date, date); 77 | } 78 | 79 | if (write(outd, buffer, nbytes) == ERR) 80 | { 81 | STDERRA("Write failure to dest tape, errno = %d\n", errno); 82 | rc = 1; 83 | goto exit; 84 | } 85 | 86 | ++cnt; 87 | } 88 | 89 | if (nbytes == ERR) 90 | { 91 | STDERRA("Read error, errno = %d\n", errno); 92 | rc = 1; 93 | } 94 | 95 | exit: 96 | TapeClose(); 97 | close(outd); 98 | 99 | printf("%d records successfully read and written.\n", cnt); 100 | 101 | { int hour, min, sec; 102 | 103 | cnt -= 3; 104 | hour = cnt / 3600; 105 | min = (cnt - (hour * 3600)) / 60; 106 | sec = cnt - (hour * 3600) - (min * 60); 107 | printf("Flight duration = %02d:%02d:%02d\n", hour, min, sec); 108 | } 109 | return(rc); 110 | 111 | } 112 | -------------------------------------------------------------------------------- /dnload/tppn.c: -------------------------------------------------------------------------------- 1 | /* 2 | :set tabstop=4 3 | ------------------------------------------------------------------------- 4 | OBJECT NAME: tptcp.c 5 | 6 | FULL NAME: Tape Tee Copy 7 | 8 | DESCRIPTION: Copy a tape from one tape to another and also dump a copy 9 | to disk sans 2d records 10 | 11 | INPUT: 12 | 13 | OUTPUT: 14 | 15 | NOTES: gcc tptcp.c -lraf -o tptcp 16 | 17 | COPYRIGHT: University Corporation for Atmospheric Research, 1992 18 | ------------------------------------------------------------------------- 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #include "/opt/local/include/raf/header.h" 26 | 27 | #define STDERR(msg) fprintf(stderr, msg) 28 | #define STDERRA(msg, arg) fprintf(stderr, msg, arg) 29 | 30 | #define ERR (-1) 31 | 32 | main(argc, argv) 33 | int argc; 34 | char *argv[]; 35 | { 36 | int outd, rc, nbytes, cnt = 0; 37 | char buffer[65000], date[32], fltnum[32]; 38 | 39 | if (argc < 3) 40 | { 41 | STDERR("usage: tptcp src dest disk_file\n"); 42 | STDERR(" example: tptcp /dev/rex0 /dev/rex1\n"); 43 | return(1); 44 | } 45 | 46 | 47 | if (TapeOpen(argv[1]) == ERR) 48 | { 49 | STDERRA("Can't open source tape %s\n", argv[1]); 50 | return(1); 51 | } 52 | 53 | if ((outd = open(argv[2], O_WRONLY)) == ERR) 54 | { 55 | STDERRA("Can't open destination tape %s\n", argv[2]); 56 | TapeClose(); 57 | return(1); 58 | } 59 | 60 | 61 | printf("Enter flight number : "); 62 | gets(fltnum); 63 | 64 | printf("Enter date [mm/dd/yyyy]: "); 65 | gets(date); 66 | 67 | rc = 0; /* Return Code */ 68 | 69 | while ((nbytes = TapeRead(buffer)) > 0) 70 | { 71 | if (*(unsigned short *)buffer == 0x5448) 72 | { 73 | struct Fl *p = (struct Fl *)buffer; 74 | 75 | strcpy(p->fltnum, fltnum); 76 | strcpy(p->date, date); 77 | strcpy(p->prnum, "127"); 78 | } 79 | 80 | if (write(outd, buffer, nbytes) == ERR) 81 | { 82 | STDERRA("Write failure to dest tape, errno = %d\n", errno); 83 | rc = 1; 84 | goto exit; 85 | } 86 | 87 | ++cnt; 88 | } 89 | 90 | if (nbytes == ERR) 91 | { 92 | STDERRA("Read error, errno = %d\n", errno); 93 | rc = 1; 94 | } 95 | 96 | exit: 97 | TapeClose(); 98 | close(outd); 99 | 100 | printf("%d records successfully read and written.\n", cnt); 101 | 102 | { int hour, min, sec; 103 | 104 | cnt -= 3; 105 | hour = cnt / 3600; 106 | min = (cnt - (hour * 3600)) / 60; 107 | sec = cnt - (hour * 3600) - (min * 60); 108 | printf("Flight duration = %02d:%02d:%02d\n", hour, min, sec); 109 | } 110 | return(rc); 111 | 112 | } 113 | -------------------------------------------------------------------------------- /rtplot_motif/autoscale.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: autoscale.c 4 | 5 | FULL NAME: Auto Scale Axies 6 | 7 | DESCRIPTION: These procedures are responsible for auto scaling the 8 | X and Y axis. 9 | 10 | INPUT: Byte containing bits set for which axies to scale 11 | 12 | OUTPUT: Globals ymin, ymax affected. 13 | 14 | COPYRIGHT: University Corporation for Atmospheric Research, 1994-9 15 | ------------------------------------------------------------------------- 16 | */ 17 | 18 | #include "define.h" 19 | #include 20 | 21 | static void scaleaxis(NR_TYPE *, NR_TYPE *); 22 | static NR_TYPE RoundBig(NR_TYPE, int), expt(NR_TYPE, int); 23 | 24 | /* -------------------------------------------------------------------- */ 25 | void AutoScale(char axis) 26 | { 27 | if (axis & SCALE_YAXIS && NumberDataSets > 0) 28 | { 29 | ymin = smallest_y; 30 | ymax = biggest_y; 31 | scaleaxis(&ymin, &ymax); 32 | } 33 | 34 | } /* END AUTOSCALE */ 35 | 36 | /* -------------------------------------------------------------------- */ 37 | static void scaleaxis(NR_TYPE *min, NR_TYPE *max) 38 | { 39 | NR_TYPE tmpmin, tmpmax, range, d; 40 | 41 | /* min better not equal max */ 42 | if (*min == *max) 43 | *max += 1.0; 44 | 45 | range = RoundBig(*max - *min, false); 46 | d = RoundBig(range / numtics, true); /* tic mark spacing */ 47 | 48 | tmpmin = floor(*min / d) * d; 49 | tmpmax = ceil(*max / d) * d; 50 | 51 | *min = tmpmin; 52 | *max = tmpmax; 53 | 54 | } /* END SCALEAXIS */ 55 | 56 | /* -------------------------------------------------------------------- */ 57 | static NR_TYPE RoundBig(NR_TYPE x, int round) 58 | { 59 | int exp; 60 | NR_TYPE f, y; 61 | 62 | exp = (int)floor(log10(x)); 63 | f = x / expt(10.0, exp); /* fraction between 1 and 10 */ 64 | 65 | if (round) 66 | if (f < 1.5) 67 | y = 1.0; 68 | else 69 | if (f < 3.0) 70 | y = 2.0; 71 | else 72 | if (f < 7.0) 73 | y = 5.0; 74 | else 75 | y = 10.0; 76 | else 77 | if (f <= 1.0) 78 | y = 1.0; 79 | else 80 | if (f <= 2.0) 81 | y = 2.0; 82 | else 83 | if (f <= 5.0) 84 | y = 5.0; 85 | else 86 | y = 10.0; 87 | 88 | return(y * expt(10.0, exp)); 89 | 90 | } /* END ROUNDBIG */ 91 | 92 | /* -------------------------------------------------------------------- */ 93 | static NR_TYPE expt(NR_TYPE a, int n) 94 | { 95 | NR_TYPE x; 96 | 97 | x = 1.0; 98 | 99 | if (n > 0) 100 | for (; n > 0; n--) 101 | x *= a; 102 | else 103 | for (; n < 0; n++) 104 | x /= a; 105 | 106 | return(x); 107 | 108 | } /* END EXPT */ 109 | 110 | /* END AUTOSCALE.C */ 111 | -------------------------------------------------------------------------------- /sppSim/sppSim.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | #include "/opt/local/include/raf/header.h" 11 | 12 | char buffer[256]; 13 | 14 | ushort computeCheckSum (unsigned char *pkt, int len); 15 | 16 | main() 17 | { 18 | int i, rc; 19 | char dummy[32], *p; 20 | int in, out, cntr; 21 | DMT100_blk spp100; 22 | ushort chkSum = 0, *usp; 23 | 24 | usp = (ushort *)buffer; 25 | 26 | for (i = 0; i < 8; ++i) 27 | spp100.cabinChan[i] = 5; 28 | 29 | spp100.rejDOF = 7; 30 | spp100.rejAvgTrans = 8; 31 | spp100.range = 0; 32 | spp100.AvgTransit = 9; 33 | spp100.FIFOfull = 0; 34 | spp100.resetFlag = 0; 35 | spp100.ADCoverflow = 0; 36 | 37 | for (i = 0; i < OPCCHAN; ++i) 38 | spp100.OPCchan[i] = 80 - (i<<1); 39 | 40 | chkSum = computeCheckSum((char *)&spp100, sizeof(spp100)); 41 | 42 | if ((in = open("/dev/ttyS2", O_RDWR)) < 0) 43 | { 44 | fprintf(stderr, "Can't open in.\n"); 45 | exit(1); 46 | } 47 | 48 | { 49 | struct termios tty; 50 | speed_t spd; 51 | 52 | tcgetattr(in, &tty); 53 | tty.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); 54 | tty.c_oflag &= ~OPOST; 55 | tty.c_iflag |= IGNPAR; 56 | tty.c_cflag |= (CLOCAL | CREAD); 57 | cfsetispeed(&tty, B38400); 58 | cfsetospeed(&tty, B38400); 59 | tcsetattr(in, TCSANOW, &tty); 60 | } 61 | 62 | 63 | while (1) 64 | { 65 | do 66 | { 67 | read(in, dummy, 1); 68 | } 69 | while (dummy[0] != 0x1b); 70 | 71 | read(in, &dummy[1], 3); 72 | //printf("%x %x\n", dummy[0], dummy[1]); 73 | 74 | if (dummy[1] == 0x01) 75 | { 76 | rc = 4; 77 | 78 | do 79 | { 80 | rc += read(in, &buffer[rc+2], 106-rc); 81 | } 82 | while (rc < 106); 83 | 84 | printf("Rcvd init pckt, %d, ", usp[1]); 85 | memcpy(buffer, dummy, 4); 86 | usp[2] = 0x105; 87 | usp[53] = computeCheckSum(buffer, 106); 88 | //printf(" %x %x %x\n", usp[53], buffer[106], buffer[107]); 89 | rc = write(in, buffer, 108); 90 | printf("rc = %d\n", rc); 91 | } 92 | else 93 | { 94 | memcpy(buffer, &spp100, sizeof(spp100)); 95 | usp[194>>1] = chkSum; 96 | rc = write(in, buffer, sizeof(spp100)); 97 | } 98 | } 99 | 100 | } 101 | 102 | /*****************************************************************************/ 103 | ushort computeCheckSum (unsigned char *pkt, int len) 104 | 105 | // Computes the packet check sum. 106 | { 107 | ushort local_len; 108 | ushort j, sum; 109 | 110 | // Get the length of the data bytes, minus the length of the checksum field. 111 | local_len = len - 2; 112 | 113 | // Sum the byte count and data bytes; 114 | for (j = 0, sum = 0; j < local_len; j++) { 115 | sum += (ushort)pkt[j]; 116 | } 117 | return sum; 118 | } 119 | 120 | -------------------------------------------------------------------------------- /rtplot_motif/rec_decode.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: rec_decode.c 4 | 5 | FULL NAME: Decode ADS data Record 6 | 7 | ENTRY POINTS: DecodeRecord() 8 | 9 | DESCRIPTION: Translates ADS data records into the internal format. 10 | The internal format is all one data type for ease of 11 | processing. The 2 functions are essentially identical, 12 | the difference is that the one ForRealTime also puts the 13 | data into the arrays bits[] and volts[], for display 14 | purposes. 15 | 16 | INPUT: ADS logical record 17 | 18 | OUTPUT: New logical record 19 | 20 | REFERENCES: libxlate.a 21 | 22 | REFERENCED BY: lrloop.c hrloop.c winputops.c 23 | 24 | NOTE: If you chnage one, make sure the other does/doesn't need 25 | the same change. 26 | 27 | COPYRIGHT: University Corporation for Atmospheric Research, 1992-9 28 | ------------------------------------------------------------------------- 29 | */ 30 | 31 | #include "define.h" 32 | #include "decode.h" 33 | 34 | /* -------------------------------------------------------------------- */ 35 | void DecodeRecord() 36 | { 37 | int i, j, pos; 38 | SDITBL *sp; /* Current SDI Variable Pointer */ 39 | RAWTBL *rp; /* Current Raw Variable Pointer */ 40 | ushort *lrp; /* ADS Logical Record Pointer */ 41 | 42 | 43 | /* Cast SDI variables into new record 44 | */ 45 | for (i = 0; (sp = sdi[i]); ++i) 46 | { 47 | lrp = &((ushort *)ADSrecord)[sp->ADSstart]; 48 | pos = sp->SRstart; 49 | 50 | 51 | if (sp->type[0] == 'C') 52 | { 53 | if (strcmp(sp->type, "C24") == 0) 54 | { 55 | for (j = 0; j < sp->SampleRate; ++j, ++pos) 56 | { 57 | SampledData[pos] = bits[pos] = 58 | ntohl(*((unsigned long *)&lrp[j * sp->ADSoffset])); 59 | volts[pos] = (bits[pos] - sp->convertOffset) * sp->convertFactor; 60 | } 61 | } 62 | else 63 | { 64 | for (j = 0; j < sp->SampleRate; ++j, ++pos) 65 | { 66 | SampledData[pos] = bits[pos] = ntohs(lrp[j * sp->ADSoffset]); 67 | volts[pos] = (bits[pos] - sp->convertOffset) * sp->convertFactor; 68 | } 69 | } 70 | } 71 | else 72 | { 73 | if (strcmp(sp->type, "D20") == 0) 74 | { 75 | for (j = 0; j < sp->SampleRate; ++j, ++pos) 76 | { 77 | SampledData[pos] = bits[pos] = 78 | (long)ntohl(*((long *)&lrp[j * sp->ADSoffset])); 79 | volts[pos] = (bits[pos] - sp->convertOffset) * sp->convertFactor; 80 | } 81 | } 82 | else 83 | { 84 | for (j = 0; j < sp->SampleRate; ++j, ++pos) 85 | { 86 | SampledData[pos] = bits[pos] = 87 | (short)ntohs((ushort)lrp[j * sp->ADSoffset]); 88 | volts[pos] = (bits[pos] - sp->convertOffset) * sp->convertFactor; 89 | } 90 | } 91 | } 92 | } 93 | 94 | 95 | /* Extract block variables into new record 96 | */ 97 | for (i = 0; (rp = raw[i]); ++i) 98 | (*rp->xlate)( rp, 99 | &((ushort *)ADSrecord)[rp->ADSstart], 100 | &SampledData[rp->SRstart]); 101 | 102 | } /* END DECODEADSRECORD */ 103 | 104 | /* END REC_DECODE.C */ 105 | -------------------------------------------------------------------------------- /old_ads/ohdump.c: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: ohdump.c 4 | 5 | FULL NAME: Old Header Dump 6 | 7 | ENTRY POINTS: main 8 | 9 | STATIC FNS: 10 | 11 | DESCRIPTION: 12 | 13 | INPUT: Old HP style header 14 | 15 | OUTPUT: New header. 16 | 17 | COPYRIGHT: University Corporation for Atmospheric Research, 1993 18 | ------------------------------------------------------------------------- 19 | */ 20 | 21 | #include 22 | #include "oldhdr.h" 23 | 24 | float fphp2mc(); 25 | 26 | /* -------------------------------------------------------------------- */ 27 | main(argc, argv) 28 | int argc; 29 | char *argv[]; 30 | { 31 | int i, n = 120; 32 | struct old_hdr OldHdr; 33 | FILE *fp; 34 | 35 | if ((fp = fopen(argv[1], "r")) == NULL) 36 | { 37 | fprintf(stderr, "Can't open %s\n", argv[1]); 38 | exit(1); 39 | } 40 | 41 | fread(&OldHdr, sizeof(struct old_hdr), 1, fp); 42 | fclose(fp); 43 | 44 | printf("Flag = %d\n", OldHdr.flag); 45 | printf("TapeNum = %d\n", OldHdr.tapenum); 46 | printf("FlightNum = %d\n", OldHdr.flightnum); 47 | printf("Date = %d/%d/%d\n", OldHdr.yymm & 0x00ff, OldHdr.ddhh >> 8, OldHdr.yymm >> 8); 48 | printf("Time = %d:%d:%d\n", OldHdr.ddhh & 0x00ff, OldHdr.mmss >> 8, OldHdr.mmss & 0x00ff); 49 | 50 | printf("Aircraft = %-4.4s\n", OldHdr.aircraft); 51 | printf("ProjName = %-4.4s\n", OldHdr.projname); 52 | printf("HdrLen = %d, better = 1655\n", OldHdr.hdr_len); 53 | printf("lrppr = %d\n", OldHdr.lrppr); 54 | printf("lrlen = %d\n", OldHdr.lrlen); 55 | 56 | 57 | /* SDI vars */ 58 | printf("\nName Rate Start Type Chnl c0 c1 c2\n"); 59 | 60 | fphp2mc_(OldHdr.cals[0], &n); 61 | fphp2mc_(OldHdr.cals[1], &n); 62 | fphp2mc_(OldHdr.cals[2], &n); 63 | 64 | for (i = 0; i < OldHdr.nFull; ++i) 65 | printf("%-6.6s %3d %5d %-2.2s %5d %12.6f %12.6f %12.6f\n", 66 | OldHdr.SDIname[i], 67 | OldHdr.sampleRate[i], 68 | OldHdr.locate[i][1], 69 | OldHdr.type[i], 70 | OldHdr.locate[i][0], 71 | OldHdr.cals[0][i], OldHdr.cals[1][i], OldHdr.cals[2][i]); 72 | 73 | 74 | /* Block Probes */ 75 | printf("\nName Size Start Last\n"); 76 | 77 | for (i = 0; i < 8; ++i) 78 | if (OldHdr.blkSiz[i] > 0) 79 | printf("%-4.4s %6d %6d %6d\n", OldHdr.blkName[i], OldHdr.blkSiz[i], 80 | OldHdr.startWord[i], OldHdr.lastWord[i]); 81 | 82 | 83 | /* PMS1D probes */ 84 | printf("\nName Rate Start Size\n"); 85 | 86 | for (i = 0; i < 4; ++i) 87 | printf("%-4.4s %4d %6d %6d\n", OldHdr.pmsName[i], OldHdr.pmsRate[i], 88 | OldHdr.pmsStart[i], OldHdr.probeSize[i]); 89 | 90 | printf("\n\n"); 91 | 92 | return(0); 93 | 94 | } /* END MAIN */ 95 | 96 | /* -------------------------------------------------------------------- */ 97 | fphp2mc_(a, n) 98 | int a[], *n; 99 | { 100 | int signfr,frac,expon,signex,i; 101 | 102 | for (i = 0; i < *n; i++) 103 | { 104 | if (a[i] == 0x00000000) 105 | continue; 106 | 107 | signfr=a[i] & 0x80000000; 108 | frac = a[i] & 0x3fffff00; 109 | expon= a[i] & 0xfe; 110 | signex=a[i] & 1; 111 | frac= frac>>7; 112 | if (signfr != 0) 113 | frac = (frac ^ 0x7fffff) + 1; 114 | expon= expon >> 1; 115 | expon= expon+126-signex*128 ; 116 | expon= expon << 23; 117 | a[i] = signfr+expon+frac; 118 | } 119 | 120 | } 121 | 122 | /* END OHDUMP.C */ 123 | -------------------------------------------------------------------------------- /rtplot_motif/Colors.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: Colors.cc 4 | 5 | FULL NAME: X Color values. 6 | 7 | ENTRY POINTS: Colors() 8 | 9 | STATIC FNS: 10 | 11 | DESCRIPTION: 12 | 13 | COPYRIGHT: University Corporation for Atmospheric Research, 1997 14 | ------------------------------------------------------------------------- 15 | */ 16 | 17 | #include "Colors.h" 18 | 19 | struct { 20 | char *name; 21 | float rgb[3]; /* For PostScript */ 22 | unsigned long pixel; 23 | } colorInfo[] = { 24 | { "Black", { 0, 0, 0 }, 0 }, 25 | { "blue", { 0, 0, 1 }, 0 }, 26 | { "maroon", { 0.69, 0.1882, 0.3765 }, 0 }, 27 | { "green", { 0, 1, 0 }, 0 }, 28 | { "red", { 1, 0, 0 }, 0 }, 29 | { "violet", { 0.9333, 0.5098, 0.9333 }, 0 }, 30 | { "yellow", { 1, 1, 0 }, 0 }, 31 | { "purple", { 0.6275, 0.1255, 0.9412 }, 0 }, 32 | { NULL, { 0, 0, 0 }, 0 } }; 33 | 34 | /* -------------------------------------------------------------------- */ 35 | Colors::Colors(const Widget w) 36 | { 37 | int i = 5, defaultDepth; 38 | Colormap defaultCMap; 39 | Display *dpy; 40 | int screenNum; 41 | XVisualInfo visualInfo; 42 | XColor screenDef, exactDef; 43 | 44 | Color = true; 45 | 46 | dpy = XtDisplay(w); 47 | screenNum = XScreenNumberOfScreen(XtScreen(w)); 48 | defaultDepth = DefaultDepth(dpy, screenNum); 49 | 50 | if (defaultDepth == 1) 51 | { 52 | Color = false; 53 | return; 54 | } 55 | 56 | while (!XMatchVisualInfo(dpy, screenNum, defaultDepth, i, &visualInfo)) 57 | --i; 58 | 59 | if (i < StaticColor) 60 | { 61 | Color = false; 62 | return; 63 | } 64 | 65 | 66 | /* OK, we have a color scree, allocate colors. 67 | */ 68 | defaultCMap = DefaultColormap(dpy, screenNum); 69 | 70 | for (i = 0; colorInfo[i].name; ++i) 71 | { 72 | if (!XAllocNamedColor( 73 | dpy, defaultCMap, colorInfo[i].name, &screenDef, &exactDef)) 74 | { 75 | cerr << "Color.cc: Can't allocate color, reverting to B&W.\n"; 76 | Color = false; 77 | return; 78 | } 79 | 80 | colorInfo[i].pixel = exactDef.pixel; 81 | } 82 | 83 | } /* END CONSTRUCTOR */ 84 | 85 | /* -------------------------------------------------------------------- */ 86 | void Colors::ResetColors() 87 | { 88 | colorIndex = 0; 89 | } 90 | 91 | /* -------------------------------------------------------------------- */ 92 | unsigned long Colors::GetColor(int indx) 93 | { 94 | return(colorInfo[indx].pixel); 95 | } 96 | 97 | /* -------------------------------------------------------------------- */ 98 | unsigned long Colors::NextColor() 99 | { 100 | return(colorInfo[++colorIndex].pixel); 101 | } 102 | 103 | /* -------------------------------------------------------------------- */ 104 | float *Colors::GetColorPS(int indx) 105 | { 106 | return(colorInfo[indx].rgb); 107 | } 108 | 109 | /* -------------------------------------------------------------------- */ 110 | float *Colors::NextColorPS() 111 | { 112 | return(GetColorPS(++colorIndex)); 113 | } 114 | 115 | /* -------------------------------------------------------------------- */ 116 | float *Colors::CurrentColorPS() 117 | { 118 | return(GetColorPS(colorIndex)); 119 | } 120 | 121 | /* END COLORS.CC */ 122 | -------------------------------------------------------------------------------- /dnload/tps.c: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: tptcp.c 4 | 5 | FULL NAME: Tape Tee Copy 6 | 7 | DESCRIPTION: Copy a tape from one tape to another and also dump a copy 8 | to disk sans 2d records 9 | 10 | INPUT: 11 | 12 | OUTPUT: 13 | 14 | NOTES: gcc tptcp.c -lraf -o tptcp 15 | 16 | COPYRIGHT: University Corporation for Atmospheric Research, 1992 17 | ------------------------------------------------------------------------- 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #define STDERR(msg) fprintf(stderr, msg) 25 | #define STDERRA(msg, arg) fprintf(stderr, msg, arg) 26 | 27 | #define ERR (-1) 28 | 29 | /* -------------------------------------------------------------------- */ 30 | main(argc, argv) 31 | int argc; 32 | char *argv[]; 33 | { 34 | int outd, diskd, rc, nbytes, cnt = 0, flag; 35 | char buffer[65000]; 36 | 37 | if (argc < 3) 38 | { 39 | STDERR("usage: tptcp src dest [disk_file]\n"); 40 | STDERR(" example: tptcp /dev/rex0 /dev/rex1 /home/tmp/ads.out\n"); 41 | return(1); 42 | } 43 | 44 | if (argc < 4) 45 | printf("No disk file being created.\n"); 46 | 47 | 48 | if (TapeOpen(argv[1]) == ERR) 49 | { 50 | STDERRA("Can't open source tape %s\n", argv[1]); 51 | return(1); 52 | } 53 | 54 | if ((outd = open(argv[2], O_WRONLY)) == ERR) 55 | { 56 | STDERRA("Can't open destination tape %s\n", argv[2]); 57 | TapeClose(); 58 | return(1); 59 | } 60 | 61 | if (argc == 4 && 62 | (diskd = open(argv[3], O_CREAT | O_WRONLY | O_TRUNC, 0666)) == ERR) 63 | { 64 | STDERRA("Can't open destination file %s\n", argv[3]); 65 | TapeClose(); 66 | close(outd); 67 | return(1); 68 | } 69 | 70 | 71 | rc = 0; /* Return Code */ 72 | flag = 1; 73 | 74 | while ((nbytes = TapeRead(buffer)) > 0) 75 | { 76 | if (flag && *(unsigned short *)buffer == 0x8681 && ((unsigned short *)buffer)[1] < 12) 77 | continue; 78 | 79 | if (*(unsigned short *)buffer == 0x8681 && ((unsigned short *)buffer)[1] > 20) 80 | flag = 0; 81 | 82 | if (write(outd, buffer, nbytes) == ERR) 83 | { 84 | STDERRA("Write failure to dest tape, errno = %d\n", errno); 85 | rc = 1; 86 | goto exit; 87 | } 88 | 89 | if (*(unsigned short *)buffer == 0x8681 || 90 | *(unsigned short *)buffer == 0x4144 || 91 | *(unsigned short *)buffer == 0x5448) 92 | { 93 | if (argc == 4 && write(diskd, buffer, nbytes) == ERR) 94 | { 95 | if (errno == ENOSPC) 96 | { 97 | STDERR("Disk full, closing disk file and continuing.\n"); 98 | STDERRA("%d records successfully written to disk file.\n", cnt); 99 | close(diskd); 100 | argc = 3; 101 | } 102 | 103 | STDERRA("Write failure to dest disk, errno = %d\n", errno); 104 | rc = 1; 105 | goto exit; 106 | } 107 | } 108 | 109 | ++cnt; 110 | } 111 | 112 | if (nbytes == ERR) 113 | { 114 | STDERRA("Read error, errno = %d\n", errno); 115 | rc = 1; 116 | } 117 | 118 | exit: 119 | TapeClose(); 120 | close(outd); 121 | 122 | if (argc == 4) 123 | close(diskd); 124 | 125 | printf("%d records successfully read and written\n", cnt); 126 | return(rc); 127 | 128 | } /* END MAIN */ 129 | 130 | /* END TPTCP.C */ 131 | -------------------------------------------------------------------------------- /rtplot_motif/ccb.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: ccb.c 4 | 5 | FULL NAME: Command CallBacks 6 | 7 | ENTRY POINTS: 8 | 9 | STATIC FNS: none 10 | 11 | DESCRIPTION: 12 | 13 | REFERENCES: 14 | 15 | REFERENCED BY: XtAppMainLoop() 16 | 17 | COPYRIGHT: University Corporation for Atmospheric Research, 1994-9 18 | ------------------------------------------------------------------------- 19 | */ 20 | 21 | #include "define.h" 22 | #include 23 | 24 | #include 25 | 26 | void SetYLabelPixmap(), DeleteVariable(int), AddVariable(int); 27 | 28 | /* -------------------------------------------------------------------- */ 29 | void Freeze(Widget w, XtPointer client, XtPointer call) 30 | { 31 | Frozen = !Frozen; 32 | 33 | } /* END FREEZE */ 34 | 35 | /* -------------------------------------------------------------------- */ 36 | void DoAutoScale(Widget w, XtPointer client, XtPointer call) 37 | { 38 | AutoScale(SCALE_YAXIS); 39 | 40 | PlotData((Widget)NULL, (XtPointer)NULL, (XtPointer *)NULL); 41 | 42 | } /* END AUTOSCALE */ 43 | 44 | /* -------------------------------------------------------------------- */ 45 | void ToggleUnits(Widget w, XtPointer client, XtPointer call) 46 | { 47 | switch ((Units = (int)client)) 48 | { 49 | case COUNTS: 50 | ylabel = "Counts"; 51 | break; 52 | 53 | case VOLTS: 54 | ylabel = "Volts"; 55 | break; 56 | 57 | case ENGINEERING: 58 | ylabel = "Engineering"; 59 | break; 60 | } 61 | 62 | SetYLabelPixmap(); 63 | 64 | } /* END TOGGLECOUNTS */ 65 | 66 | /* -------------------------------------------------------------------- */ 67 | void ToggleFlash(Widget w, XtPointer client, XtPointer call) 68 | { 69 | FlashMode = !FlashMode; 70 | 71 | } /* END TOGGLEFLASH */ 72 | 73 | /* -------------------------------------------------------------------- */ 74 | void ToggleGrid(Widget w, XtPointer client, XtPointer call) 75 | { 76 | Grid = !Grid; 77 | PlotData((Widget)NULL, (XtPointer)NULL, (XtPointer *)NULL); 78 | 79 | } /* END TOGGLEGRID */ 80 | 81 | /* -------------------------------------------------------------------- */ 82 | void ModifyActiveVars(Widget w, XtPointer client, XtPointer call) 83 | { 84 | int i; 85 | int *pos_list, pos_cnt; 86 | 87 | if (XmListGetSelectedPos(varList, &pos_list, &pos_cnt) == FALSE) 88 | return; 89 | 90 | pos_list[0] -= 1; 91 | 92 | if (pos_list[0] >= nsdi) 93 | { 94 | pos_list[0] -= nsdi; 95 | 96 | for (i = 0; i < nVariables; ++i) 97 | if (strcmp(Variable[i].name, raw[pos_list[0]]->name) == 0) 98 | { 99 | DeleteVariable(i); 100 | return; 101 | } 102 | 103 | if (NumberDataSets + 1 > MAXDATASETS) 104 | { 105 | ErrorMsg("Out of data sets."); 106 | return; 107 | } 108 | else 109 | AddVariable(pos_list[0] + nsdi); 110 | } 111 | else 112 | { 113 | for (i = 0; i < nVariables; ++i) 114 | if (strcmp(Variable[i].name, sdi[pos_list[0]]->name) == 0) 115 | { 116 | DeleteVariable(i); 117 | return; 118 | } 119 | 120 | if (NumberDataSets + 1 > MAXDATASETS) 121 | { 122 | ErrorMsg("Out of data sets."); 123 | return; 124 | } 125 | else 126 | AddVariable(pos_list[0]); 127 | } 128 | 129 | } /* END MODIFYACTIVEVARS */ 130 | 131 | /* -------------------------------------------------------------------- */ 132 | void Quit(Widget w, XtPointer client, XtPointer call) 133 | { 134 | exit(0); 135 | 136 | } /* END QUIT */ 137 | 138 | /* END CCB.C */ 139 | -------------------------------------------------------------------------------- /rtplot_motif/dataIO.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: dataIO.c 4 | 5 | FULL NAME: Data IO 6 | 7 | ENTRY POINTS: ReadData() 8 | GetData() 9 | AddVariable() 10 | DeleteVariable() 11 | 12 | STATIC FNS: free_data() 13 | 14 | DESCRIPTION: Read data from shared memory and process it. 15 | 16 | INPUT: none 17 | 18 | OUTPUT: none 19 | 20 | COPYRIGHT: University Corporation for Atmospheric Research, 1994-9 21 | ------------------------------------------------------------------------- 22 | */ 23 | 24 | #include "define.h" 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | extern XtAppContext app_con; 31 | 32 | /* -------------------------------------------------------------------- */ 33 | void AddDataToBuffer(NR_TYPE *newData) 34 | { 35 | int i, j; 36 | 37 | biggest_y = -FLT_MAX; 38 | smallest_y = FLT_MAX; 39 | 40 | for (i = 0; i < nVariables; ++i) 41 | { 42 | memcpy( (char *)&plotData[i][Variable[i].buffIndex], 43 | (char *)&newData[Variable[i].SRstart], 44 | NR_SIZE * Variable[i].SampleRate); 45 | 46 | Variable[i].buffIndex += Variable[i].SampleRate; 47 | 48 | if (Variable[i].buffIndex >= Variable[i].nPoints) 49 | Variable[i].buffIndex -= Variable[i].nPoints; 50 | 51 | for (j = 0; j < Variable[i].nPoints; ++j) 52 | { 53 | biggest_y = max(biggest_y, plotData[i][j]); 54 | smallest_y = min(smallest_y, plotData[i][j]); 55 | } 56 | } 57 | 58 | } /* END ADDDATATOBUFFER */ 59 | 60 | /* -------------------------------------------------------------------- */ 61 | NR_TYPE GetData(int set, int indx) 62 | { 63 | indx += Variable[set].buffIndex; 64 | 65 | if (indx >= Variable[set].nPoints) 66 | indx -= Variable[set].nPoints; 67 | 68 | return(plotData[set][indx]); 69 | 70 | } /* END GETDATA */ 71 | 72 | /* -------------------------------------------------------------------- */ 73 | void AddVariable(int indx) 74 | { 75 | if (indx > nsdi) 76 | { 77 | indx -= nsdi; 78 | 79 | strcpy(Variable[nVariables].name, raw[indx]->name); 80 | Variable[nVariables].SampleRate = raw[indx]->SampleRate; 81 | Variable[nVariables].SRstart = raw[indx]->SRstart; 82 | Variable[nVariables].nPoints = raw[indx]->SampleRate * NumberSeconds; 83 | Variable[nVariables].buffIndex = 0; 84 | } 85 | else 86 | { 87 | strcpy(Variable[nVariables].name, sdi[indx]->name); 88 | Variable[nVariables].SampleRate = sdi[indx]->SampleRate; 89 | Variable[nVariables].SRstart = sdi[indx]->SRstart; 90 | Variable[nVariables].nPoints = sdi[indx]->SampleRate * NumberSeconds; 91 | Variable[nVariables].buffIndex = 0; 92 | } 93 | 94 | plotData[nVariables] = new float[Variable[nVariables].nPoints]; 95 | Variable[nVariables].pts = new XPoint[Variable[nVariables].nPoints]; 96 | memset(plotData[nVariables], 0, Variable[nVariables].nPoints * NR_SIZE); 97 | 98 | ++NumberDataSets; 99 | ++nVariables; 100 | 101 | PlotData(NULL, NULL, NULL); 102 | 103 | } /* END ADDVARAIBLE */ 104 | 105 | /* -------------------------------------------------------------------- */ 106 | void DeleteVariable(int indx) 107 | { 108 | int i; 109 | 110 | delete [] plotData[indx]; 111 | delete [] Variable[indx].pts; 112 | 113 | for (i = indx+1; i < NumberDataSets; ++i) 114 | { 115 | memcpy(&Variable[i-1], &Variable[i], sizeof(VARTBL)); 116 | plotData[i-1] = plotData[i]; 117 | } 118 | 119 | --NumberDataSets; 120 | --nVariables; 121 | 122 | PlotData(NULL, NULL, NULL); 123 | 124 | } /* END DELETEVARIABLE */ 125 | 126 | /* END DATAIO.C */ 127 | -------------------------------------------------------------------------------- /dmptime/dmptime.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: dmptime.cc 4 | 5 | FULL NAME: ADS tape copier & downloader. 6 | 7 | DESCRIPTION: Print time stamps from all records in an ADS file. 8 | to individual disk files [ads|2d|MCR|AVAPS]. 9 | 10 | COPYRIGHT: University Corporation for Atmospheric Research, 2003-06 11 | ------------------------------------------------------------------------- 12 | */ 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | 27 | char buffer[100000]; 28 | char sourceTape[200]; 29 | 30 | int Output(char buff[], int nBytes); 31 | 32 | 33 | /* -------------------------------------------------------------------- */ 34 | main(int argc, char *argv[]) 35 | { 36 | int rc, nBytes; 37 | ADS_DataFile *source; 38 | 39 | if (argc < 2) 40 | { 41 | printf("Enter file : "); 42 | fgets(sourceTape, 200, stdin); 43 | sourceTape[strlen(sourceTape)-1] = '\0'; 44 | } 45 | else 46 | strcpy(sourceTape, argv[1]); 47 | 48 | source = new ADS_DataFile(sourceTape); 49 | 50 | 51 | rc = 0; /* Return Code */ 52 | 53 | while ((nBytes = source->NextPhysicalRecord(buffer)) > 0) 54 | { 55 | // if (strncmp(buffer, "MCR", 3) == 0) 56 | Output(buffer, nBytes); 57 | } 58 | 59 | 60 | if (nBytes == ERR) 61 | { 62 | fprintf(stderr, "Read error, errno = %d.\n", errno); 63 | rc = 1; 64 | } 65 | 66 | 67 | return(rc); 68 | 69 | } /* END MAIN */ 70 | 71 | /* -------------------------------------------------------------------- */ 72 | int Output(char buff[], int nBytes) 73 | { 74 | int rc, thisTime; 75 | static int prev; 76 | Hdr_blk *hdr; 77 | P2d_rec *p2d; 78 | Mcr_rec *mcr; 79 | 80 | static size_t recCntr = 0; 81 | static size_t prevTime = 0; 82 | 83 | hdr = (Hdr_blk *)buffer; 84 | p2d = (P2d_rec *)buffer; 85 | mcr = (Mcr_rec *)buffer; 86 | 87 | switch (ntohs(*(unsigned short *)buff)) 88 | { 89 | case 0x8681: 90 | thisTime = ntohs(hdr->hour) * 3600 + ntohs(hdr->minute) * 60 + ntohs(hdr->second); 91 | 92 | printf("[%d] Sync, nBytes=%d, %02d/%02d/%02d - %02d:%02d:%02d", 93 | recCntr++, nBytes, 94 | ntohs(hdr->year), ntohs(hdr->month), ntohs(hdr->day), 95 | ntohs(hdr->hour), ntohs(hdr->minute), ntohs(hdr->second)); 96 | 97 | if (prevTime + 1 != thisTime) 98 | printf(" gap?"); 99 | 100 | printf("\n"); 101 | prevTime = thisTime; 102 | break; 103 | 104 | case 0x4331: // PMS2D types. 105 | case 0x4332: 106 | case 0x5031: 107 | case 0x5032: 108 | case 0x4731: 109 | case 0x4732: 110 | case 0x4831: 111 | case 0x4832: 112 | // printf("PMS 2d %c, nBytes=%d\n", buff[0], nBytes); 113 | for (int i = 0; i < 7; ++i) { 114 | if ( (((short*)p2d[i].data)[0] - prev) != 1) 115 | printf("lost %d %d\n", prev, ((short*)p2d[i].data)[0]); 116 | // printf(" %c %02d:%02d:%02d.%03d, tas=%d %x\n", ((char*)&p2d[i])[0], ntohs(p2d[i].hour), ntohs(p2d[i].minute), ntohs(p2d[i].second), ntohs(p2d[i].msec), ntohs(p2d[i].tas), ((short*)p2d[i].data)[0]); 117 | prev = ((short*)p2d[i].data)[0]; 118 | } 119 | break; 120 | 121 | case 0x4d43: // MCR 122 | printf(" %s, nBytes=%d, %02d:%02d:%02d\n", mcr->id, nBytes, ntohs(mcr->hour), ntohs(mcr->minute), ntohs(mcr->second)); 123 | break; 124 | } 125 | 126 | return(OK); 127 | 128 | } /* END WRITEDISK */ 129 | 130 | /* END DNLOAD.CC */ 131 | -------------------------------------------------------------------------------- /edADShdr/fbr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Resource file for edADShdr (ADS header editor) 3 | */ 4 | 5 | static String fallback_resources[] = 6 | { 7 | "*defaultFontList: -adobe-courier-bold-r-*-*-14-140-75-75-*-*-*-*", 8 | "*XmForm.horizontalSpacing: 8", 9 | "*XmForm.verticalSpacing: 8", 10 | "*editFieldRC*XmLabel.width: 200", 11 | "*editFieldRC*XmLabel.recomputeSize: False", 12 | "*buttonFrame*XmPushButton.height: 32", 13 | "*buttonFrame*XmPushButton.width: 100", 14 | "*buttonFrame*XmPushButton.recomputeSize: False", 15 | "*XmTextField.background: Burlywood", 16 | "*XmTextField.foreground: black", 17 | "*buttonFrame.shadowType: SHADOW_IN", 18 | "*buttonRC.entryAlignment: ALIGNMENT_CENTER", 19 | "*buttonRC.isAligned: True", 20 | "*buttonRC.orientation: HORIZONTAL", 21 | 22 | "*topLevelShell.x: 200", 23 | "*topLevelShell.y: 200", 24 | "*topLevelShell.title: Variable DataBase Editor", 25 | "*topLevelShell.iconName: edADShdr", 26 | "*topLevelForm.resizePolicy: RESIZE_GROW", 27 | 28 | "*menuBar*filePD_CB.labelString: File", 29 | "*menuBar*filePD_CB.mnemonic: F", 30 | "*menuBar*editPD_CB.labelString: Edit", 31 | "*menuBar*editPD_CB.mnemonic: E", 32 | 33 | "*menuBar*openNewFile.labelString: Open New File", 34 | "*menuBar*openNewFile.mnemonic: O", 35 | "*menuBar*openNewFile.accelerator: CtrlO", 36 | "*menuBar*openNewFile.acceleratorText: Ctrl-O", 37 | "*menuBar*saveFile.labelString: Save", 38 | "*menuBar*saveFile.mnemonic: S", 39 | "*menuBar*saveFile.accelerator: CtrlS", 40 | "*menuBar*saveFile.acceleratorText: Ctrl-S", 41 | "*menuBar*quit.labelString: Quit", 42 | "*menuBar*quit.mnemonic: Q", 43 | "*menuBar*quit.accelerator: CtrlQ", 44 | "*menuBar*quit.acceleratorText: Ctrl-Q", 45 | 46 | "*menuBar*clearVar.labelString: Clear Variable", 47 | "*menuBar*clearVar.mnemonic: C", 48 | "*menuBar*clearVar.accelerator: CtrlC", 49 | "*menuBar*clearVar.acceleratorText: Ctrl-C", 50 | "*menuBar*resetVar.labelString: Reset Variable", 51 | "*menuBar*resetVar.mnemonic: R", 52 | "*menuBar*resetVar.accelerator: CtrlR", 53 | "*menuBar*resetVar.acceleratorText: Ctrl-R", 54 | "*menuBar*deleteVar.labelString: Delete Variable", 55 | "*menuBar*deleteVar.mnemonic: D", 56 | "*menuBar*deleteVar.accelerator: CtrlD", 57 | "*menuBar*deleteVar.acceleratorText: Ctrl-D", 58 | 59 | "*acceptButton.labelString: Accept", 60 | 61 | "*editFieldRC.orientation: VERTICAL", 62 | "*editFieldRC.rowColumnType: WORK_AREA", 63 | "*editFieldRC*XmForm.verticalSpacing: 0", 64 | "*editFieldRC*XmForm.horizontalSpacing: 3", 65 | "*editFieldRC*XmLabel.alignment: ALIGNMENT_END", 66 | "*EFlabel0.labelString: Project Number:", 67 | "*EFlabel1.labelString: Flight Number:", 68 | "*EFlabel2.labelString: Tape Number:", 69 | "*EFlabel3.labelString: Flight Date:", 70 | "*EFlabel4.labelString: Flight Time:", 71 | "*EFlabel5.labelString: Aircraft:", 72 | "*EFtext0.columns: 8", 73 | "*EFtext0.maxLength: 8", 74 | "*EFtext1.columns: 8", 75 | "*EFtext1.maxLength: 8", 76 | "*EFtext2.columns: 8", 77 | "*EFtext2.maxLength: 8", 78 | "*EFtext3.columns: 12", 79 | "*EFtext3.maxLength: 12", 80 | "*EFtext4.columns: 12", 81 | "*EFtext4.maxLength: 12", 82 | "*EFtext5.columns: 8", 83 | "*EFtext5.maxLength: 8", 84 | 85 | "*errorBox*background: DarkSlateGray", 86 | "*errorBox*dialogTitle: Error Message", 87 | "*errorBox*foreground: Red", 88 | "*errorBox*XmLabel.alignment: ALIGNMENT_CENTER", 89 | "*warnBox*background: DarkSlateGray", 90 | "*warnBox*dialogTitle: Warning Message", 91 | "*warnBox*foreground: Yellow", 92 | "*warnBox*XmLabel.alignment: ALIGNMENT_CENTER", 93 | "*fileBox.defaultPosition: FALSE", 94 | "*fileBox.x: 130", 95 | "*fileBox.y: 200", 96 | "*fileBox*textColumns: 50", 97 | "*fileBox*dialogTitle: Select a File", 98 | NULL 99 | }; 100 | -------------------------------------------------------------------------------- /edADShdr/ccb.c: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: ccb.c 4 | 5 | FULL NAME: Command Callbacks 6 | 7 | ENTRY POINTS: Quit() 8 | OpenNewFile() 9 | SaveFile() 10 | 11 | STATIC FNS: none 12 | 13 | DESCRIPTION: 14 | 15 | INPUT: 16 | 17 | OUTPUT: none 18 | 19 | REFERENCES: none 20 | 21 | REFERENCED BY: XtAppMainLoop() 22 | 23 | COPYRIGHT: University Corporation for Atmospheric Research, 2000 24 | ------------------------------------------------------------------------- 25 | */ 26 | 27 | #include 28 | #include 29 | 30 | #include "define.h" 31 | #include 32 | 33 | static int ChangesMade = FALSE, currentCategory = 0; 34 | 35 | extern Widget EFtext[]; 36 | extern char buffer[], FileName[], *DataDirectory; 37 | extern Fl flInfo; 38 | 39 | void exit(); 40 | double atof(); 41 | 42 | /* -------------------------------------------------------------------- */ 43 | void Quit(Widget w, XtPointer client, XtPointer call) 44 | { 45 | if (ChangesMade) 46 | { 47 | WarnUser("You have not saved this file.", exit); 48 | return; 49 | } 50 | 51 | exit(0); 52 | 53 | } /* END QUIT */ 54 | 55 | /* -------------------------------------------------------------------- */ 56 | void OpenNewFile(Widget w, XtPointer client, XtPointer call) 57 | { 58 | sprintf(buffer, "%s/*", DataDirectory); 59 | QueryFile("Enter file name to load:", buffer, OpenNewFile_OK); 60 | 61 | } /* END OPENNEWFILE */ 62 | 63 | /* -------------------------------------------------------------------- */ 64 | void OpenNewFile_OK(Widget w, XtPointer client, XmFileSelectionBoxCallbackStruct *call) 65 | { 66 | char *file; 67 | FILE *fp; 68 | 69 | if (w) 70 | { 71 | ExtractFileName(call->value, &file); 72 | FileCancel((Widget)NULL, (XtPointer)NULL, (XtPointer)NULL); 73 | 74 | strcpy(FileName, file); 75 | } 76 | 77 | 78 | if ((fp = fopen(FileName, "rb+")) == NULL) 79 | { 80 | fprintf(stderr, "Failed to open file for output.\n"); 81 | } 82 | else 83 | { 84 | fseek(fp, 20, SEEK_SET); 85 | fread((char *)&flInfo, sizeof(Fl), 1, fp); 86 | fclose(fp); 87 | 88 | if (strcmp(flInfo.thdr, "THDR")) 89 | { 90 | fprintf(stderr, "Not a valid ADS file.\n"); 91 | return; 92 | } 93 | 94 | XmTextFieldSetString(EFtext[0], flInfo.prnum); 95 | XmTextFieldSetString(EFtext[1], flInfo.fltnum); 96 | XmTextFieldSetString(EFtext[2], flInfo.tpnum); 97 | XmTextFieldSetString(EFtext[3], flInfo.date); 98 | XmTextFieldSetString(EFtext[4], flInfo.time); 99 | XmTextFieldSetString(EFtext[5], flInfo.acraft); 100 | } 101 | 102 | } /* END OPENNEWFILE_OK */ 103 | 104 | /* -------------------------------------------------------------------- */ 105 | void SaveFile(Widget w, XtPointer client, XtPointer call) 106 | { 107 | FILE *fp; 108 | 109 | if ((fp = fopen(FileName, "rb+")) == NULL) 110 | { 111 | if (errno == EACCES) 112 | fprintf(stderr, "Write permission denied.\n"); 113 | 114 | fprintf(stderr, "Failed to open file for output.\n"); 115 | } 116 | else 117 | { 118 | char *p; 119 | 120 | p = XmTextFieldGetString(EFtext[0]); 121 | strcpy(flInfo.prnum, p); 122 | XtFree(p); 123 | 124 | p = XmTextFieldGetString(EFtext[1]); 125 | strcpy(flInfo.fltnum, p); 126 | XtFree(p); 127 | 128 | p = XmTextFieldGetString(EFtext[2]); 129 | strcpy(flInfo.tpnum, p); 130 | XtFree(p); 131 | 132 | p = XmTextFieldGetString(EFtext[3]); 133 | strcpy(flInfo.date, p); 134 | XtFree(p); 135 | 136 | p = XmTextFieldGetString(EFtext[4]); 137 | strcpy(flInfo.time, p); 138 | XtFree(p); 139 | 140 | p = XmTextFieldGetString(EFtext[5]); 141 | strcpy(flInfo.acraft, p); 142 | XtFree(p); 143 | 144 | 145 | fseek(fp, 20, SEEK_SET); 146 | fwrite((char *)&flInfo, sizeof(Fl), 1, fp); 147 | fclose(fp); 148 | } 149 | 150 | } /* END SAVEFILE */ 151 | 152 | /* END CCB.C */ 153 | -------------------------------------------------------------------------------- /old_ads/hdrdump_all.c: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: hdrdump.c 4 | 5 | FULL NAME: Header Dump 6 | 7 | ENTRY POINTS: main() 8 | 9 | DESCRIPTION: 10 | 11 | INPUT: Filename of header 12 | 13 | OUTPUT: Tape dump to stdout 14 | 15 | REFERENCES: Header API (libhdr_api.a) 16 | 17 | COPYRIGHT: University Corporation for Atmospheric Research, 1992 18 | ------------------------------------------------------------------------- 19 | */ 20 | 21 | #include 22 | #include "raf/ctape.h" 23 | 24 | 25 | char buffer[1024]; 26 | 27 | char *sdititle = 28 | "\nType Name Start Len Rate Offset Type\n"; 29 | 30 | char *otitle = 31 | "\n\n Block name Start byte Length (bytes)\n"; 32 | 33 | char *atitle = 34 | "\n\n Async blocks\n"; 35 | 36 | 37 | 38 | /* -------------------------------------------------------------------- */ 39 | main(argc, argv) 40 | int argc; 41 | char *argv[]; 42 | { 43 | int i; 44 | char *cvar; /* Pointer to current variable */ 45 | char *cp[3]; /* Some generic Char Pointers */ 46 | long l; /* Long result storage */ 47 | float f; /* Float result storage */ 48 | float *cal; /* Cal Coeff storage */ 49 | 50 | 51 | if (argc < 2) 52 | { 53 | fprintf(stderr, "usage:\thdrdump [prj# | headerfile]\n"); 54 | exit(1); 55 | } 56 | 57 | 58 | /* Deterimine if header feader filename is a project# or filename 59 | */ 60 | if (isdigit(argv[1][0])) 61 | sprintf(buffer, "/home/local/winds/proj/%s/header", argv[1]); 62 | else 63 | strcpy(buffer, argv[1]); 64 | 65 | 66 | if (InitFlightHeader(buffer, CLOSE) == ERR) 67 | { 68 | fprintf(stderr, "hdrdump: init error, taperr = %d\n", taperr); 69 | exit(1); 70 | } 71 | 72 | 73 | GetAircraft(&cp[0]); 74 | GetProjectNumber(&cp[1]); 75 | GetFlightNumber(&cp[2]); 76 | printf(" Aircraft: %s, Project: %s, Flight: %s\n", cp[0], cp[1], cp[2]); 77 | 78 | GetHeaderDate(&cp[0]); 79 | GetHeaderTime(&cp[1]); 80 | printf(" Date: %s Time: %s\n", cp[0], cp[1]); 81 | 82 | GetNumberItems(&l); 83 | printf(" Number of data items: %ld", l); 84 | get_lrlen(&l); 85 | printf(" Logical record length: %ld\n", l); 86 | 87 | 88 | 89 | /* Do SDI vars first 90 | */ 91 | printf(sdititle); 92 | 93 | cvar = GetFirst(); 94 | 95 | while (cvar = GetNext()) 96 | { 97 | GetItemType(cvar, &cp[0]); 98 | if (!(strcmp(cp[0], "SDI") == 0 || strcmp(cp[0], "HSKP") == 0 99 | || strcmp(cp[0], "DIGOUT") == 0)) 100 | continue; 101 | 102 | printf("%-8s%-8s ", cp[0], cvar); 103 | 104 | if (GetStart(cvar, &l) == ERR) 105 | printf("<%d> ", taperr); 106 | else 107 | printf("%4ld ", l); 108 | 109 | if (GetLength(cvar, &l) == ERR) 110 | printf("<%d> ", taperr); 111 | else 112 | printf("%4ld ", l); 113 | 114 | if (GetRate(cvar, &l) == ERR) 115 | printf("<%d> ", taperr); 116 | else 117 | printf("%5ld ", l); 118 | 119 | if (GetSampleOffset(cvar, &l) == ERR) 120 | printf("<%d> ", taperr); 121 | else 122 | printf("%7ld ", l); 123 | 124 | if (GetType(cvar, &cp[0]) == ERR) 125 | printf("<%d> ", taperr); 126 | else 127 | printf(" %s ", cp[0]); 128 | 129 | printf("\n"); 130 | } 131 | 132 | 133 | 134 | /* Do the rest of the vars, except ASYNC 135 | */ 136 | printf(otitle); 137 | 138 | cvar = GetFirst(); 139 | 140 | while (cvar = GetNext()) 141 | { 142 | GetItemType(cvar, &cp[0]); 143 | if (strcmp(cp[0], "SDI") == 0 || strcmp(cp[0], "HSKP") == 0 || 144 | strcmp(cp[0], "DIGOUT") == 0 || strcmp(cp[0], "ASYNC") == 0) 145 | continue; 146 | 147 | printf(" %-8s ", cvar); 148 | 149 | if (GetStart(cvar, &l) == ERR) 150 | printf(" <%d> ", taperr); 151 | else 152 | printf("%7ld ", l); 153 | 154 | if (GetLength(cvar, &l) == ERR) 155 | printf("\t\t<%d>", taperr); 156 | else 157 | printf("\t\t%5ld", l); 158 | 159 | printf("\n"); 160 | } 161 | 162 | 163 | /* Do ASYNC 164 | */ 165 | printf(atitle); 166 | 167 | cvar = GetFirst(); 168 | 169 | while (cvar = GetNext()) 170 | { 171 | GetItemType(cvar, &cp[0]); 172 | if (strcmp(cp[0], "ASYNC") != 0) 173 | continue; 174 | 175 | printf(" %-8s ", cvar); 176 | 177 | if (GetLength(cvar, &l) == ERR) 178 | printf(" <%d>", taperr); 179 | else 180 | printf("% 5ld", l); 181 | 182 | printf("\n"); 183 | } 184 | 185 | ReleaseFlightHeader(); 186 | 187 | return(0); 188 | 189 | } /* END MAIN */ 190 | 191 | /* END HDRDUMP.C */ 192 | -------------------------------------------------------------------------------- /mcr/mcr_cut.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: mcr_cut.cc 4 | 5 | FULL NAME: 6 | 7 | DESCRIPTION: Cut raw data out of MCR file for user specified time and 8 | channels. Each channel goes to seperate file. 9 | 10 | REFERENCES: libraf++.a 11 | 12 | NOTES: g++ -I/home/local/libraf++ mcr_cut.cc -o mcr_cut -lraf++ 13 | 14 | COPYRIGHT: University Corporation for Atmospheric Research, 1999 15 | ------------------------------------------------------------------------- 16 | */ 17 | 18 | #include "raf/adsIO.h" 19 | 20 | char buffer[65000], mcrFileName[128]; 21 | Mcr_rec mcrRec; 22 | ADS_DataFile *file; 23 | 24 | bool NextMCRfile(); 25 | 26 | /* -------------------------------------------------------------------- */ 27 | main() 28 | { 29 | char outputFile[128], tmp[32], hdr[30000]; 30 | short start[3], end[3]; 31 | FILE *fp[7]; 32 | int i, l1, l2; 33 | bool channel[7]; 34 | 35 | 36 | /* Query user for info. 37 | */ 38 | printf("Enter input file : "); 39 | gets(mcrFileName); 40 | 41 | printf("Enter output file : "); 42 | gets(outputFile); 43 | 44 | printf("Enter start time [hhmmss] : "); 45 | gets(buffer); 46 | sscanf(buffer, "%02hd%02hd%02hd\n", &start[0], &start[1], &start[2]); 47 | 48 | printf("Enter end time [hhmmss] : "); 49 | gets(buffer); 50 | sscanf(buffer, "%02hd%02hd%02hd\n", &end[0], &end[1], &end[2]); 51 | 52 | printf("Enter channels [ex: 1347] : "); 53 | gets(buffer); 54 | 55 | for (i = 0; i < 7; ++i) 56 | channel[i] = false; 57 | 58 | for (i = 0; i < strlen(buffer); ++i) 59 | channel[buffer[i] - '1'] = true; 60 | 61 | 62 | /* Open files. 63 | */ 64 | file = new ADS_DataFile(mcrFileName); 65 | 66 | l1 = file->NextPhysicalRecord(tmp); 67 | l2 = file->NextPhysicalRecord(hdr); 68 | 69 | for (i = 0; i < 7; ++i) 70 | if (channel[i]) 71 | { 72 | sprintf(buffer, "%s%d-%02d%02d%02d-%02d%02d%02d", outputFile, i + 1, 73 | start[0], start[1], start[2], end[0], end[1], end[2]); 74 | 75 | if ((fp[i] = fopen(buffer, "w+b")) == NULL) 76 | { 77 | fprintf(stderr, "Can't open output file %s.\n", buffer); 78 | exit(1); 79 | } 80 | 81 | /* Un comment to be able to view the files via mcrtd. 82 | fwrite(tmp, l1, 1, fp[i]); 83 | fwrite(hdr, l2, 1, fp[i]); 84 | fwrite(hdr, l2, 1, fp[i]); 85 | */ 86 | } 87 | 88 | 89 | /* Find start time. 90 | */ 91 | file->FirstMCRRecord(&mcrRec); 92 | 93 | while (memcmp((char *)start, (char *)&(mcrRec.hour), 6)) 94 | { 95 | if (file->NextMCRRecord(&mcrRec) == false) 96 | if (NextMCRfile() == false) 97 | { 98 | fprintf(stderr, "Failed to locate start time.\n"); 99 | exit(1); 100 | } 101 | 102 | if (mcrRec.id[4] == '0' && mcrRec.second == 0) 103 | { 104 | printf("%02d:%02d:%02d\r", mcrRec.hour, mcrRec.minute, mcrRec.second); 105 | fflush(stdout); 106 | } 107 | } 108 | 109 | 110 | printf("\n"); 111 | 112 | 113 | /* Dump records until you reach end time. 114 | */ 115 | while (memcmp((char *)end, (char *)&(mcrRec.hour), 6)) 116 | { 117 | if (file->NextMCRRecord(&mcrRec) == false) 118 | if (NextMCRfile() == false) 119 | { 120 | fprintf(stderr, "Failed to reach end time, closing files, and"); 121 | fprintf(stderr, "quitting @ %02d:%02d:%02d.\n", mcrRec.hour, 122 | mcrRec.minute, mcrRec.second); 123 | break; 124 | } 125 | 126 | if (channel[mcrRec.id[4]-'0']) 127 | fwrite((char *)&mcrRec, sizeof(Mcr_rec), 1, fp[mcrRec.id[4]-'0']); 128 | 129 | if (mcrRec.id[4] == '0' && mcrRec.second == 0) 130 | { 131 | printf("%02d:%02d:%02d\r", mcrRec.hour, mcrRec.minute, mcrRec.second); 132 | fflush(stdout); 133 | } 134 | } 135 | 136 | 137 | /* Out of here. 138 | */ 139 | for (i = 0; i < 7; ++i) 140 | if (channel[i]) 141 | fclose(fp[i]); 142 | 143 | printf("\n"); 144 | 145 | } 146 | 147 | /* -------------------------------------------------------------------- */ 148 | bool NextMCRfile() 149 | { 150 | delete file; 151 | 152 | ++(mcrFileName[strlen(mcrFileName)-1]); 153 | 154 | file = new ADS_DataFile(mcrFileName); 155 | 156 | printf(" \nChanging to MCR file %s.\n", mcrFileName); 157 | 158 | return(file->FirstMCRRecord(&mcrRec)); 159 | 160 | } /* END NEXTMCRFILE */ 161 | 162 | /* END MCR_CUT.CC */ 163 | 164 | -------------------------------------------------------------------------------- /gpsChk.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char buffer[32000]; 4 | int year, month, day, hour, minute, second; 5 | 6 | int calcDateTime(int week, int secs, int gps_off); 7 | 8 | 9 | /* -------------------------------------------------------------------- */ 10 | main(int argc, char *argv[]) 11 | { 12 | int infd, firstRecord, timesMatch = TRUE, print = FALSE; 13 | long start, lrLen; 14 | char *vn, *item_type; 15 | Hdr_blk *hdr; 16 | Gps_blk *gpsDat; 17 | 18 | if ((infd = InitFlightHeader(argv[1], LEAVE_OPEN)) == ERR) 19 | return(1); 20 | 21 | get_lrlen(&lrLen); 22 | 23 | for (vn = GetFirst(); vn; vn = GetNext()) 24 | { 25 | GetItemType(vn, &item_type); 26 | 27 | if (strcmp(item_type, GPS_TANS3_STR)) 28 | continue; 29 | 30 | GetStart(vn, &start); 31 | break; 32 | } 33 | 34 | hdr = (Hdr_blk *)buffer; 35 | gpsDat = (Gps_blk *)&buffer[start]; 36 | 37 | while (read(infd, buffer, 2) == 2) 38 | { 39 | if (*((unsigned short *)buffer) != 0x8681) 40 | continue; 41 | 42 | if (read(infd, &buffer[2], lrLen - 2) != lrLen -2) 43 | break; 44 | 45 | calcDateTime( (int)gpsDat->gpsweek, 46 | (int)gpsDat->gpstime, 47 | (int)gpsDat->gpsutc); 48 | 49 | if (firstRecord) 50 | { 51 | if (hdr->year != year || hdr->month != month || hdr->day != day) 52 | { 53 | printf("*** Date doesn't match. ***\n"); 54 | print = TRUE; 55 | } 56 | firstRecord = FALSE; 57 | } 58 | 59 | if (hdr->hour == hour && hdr->minute == minute && hdr->sec == second) 60 | { 61 | if (!timesMatch) 62 | { 63 | printf("Time synchronized\n"); 64 | print = TRUE; 65 | } 66 | 67 | timesMatch = TRUE; 68 | } 69 | else 70 | { 71 | if (timesMatch) 72 | { 73 | printf("Times do not match.\n"); 74 | print = TRUE; 75 | } 76 | 77 | timesMatch = FALSE; 78 | } 79 | 80 | if (print) 81 | { 82 | printf(" ADS stamp = %02d/%02d/%02d %02d:%02d:%02d\n", 83 | hdr->year, hdr->month, hdr->day, 84 | hdr->hour, hdr->minute, hdr->sec); 85 | 86 | printf(" GPS stamp = %02d/%02d/%02d %02d:%02d:%02d - week=%d, secs = %f, health=%d\n", 87 | year, month, day, hour, minute, second, 88 | gpsDat->gpsweek, gpsDat->gpstime, gpsDat->ghealth); 89 | } 90 | 91 | print = FALSE; 92 | } 93 | 94 | close(infd); 95 | return(0); 96 | 97 | } 98 | 99 | /* -------------------------------------------------------------------- */ 100 | // Time conversion defines. 101 | #define SECS_PER_DAY 86400 102 | #define SECS_PER_HOUR 3600 103 | #define SECS_PER_MIN 60 104 | #define DAYS_PER_YEAR 365 105 | #define DAYS_PER_LEAP_YEAR 366 106 | #define DAYS_PER_WEEK 7 107 | #define CALENDAR_SIZE 13 108 | #define LEAP_YEAR_MOD 4 109 | #define GPS3_BASE_YEAR 80 110 | 111 | int calcDateTime(int week, int secs, int gps_off) 112 | { 113 | int tot_days; // total days since 1/1/1980 114 | int julian_day; // current julian day 115 | int *cal_ptr; // calendar pointer 116 | 117 | static int calendar[] = 118 | {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}; 119 | static int leap_calendar[] = 120 | {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366}; 121 | 122 | // Apply the gps/utc offset. See the Trimble manual. 123 | secs -= gps_off; 124 | if (secs < 0) 125 | return(0); // time is not yet valid 126 | 127 | // Compute the day, hour, minute, and second of the current week. 128 | day = secs / SECS_PER_DAY; 129 | hour = (secs % SECS_PER_DAY) / SECS_PER_HOUR; 130 | minute = (secs % SECS_PER_HOUR) / SECS_PER_MIN; 131 | second = (secs % SECS_PER_MIN); 132 | 133 | // GPS time begins on 1/6/80. Compute the total number of days. Then 134 | // compute the year and julian day. 135 | tot_days = week * DAYS_PER_WEEK + day + 5; 136 | year = tot_days / DAYS_PER_YEAR; 137 | julian_day = tot_days - (year * DAYS_PER_YEAR) + 1; 138 | 139 | month = 0; 140 | 141 | // Compute number of previous leap days, and correct the julian day. 142 | julian_day -= (year - 1) / LEAP_YEAR_MOD + 1; 143 | 144 | // If julian day is <= 0, roll back to the previous year, and correct the 145 | // julian day. 146 | if (julian_day <= 0) { 147 | year--; 148 | if (year % LEAP_YEAR_MOD) 149 | julian_day += DAYS_PER_YEAR; 150 | else 151 | julian_day += DAYS_PER_LEAP_YEAR; 152 | } 153 | 154 | if (year % LEAP_YEAR_MOD) 155 | cal_ptr = calendar; 156 | else 157 | cal_ptr = leap_calendar; 158 | 159 | // Compute the month index. 160 | for (month = 1; (month < CALENDAR_SIZE) && 161 | (julian_day > *(cal_ptr + month)); 162 | month++); 163 | 164 | // Compute the day of the month for the start of the week. 165 | day = julian_day - *(cal_ptr + month - 1); 166 | 167 | // Add the base year, 1980, to the computed year. 168 | year += GPS3_BASE_YEAR; 169 | 170 | return(1); 171 | 172 | } 173 | 174 | -------------------------------------------------------------------------------- /edADShdr/Xwin.c: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: Xwin.c 4 | 5 | FULL NAME: Create X window GUI 6 | 7 | ENTRY POINTS: CreateMainWindow() 8 | 9 | STATIC FNS: none 10 | 11 | DESCRIPTION: 12 | 13 | INPUT: 14 | 15 | OUTPUT: 16 | 17 | REFERENCES: none 18 | 19 | REFERENCED BY: edADShdr.c (main) 20 | 21 | COPYRIGHT: University Corporation for Atmospheric Research, 2000 22 | ------------------------------------------------------------------------- 23 | */ 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #include "define.h" 35 | 36 | 37 | /* Global widget declarations. 38 | */ 39 | Widget EFtext[16], opMenu, x; 40 | Widget list, fixedButton, floatButton; 41 | 42 | extern char buffer[]; 43 | 44 | 45 | /* -------------------------------------------------------------------- */ 46 | Widget CreateMainWindow(Widget parent) 47 | { 48 | int i, textCnt; 49 | Arg args[32]; 50 | Cardinal n; 51 | Widget topLevelForm; 52 | Widget buttonFrame, buttonRC; 53 | Widget menuBar, pullDown[3], cascadeButton[2]; 54 | Widget b[10], acceptButton, clearButton; 55 | Widget separ, typeRB; 56 | Widget editFieldRC, EFform[16], EFlabel[16]; 57 | 58 | n = 0; 59 | topLevelForm = XmCreateForm(parent, "topLevelForm", args, n); 60 | 61 | 62 | /* Create Menus 63 | */ 64 | n = 0; 65 | XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; 66 | XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; 67 | menuBar = XmCreateMenuBar(topLevelForm, "menuBar", args, n); 68 | XtManageChild(menuBar); 69 | 70 | n = 0; 71 | pullDown[0] = XmCreatePulldownMenu(menuBar, "filePullDown", args, n); 72 | pullDown[1] = XmCreatePulldownMenu(menuBar, "editPullDown", args, n); 73 | 74 | n = 0; 75 | XtSetArg(args[n], XmNsubMenuId, pullDown[0]); ++n; 76 | cascadeButton[0] = XmCreateCascadeButton(menuBar, "filePD_CB", args, n); 77 | 78 | n = 0; 79 | XtSetArg(args[n], XmNsubMenuId, pullDown[1]); ++n; 80 | cascadeButton[1] = XmCreateCascadeButton(menuBar, "editPD_CB", args, n); 81 | 82 | XtManageChildren(cascadeButton, 1); 83 | XtManageChildren(pullDown, 1); 84 | 85 | n = 0; 86 | b[0] = XmCreatePushButton(pullDown[0], "openNewFile", args, n); 87 | b[1] = XmCreatePushButton(pullDown[0], "saveFile", args, n); 88 | b[2] = XmCreatePushButton(pullDown[0], "quit", args, n); 89 | XtAddCallback(b[0], XmNactivateCallback, OpenNewFile, NULL); 90 | XtAddCallback(b[1], XmNactivateCallback, SaveFile, NULL); 91 | XtAddCallback(b[2], XmNactivateCallback, Quit, NULL); 92 | XtManageChildren(b, 3); 93 | /* 94 | n = 0; 95 | b[0] = XmCreatePushButton(pullDown[1], "clearVar", args, n); 96 | b[1] = XmCreatePushButton(pullDown[1], "deleteVar", args, n); 97 | b[2] = XmCreatePushButton(pullDown[1], "resetVar", args, n); 98 | XtAddCallback(b[0], XmNactivateCallback, Clear, NULL); 99 | XtAddCallback(b[1], XmNactivateCallback, Delete, NULL); 100 | XtAddCallback(b[2], XmNactivateCallback, EditVariable, NULL); 101 | XtManageChildren(b, 3); 102 | */ 103 | 104 | 105 | /* Separator 106 | */ 107 | n = 0; 108 | XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++; 109 | XtSetArg(args[n], XmNtopWidget, menuBar); n++; 110 | XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; 111 | XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; 112 | separ = XmCreateSeparator(topLevelForm, "separ1", args, n); 113 | XtManageChild(separ); 114 | 115 | 116 | /* Create Form & Label widgets. 117 | */ 118 | n = 0; 119 | XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++; 120 | XtSetArg(args[n], XmNtopWidget, separ); n++; 121 | XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; 122 | editFieldRC = XmCreateRowColumn(topLevelForm, "editFieldRC", args, n); 123 | XtManageChild(editFieldRC); 124 | 125 | for (i = 0; i < 6; ++i) 126 | { 127 | n = 0; 128 | sprintf(buffer, "EFform%d", i); 129 | EFform[i] = XmCreateForm(editFieldRC, buffer, args, n); 130 | 131 | sprintf(buffer, "EFlabel%d", i); 132 | 133 | n = 0; 134 | XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; 135 | XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++; 136 | XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; 137 | EFlabel[i] = XmCreateLabel(EFform[i], buffer, args, n); 138 | XtManageChild(EFlabel[i]); 139 | } 140 | 141 | XtManageChildren(EFform, 6); 142 | 143 | 144 | /* Add TextField widgets 145 | */ 146 | for (i = 0; i < 6; ++i) 147 | { 148 | n = 0; 149 | XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; 150 | XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++; 151 | XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++; 152 | XtSetArg(args[n], XmNleftWidget, EFlabel[i]); n++; 153 | sprintf(buffer, "EFtext%d", i); 154 | EFtext[i] = XmCreateTextField(EFform[i], buffer, args, n); 155 | XtAddCallback(EFtext[i], XmNactivateCallback, 156 | XmProcessTraversal, (XtPointer)XmTRAVERSE_NEXT_TAB_GROUP); 157 | XtManageChild(EFtext[i]); 158 | } 159 | 160 | return(topLevelForm); 161 | 162 | } /* END CREATEMAINWINDOW */ 163 | 164 | /* END XWIN.C */ 165 | -------------------------------------------------------------------------------- /rtplot_motif/CanvasWindow.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: CanvasWindow.cc 4 | 5 | FULL NAME: 6 | 7 | ENTRY POINTS: CanvasWindow() 8 | 9 | STATIC FNS: 10 | 11 | DESCRIPTION: 12 | 13 | NOTES: 14 | 15 | COPYRIGHT: University Corporation for Atmospheric Research, 1997-9 16 | ------------------------------------------------------------------------- 17 | */ 18 | 19 | #include "CanvasWindow.h" 20 | 21 | struct menu 22 | { 23 | char *title; 24 | void (*callback)(Widget, XtPointer, XtPointer); 25 | XtPointer callData; 26 | } ; 27 | 28 | static struct menu fileMenu[] = { 29 | { "quit", Quit, NULL, }, 30 | { NULL, NULL, NULL }}; 31 | 32 | static struct menu unitMenu[] = { 33 | "Counts", ToggleUnits, (XtPointer)COUNTS, 34 | "Volts", ToggleUnits, (XtPointer)VOLTS, 35 | "Engineering", ToggleUnits, (XtPointer)ENGINEERING, 36 | { NULL, NULL, NULL }}; 37 | 38 | static struct menu viewMenu[] = { 39 | "autoScale", DoAutoScale, NULL, 40 | "toggleGrid", ToggleGrid, NULL, 41 | "toggleFlash", ToggleFlash, NULL, 42 | { NULL, NULL, NULL }}; 43 | 44 | static struct 45 | { 46 | char *title; 47 | struct menu *sub; 48 | } main_menu[] = { 49 | { "File", fileMenu, }, 50 | { "Units", unitMenu, }, 51 | { "Options", viewMenu, }, 52 | { NULL, NULL }}; 53 | 54 | 55 | /* -------------------------------------------------------------------- */ 56 | CanvasWindow::CanvasWindow(const Widget parent) : WinForm(parent, "canvas", Form) 57 | { 58 | int i, j; 59 | Cardinal n; 60 | Arg args[8]; 61 | Widget menubar, menu[5], bttn[16], menu_button[5], form, form1, frame, 62 | brc, freeze; 63 | XmString item; 64 | 65 | n = 0; 66 | form = XmCreateForm(Window(), "mainForm", args, n); 67 | 68 | n = 0; 69 | menubar = XmCreateMenuBar(form, "menuBar", args, n); 70 | XtManageChild(menubar); 71 | 72 | for (i = 0; main_menu[i].title; ++i) 73 | { 74 | n = 0; 75 | menu[i] = XmCreatePulldownMenu(menubar, main_menu[i].title, args, n); 76 | 77 | n = 0; 78 | XtSetArg(args[n], XmNsubMenuId, menu[i]); ++n; 79 | menu_button[i] = XmCreateCascadeButton(menubar, main_menu[i].title, args,n); 80 | 81 | for (j = 0; main_menu[i].sub[j].title; ++j) 82 | { 83 | n = 0; 84 | 85 | if (main_menu[i].sub[j].callback == NULL) 86 | { 87 | bttn[j] = XmCreateSeparator(menu[i], main_menu[i].sub[j].title, args,n); 88 | continue; 89 | } 90 | 91 | bttn[j] = XmCreatePushButton(menu[i], main_menu[i].sub[j].title, args, n); 92 | XtAddCallback(bttn[j], XmNactivateCallback, 93 | main_menu[i].sub[j].callback, (void *)main_menu[i].sub[j].callData); 94 | } 95 | 96 | XtManageChildren(bttn, j); 97 | } 98 | 99 | XtManageChildren(menu_button, i); 100 | 101 | 102 | 103 | /* Create Graphics Canvas 104 | */ 105 | n = 0; 106 | XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; 107 | XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; 108 | XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++; 109 | form1 = XmCreateForm(form, "varForm", args, n); 110 | XtManageChild(form1); 111 | 112 | n = 0; 113 | XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; 114 | XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++; 115 | XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; 116 | XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++; 117 | XtSetArg(args[n], XmNrightWidget, form1); n++; 118 | drawA = XmCreateDrawingArea(form, "canvas", args, n); 119 | 120 | XtAddCallback(drawA, XmNexposeCallback, (XtCallbackProc)PlotData, NULL); 121 | XtAddCallback(drawA, XmNresizeCallback, (XtCallbackProc)ResizePlotWindow, NULL); 122 | XtAddCallback(drawA, XmNresizeCallback, (XtCallbackProc)PlotData, NULL); 123 | 124 | XtManageChild(drawA); 125 | 126 | 127 | /* Page Fwd & Bkwd buttons. 128 | */ 129 | n = 0; 130 | XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; 131 | XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; 132 | XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; 133 | frame = XmCreateFrame(form1, "buttonFrame", args, n); 134 | XtManageChild(frame); 135 | 136 | n = 0; 137 | brc = XmCreateRowColumn(frame, "pgButtRC", args, n); 138 | XtManageChild(brc); 139 | 140 | n = 0; 141 | freeze = XmCreatePushButton(brc, "freeze", args, n); 142 | XtAddCallback(freeze, XmNactivateCallback, Freeze, NULL); 143 | XtManageChild(freeze); 144 | 145 | n = 0; 146 | XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++; 147 | XtSetArg(args[n], XmNtopWidget, frame); n++; 148 | XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; 149 | XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++; 150 | XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; 151 | varList = XmCreateScrolledList(form1, "varList", args, n); 152 | XtAddCallback(varList, XmNbrowseSelectionCallback, ModifyActiveVars, NULL); 153 | XtManageChild(varList); 154 | 155 | for (i = 0; i < nsdi; ++i) 156 | { 157 | item = XmStringCreateLocalized(sdi[i]->name); 158 | XmListAddItem(varList, item, 0); 159 | XmStringFree(item); 160 | } 161 | 162 | for (i = 0; i < nraw; ++i) 163 | { 164 | item = XmStringCreateLocalized(raw[i]->name); 165 | XmListAddItem(varList, item, 0); 166 | XmStringFree(item); 167 | } 168 | 169 | XtManageChild(form); 170 | 171 | } /* END CONSTRUCTOR */ 172 | 173 | /* END CANVASWINDOW.CC */ 174 | -------------------------------------------------------------------------------- /rtplot_motif/fbr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Resource file for rtplot. 3 | */ 4 | 5 | static String fallback_resources[] = 6 | { 7 | "*defaultFontList: -adobe-courier-bold-r-*-*-14-140-75-75-m-90-*-*", 8 | 9 | "*font24: -adobe-courier-bold-r-*-*-24-240-75-75-*-*-*-*", 10 | "*font18: -adobe-courier-bold-r-*-*-18-180-75-75-*-*-*-*", 11 | "*font14: -adobe-courier-bold-r-*-*-14-140-75-75-*-90-*-*", 12 | "*font12: -adobe-courier-bold-r-*-*-12-120-75-75-*-70-*-*", 13 | "*font10: -adobe-courier-bold-r-*-*-10-100-75-75-*-60-*-*", 14 | 15 | "*XmPushButton.height: 32", 16 | "*XmTextField.background: Burlywood", 17 | "*XmTextField.foreground: black", 18 | "*XmForm.horizontalSpacing: 4", 19 | "*XmForm.verticalSpacing: 4", 20 | "*canvasShell.title: rtplot 2.0", 21 | "*canvasShell.iconName: rtplot", 22 | "*buttonFrame.shadowType: SHADOW_IN", 23 | "*buttonRC.XmPushButton.recomputeSize: False", 24 | "*buttonRC.XmPushButton.width: 130", 25 | "*buttonRC.entryAlignment: ALIGNMENT_CENTER", 26 | "*buttonRC.isAligned: True", 27 | "*buttonRC.orientation: HORIZONTAL", 28 | 29 | "*canvas.background: grey", 30 | "*canvas.height: 500", 31 | "*canvas.width: 800", 32 | 33 | "*varList.background: black", 34 | "*varList.foreground: green", 35 | "*varList.scrollBarDisplayPolicy: STATIC", 36 | "*varList.width: 100", 37 | 38 | "*pgButtRC.entryAlignment: ALIGNMENT_CENTER", 39 | "*pgButtRC.orientation: VERTICAL", 40 | "*freeze.labelString: Freeze", 41 | 42 | "*editShell.title: Edit Parameters", 43 | "*parmsForm.horizontalSpacing: 8", 44 | "*parmsForm.verticalSpacing: 8", 45 | "*parmsForm*buttonRC.spacing: 39", 46 | "*parmsRC*XmForm.horizontalSpacing: 5", 47 | "*parmsRC*XmLabel.alignment: ALIGNMENT_END", 48 | "*parmsRC*XmLabel.recomputeSize: False", 49 | "*parmsRC*XmLabel.height: 32", 50 | "*parmsRC*XmLabel.width: 120", 51 | "*menuBar*print.labelString: Print", 52 | "*menuBar*print.mnemonic: P", 53 | "*menuBar*print.accelerator: CtrlP", 54 | "*menuBar*print.acceleratorText: Ctrl-P", 55 | "*menuBar*quit.labelString: Quit", 56 | "*menuBar*quit.mnemonic: Q", 57 | "*menuBar*quit.accelerator: CtrlQ", 58 | "*menuBar*quit.acceleratorText: Ctrl-Q", 59 | "*menuBar*toggleCounts.labelString: Toggle Counts", 60 | "*menuBar*toggleCounts.mnemonic: C", 61 | "*menuBar*toggleCounts.accelerator: CtrlC", 62 | "*menuBar*toggleCounts.acceleratorText: Ctrl-C", 63 | "*menuBar*toggleFlash.labelString: Toggle Snapshot Mode", 64 | "*menuBar*toggleFlash.mnemonic: F", 65 | "*menuBar*toggleFlash.accelerator: CtrlF", 66 | "*menuBar*toggleFlash.acceleratorText: Ctrl-F", 67 | "*menuBar*autoScale.labelString: Auto Scale Axies", 68 | "*menuBar*autoScale.mnemonic: A", 69 | "*menuBar*autoScale.accelerator: CtrlA", 70 | "*menuBar*autoScale.acceleratorText: Ctrl-A", 71 | "*menuBar*toggleGrid.labelString: Toggle Grid", 72 | "*menuBar*toggleGrid.mnemonic: G", 73 | "*menuBar*toggleGrid.accelerator: CtrlG", 74 | "*menuBar*toggleGrid.acceleratorText: Ctrl-G", 75 | "*parmsRC*lbl0.labelString: Title", 76 | "*parmsRC*txt0.columns: 40", 77 | "*parmsRC*txt0.maxLength: 40", 78 | "*parmsRC*lbl1.labelString: Subtitle", 79 | "*parmsRC*txt1.columns: 40", 80 | "*parmsRC*txt1.maxLength: 40", 81 | "*parmsRC*lbl2.labelString: X label", 82 | "*parmsRC*txt2.columns: 40", 83 | "*parmsRC*txt2.maxLength: 40", 84 | "*parmsRC*lbl3.labelString: Y label", 85 | "*parmsRC*txt3.columns: 40", 86 | "*parmsRC*txt3.maxLength: 40", 87 | "*parmsRC*lbl4.labelString: Start time", 88 | "*parmsRC*txt4.columns: 16", 89 | "*parmsRC*txt4.maxLength: 16", 90 | "*parmsRC*lbl5.labelString: End Time", 91 | "*parmsRC*txt5.columns: 16", 92 | "*parmsRC*txt5.maxLength: 16", 93 | "*parmsRC*lbl6.labelString: Y min", 94 | "*parmsRC*txt6.columns: 16", 95 | "*parmsRC*txt6.maxLength: 16", 96 | "*parmsRC*lbl7.labelString: Y max", 97 | "*parmsRC*txt7.columns: 16", 98 | "*parmsRC*txt7.maxLength: 16", 99 | 100 | "*applyButton.labelString: Apply", 101 | "*resetButton.labelString: Reset", 102 | "*dismissButton.labelString: Dismiss", 103 | /* 104 | * Dialog Boxes 105 | */ 106 | "*fileBox.defaultPosition: FALSE", 107 | "*fileBox.x: 130", 108 | "*fileBox.y: 200", 109 | "*fileBox*textColumns: 50", 110 | "*fileBox*dialogTitle: Select a File", 111 | "*errorBox.defaultPosition: FALSE", 112 | "*errorBox.x: 450", 113 | "*errorBox.y: 100", 114 | "*errorBox*background: DarkSlateGray", 115 | "*errorBox*dialogStyle: DIALOG_FULL_APPLICATION_MODAL", 116 | "*errorBox*dialogTitle: Error Message", 117 | "*errorBox*foreground: Red", 118 | "*errorBox*XmLabel.alignment: ALIGNMENT_CENTER", 119 | "*queryBox*dialogStyle: DIALOG_FULL_APPLICATION_MODAL", 120 | "*queryBox*dialogTitle: Need input", 121 | "*queryBox*alignment: ALIGNMENT_CENTER", 122 | "*warnBox.defaultPosition: FALSE", 123 | "*warnBox.x: 450", 124 | "*warnBox.y: 100", 125 | "*warnBox*background: DarkSlateGray", 126 | "*warnBox*dialogStyle: DIALOG_FULL_APPLICATION_MODAL", 127 | "*warnBox*dialogTitle: Warning Message", 128 | "*warnBox*foreground: Yellow", 129 | "*warnBox*XmLabel.alignment: ALIGNMENT_CENTER", 130 | NULL 131 | }; 132 | -------------------------------------------------------------------------------- /rtplot_motif/Xwin.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: Xwin.c 4 | 5 | FULL NAME: X window Stuff 6 | 7 | TYPE: X11/R5 Motif 1.2 8 | 9 | DESCRIPTION: This creates the initial X window, menus and all associated 10 | widgets. Also calls CreateFile(), CreateError(), 11 | CreateQuery(). 12 | 13 | INPUT: none 14 | 15 | OUTPUT: none 16 | 17 | AUTHOR: websterc@ncar 18 | ------------------------------------------------------------------------- 19 | */ 20 | 21 | #include "define.h" 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | struct menu 35 | { 36 | char *title; 37 | void (*callback)(); 38 | XtPointer callData; 39 | } ; 40 | 41 | static struct menu file_menu[] = { 42 | "quit", Quit, NULL, 43 | NULL, NULL, NULL }; 44 | 45 | static struct menu unit_menu[] = { 46 | "Counts", ToggleUnits, (XtPointer)COUNTS, 47 | "Volts", ToggleUnits, (XtPointer)VOLTS, 48 | "Engineering", ToggleUnits, (XtPointer)ENGINEERING, 49 | NULL, NULL, NULL }; 50 | 51 | static struct menu legend_menu[] = { 52 | "autoScale", DoAutoScale, NULL, 53 | "toggleGrid", ToggleGrid, NULL, 54 | "toggleFlash", ToggleFlash, NULL, 55 | NULL, NULL, NULL }; 56 | 57 | static struct 58 | { 59 | char *title; 60 | struct menu *sub; 61 | } main_menu[] = { 62 | "File", file_menu, 63 | "Units", unit_menu, 64 | "Options", legend_menu, 65 | NULL, NULL }; 66 | 67 | void Freeze(); 68 | 69 | /* -------------------------------------------------------------------- */ 70 | Widget CreateMainWindow(parent) 71 | Widget parent; 72 | { 73 | Widget menubar, form, form1, menu[5], bttn[50], menu_button[5], freeze, 74 | frame, brc; 75 | Arg args[9]; 76 | int n, i, j; 77 | XmString item; 78 | 79 | n = 0; 80 | form = XmCreateForm(parent, "mainForm", args, n); 81 | 82 | n = 0; 83 | menubar = XmCreateMenuBar(form, "menuBar", args, n); 84 | XtManageChild(menubar); 85 | 86 | 87 | for (i = 0; main_menu[i].title; ++i) 88 | { 89 | n = 0; 90 | menu[i] = XmCreatePulldownMenu(menubar, main_menu[i].title, args, n); 91 | 92 | n = 0; 93 | XtSetArg(args[n], XmNsubMenuId, menu[i]); ++n; 94 | menu_button[i] = XmCreateCascadeButton(menubar, main_menu[i].title, args,n); 95 | 96 | for (j = 0; main_menu[i].sub[j].title; ++j) 97 | { 98 | n = 0; 99 | bttn[j] = XmCreatePushButton(menu[i], main_menu[i].sub[j].title, args, n); 100 | XtAddCallback(bttn[j], XmNactivateCallback, 101 | main_menu[i].sub[j].callback, 102 | main_menu[i].sub[j].callData); 103 | } 104 | 105 | XtManageChildren(bttn, j); 106 | } 107 | 108 | XtManageChildren(menu, i); 109 | XtManageChildren(menu_button, i); 110 | 111 | 112 | /* Create Graphics Canvas 113 | */ 114 | n = 0; 115 | XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; 116 | XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; 117 | XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++; 118 | form1 = XmCreateForm(form, "varForm", args, n); 119 | XtManageChild(form1); 120 | 121 | n = 0; 122 | XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; 123 | XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++; 124 | XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; 125 | XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++; 126 | XtSetArg(args[n], XmNrightWidget, form1); n++; 127 | canvas = XmCreateDrawingArea(form, "canvas", args, n); 128 | XtAddCallback(canvas, XmNexposeCallback, (XtCallbackProc)PlotData, 129 | (XtPointer)NULL); 130 | XtAddCallback(canvas, XmNresizeCallback, ResizePlotWindow, NULL); 131 | XtAddCallback(canvas, XmNresizeCallback, PlotData, NULL); 132 | 133 | XtManageChild(canvas); 134 | 135 | 136 | /* Page Fwd & Bkwd buttons. 137 | */ 138 | n = 0; 139 | XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; 140 | XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; 141 | XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; 142 | frame = XmCreateFrame(form1, "buttonFrame", args, n); 143 | XtManageChild(frame); 144 | 145 | n = 0; 146 | brc = XmCreateRowColumn(frame, "pgButtRC", args, n); 147 | XtManageChild(brc); 148 | 149 | n = 0; 150 | freeze = XmCreatePushButton(brc, "freeze", args, n); 151 | XtAddCallback(freeze, XmNactivateCallback, Freeze, NULL); 152 | XtManageChild(freeze); 153 | 154 | n = 0; 155 | XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++; 156 | XtSetArg(args[n], XmNtopWidget, frame); n++; 157 | XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; 158 | XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++; 159 | XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; 160 | varList = XmCreateScrolledList(form1, "varList", args, n); 161 | XtAddCallback(varList, XmNdefaultActionCallback, ModifyActiveVars, NULL); 162 | XtManageChild(varList); 163 | 164 | 165 | for (i = 0; i < nsdi; ++i) 166 | { 167 | item = XmStringCreateLocalized(sdi[i]->name); 168 | XmListAddItem(varList, item, 0); 169 | XmStringFree(item); 170 | } 171 | 172 | for (i = 0; i < nraw; ++i) 173 | { 174 | item = XmStringCreateLocalized(raw[i]->name); 175 | XmListAddItem(varList, item, 0); 176 | XmStringFree(item); 177 | } 178 | 179 | return(form); 180 | 181 | } /* END CREATEMAINWINDOW */ 182 | 183 | /* -------------------------------------------------------------------- */ 184 | void FlushXEvents() 185 | { 186 | extern XtAppContext app_con; 187 | 188 | while (XtAppPending(app_con)) 189 | XtAppProcessEvent(app_con, XtIMAll); 190 | 191 | } /* END FLUSHXEVENTS */ 192 | 193 | /* END XWIN.C */ 194 | -------------------------------------------------------------------------------- /old_ads/telford.c: -------------------------------------------------------------------------------- 1 | /* 2 | :set tabstop=4 3 | ------------------------------------------------------------------------- 4 | OBJECT NAME: hdrdump.c 5 | 6 | FULL NAME: Header Dump 7 | 8 | ENTRY POINTS: main() 9 | 10 | DESCRIPTION: 11 | 12 | INPUT: Filename of header 13 | 14 | OUTPUT: Tape dump to stdout 15 | 16 | REFERENCES: Header API (libhdr_api.a) 17 | 18 | COPYRIGHT: University Corporation for Atmospheric Research, 1992 19 | 20 | COMPILE: gcc -I/home/local/include telford.c -o telford -lhdr_api 21 | ------------------------------------------------------------------------- 22 | */ 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | 29 | char buffer[1024]; 30 | 31 | char *sdititle = 32 | "\n Name Start Rate Offset Type Conv.Fact\n"; 33 | 34 | char *otitle = 35 | "\n\n Block name Rate Start byte Length (bytes)\n"; 36 | 37 | char *ptitle = 38 | "\n\n Probe name Location LRlength LRPPR Resolution\n"; 39 | 40 | char *atitle = 41 | "\n\n Async blocks\n"; 42 | 43 | 44 | 45 | /* -------------------------------------------------------------------- */ 46 | main(argc, argv) 47 | int argc; 48 | char *argv[]; 49 | { 50 | int i; 51 | char *cvar; /* Pointer to current variable */ 52 | char *loc; /* Probe Location */ 53 | char *cp[3]; /* Some generic Char Pointers */ 54 | long l; /* Long result storage */ 55 | short s; /* Short result storage */ 56 | float f; /* Float result storage */ 57 | float *cal; /* Cal Coeff storage */ 58 | 59 | 60 | if (argc < 2) 61 | { 62 | fprintf(stderr, "usage:\thdrdump [prj# | headerfile]\n"); 63 | exit(1); 64 | } 65 | 66 | 67 | /* Deterimine if header filename is a project# or filename 68 | */ 69 | if (isdigit(argv[1][0])) 70 | { 71 | char *proj_dir; 72 | 73 | if ((proj_dir = getenv("PROJ_DIR")) == NULL) 74 | proj_dir = "/home/local/proj"; 75 | 76 | sprintf(buffer, "%s/%s/header", proj_dir, argv[1]); 77 | } 78 | else 79 | strcpy(buffer, argv[1]); 80 | 81 | 82 | if (InitFlightHeader(buffer, CLOSE) == ERR) 83 | { 84 | fprintf(stderr, "hdrdump: init error, taperr = %d\n", taperr); 85 | exit(1); 86 | } 87 | 88 | 89 | GetAircraft(&cp[0]); 90 | GetProjectNumber(&cp[1]); 91 | GetFlightNumber(&cp[2]); 92 | printf(" Aircraft: %s, Project: %s, Flight: %s\n", cp[0], cp[1], cp[2]); 93 | 94 | GetHeaderDate(&cp[0]); 95 | GetHeaderTime(&cp[1]); 96 | printf(" Date: %s Time: %s\n", cp[0], cp[1]); 97 | 98 | GetNumberItems(&l); 99 | printf(" Number of data items: %6ld,", l); 100 | get_lrlen(&l); 101 | printf(" Logical record length: %6ld,", l); 102 | get_lrppr(&l); 103 | printf(" LR/PR: %6ld\n", l); 104 | 105 | 106 | 107 | /* Do SDI vars first 108 | */ 109 | printf(sdititle); 110 | 111 | cvar = GetFirst(); 112 | 113 | do 114 | { 115 | GetItemType(cvar, &cp[0]); 116 | if (!(strcmp(cp[0], "SDI") == 0 || strcmp(cp[0], "HSKP") == 0 117 | || strcmp(cp[0], "DIGOUT") == 0)) 118 | continue; 119 | 120 | printf("%-8s ", cvar); 121 | 122 | if (GetStart(cvar, &l) == ERR) 123 | printf("<%d> ", taperr); 124 | else 125 | printf("%5ld ", l); 126 | 127 | if (GetRate(cvar, &l) == ERR) 128 | printf("<%d> ", taperr); 129 | else 130 | printf("%4ld ", l); 131 | 132 | if (GetSampleOffset(cvar, &l) == ERR) 133 | printf("<%d> ", taperr); 134 | else 135 | printf(" %5ld ", l); 136 | 137 | if (GetType(cvar, &cp[0]) == ERR) 138 | printf("<%d> ", taperr); 139 | else 140 | printf(" %s ", cp[0]); 141 | 142 | if (GetConversionFactor(cvar, &f) == ERR) 143 | printf("<%d>", taperr); 144 | else 145 | printf("%10.6f", f); 146 | 147 | printf("\n"); 148 | } 149 | while (cvar = GetNext()); 150 | 151 | 152 | 153 | /* Do the rest of the vars, except ASYNC 154 | */ 155 | printf(otitle); 156 | 157 | cvar = GetFirst(); 158 | 159 | do 160 | { 161 | GetItemType(cvar, &cp[0]); 162 | if (strcmp(cp[0], "SDI") == 0 || strcmp(cp[0], "HSKP") == 0 || 163 | strcmp(cp[0], "DIGOUT") == 0 || strcmp(cp[0], "ASYNC") == 0 || 164 | strcmp(cp[0], "PMS2D") == 0) 165 | continue; 166 | 167 | printf(" %-8s ", cvar); 168 | 169 | if (GetRate(cvar, &l) == ERR) 170 | printf(" N/A ", taperr); 171 | else 172 | printf("%5ld ", l); 173 | 174 | if (GetStart(cvar, &l) == ERR) 175 | printf(" N/A ", taperr); 176 | else 177 | printf("%8ld ", l); 178 | 179 | if (GetLength(cvar, &l) == ERR) 180 | printf("\t N/A", taperr); 181 | else 182 | printf("\t%8ld", l); 183 | 184 | printf("\n"); 185 | } 186 | while (cvar = GetNext()); 187 | 188 | 189 | /* Do PMS2D 190 | */ 191 | printf(ptitle); 192 | 193 | cvar = GetFirst(); 194 | 195 | do 196 | { 197 | GetItemType(cvar, &cp[0]); 198 | if (strcmp(cp[0], "PMS2D") != 0) 199 | continue; 200 | 201 | printf(" %-8s ", cvar); 202 | 203 | if (GetLocation(cvar, &loc) == ERR) 204 | printf(" <%d>", taperr); 205 | else 206 | printf(" %-8s", loc); 207 | 208 | if (GetLRLength(cvar, &l) == ERR) 209 | printf(" <%d>", taperr); 210 | else 211 | printf(" %5ld", l); 212 | 213 | if (GetLRPPR(cvar, &l) == ERR) 214 | printf(" <%d>", taperr); 215 | else 216 | printf(" %5ld", l); 217 | 218 | if (GetResolution(cvar, &s) == ERR) 219 | printf(" <%d>", taperr); 220 | else 221 | printf(" %5ld", s); 222 | 223 | printf("\n"); 224 | } 225 | while (cvar = GetNext()); 226 | 227 | 228 | /* Do ASYNC 229 | */ 230 | printf(atitle); 231 | 232 | cvar = GetFirst(); 233 | 234 | do 235 | { 236 | GetItemType(cvar, &cp[0]); 237 | if (strcmp(cp[0], "ASYNC") != 0) 238 | continue; 239 | 240 | printf(" %-8s ", cvar); 241 | 242 | if (GetLength(cvar, &l) == ERR) 243 | printf(" <%d>", taperr); 244 | else 245 | printf(" %5ld", l); 246 | 247 | printf("\n"); 248 | } 249 | while (cvar = GetNext()); 250 | 251 | ReleaseFlightHeader(); 252 | 253 | return(0); 254 | 255 | } /* END MAIN */ 256 | 257 | /* END HDRDUMP.C */ 258 | -------------------------------------------------------------------------------- /dnload/dnload.c: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: dnload.cc 4 | 5 | FULL NAME: ADS tape copier & downloader. 6 | 7 | DESCRIPTION: Copy a tape from one tape to another and also dump a copy 8 | to disk sans 2d records 9 | 10 | INPUT: 11 | 12 | OUTPUT: 13 | 14 | NOTES: 15 | 16 | COPYRIGHT: University Corporation for Atmospheric Research, 1992-8 17 | ------------------------------------------------------------------------- 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #define ERR (-1) 26 | 27 | #define TRUE 1 28 | #define FALSE 0 29 | 30 | char buffer[0x8000]; 31 | char sourceTape[64], destTape[64], destFile[80]; 32 | int outTape, outDisk, out2D; 33 | int cntDisk, cntTape, cnt2D, cntAVAPS; 34 | int pms2d; 35 | 36 | void WriteDisk(char buff[], int nBytes); 37 | 38 | 39 | /* -------------------------------------------------------------------- */ 40 | main(int argc, char *argv[]) 41 | { 42 | int rc, nBytes; 43 | 44 | 45 | outTape = outDisk = out2D = ERR; 46 | 47 | 48 | printf("Enter source tape drive [/dev/rmt/0] : "); 49 | gets(sourceTape); 50 | 51 | if (strlen(sourceTape) == 0) 52 | strcpy(sourceTape, "/dev/rmt/0"); 53 | 54 | 55 | printf("Enter destination tape drive [return for no tape copy] : "); 56 | gets(destTape); 57 | 58 | printf("Enter destination disk file [return for no disk file] : "); 59 | gets(destFile); 60 | 61 | if (strlen(destTape) == 0 && strlen(destFile) == 0) 62 | { 63 | fprintf(stderr, "Ppppphhhhhhtttttt!\n"); 64 | return(1); 65 | } 66 | 67 | 68 | if (strlen(destFile)) 69 | { 70 | if (strstr(destFile, ".ads") == 0) 71 | strcat(destFile, ".ads"); 72 | 73 | do 74 | { 75 | printf("Do you want 2D data (y/n) ? "); 76 | gets(buffer); 77 | } 78 | while (toupper(buffer[0]) != 'Y' && toupper(buffer[0]) != 'N'); 79 | 80 | pms2d = toupper(buffer[0]) == 'Y' ? TRUE : FALSE; 81 | } 82 | else 83 | pms2d = FALSE; 84 | 85 | 86 | 87 | printf("\n"); 88 | 89 | if (TapeOpen(sourceTape) == ERR) 90 | { 91 | fprintf(stderr, "Can't open source tape %s\n", sourceTape); 92 | return(1); 93 | } 94 | 95 | 96 | printf("\n\n"); 97 | 98 | if (strlen(destTape)) 99 | { 100 | printf("Tape copy from %s to %s.\n", sourceTape, destTape); 101 | 102 | if ((outTape = open(destTape, O_WRONLY)) == ERR) 103 | { 104 | fprintf(stderr, "Can't open destination tape %s\n", destTape); 105 | TapeClose(); 106 | return(1); 107 | } 108 | } 109 | 110 | 111 | if (strlen(destFile)) 112 | { 113 | char *p; 114 | 115 | strcpy(buffer, destFile); 116 | 117 | if ((p = strchr(buffer, '.')) == NULL) 118 | p = buffer; 119 | 120 | strcpy(p, ".2D"); 121 | 122 | 123 | printf("Downloading tape to disk file %s.\n", destFile); 124 | printf("PMS 2D data to disk file %s.\n", buffer); 125 | 126 | 127 | if ((outDisk = open(destFile, O_CREAT | O_WRONLY | O_TRUNC, 0666)) == ERR) 128 | { 129 | fprintf(stderr, "Can't open destination file %s\n", destFile); 130 | TapeClose(); 131 | if (outTape != ERR) close(outTape); 132 | return(1); 133 | } 134 | 135 | if (pms2d && (out2D = open(buffer, O_CREAT | O_WRONLY | O_TRUNC, 0666)) == ERR) 136 | { 137 | fprintf(stderr, "Can't open 2D destination file %s\n", buffer); 138 | TapeClose(); 139 | if (outTape != ERR) close(outTape); 140 | close(outDisk); 141 | return(1); 142 | } 143 | } 144 | 145 | 146 | rc = 0; /* Return Code */ 147 | cntTape = cntDisk = cnt2D = cntAVAPS = 0; 148 | 149 | while ((nBytes = TapeRead(buffer)) > 0) 150 | { 151 | if (outTape != ERR) 152 | { 153 | if (write(outTape, buffer, nBytes) == ERR) 154 | { 155 | fprintf(stderr, "Write failure to dest tape, errno = %d.\n", errno); 156 | rc = 1; 157 | goto exit; 158 | } 159 | else 160 | ++cntTape; 161 | } 162 | 163 | if (outDisk != ERR) 164 | WriteDisk(buffer, nBytes); 165 | 166 | if (outTape == ERR && outDisk == ERR && out2D == ERR) 167 | break; 168 | } 169 | 170 | 171 | if (nBytes == ERR) 172 | { 173 | fprintf(stderr, "Read error, errno = %d.\n", errno); 174 | rc = 1; 175 | } 176 | 177 | exit: 178 | printf("\n\n"); 179 | TapeClose(); 180 | 181 | if (outTape != ERR) 182 | { 183 | close(outTape); 184 | printf("%d records successfully written to tape copy.\n", cntTape); 185 | } 186 | 187 | if (outDisk != ERR) 188 | { 189 | close(outDisk); 190 | printf("%d records successfully written to disk.\n", cntDisk); 191 | } 192 | 193 | if (out2D != ERR) 194 | { 195 | close(out2D); 196 | printf("%d 2D records successfully written to disk.\n", cnt2D); 197 | } 198 | 199 | if (cntAVAPS != 0) 200 | printf("%d AVAPS records completely ignored.\n", cntAVAPS); 201 | 202 | return(rc); 203 | 204 | } /* END MAIN */ 205 | 206 | /* -------------------------------------------------------------------- */ 207 | void WriteDisk(char buff[], int nBytes) 208 | { 209 | int rc; 210 | 211 | switch (*(unsigned short *)buff) 212 | { 213 | case 0x8681: 214 | rc = write(outDisk, buff, nBytes); 215 | ++cntDisk; 216 | break; 217 | 218 | case 0x4331: /* PMS2D types. */ 219 | case 0x4332: 220 | case 0x5031: 221 | case 0x5032: 222 | case 0x4731: 223 | case 0x4732: 224 | if (!pms2d) 225 | return; 226 | 227 | rc = write(out2D, buff, nBytes); 228 | ++cnt2D; 229 | break; 230 | 231 | case 0x4156: /* AVAPS Dropsonde. */ 232 | ++cntAVAPS; 233 | break; 234 | 235 | case 0x4144: /* Header records. */ 236 | case 0x5448: 237 | rc = write(outDisk, buff, nBytes); 238 | rc = write(out2D, buff, nBytes); 239 | break; 240 | } 241 | 242 | 243 | if (rc == ERR) 244 | { 245 | if (errno == ENOSPC) 246 | { 247 | fprintf(stderr, "Disk full, closing disk file(s) and continuing.\n"); 248 | printf("%d records successfully written to disk.\n", cntDisk); 249 | printf("%d 2D records successfully written to disk.\n", cnt2D); 250 | close(outDisk); 251 | close(out2D); 252 | outDisk = out2D = ERR; 253 | } 254 | 255 | fprintf(stderr, "Write failure to dest disk, errno = %d.\n", errno); 256 | } 257 | 258 | } /* END WRITEDISK */ 259 | 260 | /* END DNLOAD.CC */ 261 | -------------------------------------------------------------------------------- /old_ads/hdrdump.c: -------------------------------------------------------------------------------- 1 | /* 2 | :set tabstop=4 3 | ------------------------------------------------------------------------- 4 | OBJECT NAME: hdrdump.c 5 | 6 | FULL NAME: Header Dump 7 | 8 | ENTRY POINTS: main() 9 | 10 | DESCRIPTION: 11 | 12 | INPUT: Filename of header 13 | 14 | OUTPUT: Tape dump to stdout 15 | 16 | REFERENCES: Header API (libhdr_api.a) 17 | 18 | COPYRIGHT: University Corporation for Atmospheric Research, 1992 19 | 20 | COMPILE: gcc -I/home/local/include hdrdump.c -o hdrdump -lhdr_api 21 | ------------------------------------------------------------------------- 22 | */ 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | 29 | char buffer[1024]; 30 | 31 | char *sdititle = 32 | "\n Name Start Rate Adr Type Conv.Fact. C0 C1 C2\n"; 33 | 34 | char *otitle = 35 | "\n\n Block name Rate Start byte Length (bytes)\n"; 36 | 37 | char *new_otitle = 38 | "\n\n Block name DSM Rate Start byte Length (bytes)\n"; 39 | 40 | char *ptitle = 41 | "\n\n Probe name Location LRlength LRPPR Resolution\n"; 42 | 43 | char *new_ptitle = 44 | "\n\n Probe name DSM Location LRlength LRPPR Resolution\n"; 45 | 46 | char *atitle = 47 | "\n\nAsync blocks"; 48 | 49 | 50 | 51 | /* -------------------------------------------------------------------- */ 52 | main(int argc, char *argv[]) 53 | { 54 | int i; 55 | char *cvar; /* Pointer to current variable */ 56 | char *loc; /* Probe Location */ 57 | char *cp[3]; /* Some generic Char Pointers */ 58 | long l; /* Long result storage */ 59 | short s; /* Short result storage */ 60 | float f; /* Float result storage */ 61 | float *cal; /* Cal Coeff storage */ 62 | float version; /* Cal Coeff storage */ 63 | 64 | 65 | if (argc < 2) 66 | { 67 | fprintf(stderr, "usage:\thdrdump [prj# | headerfile]\n"); 68 | exit(1); 69 | } 70 | 71 | 72 | /* Deterimine if header filename is a project# or filename 73 | */ 74 | if (isdigit(argv[1][0])) 75 | { 76 | char *proj_dir; 77 | 78 | if ((proj_dir = getenv("PROJ_DIR")) == NULL) 79 | proj_dir = "/home/local/proj"; 80 | 81 | sprintf(buffer, "%s/%s/header", proj_dir, argv[1]); 82 | } 83 | else 84 | strcpy(buffer, argv[1]); 85 | 86 | 87 | if (InitFlightHeader(buffer, CLOSE) == ERR) 88 | { 89 | fprintf(stderr, "hdrdump: init error, taperr = %d\n", taperr); 90 | exit(1); 91 | } 92 | 93 | 94 | GetVersion(&cp[0]); 95 | version = atof(cp[0]); 96 | printf("Header Version = %4.1f\n\n", version); 97 | 98 | GetAircraft(&cp[0]); 99 | GetProjectNumber(&cp[1]); 100 | GetFlightNumber(&cp[2]); 101 | printf(" Aircraft: %s, Project: %s, Flight: %s\n", cp[0], cp[1], cp[2]); 102 | 103 | GetHeaderDate(&cp[0]); 104 | GetHeaderTime(&cp[1]); 105 | printf(" Date: %s Time: %s\n", cp[0], cp[1]); 106 | 107 | GetNumberItems(&l); 108 | printf(" Number of data items: %6ld,", l); 109 | get_lrlen(&l); 110 | printf(" Logical record length: %6ld,", l); 111 | get_lrppr(&l); 112 | printf(" LR/PR: %6ld\n", l); 113 | 114 | 115 | 116 | /* Do SDI vars first 117 | */ 118 | printf(sdititle); 119 | 120 | cvar = GetFirst(); 121 | 122 | do 123 | { 124 | GetItemType(cvar, &cp[0]); 125 | if (!(strcmp(cp[0], "SDI") == 0 || strcmp(cp[0], "HSKP") == 0 126 | || strcmp(cp[0], "DIGOUT") == 0)) 127 | continue; 128 | 129 | printf("%-8s ", cvar); 130 | 131 | if (GetStart(cvar, &l) == ERR) 132 | printf("<%d> ", taperr); 133 | else 134 | printf("%5ld ", l); 135 | 136 | if (GetRate(cvar, &l) == ERR) 137 | printf("<%d> ", taperr); 138 | else 139 | printf("%4ld ", l); 140 | 141 | if (GetPrimaryAddr(cvar, &l) == ERR) 142 | printf("<%d> ", taperr); 143 | else 144 | printf("%5lx ", l); 145 | 146 | if (GetType(cvar, &cp[0]) == ERR) 147 | printf("<%d> ", taperr); 148 | else 149 | printf(" %s ", cp[0]); 150 | 151 | if (GetConversionFactor(cvar, &f) == ERR) 152 | printf("<%d>", taperr); 153 | else 154 | printf("%10.6f", f); 155 | 156 | 157 | if (GetOrder(cvar, &l) == ERR) 158 | printf("<%d> ", taperr); 159 | else 160 | { 161 | GetCalCoeff(cvar, &cal); 162 | 163 | for (i = 0; i < l; ++i) 164 | printf(" %12.6f", cal[i]); 165 | } 166 | 167 | printf("\n"); 168 | } 169 | while (cvar = GetNext()); 170 | 171 | 172 | 173 | /* Do block probes (no async). 174 | */ 175 | if (version >= 3.0) 176 | printf(new_otitle); 177 | else 178 | printf(otitle); 179 | 180 | cvar = GetFirst(); 181 | 182 | do 183 | { 184 | GetItemType(cvar, &cp[0]); 185 | if (strcmp(cp[0], "SDI") == 0 || strcmp(cp[0], "HSKP") == 0 || 186 | strcmp(cp[0], "DIGOUT") == 0 || strcmp(cp[0], "ASYNC") == 0 || 187 | strcmp(cp[0], "PMS2D") == 0) 188 | continue; 189 | 190 | printf(" %-8s ", cvar); 191 | 192 | if (version >= 3.0) 193 | { 194 | GetDSMlocation(cvar, &cp[0]); 195 | printf(" %-8s", cp[0]); 196 | } 197 | else 198 | printf(" N/A "); 199 | 200 | if (GetRate(cvar, &l) == ERR) 201 | printf(" N/A "); 202 | else 203 | printf("%5ld ", l); 204 | 205 | if (GetStart(cvar, &l) == ERR) 206 | printf(" N/A "); 207 | else 208 | printf("%8ld ", l); 209 | 210 | if (GetLength(cvar, &l) == ERR) 211 | printf("\t N/A"); 212 | else 213 | printf("\t%8ld", l); 214 | 215 | printf("\n"); 216 | } 217 | while (cvar = GetNext()); 218 | 219 | 220 | /* Do PMS2D 221 | */ 222 | printf(atitle); 223 | 224 | if (version >= 3.0) 225 | printf(new_ptitle); 226 | else 227 | printf(ptitle); 228 | 229 | cvar = GetFirst(); 230 | 231 | do 232 | { 233 | GetItemType(cvar, &cp[0]); 234 | if (strcmp(cp[0], "PMS2D") != 0) 235 | continue; 236 | 237 | printf(" %-8s ", cvar); 238 | 239 | if (version >= 3.0) 240 | { 241 | GetDSMlocation(cvar, &cp[0]); 242 | printf(" %-8s", cp[0]); 243 | } 244 | 245 | if (GetLocation(cvar, &loc) == ERR) 246 | printf(" <%d>", taperr); 247 | else 248 | printf(" %-8s", loc); 249 | 250 | if (GetLRLength(cvar, &l) == ERR) 251 | printf(" <%d>", taperr); 252 | else 253 | printf(" %5ld", l); 254 | 255 | if (GetLRPPR(cvar, &l) == ERR) 256 | printf(" <%d>", taperr); 257 | else 258 | printf(" %5ld", l); 259 | 260 | if (GetResolution(cvar, &s) == ERR) 261 | printf(" <%d>", taperr); 262 | else 263 | printf(" %5ld", s); 264 | 265 | printf("\n"); 266 | } 267 | while (cvar = GetNext()); 268 | 269 | 270 | /* Do ASYNC 271 | */ 272 | cvar = GetFirst(); 273 | 274 | do 275 | { 276 | GetItemType(cvar, &cp[0]); 277 | if (strcmp(cp[0], "ASYNC") != 0) 278 | continue; 279 | 280 | printf(" %-8s ", cvar); 281 | 282 | if (version >= 3.0) 283 | { 284 | GetDSMlocation(cvar, &cp[0]); 285 | printf(" %-8s", cp[0]); 286 | } 287 | 288 | if (GetLength(cvar, &l) == ERR) 289 | printf(" <%d>", taperr); 290 | else 291 | printf(" %5ld", l); 292 | 293 | printf("\n"); 294 | } 295 | while (cvar = GetNext()); 296 | 297 | ReleaseFlightHeader(); 298 | 299 | return(0); 300 | 301 | } /* END MAIN */ 302 | 303 | /* END HDRDUMP.C */ 304 | -------------------------------------------------------------------------------- /old_ads/hd.c: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: hdrdump.c 4 | 5 | FULL NAME: Header Dump 6 | 7 | ENTRY POINTS: main() 8 | 9 | DESCRIPTION: 10 | 11 | INPUT: Filename of header 12 | 13 | OUTPUT: Tape dump to stdout 14 | 15 | REFERENCES: Header API (libhdr_api.a) 16 | 17 | COPYRIGHT: University Corporation for Atmospheric Research, 1992 18 | 19 | COMPILE: gcc -I/home/local/include hdrdump.c -o hdrdump -lhdr_api 20 | ------------------------------------------------------------------------- 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | 28 | char buffer[1024]; 29 | 30 | char *sdititle = "\n Name Start Rate Type Conv.Fact. Offset DSM\n"; 31 | char *otitle = "\n\n Block name Rate Start byte Length (bytes)\n"; 32 | char *new_otitle = "\n\n Block name DSM Locn Rate Start byte Length (bytes)\n"; 33 | 34 | char *ptitle = "\n\n Probe name Location LRlength LRPPR Resolution\n"; 35 | char *new_ptitle = "\n\n Probe name DSM Location LRlength LRPPR Resolution\n"; 36 | 37 | char *atitle = "\n\nAsync blocks"; 38 | 39 | 40 | 41 | /* -------------------------------------------------------------------- */ 42 | main(int argc, char *argv[]) 43 | { 44 | int i; 45 | char *cvar; /* Pointer to current variable */ 46 | char *loc; /* Probe Location */ 47 | char *cp[3]; /* Some generic Char Pointers */ 48 | long l; /* Long result storage */ 49 | short s; /* Short result storage */ 50 | float f; /* Float result storage */ 51 | float *cal; /* Cal Coeff storage */ 52 | float version; /* Cal Coeff storage */ 53 | 54 | 55 | if (argc < 2) 56 | { 57 | fprintf(stderr, "usage:\thdrdump [prj# | headerfile]\n"); 58 | exit(1); 59 | } 60 | 61 | 62 | /* Deterimine if header filename is a project# or filename 63 | */ 64 | if (isdigit(argv[1][0])) 65 | { 66 | char *proj_dir; 67 | 68 | if ((proj_dir = getenv("PROJ_DIR")) == NULL) 69 | proj_dir = "/home/local/proj"; 70 | 71 | sprintf(buffer, "%s/%s/header", proj_dir, argv[1]); 72 | } 73 | else 74 | strcpy(buffer, argv[1]); 75 | 76 | 77 | if (InitFlightHeader(buffer, CLOSE) == ERR) 78 | { 79 | fprintf(stderr, "hdrdump: init error, taperr = %d\n", taperr); 80 | exit(1); 81 | } 82 | 83 | 84 | GetVersion(&cp[0]); 85 | version = atof(cp[0]); 86 | printf("Header Version = %4.1f\n\n", version); 87 | 88 | GetAircraft(&cp[0]); 89 | GetProjectNumber(&cp[1]); 90 | GetFlightNumber(&cp[2]); 91 | printf(" Aircraft: %s, Project: %s, Flight: %s\n", cp[0], cp[1], cp[2]); 92 | 93 | GetHeaderDate(&cp[0]); 94 | GetHeaderTime(&cp[1]); 95 | printf(" Date: %s Time: %s\n", cp[0], cp[1]); 96 | 97 | GetNumberItems(&l); 98 | printf(" Number of data items: %6ld,", l); 99 | get_lrlen(&l); 100 | printf(" Logical record length: %6ld,", l); 101 | get_lrppr(&l); 102 | printf(" LR/PR: %6ld\n", l); 103 | 104 | 105 | 106 | /* Do SDI vars first 107 | */ 108 | printf(sdititle); 109 | 110 | cvar = GetFirst(); 111 | 112 | do 113 | { 114 | GetItemType(cvar, &cp[0]); 115 | if (!(strcmp(cp[0], "SDI") == 0 || strcmp(cp[0], "HSKP") == 0 116 | || strcmp(cp[0], "DIGOUT") == 0)) 117 | continue; 118 | 119 | printf("%-8s ", cvar); 120 | 121 | if (GetStart(cvar, &l) == ERR) 122 | printf("<%d> ", taperr); 123 | else 124 | printf("%5ld ", l); 125 | 126 | if (GetRate(cvar, &l) == ERR) 127 | printf("<%d> ", taperr); 128 | else 129 | printf("%4ld ", l); 130 | 131 | if (GetType(cvar, &cp[0]) == ERR) 132 | printf("<%d> ", taperr); 133 | else 134 | printf(" %s ", cp[0]); 135 | 136 | if (GetConversionFactor(cvar, &f) == ERR) 137 | printf("<%d>", taperr); 138 | else 139 | printf("%10.6f ", f); 140 | 141 | if (GetConversionOffset(cvar, &l) == ERR) 142 | printf("<%d>", taperr); 143 | else 144 | printf("%6ld ", l); 145 | 146 | if (GetDSMlocation(cvar, &cp[0]) == ERR) 147 | printf("<%d>", taperr); 148 | else 149 | printf("%-10s", cp[0]); 150 | 151 | 152 | printf("\n"); 153 | } 154 | while (cvar = GetNext()); 155 | 156 | 157 | 158 | /* Do block probes (no async). 159 | */ 160 | if (version >= 3.0) 161 | printf(new_otitle); 162 | else 163 | printf(otitle); 164 | 165 | cvar = GetFirst(); 166 | 167 | do 168 | { 169 | GetItemType(cvar, &cp[0]); 170 | if (strcmp(cp[0], "SDI") == 0 || strcmp(cp[0], "HSKP") == 0 || 171 | strcmp(cp[0], "DIGOUT") == 0 || strcmp(cp[0], "ASYNC") == 0 || 172 | strcmp(cp[0], "PMS2D") == 0) 173 | continue; 174 | 175 | printf(" %-8s ", cvar); 176 | 177 | if (version >= 3.0) 178 | { 179 | GetDSMlocation(cvar, &cp[0]); 180 | printf(" %-8s", cp[0]); 181 | 182 | if (GetLocation(cvar, &cp[0]) == ERR) 183 | printf(" N/A ", taperr); 184 | else 185 | printf("%-8s ", cp[0]); 186 | } 187 | 188 | if (GetRate(cvar, &l) == ERR) 189 | printf(" N/A ", taperr); 190 | else 191 | printf("%5ld ", l); 192 | 193 | if (GetStart(cvar, &l) == ERR) 194 | printf(" N/A ", taperr); 195 | else 196 | printf("%8ld ", l); 197 | 198 | if (GetLength(cvar, &l) == ERR) 199 | printf("\t N/A", taperr); 200 | else 201 | printf("\t%8ld", l); 202 | 203 | printf("\n"); 204 | } 205 | while (cvar = GetNext()); 206 | 207 | 208 | /* Do PMS2D 209 | */ 210 | printf(atitle); 211 | 212 | if (version >= 3.0) 213 | printf(new_ptitle); 214 | else 215 | printf(ptitle); 216 | 217 | cvar = GetFirst(); 218 | 219 | do 220 | { 221 | GetItemType(cvar, &cp[0]); 222 | if (strcmp(cp[0], "PMS2D") != 0) 223 | continue; 224 | 225 | printf(" %-8s ", cvar); 226 | 227 | if (version >= 3.0) 228 | { 229 | GetDSMlocation(cvar, &cp[0]); 230 | printf(" %-8s", cp[0]); 231 | } 232 | 233 | if (GetLocation(cvar, &loc) == ERR) 234 | printf(" <%d>", taperr); 235 | else 236 | printf(" %-8s", loc); 237 | 238 | if (GetLRLength(cvar, &l) == ERR) 239 | printf(" <%d>", taperr); 240 | else 241 | printf(" %5ld", l); 242 | 243 | if (GetLRPPR(cvar, &l) == ERR) 244 | printf(" <%d>", taperr); 245 | else 246 | printf(" %5ld", l); 247 | 248 | if (GetResolution(cvar, &s) == ERR) 249 | printf(" <%d>", taperr); 250 | else 251 | printf(" %5ld", s); 252 | 253 | printf("\n"); 254 | } 255 | while (cvar = GetNext()); 256 | 257 | 258 | /* Do ASYNC 259 | */ 260 | cvar = GetFirst(); 261 | 262 | do 263 | { 264 | GetItemType(cvar, &cp[0]); 265 | if (strcmp(cp[0], "ASYNC") != 0) 266 | continue; 267 | 268 | printf(" %-8s ", cvar); 269 | 270 | if (GetLength(cvar, &l) == ERR) 271 | printf(" <%d>", taperr); 272 | else 273 | printf(" %5ld", l); 274 | 275 | printf("\n"); 276 | } 277 | while (cvar = GetNext()); 278 | 279 | ReleaseFlightHeader(); 280 | 281 | return(0); 282 | 283 | } /* END MAIN */ 284 | 285 | /* END HDRDUMP.C */ 286 | -------------------------------------------------------------------------------- /dup2d/dup2d.c: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: dup2d.c 4 | 5 | FULL NAME: ADS tape copier & downloader. 6 | 7 | DESCRIPTION: Remove duplicate 2d records from a file. 8 | 9 | INPUT: 10 | 11 | OUTPUT: 12 | 13 | NOTES: 14 | 15 | COPYRIGHT: University Corporation for Atmospheric Research, 1999 16 | ------------------------------------------------------------------------- 17 | */ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include "raf/header.h" 25 | 26 | #define ERR (-1) 27 | 28 | #define TRUE 1 29 | #define FALSE 0 30 | 31 | char buffer[65000]; 32 | char sourceTape[64], destTape[64], destFile[80]; 33 | int outTape, outDisk, out2D; 34 | int cntDisk, cntTape, cnt2D, cntAVAPS; 35 | int pms2d; 36 | 37 | int cntP2Dtossed, cntP2D, cntC2Dtossed, cntC2D; 38 | 39 | void WriteDisk(char buff[], int nBytes); 40 | 41 | 42 | /* -------------------------------------------------------------------- */ 43 | main(int argc, char *argv[]) 44 | { 45 | int rc, nBytes; 46 | P2d_rec prevP, prevC; 47 | 48 | 49 | outTape = outDisk = out2D = ERR; 50 | 51 | 52 | printf("Enter source tape drive [/dev/rmt/0] : "); 53 | gets(sourceTape); 54 | 55 | if (strlen(sourceTape) == 0) 56 | strcpy(sourceTape, "/dev/rmt/0"); 57 | 58 | 59 | printf("Enter destination tape drive [return for no tape copy] : "); 60 | gets(destTape); 61 | 62 | printf("Enter destination disk file [return for no disk file] : "); 63 | gets(destFile); 64 | 65 | if (strlen(destTape) == 0 && strlen(destFile) == 0) 66 | { 67 | fprintf(stderr, "Ppppphhhhhhtttttt!\n"); 68 | return(1); 69 | } 70 | 71 | 72 | if (strlen(destFile)) 73 | { 74 | do 75 | { 76 | printf("Do you want 2D data (y/n) ? "); 77 | gets(buffer); 78 | } 79 | while (toupper(buffer[0]) != 'Y' && toupper(buffer[0]) != 'N'); 80 | 81 | pms2d = toupper(buffer[0]) == 'Y' ? TRUE : FALSE; 82 | } 83 | else 84 | pms2d = FALSE; 85 | 86 | 87 | 88 | printf("\n"); 89 | 90 | if (TapeOpen(sourceTape) == ERR) 91 | { 92 | fprintf(stderr, "Can't open source tape %s\n", sourceTape); 93 | return(1); 94 | } 95 | 96 | 97 | printf("\n\n"); 98 | 99 | if (strlen(destTape)) 100 | { 101 | printf("Tape copy from %s to %s.\n", sourceTape, destTape); 102 | 103 | if ((outTape = open(destTape, O_WRONLY)) == ERR) 104 | { 105 | fprintf(stderr, "Can't open destination tape %s\n", destTape); 106 | TapeClose(); 107 | return(1); 108 | } 109 | } 110 | 111 | 112 | if (strlen(destFile)) 113 | { 114 | char *p; 115 | 116 | strcpy(buffer, destFile); 117 | 118 | if ((p = strchr(buffer, '.')) == NULL) 119 | p = buffer; 120 | 121 | strcpy(p, ".2D"); 122 | 123 | 124 | printf("Downloading tape to disk file %s.\n", destFile); 125 | printf("PMS 2D data to disk file %s.\n", buffer); 126 | 127 | 128 | if ((outDisk = open(destFile, O_CREAT | O_WRONLY | O_TRUNC, 0666)) == ERR) 129 | { 130 | fprintf(stderr, "Can't open destination file %s\n", destFile); 131 | TapeClose(); 132 | if (outTape != ERR) close(outTape); 133 | return(1); 134 | } 135 | 136 | if (pms2d && (out2D = open(buffer, O_CREAT | O_WRONLY | O_TRUNC, 0666)) == ERR) 137 | { 138 | fprintf(stderr, "Can't open 2D destination file %s\n", buffer); 139 | TapeClose(); 140 | if (outTape != ERR) close(outTape); 141 | close(outDisk); 142 | return(1); 143 | } 144 | } 145 | 146 | 147 | rc = 0; /* Return Code */ 148 | cntTape = cntDisk = cnt2D = cntAVAPS = 0; 149 | cntP2Dtossed = cntP2D = cntC2Dtossed = cntC2D = 0; 150 | 151 | while ((nBytes = TapeRead(buffer)) > 0) 152 | { 153 | if (outTape != ERR) 154 | { 155 | if (write(outTape, buffer, nBytes) == ERR) 156 | { 157 | fprintf(stderr, "Write failure to dest tape, errno = %d.\n", errno); 158 | rc = 1; 159 | goto exit; 160 | } 161 | else 162 | ++cntTape; 163 | } 164 | 165 | if (outDisk != ERR) 166 | WriteDisk(buffer, nBytes); 167 | 168 | if (outTape == ERR && outDisk == ERR && out2D == ERR) 169 | break; 170 | } 171 | 172 | 173 | if (nBytes == ERR) 174 | { 175 | fprintf(stderr, "Read error, errno = %d.\n", errno); 176 | rc = 1; 177 | } 178 | 179 | exit: 180 | printf("\n\n"); 181 | TapeClose(); 182 | 183 | if (outTape != ERR) 184 | { 185 | close(outTape); 186 | printf("%d records successfully written to tape copy.\n", cntTape); 187 | } 188 | 189 | if (outDisk != ERR) 190 | { 191 | close(outDisk); 192 | printf("%d records successfully written to disk.\n", cntDisk); 193 | } 194 | 195 | if (out2D != ERR) 196 | { 197 | close(out2D); 198 | printf("%d 2D-P logical records found, %d non-duplicates.\n", cntP2D, cntP2Dtossed); 199 | printf("%d 2D-C logical records found, %d non-duplicates.\n", cntC2D, cntC2Dtossed); 200 | } 201 | 202 | if (cntAVAPS != 0) 203 | printf("%d AVAPS records completely ignored.\n", cntAVAPS); 204 | 205 | return(rc); 206 | 207 | } /* END MAIN */ 208 | 209 | /* -------------------------------------------------------------------- */ 210 | void WriteDisk(char buff[], int nBytes) 211 | { 212 | int rc, i; 213 | P2d_rec *p2, prevP, prevC; 214 | 215 | switch (*(unsigned short *)buff) 216 | { 217 | case 0x8681: 218 | rc = write(outDisk, buff, nBytes); 219 | ++cntDisk; 220 | break; 221 | 222 | case 0x4331: /* PMS2D types. */ 223 | case 0x4332: 224 | case 0x5031: 225 | case 0x5032: 226 | case 0x4731: 227 | case 0x4732: 228 | if (!pms2d) 229 | return; 230 | 231 | for (p2 = (P2d_rec *)buff, i = 0; i < 7; ++i, ++p2) 232 | { 233 | if (((char *)p2)[0] == 'P') 234 | { 235 | if (memcmp((void *)p2, (void *)&prevP, sizeof(P2d_rec))) 236 | { 237 | rc = write(out2D, (void *)p2, sizeof(P2d_rec)); 238 | memcpy((void *)&prevP, (void *)p2, sizeof(P2d_rec)); 239 | ++cntP2Dtossed; 240 | } 241 | 242 | ++cntP2D; 243 | } 244 | else 245 | { 246 | if (memcmp((void *)p2, (void *)&prevC, sizeof(P2d_rec))) 247 | { 248 | rc = write(out2D, (void *)p2, sizeof(P2d_rec)); 249 | memcpy((void *)&prevC, (void *)p2, sizeof(P2d_rec)); 250 | ++cntC2Dtossed; 251 | } 252 | 253 | ++cntC2D; 254 | } 255 | } 256 | 257 | break; 258 | 259 | case 0x4156: /* AVAPS Dropsonde. */ 260 | ++cntAVAPS; 261 | break; 262 | 263 | case 0x4144: /* Header records. */ 264 | case 0x5448: 265 | rc = write(outDisk, buff, nBytes); 266 | rc = write(out2D, buff, nBytes); 267 | break; 268 | } 269 | 270 | 271 | if (rc == ERR) 272 | { 273 | if (errno == ENOSPC) 274 | { 275 | fprintf(stderr, "Disk full, closing disk file(s) and continuing.\n"); 276 | printf("%d records successfully written to disk.\n", cntDisk); 277 | printf("%d 2D records successfully written to disk.\n", cnt2D); 278 | close(outDisk); 279 | close(out2D); 280 | outDisk = out2D = ERR; 281 | } 282 | 283 | fprintf(stderr, "Write failure to dest disk, errno = %d.\n", errno); 284 | } 285 | 286 | } /* END WRITEDISK */ 287 | 288 | /* END DNLOAD.C */ 289 | -------------------------------------------------------------------------------- /rtplot_motif/Xplot.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: Xplot.c 4 | 5 | FULL NAME: Plot Graph in X window 6 | 7 | ENTRY POINTS: PlotData() 8 | 9 | STATIC FNS: set_clipping() 10 | do_ytics() 11 | PlotLines() 12 | 13 | DESCRIPTION: This is the Expose event procedure to regenerate the 14 | whole image. 15 | 16 | INPUT: none 17 | 18 | OUTPUT: none 19 | 20 | COPYRIGHT: University Corporation for Atmospheric Research, 1994-9 21 | ------------------------------------------------------------------------- 22 | */ 23 | 24 | #include "define.h" 25 | #include "raf/header.h" 26 | #include "raf/Canvas.h" 27 | #include "raf/Colors.h" 28 | #include "raf/PixMap.h" 29 | #include "raf/XPen.h" 30 | #include "raf/XFonts.h" 31 | 32 | #include 33 | #include 34 | 35 | extern Canvas *canvas; 36 | 37 | /* Y offset from Graph Origin */ 38 | #define YLEGEND(s) (canvas->Height() - 10 - (s * 12)) 39 | 40 | static int HD, VD, LV, RV, TH, BH, TICLEN, TITLE_OFFSET, SUBTITLE_OFFSET, 41 | XLABEL_OFFSET, YLABEL_OFFSET, Y_TIC_LABEL_OFFSET, 42 | X_TIC_LABEL_OFFSET, XLEGEND_START, XLEGEND_END, XLEGEND_TEXT; 43 | 44 | 45 | static XPen *blackPen, *colorPen; 46 | static XFonts *fonts; 47 | static Colors *colors; 48 | 49 | static XImage *im_out = NULL, *im_in; 50 | static PixMap *in_pm, *out_pm; 51 | 52 | static int pixLen, charSize; 53 | 54 | static void do_ytics(); 55 | static void set_clipping(Display *dpy, GC gc); 56 | 57 | void PlotLines(), SetYlabelPixmap(); 58 | void MakeTicLabel(char buffer[], double diff, double value); 59 | NR_TYPE GetData(int set, int indx); 60 | 61 | 62 | 63 | /* -------------------------------------------------------------------- */ 64 | void ResizePlotWindow(Widget w, XtPointer client, XtPointer call) 65 | { 66 | canvas->Resize(); 67 | 68 | 69 | /* NOTE: In an X window the origin is the upper left corner with X 70 | * going accross, and Y going down. I have also noticed that 71 | * there are 83 pixels/inch across and 82 pixels/inch down. 72 | */ 73 | HD = (int)(canvas->Width() * 0.78); 74 | VD = (int)(canvas->Height() * 0.676); 75 | LV = (int)(canvas->Width() * 0.15); 76 | TH = (int)(canvas->Height() * 0.15); 77 | 78 | RV = LV + HD; 79 | BH = TH + VD; 80 | 81 | TICLEN = HD > 400 ? 10 : 5; 82 | TITLE_OFFSET = (int)(TH * 0.5); 83 | SUBTITLE_OFFSET = (int)(TH * 0.75); 84 | XLABEL_OFFSET = BH + 50; 85 | YLABEL_OFFSET = 20; 86 | Y_TIC_LABEL_OFFSET = 5; 87 | X_TIC_LABEL_OFFSET = 20; 88 | 89 | XLEGEND_START = 12; 90 | XLEGEND_END = 50; 91 | XLEGEND_TEXT = 55; 92 | 93 | } /* END RESETWINDOWSIZE */ 94 | 95 | /* -------------------------------------------------------------------- */ 96 | void PlotData(Widget w, XtPointer client, XtPointer call) 97 | { 98 | int offset; 99 | XmDrawingAreaCallbackStruct *cb = (XmDrawingAreaCallbackStruct *)call; 100 | 101 | static bool firstTime = true; 102 | 103 | 104 | /* If there are more Expose Events on the queue, then ignore this 105 | * one. 106 | */ 107 | if (cb && cb->event && ((XExposeEvent *)cb->event)->count > 0) 108 | return; 109 | 110 | 111 | /* Set default Graphics Context stuff and get the GC 112 | */ 113 | if (firstTime) 114 | { 115 | blackPen = new XPen(canvas->Wdgt()); 116 | colorPen = new XPen(canvas->Wdgt()); 117 | fonts = new XFonts(canvas->Wdgt()); 118 | colors = new Colors(canvas->Wdgt()); 119 | 120 | in_pm = new PixMap(canvas->Wdgt(), 300, 30); 121 | out_pm = new PixMap(canvas->Wdgt(), 30, 300); 122 | 123 | ResizePlotWindow(NULL, NULL, NULL); 124 | ToggleUnits(NULL, (XtPointer)VOLTS, NULL); 125 | 126 | blackPen->SetLineWidth(1); 127 | 128 | firstTime = false; 129 | } 130 | 131 | 132 | /* Set clipping to whole window */ 133 | blackPen->ClearClipping(); 134 | canvas->Clear(); 135 | 136 | blackPen->DrawRectangle(canvas->Surface(), LV, TH, HD, VD); 137 | 138 | /* Display title, then do subtitle and ylabel. 139 | */ 140 | if (title.length() > 0) 141 | { 142 | blackPen->SetFont(fonts->Font(XFonts::Point24)); 143 | offset = LV + (HD>>1) - (fonts->StringWidth(XFonts::Point24, title)>>1); 144 | blackPen->DrawText(canvas->Surface(), offset, TITLE_OFFSET, title); 145 | } 146 | 147 | blackPen->SetFont(fonts->Font(XFonts::Point18)); 148 | 149 | if (subtitle.length() > 0) 150 | { 151 | offset = LV + (HD>>1) - (fonts->StringWidth(XFonts::Point18, subtitle)>>1); 152 | blackPen->DrawText(canvas->Surface(), offset, SUBTITLE_OFFSET, subtitle); 153 | } 154 | 155 | if (ylabel.length() > 0) 156 | { 157 | 158 | /* Write out the rotated text 159 | */ 160 | offset = TH + (VD >> 1) - (pixLen >> 1); 161 | 162 | blackPen->PutImage(canvas->Surface(), im_out, 0, 0, YLABEL_OFFSET, 163 | offset, charSize, pixLen); 164 | } 165 | 166 | if (xlabel.length() > 0) 167 | { 168 | int offset; 169 | 170 | offset = LV + (HD>>1) - (fonts->StringWidth(XFonts::Point18, xlabel)>>1); 171 | blackPen->DrawText(canvas->Surface(), offset, XLABEL_OFFSET, xlabel); 172 | } 173 | 174 | 175 | blackPen->SetFont(fonts->Font(XFonts::Point12)); 176 | do_ytics(); 177 | 178 | PlotLines(); 179 | 180 | canvas->ExposeAll(); 181 | 182 | } /* END PLOTDATA */ 183 | 184 | /* -------------------------------------------------------------------- */ 185 | void PlotLines() 186 | { 187 | int i, n; 188 | NR_TYPE xscale, yscale, halfSecond; 189 | 190 | if (nVariables == 0) 191 | return; 192 | 193 | 194 | /* Draw X-axis tic marks and #'s 195 | */ 196 | { 197 | int offset, ticlen, nsex, nh, nm, ns; 198 | 199 | ticlen = Grid ? TH : BH-TICLEN; 200 | 201 | for (i = 0; i <= numtics; ++i) 202 | { 203 | if ((offset = (int)(LV + ((float)HD / numtics) * i)) > RV) 204 | offset = RV; 205 | 206 | blackPen->DrawLine(canvas->Surface(), offset, BH, offset, ticlen); 207 | 208 | if (i % 2) 209 | continue; 210 | 211 | nsex = i * NumberSeconds / numtics; 212 | 213 | nh = nsex / 3600; 214 | nm = (nsex - (nh * 3600)) / 60; 215 | ns = nsex - (nh * 3600) - (nm * 60); 216 | 217 | sprintf(buffer, "%02d:%02d:%02d", nh, nm, ns); 218 | string tmp = buffer; 219 | 220 | offset -= fonts->StringWidth(XFonts::Point14, tmp) >> 1; 221 | blackPen->DrawText(canvas->Surface(), offset, BH+X_TIC_LABEL_OFFSET, tmp); 222 | } 223 | } 224 | 225 | /* Plot data 226 | */ 227 | colors->ResetColors(); 228 | 229 | for (CurrentDataSet = 0; CurrentDataSet < NumberDataSets; ++CurrentDataSet) 230 | { 231 | // Erase old points. 232 | 233 | colorPen->SetColor(colors->NextColor()); 234 | /* 235 | colorPen->DrawLines(canvas->Surface(), Variable[CurrentDataSet].pts, 236 | Variable[CurrentDataSet].nPoints); 237 | */ 238 | 239 | xscale = (NR_TYPE)HD / Variable[CurrentDataSet].nPoints; 240 | yscale = (NR_TYPE)VD / (ymax - ymin); 241 | 242 | /* Center 1hz data. 243 | */ 244 | if (Variable[CurrentDataSet].nPoints == NumberSeconds) 245 | halfSecond = HD / NumberSeconds / 2; 246 | else 247 | halfSecond = 0.0; 248 | 249 | /* Calculate points for lines */ 250 | for (i = 0; i < Variable[CurrentDataSet].nPoints; ++i) 251 | { 252 | Variable[CurrentDataSet].pts[i].x = (int)(LV + (xscale * i) + halfSecond); 253 | Variable[CurrentDataSet].pts[i].y = (int)(BH - (yscale * (GetData(CurrentDataSet, i) - ymin))); 254 | } 255 | 256 | /* Display lines */ 257 | colorPen->SetClipping(LV, TH, HD, VD); 258 | colorPen->DrawLines(canvas->Surface(), Variable[CurrentDataSet].pts, i); 259 | colorPen->ClearClipping(); 260 | 261 | 262 | /* Display legend for each dataset 263 | */ 264 | { 265 | VARTBL *vp = &Variable[CurrentDataSet]; 266 | int ylegend = YLEGEND(CurrentDataSet); 267 | 268 | sprintf(buffer, "%s, %d s/sec", vp->name, vp->SampleRate); 269 | 270 | colorPen->DrawLine(canvas->Surface(), XLEGEND_START, ylegend, 271 | XLEGEND_END, ylegend); 272 | blackPen->DrawText(canvas->Surface(), XLEGEND_TEXT, ylegend+3, buffer); 273 | } 274 | } 275 | 276 | blackPen->ClearDash(); 277 | blackPen->DrawRectangle(canvas->Surface(), LV, TH, HD, VD); 278 | 279 | } /* END PLOTLINES */ 280 | 281 | /* -------------------------------------------------------------------- */ 282 | static void do_ytics() 283 | { 284 | int i, xoffset, yoffset, len; 285 | int ticlen; 286 | double y_diff, value; 287 | 288 | /* Draw Y-axis tic marks and #'s 289 | */ 290 | ticlen = Grid ? RV : LV + TICLEN; 291 | y_diff = ymax - ymin; 292 | 293 | for (i = 0; i <= numtics; ++i) 294 | { 295 | yoffset = (int)(BH - ((float)VD / numtics) * i); 296 | if (yoffset < TH) 297 | yoffset = TH; 298 | 299 | blackPen->DrawLine(canvas->Surface(), LV, yoffset, ticlen, yoffset); 300 | 301 | value = ymin + (y_diff / numtics * i); 302 | 303 | MakeTicLabel(buffer, y_diff, value); 304 | len = strlen(buffer); 305 | 306 | xoffset = LV - Y_TIC_LABEL_OFFSET - fonts->StringWidth(XFonts::Point12, buffer); 307 | 308 | blackPen->DrawText(canvas->Surface(), xoffset, yoffset, buffer); 309 | } 310 | 311 | } /* END DO_YTICS */ 312 | 313 | /* -------------------------------------------------------------------- */ 314 | void SetYLabelPixmap() 315 | { 316 | int i, j, ascent, descent; 317 | const XFontStruct *fontInfo = fonts->Font(XFonts::Point18); 318 | 319 | ascent = fontInfo->max_bounds.ascent; 320 | descent = fontInfo->max_bounds.descent; 321 | pixLen = fonts->StringWidth(XFonts::Point18, ylabel); 322 | charSize = ascent + descent; 323 | 324 | if (im_out) 325 | XDestroyImage(im_out); 326 | 327 | blackPen->SetFont(fonts->Font(XFonts::Point18)); 328 | pixLen = fonts->StringWidth(XFonts::Point18, ylabel); 329 | 330 | /* Create a pixmap, draw string to it and read it back out as an Image. 331 | */ 332 | in_pm->Clear(); 333 | blackPen->DrawText(in_pm->Surface(), 0, ascent, ylabel); 334 | 335 | im_in = in_pm->GetImage(pixLen, charSize); 336 | im_out = out_pm->GetImage(charSize, pixLen); 337 | 338 | 339 | /* Rotate pixmap 340 | */ 341 | for (int i = 0; i < charSize; i++) 342 | for (int j = 0; j < pixLen; j++) 343 | XPutPixel(im_out, i, pixLen-j-1, XGetPixel(im_in, j, i)); 344 | 345 | XDestroyImage(im_in); 346 | 347 | } /* END SETYLABELPIXMAP */ 348 | 349 | /* END XPLOT.C */ 350 | -------------------------------------------------------------------------------- /dnload/dnload.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: dnload.cc 4 | 5 | FULL NAME: ADS tape copier & downloader. 6 | 7 | DESCRIPTION: Copy a tape from one tape to another and also dump a copy 8 | to individual disk files [ads|2d|MCR|AVAPS]. 9 | 10 | INPUT: 11 | 12 | OUTPUT: 13 | 14 | NOTES: 15 | 16 | COPYRIGHT: University Corporation for Atmospheric Research, 1992-9 17 | ------------------------------------------------------------------------- 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include "adsIO.h" 28 | 29 | 30 | char buffer[65000]; 31 | char sourceTape[64], destTape[64], destFile[80], dest2d[80], destMCR[80], 32 | destAVAPS[80], destMASP[80]; 33 | int outTape, outDisk, out2D, outMCR, outAVAPS, outMASP; 34 | int cntTape, cntDisk, cnt2D, cntMCR, cntAVAPS, cntMASP; 35 | int pms2d = false, mcr = false, avaps = false, masp = false; 36 | 37 | void CloseDiskFiles(); 38 | int WriteDisk(char buff[], int nBytes); 39 | 40 | Hdr_blk startTime, endTime; 41 | 42 | int hdrLen = 0; 43 | char hdrBuffer[65000]; 44 | 45 | /* -------------------------------------------------------------------- */ 46 | main(int argc, char *argv[]) 47 | { 48 | int rc, nBytes; 49 | ADS_DataFile *source; 50 | 51 | 52 | outTape = outDisk = out2D = outMCR = outAVAPS = outMASP = ERR; 53 | 54 | 55 | printf("Enter source tape drive [/dev/rmt/0] : "); 56 | gets(sourceTape); 57 | 58 | if (strlen(sourceTape) == 0) 59 | strcpy(sourceTape, "/dev/rmt/0"); 60 | 61 | 62 | printf("Enter destination tape drive [return for no tape copy] : "); 63 | gets(destTape); 64 | 65 | printf("Enter destination disk file [return for no disk file] : "); 66 | gets(destFile); 67 | 68 | if (strlen(destTape) == 0 && strlen(destFile) == 0) 69 | { 70 | fprintf(stderr, "Ppppphhhhhhtttttt!\n"); 71 | return(1); 72 | } 73 | 74 | 75 | source = new ADS_DataFile(sourceTape); 76 | 77 | 78 | if (strlen(destFile)) 79 | { 80 | if (strstr(destFile, ".ads") == 0) 81 | strcat(destFile, ".ads"); 82 | 83 | if (source->hdr->GetFirst(PMS2D_STR)) 84 | { 85 | do 86 | { 87 | printf("Do you want a PMS 2D disk file (y/n) ? "); 88 | gets(buffer); 89 | } 90 | while (toupper(buffer[0]) != 'Y' && toupper(buffer[0]) != 'N'); 91 | 92 | pms2d = toupper(buffer[0]) == 'Y' ? true : false; 93 | } 94 | 95 | if (source->hdr->GetSDI("MCROUT")) 96 | { 97 | do 98 | { 99 | printf("Do you want a MCR disk file (y/n) ? "); 100 | gets(buffer); 101 | } 102 | while (toupper(buffer[0]) != 'Y' && toupper(buffer[0]) != 'N'); 103 | 104 | mcr = toupper(buffer[0]) == 'Y' ? true : false; 105 | } 106 | 107 | if (source->hdr->GetFirst(AVAPS_STR)) 108 | { 109 | do 110 | { 111 | printf("Do you want an AVAPS disk file (y/n) ? "); 112 | gets(buffer); 113 | } 114 | while (toupper(buffer[0]) != 'Y' && toupper(buffer[0]) != 'N'); 115 | 116 | avaps = toupper(buffer[0]) == 'Y' ? true : false; 117 | } 118 | 119 | if (source->hdr->GetFirst(MASP_STR)) 120 | { 121 | do 122 | { 123 | printf("Do you want an MASP disk file (y/n) ? "); 124 | gets(buffer); 125 | } 126 | while (toupper(buffer[0]) != 'Y' && toupper(buffer[0]) != 'N'); 127 | 128 | masp = toupper(buffer[0]) == 'Y' ? true : false; 129 | } 130 | } 131 | 132 | 133 | 134 | printf("\n"); 135 | 136 | if (strlen(destTape)) 137 | { 138 | printf("Tape copy from %s to %s.\n", sourceTape, destTape); 139 | 140 | if ((outTape = open(destTape, O_WRONLY)) == ERR) 141 | { 142 | fprintf(stderr, "Can not open destination tape %s\n", destTape); 143 | return(1); 144 | } 145 | } 146 | 147 | 148 | if (strlen(destFile)) 149 | { 150 | char *p; 151 | 152 | printf("Downloading tape to disk file %s.\n", destFile); 153 | strcpy(dest2d, destFile); 154 | strcpy(destMCR, destFile); 155 | strcpy(destAVAPS, destFile); 156 | strcpy(destMASP, destFile); 157 | 158 | if (pms2d) 159 | { 160 | if ((p = strchr(dest2d, '.')) == NULL) 161 | strcat(dest2d, ".2d"); 162 | else 163 | strcpy(p, ".2d"); 164 | 165 | printf("PMS 2D data to disk file %s.\n", dest2d); 166 | } 167 | 168 | if (mcr) 169 | { 170 | if ((p = strchr(destMCR, '.')) == NULL) 171 | strcat(destMCR, ".rawMCRa"); 172 | else 173 | strcpy(p, ".rawMCRa"); 174 | 175 | printf("MCR data to disk file %s.\n", destMCR); 176 | } 177 | 178 | if (avaps) 179 | { 180 | if ((p = strchr(destAVAPS, '.')) == NULL) 181 | strcat(destAVAPS, ".AVAPS"); 182 | else 183 | strcpy(p, ".AVAPS"); 184 | 185 | printf("AVAPS data to disk file %s.\n", destAVAPS); 186 | } 187 | 188 | if (masp) 189 | { 190 | if ((p = strchr(destMASP, '.')) == NULL) 191 | strcat(destMASP, ".MASP"); 192 | else 193 | strcpy(p, ".MASP"); 194 | 195 | printf("MASP data to disk file %s.\n", destMASP); 196 | } 197 | 198 | 199 | 200 | 201 | if ((outDisk = open(destFile, O_CREAT | O_WRONLY | O_TRUNC, 0666)) == ERR) 202 | { 203 | fprintf(stderr, "Can not open destination file %s\n", destFile); 204 | return(1); 205 | } 206 | 207 | if (pms2d && 208 | (out2D = open(dest2d, O_CREAT | O_WRONLY | O_TRUNC, 0666)) == ERR) 209 | { 210 | fprintf(stderr, "Can not open 2D destination file %s\n", dest2d); 211 | return(1); 212 | } 213 | 214 | if (mcr && 215 | (outMCR = open(destMCR, O_CREAT | O_WRONLY | O_TRUNC, 0666)) == ERR) 216 | { 217 | fprintf(stderr, "Can not open MCR destination file %s\n", destMCR); 218 | return(1); 219 | } 220 | 221 | if (avaps && 222 | (outAVAPS = open(destAVAPS, O_CREAT | O_WRONLY | O_TRUNC, 0666)) == ERR) 223 | { 224 | fprintf(stderr, "Can not open AVAPS destination file %s\n", destAVAPS); 225 | return(1); 226 | } 227 | 228 | if (masp && 229 | (outMASP = open(destMASP, O_CREAT | O_WRONLY | O_TRUNC, 0666)) == ERR) 230 | { 231 | fprintf(stderr, "Can not open MASP destination file %s\n", destMASP); 232 | return(1); 233 | } 234 | } 235 | 236 | 237 | rc = 0; /* Return Code */ 238 | cntTape = cntDisk = cnt2D = cntAVAPS = 0; 239 | 240 | while ((nBytes = source->NextPhysicalRecord(buffer)) > 0) 241 | { 242 | if (outTape != ERR) 243 | { 244 | if (write(outTape, buffer, nBytes) == ERR) 245 | { 246 | fprintf(stderr, "Write failure to dest tape, errno = %d.\n", errno); 247 | rc = 1; 248 | break; 249 | } 250 | else 251 | ++cntTape; 252 | } 253 | 254 | if (outDisk != ERR) 255 | if (WriteDisk(buffer, nBytes) == ERR) 256 | break; 257 | } 258 | 259 | 260 | if (nBytes == ERR) 261 | { 262 | fprintf(stderr, "READ ERROR, errno = %d.\n", errno); 263 | rc = 1; 264 | } 265 | 266 | printf("\n\n"); 267 | 268 | printf("%02d:%02d:%02d - %02d:%02d:%02d\n\n", 269 | startTime.hour, startTime.minute, startTime.second, 270 | endTime.hour, endTime.minute, endTime.second); 271 | 272 | if (outTape != ERR) 273 | { 274 | close(outTape); 275 | printf("%d records successfully written to tape copy.\n", cntTape); 276 | } 277 | 278 | CloseDiskFiles(); 279 | return(rc); 280 | 281 | } /* END MAIN */ 282 | 283 | /* -------------------------------------------------------------------- */ 284 | void CloseDiskFiles() 285 | { 286 | if (outDisk != ERR) 287 | { 288 | close(outDisk); 289 | printf("%d records successfully written to disk.\n", cntDisk); 290 | } 291 | 292 | if (out2D != ERR) 293 | { 294 | close(out2D); 295 | printf("%d PMS 2D records successfully written to disk.\n", cnt2D); 296 | } 297 | 298 | if (outMCR != ERR) 299 | { 300 | close(outMCR); 301 | printf("%d MCR records successfully written to disk.\n", cntMCR); 302 | } 303 | 304 | if (outAVAPS != ERR) 305 | { 306 | close(outAVAPS); 307 | printf("%d AVAPS records successfully written to disk.\n", cntAVAPS); 308 | } 309 | 310 | if (outMASP != ERR) 311 | { 312 | close(outMASP); 313 | printf("%d MASP records successfully written to disk.\n", cntMASP); 314 | } 315 | 316 | outDisk = out2D = outMCR = outAVAPS = outMASP = ERR; 317 | pms2d = mcr = avaps = masp = false; 318 | 319 | } /* END CLOSEDISKFILES */ 320 | 321 | /* -------------------------------------------------------------------- */ 322 | int WriteDisk(char buff[], int nBytes) 323 | { 324 | int rc; 325 | static bool firstSync = true; 326 | 327 | switch (*(unsigned short *)buff) 328 | { 329 | case 0x8681: 330 | rc = write(outDisk, buff, nBytes); 331 | if (firstSync) 332 | { 333 | memcpy((char *)&startTime, buff, sizeof(Hdr_blk)); 334 | firstSync = false; 335 | } 336 | else 337 | memcpy((char *)&endTime, buff, sizeof(Hdr_blk)); 338 | 339 | ++cntDisk; 340 | break; 341 | 342 | case 0x4331: // PMS2D types. 343 | case 0x4332: 344 | case 0x5031: 345 | case 0x5032: 346 | case 0x4731: 347 | case 0x4732: 348 | if (!pms2d) 349 | return(OK); 350 | 351 | rc = write(out2D, buff, nBytes); 352 | ++cnt2D; 353 | break; 354 | 355 | case 0x4d43: // MCR 356 | if (!mcr) 357 | return(OK); 358 | 359 | rc = write(outMCR, buff, nBytes); 360 | ++cntMCR; 361 | 362 | if (cntMCR >= 100800) // close file after 4 hours. 363 | { 364 | close(outMCR); 365 | ++destMCR[strlen(destMCR)-1]; // increment file name. 366 | 367 | if ((outMCR = open(destMCR, O_CREAT | O_WRONLY | O_TRUNC, 0666)) == ERR) 368 | { 369 | fprintf(stderr, "Can not open MCR destination file %s\n", destMCR); 370 | fprintf(stderr, "Continuing without MCR disk file.\n"); 371 | mcr = false; 372 | } 373 | 374 | write(outMCR, hdrBuffer, hdrLen); 375 | cntMCR = 0; 376 | } 377 | 378 | break; 379 | 380 | case 0x4156: // AVAPS Dropsonde. 381 | if (!avaps) 382 | return(OK); 383 | 384 | rc = write(outAVAPS, buff, nBytes); 385 | ++cntAVAPS; 386 | break; 387 | 388 | case 0x4450: // MASP. 389 | if (!masp) 390 | return(OK); 391 | 392 | rc = write(outMASP, buff, nBytes); 393 | ++cntMASP; 394 | break; 395 | 396 | case 0x4144: // Header records. 397 | case 0x5448: 398 | memcpy(&hdrBuffer[hdrLen], buff, nBytes); 399 | hdrLen += nBytes; 400 | 401 | rc = write(outDisk, buff, nBytes); 402 | 403 | if (pms2d) 404 | rc = write(out2D, buff, nBytes); 405 | 406 | if (mcr) 407 | rc = write(outMCR, buff, nBytes); 408 | 409 | break; 410 | } 411 | 412 | 413 | if (rc == ERR) 414 | { 415 | if (errno == ENOSPC) 416 | { 417 | fprintf(stderr, ">>> DISK FULL, closing disk file(s) and continuing.\n"); 418 | CloseDiskFiles(); 419 | } 420 | 421 | fprintf(stderr, "Write failure to dest disk, errno = %d.\n", errno); 422 | return(ERR); 423 | } 424 | 425 | return(OK); 426 | 427 | } /* END WRITEDISK */ 428 | 429 | /* END DNLOAD.CC */ 430 | -------------------------------------------------------------------------------- /old_ads/hdrcvt852.c: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: hdrcvt852.c 4 | 5 | FULL NAME: Header Convert (Proj 852) 6 | 7 | ENTRY POINTS: main() 8 | 9 | DESCRIPTION: This program converts the old new header format to the 10 | newest new header format. (i.e. There should only be a 11 | few exabytes that this works for). 12 | 13 | INPUT: 14 | 15 | OUTPUT: 16 | 17 | REFERENCES: none 18 | 19 | REFERENCED BY: none 20 | 21 | COPYRIGHT: University Corporation for Atmospheric Research, 1992 22 | ------------------------------------------------------------------------- 23 | */ 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include 32 | #include "/h/9/cjw/wrk/tape/hdr_api-1.1/header.h" 33 | 34 | #define TAPE_BLK_SIZE 32767 35 | 36 | typedef unsigned char bool; 37 | 38 | 39 | 40 | struct old_Fl *old_header; /* Pointer where data is/will be stored */ 41 | 42 | char *p_name = "hdrcvt852"; 43 | char *filename; 44 | bool HeaderInitialized = FALSE; 45 | int taperr; /* Tape Error, analogous to errno */ 46 | int name_ptr; /* Index to current variable */ 47 | 48 | 49 | /* -------------------------------------------------------------------- */ 50 | main(argc, argv) 51 | int argc; 52 | char *argv[]; 53 | { 54 | if (argc < 3) 55 | { 56 | fprintf(stderr, "usage: %s input_file output_file\n", p_name); 57 | exit(1); 58 | } 59 | 60 | filename = argv[2]; 61 | 62 | if (InitFlightHeader(argv[1], CLOSE) == ERR) 63 | { 64 | fprintf(stderr, "hdrdump: init error, taperr = %d\n", taperr); 65 | exit(1); 66 | } 67 | 68 | } /* END MAIN */ 69 | 70 | /* -------------------------------------------------------------------- */ 71 | InitFlightHeader(name) 72 | char name[]; 73 | { 74 | int fd; 75 | char buffer[256]; 76 | bool tape = FALSE; 77 | int rc; 78 | 79 | HeaderInitialized = FALSE; 80 | 81 | /* Check for Exabyte Tape Names of ex0 or ex1 82 | */ 83 | if (strcmp(name, "ex0") == 0 || strcmp(name, "ex1") == 0) 84 | { 85 | strcpy(buffer, "/dev/r"); 86 | strcat(buffer, name); 87 | tape = TRUE; 88 | } 89 | else 90 | strcpy(buffer, name); 91 | 92 | /* Open File/Tape 93 | */ 94 | if ((fd = open(buffer, O_RDONLY)) == NULL) 95 | { 96 | taperr = errno; 97 | return(ERR); 98 | } 99 | 100 | if ((old_header = (struct old_Fl *)malloc((unsigned)TAPE_BLK_SIZE)) == NULL) 101 | { 102 | taperr = errno; 103 | return(ERR); 104 | } 105 | 106 | /* If it's a tape then skip past the first record 107 | */ 108 | if (tape) 109 | { 110 | read(fd, (char *)old_header, TAPE_BLK_SIZE); 111 | 112 | if (strcmp((char *)old_header, "ADS DATA TAPE") != 0) 113 | { 114 | taperr = BADHDR; 115 | return(ERR); 116 | } 117 | } 118 | 119 | 120 | read(fd, (char *)old_header, TAPE_BLK_SIZE); 121 | close(fd); 122 | 123 | 124 | /* Check if valid file */ 125 | if (strcmp(TAPEHDR_STR, old_header->thdr) != 0) 126 | { 127 | taperr = BADHDR; 128 | return(ERR); 129 | } 130 | 131 | /* Setup the var pointers and init the var name list 132 | */ 133 | if ((rc = setup_var_list()) == OK) 134 | HeaderInitialized = TRUE; 135 | 136 | return(rc); 137 | 138 | } /* END INITFLIGHTDATA */ 139 | 140 | /* -------------------------------------------------------------------- */ 141 | ReleaseFlightHeader() 142 | { 143 | free(old_header); 144 | HeaderInitialized = FALSE; 145 | } 146 | 147 | /* -------------------------------------------------------------------- */ 148 | static setup_var_list() 149 | { 150 | int i, type, rc = OK; 151 | char *p; 152 | FILE *fp; 153 | struct Fl flight; 154 | 155 | if ((fp = fopen(filename, "wb")) == NULL) 156 | { 157 | fprintf(stderr, "%s: can't open output file %s\n", 158 | p_name, filename); 159 | exit(1); 160 | } 161 | 162 | strcpy(flight.thdr, "THDR"); 163 | flight.item_len = sizeof(struct Fl); 164 | strcpy(flight.version, VERSION_STR); 165 | memcpy(flight.prnum, old_header->prnum, 76); 166 | fwrite((char *)&flight, sizeof(struct Fl), 1, fp); 167 | 168 | 169 | /* loop 170 | * - Get Struct Type 171 | * - Add var name to list of var names 172 | * - Set Pointer into heap 173 | */ 174 | p = (char *)old_header + sizeof(struct old_Fl); 175 | 176 | for (i = 0; i < old_header->n_items; ++i) 177 | { 178 | if ((type = write_struct((struct old_Blk *)p, fp)) == ERR) 179 | { rc = ERR; break; } 180 | 181 | switch (type) 182 | { 183 | case SH: 184 | p += sizeof(struct old_Sh); 185 | break; 186 | 187 | case DME: 188 | p += sizeof(struct old_Dme); 189 | break; 190 | 191 | case INS: 192 | p += sizeof(struct old_Ins); 193 | break; 194 | 195 | case IRS: 196 | p += sizeof(struct old_Irs); 197 | break; 198 | 199 | case PMS1D: 200 | p += sizeof(struct old_Pms1); 201 | break; 202 | 203 | case EVENT: 204 | p += sizeof(struct old_Evt); 205 | break; 206 | 207 | case BLK: 208 | p += sizeof(struct old_Blk); 209 | break; 210 | 211 | case ASYNC: 212 | p += sizeof(struct old_Asy); 213 | break; 214 | 215 | default: 216 | fprintf(stderr, "Unrecognized type\n"); 217 | } 218 | 219 | } 220 | 221 | fclose(fp); 222 | return(rc); 223 | 224 | } /* END SETUP_VAR_LIST */ 225 | 226 | /* -------------------------------------------------------------------- */ 227 | static write_struct(p, fp) 228 | struct old_Blk *p; 229 | FILE *fp; 230 | { 231 | char *type; 232 | struct Sh sh; 233 | struct Asy async; 234 | struct Dme dme; 235 | struct Ins ins; 236 | struct Irs irs; 237 | struct Pms1 pms1; 238 | struct Evt event; 239 | struct Blk blk; 240 | 241 | type = (char *)p; 242 | 243 | /* Determine Struct Type 244 | */ 245 | switch (type[0]) 246 | { 247 | case 'A': 248 | do_async(&async, p); 249 | fwrite(&async, sizeof(struct Asy), 1, fp); 250 | return(ASYNC); 251 | 252 | case 'C': case 'G': case 'L': 253 | do_blk(&blk, p); 254 | fwrite(&blk, sizeof(struct Blk), 1, fp); 255 | return(BLK); 256 | 257 | case 'D': 258 | if (strcmp(type, DME_STR) == 0) 259 | { 260 | do_dme(&dme, p); 261 | fwrite(&dme, sizeof(struct Dme), 1, fp); 262 | return(DME); 263 | } 264 | else 265 | if(strcmp(type, DIGOUT_STR) == 0) 266 | { 267 | do_sh(&sh, p); 268 | fwrite(&sh, sizeof(struct Sh), 1, fp); 269 | return(SH); 270 | } 271 | break; 272 | 273 | case 'E': 274 | do_event(&event, p); 275 | fwrite(&event, sizeof(struct Evt), 1, fp); 276 | return(EVENT); 277 | 278 | case 'H': 279 | if (strcmp(type, HDR_STR) == 0) 280 | { 281 | do_blk(&blk, p); 282 | fwrite(&blk, sizeof(struct Blk), 1, fp); 283 | return(BLK); 284 | } 285 | else 286 | if(strcmp(type, HSKP_STR) == 0) 287 | { 288 | do_sh(&sh, p); 289 | fwrite(&sh, sizeof(struct Sh), 1, fp); 290 | return(SH); 291 | } 292 | break; 293 | 294 | case 'I': 295 | if (strcmp(type, IRS_STR) == 0) 296 | { 297 | do_event(&irs, p); 298 | fwrite(&irs, sizeof(struct Irs), 1, fp); 299 | return(IRS); 300 | } 301 | else 302 | if(strcmp(type, INS_STR) == 0) 303 | { 304 | do_ins(&ins, p); 305 | fwrite(&ins, sizeof(struct Ins), 1, fp); 306 | return(INS); 307 | } 308 | break; 309 | 310 | case 'P': 311 | do_pms1(&pms1, p); 312 | fwrite(&pms1, sizeof(struct Pms1), 1, fp); 313 | return(PMS1D); 314 | 315 | case 'S': 316 | do_sh(&sh, p); 317 | fwrite(&sh, sizeof(struct Sh), 1, fp); 318 | return(SH); 319 | } 320 | 321 | taperr = BADTYPE; 322 | return(ERR); 323 | 324 | } /* END GETITEMTYPE */ 325 | 326 | /* -------------------------------------------------------------------- */ 327 | do_async(new, old) 328 | struct Asy *new; 329 | struct old_Asy *old; 330 | { 331 | strcpy(new->item_type, old->blkid); 332 | strcpy(new->name, old->name); 333 | new->item_len = sizeof(struct Asy); 334 | new->lrlen = old->lrlen; 335 | new->lrppr = old->lrppr; 336 | 337 | printf("Item_type = [%s]\n", new->item_type); 338 | 339 | } 340 | 341 | /* -------------------------------------------------------------------- */ 342 | do_blk(new, old) 343 | struct Blk *new; 344 | struct old_Blk *old; 345 | { 346 | strcpy(new->item_type, old->name); 347 | new->item_len = sizeof(struct Blk); 348 | new->start = old->start; 349 | new->length = old->length; 350 | 351 | printf("Item_type = [%s]\n", new->item_type); 352 | 353 | } 354 | 355 | /* -------------------------------------------------------------------- */ 356 | do_pms1(new, old) 357 | struct Pms1 *new; 358 | struct old_Pms1 *old; 359 | { 360 | strcpy(new->item_type, old->name); 361 | strcpy(new->name, old->prb_name); 362 | strcpy(new->locn, ""); 363 | new->item_len = sizeof(struct Pms1); 364 | new->start = old->start; 365 | new->length = old->length; 366 | new->rate = old->rate; 367 | new->adsaddr = old->adsaddr; 368 | new->auxaddr = old->auxaddr; 369 | 370 | printf("Item_type = [%s]\n", new->item_type); 371 | 372 | } 373 | 374 | /* -------------------------------------------------------------------- */ 375 | do_ins(new, old) 376 | struct Ins *new; 377 | struct old_Ins *old; 378 | { 379 | strcpy(new->item_type, old->name); 380 | new->item_len = sizeof(struct Ins); 381 | new->start = old->start; 382 | new->length = old->length; 383 | new->rate = old->rate; 384 | new->adsadr1 = old->adsadr1; 385 | new->adsadr2 = old->adsadr2; 386 | 387 | printf("Item_type = [%s]\n", new->item_type); 388 | 389 | } 390 | 391 | /* -------------------------------------------------------------------- */ 392 | do_event(new, old) 393 | struct Evt *new; 394 | struct old_Evt *old; 395 | { 396 | strcpy(new->item_type, old->name); 397 | strcpy(new->locn, old->locn); 398 | new->item_len = sizeof(struct Evt); 399 | new->start = old->start; 400 | new->length = old->length; 401 | 402 | printf("Item_type = [%s]\n", new->item_type); 403 | 404 | } 405 | 406 | /* -------------------------------------------------------------------- */ 407 | do_sh(new, old) 408 | struct Sh *new; 409 | struct old_Sh *old; 410 | { 411 | int i; 412 | 413 | strcpy(new->item_type, old->name); 414 | strcpy(new->name, old->vname); 415 | strcpy(new->type, old->type); 416 | new->item_len = sizeof(struct Sh); 417 | new->start = old->start; 418 | new->length = old->length; 419 | new->rate = old->rate; 420 | new->adsaddr = old->adsaddr; 421 | new->convert = old->convert; 422 | new->order = old->order; 423 | 424 | switch (new->rate) 425 | { 426 | case 250: 427 | new->offset = 0x06; 428 | break; 429 | 430 | case 50: 431 | new->offset = 0x1e; 432 | break; 433 | 434 | case 5: 435 | new->offset = 0x3a; 436 | break; 437 | 438 | case 1: 439 | new->offset = 0; 440 | break; 441 | 442 | default: 443 | fprintf(stderr, "Invalid rate = %d\n", new->rate); 444 | break; 445 | } 446 | 447 | 448 | for (i = 0; i < new->order; ++i) 449 | new->cof[i] = old->cof[i]; 450 | 451 | for (; i < 10; ++i) 452 | new->cof[i] = 0.0; 453 | 454 | printf("Item_type = [%s]\n", new->item_type); 455 | 456 | } 457 | 458 | /* -------------------------------------------------------------------- */ 459 | do_dme(new, old) 460 | struct Dme *new; 461 | struct old_Dme *old; 462 | { 463 | strcpy(new->item_type, old->name); 464 | new->item_len = sizeof(struct Dme); 465 | new->start = old->start; 466 | new->length = old->length; 467 | new->rate = old->rate; 468 | new->rdadr1 = old->rdadr1; 469 | new->rdadr2 = old->rdadr2; 470 | new->wradr = old->wradr; 471 | 472 | printf("Item_type = [%s]\n", new->item_type); 473 | 474 | } 475 | 476 | /* END HDRCVT852.C */ 477 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 1992 University Corporation for Atmospheric Research 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | Any external libraries used in this software are subject to their own licenses, when applicable. 204 | -------------------------------------------------------------------------------- /rtplot_motif/hdr_decode.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: hdr_decode.c 4 | 5 | FULL NAME: Decode Header 6 | 7 | ENTRY POINTS: DecodeHeader() 8 | 9 | STATIC FNS: in_hdr(), in_sdi(), in_irs(), in_ophir3(), in_pms1d(), 10 | in_pms1dv2(), locatePMS(), add_file_to_???TBL(), 11 | add_name_to_???TBL(), add_derived_names(), in_ins(), 12 | check_cal_coes() 13 | 14 | DESCRIPTION: Read header & add variables to appropriate table. There 15 | are 3 major tables here: 16 | - SDI table 17 | - Raw table (From block probes) 18 | - Derived table 19 | 20 | This module is the brunt end interface between an ADS tape 21 | and the rest of nimbus. 22 | 23 | INPUT: Header filename. 24 | 25 | OUTPUT: sdi, nsdi, raw, nraw, derived, nderive 26 | (These globals are initialized in this file) 27 | 28 | REFERENCES: Header API (libhdr_api.a) 29 | OpenProjectFile(), AccessProjectFile() 30 | ReadTextFile(), FreeTextFile() 31 | SearchList(), SearchDERIVEFTNS() 32 | ReadStaticLags(), SetUpDependencies(), ReadDefaultsFile() 33 | SortTable() 34 | 35 | REFERENCED BY: rtplot.c 36 | 37 | NOTE: This file is from hell. 38 | 39 | COPYRIGHT: University Corporation for Atmospheric Research, 1992-9 40 | ------------------------------------------------------------------------- 41 | */ 42 | 43 | #include 44 | #include 45 | 46 | #include "define.h" 47 | #include "decode.h" 48 | #include "amlib.h" 49 | 50 | #include "raf/adsIOrt.h" 51 | 52 | ADS_rtFile *file; 53 | 54 | char *ProjectDirectory, *ProjectNumber; 55 | 56 | /* Global to ease parameter passing in this file */ 57 | static int InertialSystemCount; 58 | static int start, rate, probe_cnt = 0; 59 | static char *item_type, location[NAMELEN], 60 | *rawlist[MAX_RAW*2]; 61 | 62 | 63 | static void add_raw_names(char name[]); 64 | static RAWTBL *add_name_to_RAWTBL(char vn[]); 65 | static int check_cal_coes(int order, float *coef); 66 | static void add_file_to_RAWTBL(char file[]), in_hdr(), 67 | in_sdi(Sh *vn), in_irs(Irs *vn), in_ophir3(Blk *vn); 68 | 69 | static Header *hdr; 70 | 71 | 72 | extern int Aircraft; 73 | 74 | /* -------------------------------------------------------------------- */ 75 | int DecodeHeader(char dummy[]) 76 | { 77 | void *vn; 78 | FILE *fp; 79 | char *loc; 80 | 81 | nsdi = nraw = InertialSystemCount = 0; 82 | 83 | probe_cnt = 0; 84 | 85 | file = new ADS_rtFile(); 86 | hdr = file->hdr; 87 | 88 | Aircraft = atoi(&(hdr->Aircraft())[1]); 89 | strcpy(FlightNumber, hdr->FlightNumber()); 90 | 91 | ProjectDirectory = getenv("PROJ_DIR"); 92 | ProjectNumber = hdr->ProjectNumber(); 93 | 94 | sprintf(buffer, "%s/%s", ProjectDirectory, ProjectNumber); 95 | if (access(buffer, R_OK) == ERR) 96 | { 97 | if ((fp = OpenProjectFile("%s/%s/ProjectName", "r", RETURN)) != NULL) 98 | { 99 | fgets(buffer, 512, fp); 100 | buffer[strlen(buffer)-1] = '\0'; /* Remove '\n' */ 101 | 102 | ProjectName = new char[strlen(buffer)+1]; 103 | strcpy(ProjectName, buffer); 104 | title = ProjectName; 105 | title += " - "; 106 | title += hdr->ProjectNumber(); 107 | fclose(fp); 108 | } 109 | } 110 | else 111 | ProjectName = ""; 112 | 113 | 114 | ReadTextFile(RAWNAMES, rawlist); 115 | 116 | SetLookupSuffix((char *)NULL); 117 | 118 | 119 | /* This is the main loop, loop through all variables in header 120 | */ 121 | for (vn = hdr->GetFirst(); vn; vn = hdr->GetNext()) 122 | { 123 | start = hdr->Start(vn); 124 | location[0] = '\0'; 125 | 126 | /* Initialize variable/probe into appropriate table(s). 127 | */ 128 | if (!strcmp(hdr->ItemType(vn), HSKP_STR) || 129 | !strcmp(hdr->ItemType(vn), DIGOUT_STR) || 130 | !strcmp(hdr->ItemType(vn), SDI_STR)) 131 | { 132 | in_sdi((Sh *)vn); 133 | continue; 134 | } 135 | 136 | 137 | if (!strcmp(hdr->ItemType(vn), HDR_STR)) 138 | in_hdr(); 139 | else 140 | if (!strcmp(hdr->ItemType(vn), IRS_STR)) 141 | { 142 | if (hdr->AircraftLocation((Irs *)vn)) 143 | { 144 | location[0] = '_'; 145 | strcpy(&location[1], hdr->AircraftLocation((Irs *)vn)); 146 | } 147 | 148 | strcpy(buffer, hdr->ItemType(vn)); 149 | strcat(buffer, location); 150 | in_irs((Irs *)vn); 151 | } 152 | else 153 | if (!strcmp(hdr->ItemType(vn), UVHYG_STR)) 154 | { 155 | rate = sizeof(struct Uv_blk) / sizeof(struct Uv_smp); 156 | add_raw_names(item_type); 157 | } 158 | else 159 | if (!strcmp(hdr->ItemType(vn), OPHIR3_STR)) 160 | { 161 | rate = 1; 162 | in_ophir3((Blk *)vn); 163 | } 164 | else 165 | if (!strcmp(hdr->ItemType(vn), GPS_TRIM_STR) || 166 | !strcmp(hdr->ItemType(vn), GPS_TANS2_STR) || 167 | !strcmp(hdr->ItemType(vn), GPS_TANS3_STR)) 168 | { 169 | rate = 1; 170 | add_raw_names(item_type); 171 | } 172 | else 173 | if (!strcmp(hdr->ItemType(vn), PPS_GPS_STR)) 174 | { 175 | rate = 1; 176 | add_raw_names(item_type); 177 | } 178 | else 179 | if (!strcmp(hdr->ItemType(vn), HW_GPS_STR)) 180 | { 181 | if (hdr->AircraftLocation((Blk *)vn)) 182 | { 183 | location[0] = '_'; 184 | strcpy(&location[1], hdr->AircraftLocation((Blk *)vn)); 185 | } 186 | 187 | add_file_to_RAWTBL(GPSHWNAMES); 188 | } 189 | else 190 | if (!strcmp(hdr->ItemType(vn), DME_STR)) 191 | { 192 | rate = 1; 193 | add_raw_names(item_type); 194 | } 195 | else 196 | if (!strcmp(hdr->ItemType(vn), DPRES_STR)) 197 | { 198 | rate = 5; 199 | add_raw_names(item_type); 200 | } 201 | else 202 | if (!strcmp(hdr->ItemType(vn), SER_STR)) 203 | add_name_to_RAWTBL("SERIAL"); 204 | } 205 | 206 | 207 | 208 | { 209 | /* 210 | int i; 211 | for (i = 0; i < nsdi; ++i) 212 | printf("%-12s%5d\n", sdi[i]->name, sdi[i]->convertOffset); 213 | 214 | for (i = 0; i < nraw; ++i) 215 | printf("%-12s%3d%5d\n", raw[i]->name, raw[i]->SampleRate, raw[i]->NRstart); 216 | 217 | */ 218 | } 219 | 220 | 221 | sdi[nsdi] = NULL; 222 | raw[nraw] = NULL; 223 | 224 | SortTable((char **)sdi, 0, nsdi - 1); 225 | SortTable((char **)raw, 0, nraw - 1); 226 | 227 | return(0); 228 | 229 | } /* END DECODEHEADER */ 230 | 231 | /* -------------------------------------------------------------------- */ 232 | static void in_hdr() 233 | { 234 | /* These items must be added to the tables first (i.e. don't 235 | * add any variables above the main loop in the fn above). 236 | */ 237 | start = 0; rate = 1; 238 | add_name_to_RAWTBL("HOUR"); 239 | add_name_to_RAWTBL("MINUTE"); 240 | add_name_to_RAWTBL("SECOND"); 241 | 242 | } /* END IN_HDR */ 243 | 244 | /* -------------------------------------------------------------------- */ 245 | static void in_sdi(Sh *vn) 246 | { 247 | int i; 248 | SDITBL *cp; 249 | 250 | if (hdr->SampleRate(vn) == 5000) 251 | return; 252 | 253 | if (strcmp(hdr->VariableName(vn), "DUMMY") == 0) 254 | return; 255 | 256 | /* By placing an SDI variable into the 'deriveftns[]' list 257 | * (ninc/amlib.fns) the variable will automatically be placed 258 | * into the 'raw' list instead of 'sdi' (i.e. if you have an SDI 259 | * variable that requires special processing). 260 | */ 261 | if (SearchDERIVEFTNS(hdr->VariableName(vn)) != ERR) 262 | { 263 | RAWTBL *rp; 264 | 265 | rp = add_name_to_RAWTBL(hdr->VariableName(vn)); 266 | 267 | rp->convertFactor = hdr->AtoDconversionFactor(vn); 268 | rp->convertOffset = hdr->AtoDconversionOffset(vn); 269 | 270 | rp->order = hdr->CalibrationOrder(vn); 271 | 272 | for (i = 0; i < rp->order; ++i) 273 | rp->cof[i] = hdr->CalibrationCoefficient(vn, i); 274 | 275 | rp->order = check_cal_coes(rp->order, rp->cof); 276 | 277 | rp->ADSoffset = hdr->InterleaveOffset(vn) >> 1; 278 | 279 | if (strcmp(rp->name, "HGM232") == 0) { /* Status bit for APN-232 */ 280 | rp = add_name_to_RAWTBL("HGM232S"); 281 | rp->ADSoffset = hdr->InterleaveOffset(vn) >> 1; 282 | } 283 | } 284 | 285 | 286 | /* Ok, it's strictly nth order polynomial, put it in the SDI table. 287 | */ 288 | if (nsdi == MAX_SDI) 289 | { 290 | cerr << "MAX_SDI reached, modify in nimbus.h and recompile.\n"; 291 | exit(1); 292 | } 293 | 294 | cp = sdi[nsdi++] = new SDITBL; 295 | 296 | cp->convertFactor = hdr->AtoDconversionFactor(vn); 297 | cp->convertOffset = hdr->AtoDconversionOffset(vn); 298 | cp->ADSoffset = hdr->InterleaveOffset(vn) >> 1; 299 | 300 | strcpy(cp->name, hdr->VariableName(vn)); 301 | strcpy(cp->type, hdr->SDItype(vn)); 302 | cp->SampleRate = hdr->SampleRate(vn); 303 | cp->OutputRate = LOW_RATE; 304 | cp->ADSstart = hdr->Start(vn) >> 1; 305 | cp->StaticLag = 0; 306 | cp->SpikeSlope = 0; 307 | cp->Average = NULL; 308 | cp->Dirty = false; 309 | cp->Modulo = NULL; 310 | cp->Output = true; 311 | cp->DependedUpon = false; 312 | 313 | cp->order = hdr->CalibrationOrder(vn); 314 | 315 | for (i = 0; i < cp->order; ++i) 316 | cp->cof[i] = hdr->CalibrationCoefficient(vn, i); 317 | 318 | cp->order = check_cal_coes(cp->order, cp->cof); 319 | cp->order = check_cal_coes(cp->order, cp->cof); 320 | 321 | } /* END IN_SDI */ 322 | 323 | /* -------------------------------------------------------------------- */ 324 | /* NOTE: this proc is assuming the primary IRS probe is stored in the 325 | * header first. Currently this is LEFT PIT. xbuild.c is responsible 326 | * for insuring this. 327 | */ 328 | static void in_irs(Irs *vn) 329 | { 330 | int i; 331 | RAWTBL *rp; 332 | char *names[50]; 333 | char name[NAMELEN]; 334 | 335 | if (InertialSystemCount == 0) 336 | location[0] = '\0'; 337 | 338 | /* This is how I resolv conflicting names between IRS & INS 339 | */ 340 | SetLookupSuffix("_IRS"); 341 | 342 | ReadTextFile(IRSNAMES, names); 343 | 344 | for (i = 0; names[i]; ++i) 345 | { 346 | sscanf(names[i], "%s %d", name, &rate); 347 | 348 | if ((rp = add_name_to_RAWTBL(name)) == (RAWTBL *)ERR) 349 | continue; 350 | } 351 | 352 | 353 | FreeTextFile(names); 354 | 355 | SetLookupSuffix((char *)NULL); 356 | 357 | } /* END IN_IRS */ 358 | 359 | /* -------------------------------------------------------------------- */ 360 | static void in_ophir3(Blk *vn) 361 | { 362 | RAWTBL *rp; 363 | int i, j; 364 | char *list[32]; 365 | 366 | ReadTextFile(OPHIR3NAMES, list); 367 | 368 | for (i = 0; list[i]; ++i) 369 | { 370 | if ((rp = add_name_to_RAWTBL(strtok(list[i], " \t"))) == (RAWTBL *)ERR) 371 | continue; 372 | 373 | rp->convertOffset = 0; 374 | rp->convertFactor = 1.0; 375 | rp->order = atoi(strtok((char *)NULL, " \t")); 376 | 377 | for (j = 0; j < rp->order; ++j) 378 | rp->cof[j] = (float)atof(strtok((char *)NULL, " \t")); 379 | } 380 | 381 | FreeTextFile(list); 382 | 383 | } /* END IN_OPHIR3 */ 384 | 385 | 386 | /* -------------------------------------------------------------------- */ 387 | /* Header Decode Atomic functions */ 388 | /* -------------------------------------------------------------------- */ 389 | static void add_raw_names(char name[]) 390 | { 391 | char *p; 392 | char buff[512]; 393 | 394 | /* Find variable in raw list and add ALL associated names to raw table. 395 | */ 396 | if ( (p = SearchList(rawlist, name)) ) 397 | { 398 | strcpy(buff, p); 399 | p = strtok(buff, " \t"); 400 | 401 | while ( (p = strtok((char *)NULL, " \t")) ) 402 | add_name_to_RAWTBL(p); 403 | } 404 | 405 | } /* END ADD_RAW_NAMES */ 406 | 407 | /* -------------------------------------------------------------------- */ 408 | static void add_file_to_RAWTBL(char filename[]) 409 | { 410 | FILE *fp; 411 | 412 | fp = OpenProjectFile(filename, "r", EXIT); 413 | 414 | while (fscanf(fp, "%s", buffer) != EOF) 415 | if (buffer[0] != '#') 416 | add_name_to_RAWTBL(buffer); 417 | 418 | fclose(fp); 419 | 420 | } /* END ADD_FILE_TO_RAWTBL */ 421 | 422 | /* -------------------------------------------------------------------- */ 423 | static RAWTBL *add_name_to_RAWTBL(char name[]) 424 | { 425 | int indx; 426 | RAWTBL *rp; 427 | 428 | if ((indx = SearchDERIVEFTNS(name)) == ERR) 429 | { 430 | cerr << "Throwing away " << name << ", has no decode function.\n"; 431 | return((RAWTBL *)ERR); 432 | } 433 | 434 | if (nraw == MAX_RAW) 435 | { 436 | cerr << "MAX_RAW reached, modify in nimbus.h and recompile.\n"; 437 | exit(1); 438 | } 439 | 440 | rp = raw[nraw++] = new RAWTBL; 441 | 442 | strcpy(rp->name, name); 443 | if (*location) 444 | strcat(rp->name, location); 445 | 446 | rp->xlate = (void (*) (void *, void *, float *))deriveftns[indx].xlate; 447 | 448 | rp->ADSstart = start >> 1; 449 | rp->ADSoffset = 1; 450 | rp->SampleRate = rate; 451 | rp->OutputRate = LOW_RATE; 452 | rp->Length = 1; 453 | rp->convertOffset = 0; 454 | rp->convertFactor = 1.0; 455 | rp->order = 0; 456 | rp->StaticLag = 0; 457 | rp->SpikeSlope = 0; 458 | rp->DynamicLag = 0; 459 | 460 | rp->Dirty = false; 461 | rp->Average = NULL; 462 | rp->Modulo = NULL; 463 | rp->Output = true; 464 | rp->DependedUpon = false; 465 | rp->ProbeType = 0; 466 | 467 | return(rp); 468 | 469 | } /* END ADD_NAME_TO_RAWTBL */ 470 | 471 | /* -------------------------------------------------------------------- */ 472 | /* Strip out trailing 0 cal coe's 473 | */ 474 | static int check_cal_coes(int order, float *coef) 475 | { 476 | do 477 | { 478 | --order; 479 | } 480 | while (order >= 0 && coef[order] == 0.0); 481 | 482 | return(order + 1); 483 | 484 | } /* END CHECK_CAL_COES */ 485 | 486 | /* END HDR_DECODE.C */ 487 | --------------------------------------------------------------------------------