/* 723 S-BAND TRANSMITTER CONTROL PROGRAM module 723.c */ /* written by Grant Bingeman and Richard Summers */ /* copyright 1990,1991,1992,1993,1994,1995,1996 by Continental Electronics */ /* see "include" directory for header files */ /* see l.bat and 723.lnk for link info */ /* see "lib" directory for foreign libraries */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include unsigned char ptbl1[]= { 0,0,0, /* black */ 0xFF,0xFF,0xFF, /* dark blue */ 0xFF,0xFF,0xFF, /* green */ 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0,0,0, /* dark grey */ 0,0,0, /* blue */ 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF }; unsigned char ptbl2[]= { 0,0,0, /* black */ 0xFF,0xFF,0xFF, /* dark blue */ 0,0,0, /* green */ 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0,0,0, /* dark grey */ 0,0,0, /* blue */ 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF }; char func[960]; /* function key definitions */ char eventime[96],evendate[96],event[160],evenable[16]; /* clocked events */ char histime[320]; /* history time and date scroll */ char dayt[9],tyme[9],oldayt[9],oltyme[9]; char dname[320],dname1[160],dname2[160],dname3[16],dname4[16]; /* user defined inputs */ char aname[320],aname1[160],aname2[16]; /* user defined meters */ char cname[160],cname1[16],cname2[16],cname3[16];/* user defined commands */ char password[10],idents[106],codec[4]; char numb[30],treegate[256],treelev[256],treenabl[16],treecmd[160]; char kernbuf[16*1024]; char *chip[]= { "Unknown", "Tseng ET3000", "Paradise", "Video7", "ATI", "Tseng ET4000", "Trident", "VESA", }; char *cmdlist[]={ "723", "ALT-R", "ALT-P", "CTRL-H", "CTRL-R", "+-/*", "ACTS", "AMOF", "AM", "ANT", "AUTO", "BAL", "BARS", "BASE", "BEAM", "CMND", "CODE", "COFF", "COOL", "COM", "COMB", "DATA", "DATE", "DBDN", "DBUP", "DFLT", "DL", "DRIV", "DROF", "DRON", "DRDN", "DRUP", "DUMP", "EXIT", "FAIL", "FALT", "FLOW", "FLOF", "FILS", "FLDN", "FLUP", "FIND", "FUNC", "GNDN", "GNUP", "HELP", "HIST", "HONK", "HVON", "HVOF", "HVDN", "HVUP", "ID", "INTL", "LIMT", "LOGS", "LONG", "MAIN", "MET", "MOF", "MAGS", "MDN", "MUP", "M1OF", "MAG1", "M1DN", "M1UP", "M2OF", "MAG2", "M2DN", "M2UP", "MAPS", "MATH", "MISC", "MUTE", "OFDN", "OFUP", "PACT", "PAL", "PASS", "PBDN", "PBUP", "PMOF", "PM", "POWR", "QUIT", "RCV", "REP", "RSET", "RTST", "SCAL", "SCOP", "SECU", "SHRT", "SIMU", "SPAR", "STAR", "STAT", "STBY", "STLG", "STOR", "TABL", "TEST", "TIME", "TITL", "TRND", "USER", "WAST", "XMT", 0 }; char *metlist[]={ "MAGNET 1 VOLTAGE", /* 0 */ "MAGNET 2 VOLTAGE", /* 1 */ "BEAM VOLTAGE", /* 2 */ "MAGNET 1 CURRENT", /* 3 */ "MAGNET 2 CURRENT", /* 4 */ "BODY CURRENT", /* 5 */ "FILAMENT 1 VOLTAGE", /* 6 */ "FILAMENT 2 VOLTAGE", /* 7 */ "FILAMENT 1 CURRENT", /* 8 */ "FILAMENT 2 CURRENT", /* 9 */ "COLLECTOR 1 CURRENT", /* 10 */ "COLLECTOR 2 CURRENT", /* 11 */ "VACION 1 CURRENT", /* 12 */ "VACION 2 CURRENT", /* 13 */ "SPARE", /* 14 */ "SPARE", /* 15 */ "WASTER FWD POWER", /* 16 */ "KLY1 FWD POWER", /* 17 */ "KLY1 REFL POWER", /* 18 */ "KLY2 FWD POWER", /* 19 */ "KLY2 REFL POWER", /* 20 */ "WASTER REFL POWER", /* 21 */ "TURNSTILE DL POWER", /* 22 */ "ANTENNA FWD POWER", /* 23 */ "ANTENNA REFL POWER", /* 24 */ "KLY1 RF DRIVE POWER", /* 25 */ "KLY2 RF DRIVE POWER", /* 26 */ "WASTER FLOW RATE", /* 27 */ "WASTER DELTA TEMP", /* 28 */ "KLY2 COLLECTOR FLOW", /* 29 */ "EXCITER INPUT PROOF", /* 30 */ "SPARE", /* 31 */ 0 }; char *calclist[]={ "CALORIMETRIC POWER", "KLYSTRON 1 VSWR", "KLYSTRON 2 VSWR", "WASTER VSWR", "ANTENNA VSWR", "TOTAL DRIVE POWER", "SPARE", "TOTAL BEAM CURRENT", "TOTAL KLY BEAM POWER", "AVG MAGNET VOLTAGE", "AVG MAGNET CURRENT", "AVG FILAMENT VOLTAGE", "AVG FILAMENT CURRENT", "AVG COLLECTOR CURRENT", "AVG VACION CURRENT", "SPARE", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined", 0 }; char *testlist[]= { "INITIAL", "KLY1 REFL A", "KLY1 REFL B", "WASTER REFL A", "TURNSTILE FWD A", "ANTENNA REFL A", "KLY2 REFL A", "KLY2 REFL B", "WASTER REFL B", "TURNSTILE FWD B", "ANT REFL B", "BODY CURRENT A", "MAGNET 1 OVER-CUR", "MAGNET 1 UNDER-CUR", "MAGNET 1 OVER-VOLT", "MAGNET 1 UNDER-VOLT", "COLLECTOR 1 OVER-CUR", "VACION 1 OVER-CUR", "BODY CURRENT B", "MAGNET 2 OVER-CUR", "MAGNET 2 UNDER-CUR", "MAGNET 2 OVER-VOLT", "MAGNET 2 UNDER-VOLT", "COLLECTOR 2 OVER-CUR", "VACION 2 OVER-CUR", "KLY1 ARC", "KLY2 ARC", "CROWBAR FIRE", "MOV", "CROWBAR EMERGENCY OFF", 0 }; unsigned char utemp[0x7FFF]; /* temporary file */ unsigned char keyboard[60],combuf1[60]; /* keyboard buffers */ unsigned char sysbuf[60],combuf3[60]; /* COM3 buffers */ unsigned char remotbuf[60],combuf2[60]; /* COM2 buffers */ unsigned char localbuf[60],parse[60]; /* parsing buffer */ unsigned char status[50],oldstat[50],statup[50]; /* status buffers */ unsigned char temp1[50],temp2[50]; unsigned char prohibs[200]; /* prohibited commands */ unsigned char histat[1000]; /* history status scroll */ unsigned char control[12]; /* control bytes */ int rgb[]= { 0,0,0, /* black */ 0,0,42, /* blue */ 0,42,0, /* green */ 0,42,42, /* cyan */ 42,0,0, /* red */ 42,0,42, /* magenta */ 42,21,0, /* brown */ 42,42,42, /* grey */ 21,21,21, /* dark grey */ 21,21,63, /* light blue */ 21,63,21, /* light green */ 21,63,63, /* light cyan */ 63,21,21, /* light red */ 63,21,63, /* light magenta */ 63,63,21, /* yellow */ 63,63,63 /* white */ }; int meter[64],avmet[64],logavg[64],longav[64],oldav[64],movav[16][64]; /* A/D buffers */ int dac[64],rmsmet[64],minmet[64],maxmet[64]; int prepow[10],prebeam[10],predriv[10],prebal[10], prepha[10],preoff[10],pregain[10]; /* preset power levels */ int hismet[640]; /* history meter scroll */ int scale[32]; /* A/D scaling multipliers */ int hvfac=155; /* beam v to dac conv fac */ int olhvset=0,oldrvset=0; /* hv and drive setting update registers */ int lolim[64],hilim[64]; /* warning boundaries */ int oldscrn=0,screen=1; /* video screen number */ int refresh=0; /* status change flag */ int inlist; /* command parsing flag */ int histflag; /* history storage flag */ int histno,logno; /* history, log sequence numbers */ int treebit[256]; /* programmable controller signal bits */ int counter[80]; /* misc timers & counters */ int remo=0,test=0; /* remote, test versions */ int pal[48]; /* palette intensities */ int nb=47; /* number of bytes in status log */ int histen=0; /* ram history enable */ int filset=0; /* fil timer complete variable */ int filrcount=0; /* fil raise timer */ int chkcount=0,veriflag=0; /* verify command timer and flag */ int statnum=0,anordig=0; /* used in verify routines */ int statnum2=0,statmask2=0; /* used in verify routines */ int statmask=0,statchk=0; /* used in verify routines */ int rflag=0,statchk2=0; /* used in verify routines */ int metnum=0,updn=0; /* used in verify routines */ long oldval=0; /* used in analog verify */ int old47=0; /* used in mainscr prepow refresh */ int comseq=0,trynum=0; /* used command sequences */ int dogs=0; /* special fault sums */ int ind_delay=0; /* inductrol delay counter */ int pset=0; /* power set routine flag */ unsigned int startime; /* start thousandths count */ long elaptime; /* elapsed time counter */ long keystart; /* keyboard activity start time */ long scrstart; /* screen-saver start time */ long calc[32],olcalc[32],longcalc[32],mincalc[32],maxcalc[32]; /* calculations */ long raw[32]; /* un-scaled meter values */ double sqsum[64],metersum[64]; /* used in metering routine */ char _far *keystat = (char far *)0x00400017; /* pointer to keyboard status byte */ FILE *stream; /* used to talk to hard drive */ GXDINFO di; GXCINFO ci; GXHEADER vhptr; union REGS inregs,outregs; void(interrupt *oldtick)(void); /* DOS 0x1C timer tick ISR */ void(interrupt *oldint09H)(void); /* DOS keyboard ISR */ /****************************************************************************/ void interrupt newtick(void) /* 18.2 per second */ { int i; for(i=0;i<=200;i++)/* intentional delay to give port time to open */ if(!(counter[77]=chkopntpt(1))) /* is TTI active? */ i=200; counter[16]&=0x01; /* clear unused bits */ counter[16]^=0x01; /* toggle alive & well bit */ tto(10,7,counter[16]); /* dome */ tto(13,13,counter[16]); /* hvps */ if((status[9]&0x10) /* dome filament timer relay */ &&(counter[40]>16380)) /* set to 15 minutes */ counter[40]=16380; if((status[20]&0x10) /* filament contactor */ &&(counter[40]!=0)) /* hold at 0 minutes */ if(--counter[40]==0) /* filament timer */ filset=1; /* Computer Timer Complete */ if(counter[52]) /* cool-down timer */ if(!(--counter[52])) /* hold at zero */ { tto(9,2,0); /* cooling off */ counter[79]=1; /* crowbar prompt enable */ } if(ind_delay) /* inductrol delay counter */ if(!(--ind_delay)) /* hold at zero */ counter[75]=1; /* set feed forward */ if(counter[73]) /* crowbar trigger recovery */ --counter[73]; /* hold at zero */ if((status[29]&0x80) /* RF fault sum */ ||counter[51]) /* continue timing */ ++counter[51]; /* 3 minute timer */ if(chkcount) /* verify timer */ if(!(--chkcount)) /* hold at zero */ veriflag=1; /* ready for verify */ if(filrcount) /* filramp timer */ if(!(--filrcount)) /* hold at zero */ tto(13,7,0); /* fil raise off */ clocker(); /* update clock-keyed params */ if(!counter[77]) counter[76]=opnacctpt(1); /* open TTI port */ } /****************************************************************************/ void far doserr(unsigned err, unsigned code, unsigned far *hdr) { status[46]|=0x20; /* DOS error */ if((code&0xFF)==10) status[46]|=0x80; /* printer out of paper */ temp2[46]=status[46]; /* used by backdata() */ _hardresume(_HARDERR_IGNORE); } /****************************************************************************/ void interrupt newint09H(void) /* Keyboard ISR */ { int i=inp(0x60); /* get key scan code */ if(((i&0x7F)==0x53)&&((*keystat&0x0C)==0x0C)) { /* CNTRL ALT DEL */ i=inp(0x61); /* save kb status */ outp(0x61,i|0x80); /* reset kb interpt */ outp(0x61,i&0x7F); outp(0x20,0x20); } else if(((i&0x7F)==0x2E)&&((*keystat&0x0C)==0x04)) { /* CNTRL C */ i=inp(0x61); /* save kb status */ outp(0x61,i|0x80); /* reset kb interpt */ outp(0x61,i&0x7F); outp(0x20,0x20); } else if(((i&0x7F)==0x46)&&((*keystat&0x0C)==0x04)) { /* CNTRL BREAK */ i=inp(0x61); /* save kb status */ outp(0x61,i|0x80); /* reset kb interpt */ outp(0x61,i&0x7F); outp(0x20,0x20); } else if(((i&0x7F)==0x1F)&&((*keystat&0x0C)==0x04)) { /* CNTRL S */ i=inp(0x61); /* save kb status */ outp(0x61,i|0x80); /* reset kb interpt */ outp(0x61,i&0x7F); outp(0x20,0x20); } else if((i&0x7F)==0x37) { /* PRTSC */ i=inp(0x61); /* save kb status */ outp(0x61,i|0x80); /* reset kb interpt */ outp(0x61,i&0x7F); outp(0x20,0x20); } else if((i&0x7F)==0x45) { /* PAUSE */ i=inp(0x61); /* save kb status */ outp(0x61,i|0x80); /* reset kb interpt */ outp(0x61,i&0x7F); outp(0x20,0x20); } else _chain_intr(oldint09H); } /*****************************************************************************/ void main(argc,argv) /* argv[0]="723" ,argv[1]="/R" for remote */ char *argv[]; int argc; { int fail,h,i,j,k,l,maxx,maxy,remot; struct dostime_t time; long free1,free2; if(argc>1) { if(!strcmp(argv[1],"/R")) remo=1; /* remote version */ if(!strcmp(argv[1],"/T")) test=1; /* test version */ } if(!remo) initout(); /* init output cards */ /*---------------------- GENUS set-up -------------------------------------*/ if(gxSetBuffer(kernbuf,16*1024)) printf("CAN'T ALLOCATE KERNAL BUFFER\n"); if(gxGetDisplayInfo(gxVGA_12,&di)) printf("CAN'T READ DISPLAY CARD\n"); maxx = di.hres-1; maxy = di.vres-1; if(gxSetDisplay(gxVGA_12)) printf("CAN'T SET DISPLAY CARD\n"); if(gxSetMode(gxGRAPHICS)) printf("CAN'T SET GRAPHICS MODE\n"); if(txSetViewPort(0,0,maxx,maxy)) printf("CAN'T SET TEXT VIEWPORT\n"); if(grSetViewPort(0,0,maxx,maxy)) printf("CAN'T SET GRAPHICS VIEWPORT\n"); if(grSetClipRegion(0,0,maxx,maxy)) printf("CAN'T SET CLIPPING REGION\n"); if(grSetClipping(grCLIP)) printf("CAN'T TURN ON CLIPPING\n"); if(grSetWorld(gxTRUE)) printf("CAN'T ENABLE WORLD COORDINATES\n"); if(grSetViewWorld(0,0,470,380)) printf("CAN'T SET WORLD COORDINATES\n"); Texas(grWHITE,grFSOLID,grBLUE); if(grSetViewWorld(0,0,maxx,maxy)) printf("CAN'T SET WORLD COORDINATES\n"); if(gxEMSInstalled()) { printf("EXTENDED MEMORY DRIVER NOT FOUND\n"); goto quit2; } else { free1=gxVirtualFree(gxEMM)/1024; printf("%d k available expanded memory\n",free1); } if(gxCreateVirtual(gxEMM,&vhptr,gxVGA_12,640,480)) printf("CAN'T CREATE VIRTUAL SCREEN\n"); else { free2=gxVirtualFree(gxEMM)/1024; printf("%d k used by virtual screen\n",free1-free2); } if(loadfont()) /* load fonts to RAM */ goto quit2; if(loadram()) /* load database from hard drive */ goto quit2; for(i=0;i<=47;i++) if(pal[i]<0||pal[i]>63) { printf("ILLEGAL COLOR PALETTE INTENSITY\n"); goto detour; } for(i=0;i<=15;i++) if(gxSetPaletteRGB(i,pal[3*i],pal[3*i+1],pal[3*i+2])) printf("CAN'T REDEFINE COLOR PALETTE\n"); detour: comopen(); /* open COM1, COM2, COM3 */ signal(SIGINT,SIG_IGN); signal(SIGBREAK,SIG_IGN); clrkey(); /* clear comm buffers */ status[46]=0; if(!test) if(fail=system_start(1,"tscs.cfg",STT_BroadcastMode)) { printf("TTI INIT FAILED\n"); status[46]|=0x08; } if(fail=!inmouse()) /* init mouse */ { printf("MOUSE DRIVER NOT INSTALLED\n"); status[46]|=0x10; } else { lefthit(); /* clear mouse button queue */ righthit(); /* clear mouse button queue */ onmouse(); /* turn on mouse cursor */ } /*---------------------- SLATE setup --------------------------------------*/ sl_dlsel(); sl_gsel(); sl_hlsel(); sl_fssel(); fail=sl_open(1); /* LPT-1 */ fail=sl_dlod(4); /* epson AP 3250 */ sl_tmset(sl_itosp(750)); /* top margin */ sl_bmset(sl_itosp(750)); /* bottom margin */ sl_lmset(sl_itosp(750)); /* left margin */ sl_rmset(sl_itosp(750)); /* right margin */ sl_mflod(sl_foget(),0,4,10,0,0,0); /* fonts */ sl_fput(2); if(sl_mflod(sl_foget(),0,0,12,0,0,8000)!=SL_OK) sl_mflod(sl_foget(),0,0,10,0,0,8000); sl_fput(1); sl_lhset(sl_ptosp(6)); /* environment */ sl_eput(1); if(fail=sl_mglod(120,180)) /* 120 by 120 dpi */ printf("could not setup 120 by 180 dpi printer resolution\n"); sl_vimst(1); /* print from screen */ if(fail=sl_vicre(1,640,480,0,0)) printf("could not create video image\n"); sl_ptst(ptbl1); /*---------------------------------------------------------------------------*/ /* initialize buffers, flags and counters */ counter[3]=0; /* moving average sums */ counter[10]=0; /* low rf counter */ counter[29]=0; /* status change flag */ counter[31]=0; /* A/D sum counter */ for(i=0;i<17;i++) counter[56+i]=0; /* tti poll counters */ for(i=0;i<50;i++) { if(i==46) status[i]&=0x18; /* tti init bit */ else status[i]=0; /* init status buffer */ } for(i=0;i<=31;i++) { calc[i]=0; metersum[i]=0; minmet[i]=10000; mincalc[i]=10000; maxmet[i]=0; maxcalc[i]=0; sqsum[i]=0; for(j=0;j<=15;j++) movav[j][i]=0; } strcpy(&idents[100],"GRANT"); tto(13,2,0); /* no mov test */ tto(13,6,1); /* no CB fire */ if(!remo) fail=setdacs(); /* set DAC outputs */ /*--------------------------------------------------------------------------*/ oldtick=_dos_getvect(0x1C); /* save DOS tick ISR vector */ _dos_setvect(0x1C,newtick); /* new tick ISR */ oldint09H=_dos_getvect(0x09); /* save dos kb ISR Vector */ _dos_setvect(0x09,newint09H); /* new kb ISR */ _harderr(doserr); /* critical error handler */ printf("program initialized\n"); free1=gxVirtualFree(gxEMM)/1024; printf("%d k available expanded memory\n",free1); initirig(); irig(); titlepag(); /* display copyright */ pause(1); status[35]|=0x10; /* boot flag*/ if(remo) if(fail=checkin()) { boxit("FAILED SECURITY CHECK"); pause(5); goto quit; } while(average()); /* get meter readings */ counter[78]=0; /*---------------------------------------------------------------------------*/ loop: counter[9]=timer(scrstart); /* screen-saver timer */ if((counter[9]>counter[8]*60)&&counter[8]) scrsaver(); /* blank screen if no activity */ _dos_gettime(&time); if(((time.minute&0x03)==0x02)&&(!time.second)) irig(); calendar(); /* real-time clock display */ stats(); /* get status inputs */ respond(); /* act on status changes */ average(); /* get meter readings */ filramp(); /* check for ramp-up */ if(counter[75]) /* check for feed forward flag */ setfeeds(); if(counter[76]) { erase(); prompt("76trombones"); puts(error_str(counter[76],0)); pause(3); counter[76]=0; } /* counter[78]++; ****loop timer**** prompt(itoa(counter[78],numb,10)); */ verifz(); /* check for command verify */ verifa(); /* check for analog verify */ seqdecode(); /* check for sequence */ if(counter[45]) /* status change */ storelog(); /* if(!keyboard[0]&&!histno&&!logno&&!(status[23]&0x01)) off(); */ /* 24 volt ps off */ update(); /* update status screen */ parsepb(); /* parse push-buttons */ console(); /* get keyboard input */ if(remo) console1(); /* get COM1 input */ console2(); /* get COM2 input */ if(!test) console3(); /* get COM3 input */ k=keyboard[0]; if(screen!=1&&screen!=5) { switch(click()) { case 1: /* left mouse button */ k=PDN; break; case 2: /* right mouse button */ k=PUP; break; case 3: /* both buttons */ k=HOME; break; } } if(k>128||k==REFRESH) /* function key? */ funky(k); if(keyboard[0] ||remotbuf[0] ||sysbuf[0]) /* keyboard buffers */ { for(i=0;keyboard[i]!=CR&&i<=59;i++); /* find end of string */ for(j=0;remotbuf[j]!=CR&&j<=59;j++); for(h=0;sysbuf[h]!=CR&&h<=59;h++); if(keyboard[i]==CR) /* keyboard input finished? */ { if(!(strncmp(keyboard,"HVOF",4))) /* if hvof command,no matter what */ strcpy(parse,keyboard); /* copy command to parse */ else if(status[26]&0x10) /* ops in odapc */ { strcpy(parse,keyboard); /* copy command to parse */ remot=0; l=i; if(strncmp(keyboard,"REP",3)) /* if not REP command, */ strcpy(combuf1,parse); /* remember command string */ } else { clkey(); /* clear command */ warn("OPS NOT IN LOCAL MODE"); erase(); } } if(sysbuf[h]==CR) /* system input finished? */ { counter[74]=1; /* set odapc command flag */ if(!(strncmp(sysbuf,"HVOF",4))) /* if hvof command,do it */ strcpy(parse,sysbuf); /* copy command to parse */ else if(!(strncmp(sysbuf,"DUMP",4))) /* if dump command, it's ok */ strcpy(parse,sysbuf); /* copy command to parse */ else if(!(strncmp(sysbuf,"STAT",4))) /* if stat command, that's fine */ strcpy(parse,sysbuf); /* copy command to parse */ else if(status[26]&0x08) /* ops in ODAPC */ { strcpy(parse,sysbuf); /* copy command to parse */ remot=0; l=h; if(strncmp(sysbuf,"REP",3)) /* if not REP command, */ strcpy(combuf3,parse); /* remember command string */ } else { clkey(); /* clear command */ command3("ER0"); warn("Not in ODAPC"); counter[74]=0; /* clear odapc command flag */ erase(); } } if(remotbuf[j]==CR) { if((status[37]&0x1F)==0) /* not logged in yet */ if(fail=security()) goto abort; remot=1; l=j; strcpy(parse,remotbuf); if(strncmp(remotbuf,"REP",3)) /* if not REP command, */ strcpy(combuf2,parse); /* remember command string */ } if(keyboard[i]==CR ||remotbuf[j]==CR ||sysbuf[h]==CR) /* something to parse? */ { if(parse[l-1]=='?') { helptext(); /* explain command */ goto abort; } inlist=0; if(strncmp(parse,"DOS",3)) /* remove spaces if not DOS command */ for(i=0;parse[i]!=CR&&parse[i]!=',';i++) if(parse[i]==SP) for(j=i;parse[j]!=CR;j++) parse[j]=parse[j+1]; /* ding(1);*/ /* verify CR */ /*---------------------------------------------------------------------------*/ if(parse[0]==CR) goto oops; /* no command */ for(i=0;k=parse[i];i++) /* calculator */ if((k=='/') ||(k=='*') ||(k=='-') ||(k=='+')) { keypad(parse); goto abort; } for(;;) /* parsing loop */ { if(match("ACTS")) /* logging activity */ { activity(0,0); break; } if(match("AMOF")) /* disconnect AM line */ { modulate(0); break; } if(match("AM")) /* connect AM line */ { modulate(1); break; } if(match("ANT")) /* rf switch to antenna */ { rfswitch(0); break; } if(match("AUTO")) /* auto-testing status */ { autotest(); break; } if(match("BAL")) /* balance RF drive */ { balance(); break; } if(match("BARS")) /* bar graphs */ { bars(); break; } if(match("BASE")) /* database signal names */ { basename(); break; } if(match("BEAM")) /* hvps adjust */ { beam(); break; } if(match("CMND")) /* user-defined commands */ { sparcmnd(); break; } if(match("CODE")) /* over-ride code */ { overcode(); break; } if(match("COFF")) /* cooling off */ { cooling(0); break; } if(match("COOL")) /* cooling on */ { cooling(1); break; } if(match("COMB")) /* wg switch to combiner */ { wgswitch(0); break; } if(match("COM")) /* send string to com port */ { comport(); clkey(); break; } if(match("DATA")) /* display database */ { database(); break; } if(match("DATE")) /* change date */ { setdate(); break; } if(match("DFLT")) /* install default values */ { defalt(); break; } if(match("DBDN")) /* lower drive balance */ { if(!argu(4,1,9)) drivebal(0); break; } if(match("DBUP")) /* raise drive balance */ { if(!argu(4,1,9)) drivebal(1); break; } if(match("DL")) /* wg switch to dummy load */ { wgswitch(1); break; } if(match("DRIV")) /* adjust RF drive level */ { drive(); break; } if(match("DROF")) /* driver off */ { driver(0); break; } if(match("DRON")) /* driver on */ { driver(1); break; } if(match("DRDN")) /* lower drive level */ { if(!argu(4,1,9)) driver(2); break; } if(match("DRUP")) /* raise drive level */ { if(!argu(4,1,9)) driver(3); break; } if(match("DUMP")) /* send database */ { dump(); break; } if(match("EXIT")) /* log out remote terminal */ { exiterm(); break; } if(match("FAIL")) /* real-time failure screen */ { failures(); break; } if(match("FALT")) /* fault real-time screen */ { faults(); break; } if(match("FLOF")) /* filaments off */ { filament(0); break; } if(match("FILS")) /* filaments on */ { filament(1); break; } if(match("FLDN")) /* lower filament voltage */ { if(!argu(4,1,9)) filament(2); break; } if(match("FLUP")) /* raise filament voltage */ { if(!argu(4,1,9)) filament(3); break; } if(match("FIND")) /* find string in help.723 */ { search(); break; } if(match("FLOW")) /* flow real-time diagram */ { flow(); break; } if(match("FUNC")) /* function keys */ { funkeys(); break; } if(match("GNDN")) /* lower gain */ { if(!argu(4,1,9)) gain(0); break; } if(match("GNUP")) /* raise gain */ { if(!argu(4,1,9)) gain(1); break; } if(match("HELP")) /* black heat off */ { genlhelp(); break; } if(match("HIST")) /* freeze-frames */ { history(); break; } if(match("HONK")) /* test sonalerts */ { sonalert(1); break; } if(match("HVOF")) /* high voltage off */ { highvolt(0); break; } if(match("HVDN")) /* high voltage lower */ { if(!argu(4,1,9)) highvolt(2); break; } if(match("HVUP")) /* high voltage raise */ { if(!argu(4,1,9)) highvolt(3); break; } if(match("HVON")) /* high voltage on */ { highvolt(1); break; } if(match("ID")) /* ID list */ { identity(); break; } if(match("INTL")) /* interlock real-time diagram */ { intrlock(); break; } if(match("LIMT")) /* metering boundaries */ { limits(); break; } if(match("LOGS")) /* read logs */ { logs(); break; } if(match("LONG")) /* long range mode */ { range(1); break; } if(match("MAIN")) /* main screen */ { mainpanl(); break; } if(match("MOF")) /* magnet voltage off */ { trynum=0; comseq=7; break; } if(match("MAGS")) /* magnet voltage on */ { trynum=0; comseq=6; break; } if(match("MDN")) /* magnet voltage lower */ { if(!argu(3,1,9)) { magnet1(2); magnet2(2); } break; } if(match("MUP")) /* magnet voltage raise */ { if(!argu(3,1,9)) { magnet1(3); magnet2(3); } break; } if(match("M1OF")) /* magnet 1 voltage off */ { magnet1(0); break; } if(match("MAG1")) /* magnet 1 voltage on */ { magnet1(1); break; } if(match("M1DN")) /* magnet 1 voltage lower */ { if(!argu(4,1,9)) magnet1(2); break; } if(match("M1UP")) /* magnet 1 voltage raise */ { if(!argu(4,1,9)) magnet1(3); break; } if(match("M2OF")) /* magnet 2 voltage off */ { magnet2(0); break; } if(match("MAG2")) /* magnet 2 voltage on */ { magnet2(1); break; } if(match("M2DN")) /* magnet 2 voltage lower */ { if(!argu(4,1,9)) magnet2(2); break; } if(match("M2UP")) /* magnet 2 voltage raise */ { if(!argu(4,1,9)) magnet2(3); break; } if(match("MAPS")) /* display valid position slots */ { maps(); break; } if(match("MATH")) /* processed metering */ { mathemat(); break; } if(match("MET")) /* print meter readings */ { Prompt("PRINTING METER READINGS"); metprint(); break; } if(match("MISC")) /* misc user-defined flags &c */ { miscel(); break; } if(match("MUTE")) /* sonalert disable */ { sonalert(0); break; } if(match("OFDN")) /* lower offset */ { if(!argu(4,1,9)) offset(0); break; } if(match("OFUP")) /* raise offset */ { if(!argu(4,1,9)) offset(1); break; } if(match("PACT")) /* print logging activity */ { activity(1,1); break; } if(match("PAL")) /* color palette */ { colors(); break; } if(match("PASS")) /* create password */ { pass(); break; } if(match("PBDN")) /* lower phase balance */ { if(!argu(4,1,9)) phasebal(0); break; } if(match("PBUP")) /* raise phase balance */ { if(!argu(4,1,9)) phasebal(1); break; } if(match("PMOF")) /* disconnect PM line */ { modulate(2); break; } if(match("PM")) /* connect PM line */ { modulate(3); break; } if(match("POWR")) /* power output adjust */ { power(); break; } if(match("QUIT")) /* quit */ goto quit; if(match("RCV")) /* receive mode */ { receive(); break; } if(match("REP")) /* repeat last command */ { if(keyboard[0]) strcpy(keyboard,combuf1); if(remotbuf[0]) strcpy(remotbuf,combuf2); if(sysbuf[0]) strcpy(sysbuf,combuf3); break; } if(match("RSET")) /* reset */ { reset(); break; } if(match("RTST")) /* reset tests */ { resetest(); break; } if(match("SCAL")) /* meter scale factors */ { scales(); break; } if(match("SCOP")) /* oscilloscope */ { scope(); break; } if(match("SECU")) /* security check */ { secure(); break; } if(match("SHRT")) /* short range mode */ { range(0); break; } if(match("SIMU")) /* simulation */ { simulate(); metsim(); break; } if(match("SPAR")) /* spare digital inputs */ { spardgtl(); break; } if(match("STAT")) /* dump one status byte */ { statout(); break; } if(match("STBY")) /* standby */ { standby(); break; } if(match("STLG")) /* store a log */ { status[35]|=0x40; /* manual flag */ clkey(); break; } if(match("STOR")) /* store a power level */ { storepow(); clkey(); break; } if(match("TABL")) /* pre-set power levels */ { table(); break; } if(match("TEST")) /* perform auto tests */ { testing(); clkey(); break; } if(match("TIME")) /* change time */ { settime(); break; } if(match("TITL")) /* title page */ { titlepag(); while(!kbhit()); break; } if(match("TRND")) /* trend analysis */ { trend(); break; } if(match("USER")) /* user-defined screen */ { user(); break; } if(match("WAST")) /* rf switch to waster load */ { rfswitch(1); break; } if(match("XMT")) /* transmit mode */ { transmit(); break; } usercmnd(); /* parse user-defined */ clkey(); break; } /* end of "for" loop */ oops: if(!inlist) if(counter[74]) /* command from remote? */ { status[36]|=0x02; /* command fail */ command3("ER1"); counter[74]=0; /* clear odapc command flag */ } else help(); /* unrecognized command */ if((inlist)&&(counter[74])) { command3("OK"); counter[74]=0; /* clear odapc command flag */ } abort: counter[7]=0; /* reset parse timer */ } for(i=0;i<=59;i++) if(keyboard[i]==ESC||remotbuf[i]==ESC||sysbuf[i]==ESC) { clkey(); comseq=0; veriflag=0; statnum2=0; if(logno||histno ||(status[35]&0x80)) /* return to real-time */ { histno=0; logno=0; restdata(); /* restore database */ refresh=1; } } } /* end of keyboard parse */ goto loop; /* continue main program loop */ quit: tto(13,7,0); /* stop filraise */ comclose(); /* close COM1, COM2, COM3 */ sl_viclr(); /* release video image memory */ sl_close(); /* close printer driver */ _dos_setvect(0x1C,oldtick); /* restore DOS ISR */ _dos_setvect(0x09,oldint09H); /* restore KB ISR */ storhist(); /* save historical data */ savemisc(); /* save counters and flags */ quit2: freeram(); /* clear expanded memory */ if(gxDestroyVirtual(&vhptr)) printf("CAN'T DESTROY VIRTUAL SCREEN\n"); if(gxSetMode(gxTEXT)) printf("CAN'T SET TEXT MODE\n"); } /**************************************************************************/ ding(n) /* ring bell */ { int i; for(i=0;it2) --i; else ++i; } abort: ; } /**************************************************************************/ usercmnd(void) /* find user-defined command name */ { char string[30]; unsigned char byte,mask1,mask2; int i,j,m=1,index,port; for(i=0;i<=15;i++) { if(i==0||i==8) { mask1=1; mask2=0xFE; } else { mask1=mask1<<1; mask2=mask2<<1; } strncpy(string,&cname[0]+10*i,20); for(j=0;string[j]&&j<10;j++) if(parse[j]!=string[j]) m=0; if(m) /* a match */ { if(inlog()||inhist()||insimu()) goto abort; if(i<=7) { byte=control[2]; index=2; port=0x512; } else { byte=control[3]; index=3; port=0x513; } if(cname3[i]) /* momentary */ { byte=byte^mask1; outp(port,byte); byte=byte^mask1; tenths(1); outp(port,byte); } else /* toggling */ { byte=byte^mask1; outp(port,byte); control[index]=byte; } inlist=1; brief("USER-DEFINED COMMAND SENT"); break; } } abort: ; } /**************************************************************************/ match(cmd) /* find command name */ char *cmd; { int i,m=1; for(i=0;cmd[i];i++) if(parse[i]!=cmd[i]) { m=0; break; } inlist=inlist|m; return(m); } /*****************************************************************************/ update(void) /* update current screen on display */ { int fail=0; if(keyboard[0]) /* wait for keyboard entry to finish */ goto abort; { switch(screen) { case 1: mainpanl(); /* main screen */ break; case 2: faults(); /* detailed fault screen */ break; case 3: intrlock(); /* interlock diagram */ break; case 4: flow(); /* flow diagram */ break; case 5: autotest(); /* test diagram */ break; case 6: failures(); /* misc failures */ break; case 7: bars(); /* klystron 1 metering */ break; case 8: bars(); /* klystron 2 metering */ break; case 9: bars(); /* directional coupler metering*/ break; case 10: bars(); /* total power */ break; case 11: bars(); /* misc metering */ break; case 12: bars(); /* DAC outputs */ break; case 13: user(); /* user defined inputs */ break; case 14: database(); /* real-time hex database */ break; case 15: basename(); /* 1 to 160 real-time database names */ break; case 16: basename(); /* 161 to 320 real-time database names */ break; case 17: basename(); /* 321 to 480 real-time database names */ break; default: warn("UNKNOWN SCREEN NUMBER"); fail=1; screen=1; break; } counter[29]=0; /* clear status change flag */ } refresh=0; abort: return(fail); } /**************************************************************************/ front(void) /* update main screen */ { if(screen!=1) { screen=1; refresh=1; } } /**************************************************************************/ inlog(void) /* in log review? */ { if(logno) { warn("CAN'T EXECUTE WHEN REVIEWING LOGS"); } return(logno); } /**************************************************************************/ inhist(void) /* in history review? */ { if(histno) { warn("CAN'T EXECUTE WHEN REVIEWING HISTORY"); } return(histno); } /**************************************************************************/ insimu(void) /* in simulation mode? */ { int simu; simu=status[35]&0x80; if(simu) { warn("CAN'T EXECUTE IN SIMULATION MODE"); } return(simu); } /**************************************************************************/ inremo(void) /* in remote program mode? */ { if(remo) warn("NOT AVAILABLE FROM REMOTE CONTROL POINT"); return(remo); } /****************************************************************************/ genlhelp(void) /* program operating instructions */ { keyboard[4]='?'; helptext(); } /****************************************************************************/ void odapc(void) /* check for ODAPC command when busy */ { int h; console3(); /* get COM3 input */ if(sysbuf[0]) /* ODAPC buffer */ { for(h=0;sysbuf[h]!=CR&&h<=59;h++); /* find end of string */ if(sysbuf[h]==CR) /* system input finished? */ { counter[74]=1; /* set odapc command flag */ if(!(strncmp(sysbuf,"DUMP",4))) /* if dump command, it's ok */ { strcpy(parse,sysbuf); /* copy command to parse */ dump(); clkey(); /* clear command */ command3("OK"); /* command complete */ counter[74]=0; /* clear odapc command flag */ erase(); } else if(!(strncmp(sysbuf,"STAT",4))) /* if stat command, that's fine */ { strcpy(parse,sysbuf); /* copy command to parse */ statout(); clkey(); /* clear command */ command3("OK"); /* command complete */ counter[74]=0; /* clear odapc command flag */ erase(); } else { clkey(); /* clear command */ command3("ER4"); /* busy code */ counter[74]=0; /* clear odapc command flag */ erase(); } } } } /*****************************************************************************/ off(void) /* report emergency off */ { int i; screen=0; clear(); font(0); for(i=0;i<=7;i++) text(RED,50*i,450-50*i,"24 VOLT PS OFF"); circle(RED,100,100,50); pause(1); front(); }