#include /* module metsim9 */ #include #include #include #include #include #include #include #include #include #include #include #include #include union REGS inregs,outregs; /*--------------------------------------------------------------------------- meter signal names kly1 MAGNET VOLTAGE 0 TTI module A7 kly2 MAGNET VOLTAGE 1 BEAM VOLTAGE 2 kly1 MAGNET CURRENT 3 kly2 MAGNET CURRENT 4 BODY CURRENT 5 kly1 FILAMENT VOLTAGE 6 kly2 FILAMENT VOLTAGE 7 kly1 FILAMENT CURRENT 8 kly2 FILAMENT CURRENT 9 kly1 COLLECTOR CURRENT 10 kly2 COLLECTOR CURRENT 11 kly1 VACION CURRENT 12 kly2 VACION CURRENT 13 SPARE 14 SPARE 15 WASTER FWD POWER 16 TTI module A8 kly1 FWD POWER 17 kly1 RFL POWER 18 kly2 FWD POWER 19 kly2 RFL POWER 20 WASTER RFL POWER 21 TURNSTILE DL POWER 22 ANTENNA FWD POWER 23 ANTENNA RFL POWER 24 kly1 RF DRIVE POWER 25 kly2 RF DRIVE POWER 26 WASTER FLOW RATE 27 DELTA TEMP 28 SPARE 29 EXCITER INPUT PROOF 30 SPARE 31 --------------------------------------------------------------------------- calculation names CALORIMETRIC POWER 0 KLYSTRON 1 VSWR 1 KLYSTRON 2 VSWR 2 COMBINER VSWR 3 ANTENNA VSWR 4 TOTAL DRIVE POWER 5 SPARE 6 TOTAL BEAM CURRENT 7 TOTAL POWER DISSIPATION 8 AVG MAGNET VOLTAGE 9 AVG MAGNET CURRENT 10 AVG FILAMENT VOLTAGE 11 AVG FILAMENT CURRENT 12 AVG COLLECTOR CURRENT 13 AVG VACION CURRENT 14 */ /*****************************************************************************/ metsim(void) /* metering simulation */ { char string[30],metval[8]; int i,k,m=0,mold=0,n=0,nold=0,x,y; long value; if(inlog()||inhist()) { clkey(); goto abort; } clear(); font(1); text(PALEBLUE,100,479,"METER SIMULATION"); font(2); text(WHITE,50,440,"TITLE"); tex(190,440,"VALUE"); tex(380,440,"TITLE"); tex(490,440,"VALUE"); font(3); rect(BLACK,0,0,639,420); line2(PALEBLUE,310,440,310,100); rect(DARKGREY,0,105,185,425); rect(DARKGREY,320,105,485,425); texcolor(WHITE); for(i=0;i<=15;i++) { y=420-20*i; tex(5,y,itoa(i+1,numb,10)); /* sequence */ tex(325,y,itoa(i+17,numb,10)); tex(30,y,metlist[i]); /* meter title */ tex(350,y,metlist[i+16]); } texcolor(PALEBLUE); for(i=0;i<=15;i++) /* display values */ { y=420-20*i; itoa(avmet[i],metval,10); tex(200,y,metval); itoa(avmet[i+16],metval,10); tex(500,y,metval); } loop: clkey(); message(WHITE,"USE CURSOR KEYS OR MOUSE TO SELECT METER, Pageup, Pagedown, Esc TO EXIT"); while(!kbhit()) { odapc(); switch(click()) /* mouse button */ { case 1: /* left click */ x=outregs.x.cx; y=479-outregs.x.dx; m=x/320; n=(420-y)/20; goto exec; case 2: /* double click */ k=ESC; goto cursor; case 3: /* both click */ k=ESC; goto cursor; } } k=caps(); cursor: if(k>128) switch(k) { case LEFT: --m; if(m==-1) m=1; /* wrap */ break; case RIGHT: ++m; if(m==2) m=0; /* wrap */ break; case UP: --n; if(n==-1) n=15; break; case DOWN: ++n; if(n==16) n=0; if(m>0&&n==32) n=0; break; case HOME: n=0; break; case END: n=15; if(m>0) n=31; break; default: goto abort; } else goto exit; exec: if(m<1&&n>=16) /* correct for column */ n=n-16; if(m>0&&n<=15) n=n+16; itoa(avmet[nold],metval,10); /* convert to ascii */ y=420-20*nold; if(nold>=16) y=420-20*(nold-16); switch(mold) { case 0: x=200; rect(BLACK,x,y,x+40,y-10); text(PALEBLUE,x,y,metval); break; case 1: x=500; rect(BLACK,x,y,x+40,y-10); text(PALEBLUE,x,y,metval); break; } nold=n; mold=m; itoa(avmet[n],metval,10); /* convert to ascii */ y=420-20*n; if(n>=16) y=420-20*(n-16); switch(mold) { case 0: x=200; rect(BLUE,x,y,x+40,y-10); text(WHITE,x,y,metval); break; case 1: x=500; rect(BLUE,x,y,x+40,y-10); text(WHITE,x,y,metval); break; } again: clkey(); message(LIGHTGREEN,"ENTER NEW VALUE, or ESC TO EXIT"); while(!kbhit()) { odapc(); if(click()==3) { k=ESC; goto exit; } } k=caps(); if(k>128) goto cursor; if(k==ESC) goto exit; keyboard[0]=k; string[0]=k; string[1]=0; prompt(string); while(console()!=CR) odapc(); if(notnum(keyboard)) goto again; value=atol(keyboard); /* convert */ switch(m) { case 0: { rect(BLACK,200,y,240,y-10); avmet[n]=value; text(GREEN,200,y,keyboard); break; } case 1: { rect(BLACK,500,y,540,y-10); avmet[n]=value; text(GREEN,500,y,keyboard); break; } } goto loop; exit: font(2); boxit("NEXT Esc RETURNS TO REAL-TIME"); pause(2); calcs(); abort: refresh=1; }