#include /* module limits9 */ #include #include #include #include #include #include #include #include #include #include #include #include #include union REGS inregs,outregs; /*--------------------------------------------------------------------------- meter signal names V1 MAGNET VOLTAGE 0 TTI module A7 V2 MAGNET VOLTAGE 1 BEAM VOLTAGE 2 V1 MAGNET CURRENT 3 V2 MAGNET CURRENT 4 BODY CURRENT 5 V1 FILAMENT VOLTAGE 6 V2 FILAMENT VOLTAGE 7 V1 FILAMENT CURRENT 8 V2 FILAMENT CURRENT 9 V1 COLLECTOR CURRENT 10 V2 COLLECTOR CURRENT 11 V1 VACION CURRENT 12 V2 VACION CURRENT 13 SPARE 14 SPARE 15 WASTER FWD POWER 16 TTI module A8 V1 FWD POWER 17 V1 RFL POWER 18 V2 FWD POWER 19 V2 RFL POWER 20 WASTER RFL POWER 21 TURNSTILE DL POWER 22 ANTENNA FWD POWER 23 ANTENNA RFL POWER 24 V1 RF DRIVE POWER 25 V2 RF DRIVE POWER 26 FLOW RATE 27 DELTA TEMP 28 SPARE 29 SPARE 30 SPARE 31 --------------------------------------------------------------------------- calculation names CALORIMETRIC POWER 0 KLYSTRON 1 VSWR 1 KLYSTRON 2 VSWR 2 WASTER 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 */ /*****************************************************************************/ limits(void) /* metering boundaries */ { char string[30],lower[8],upper[8]; int limt,index,fail=0,i,j=0,k,m=0,mold=0,n=0,nold=0,x,y; long value; if(inlog()||inhist()||insimu()) { clkey(); goto abort; } if(parse[4]!=CR) { limt=atoi(&parse[4]); /* limit number */ if(limt<1||limt>64) goto failed; index=limt-1; n=comma(2)-comma(1)-1; /* argument length */ if(n>0) { strncpy(string,&parse[comma(1)+1],n); /* lower limit */ string[n]=0; i=atoi(string); if(i<0||i>9999) goto failed; lolim[index]=i; } n=comma(3)-comma(2)-1; /* argument length */ if(n>0) { strncpy(string,&parse[comma(2)+1],n); /* upper limit */ string[n]=0; i=atoi(string); if(i<0||i>9999) goto failed; hilim[index]=i; } clkey(); goto abort; } clear(); font(1); text(PALEBLUE,0,479,"ANALOG PARAMETER WARNING BOUNDS"); txnumber(); text(WHITE,50,440,"TITLE"); tex(190,440,"LOWER"); tex(250,440,"UPPER"); tex(380,440,"TITLE"); tex(490,440,"LOWER"); tex(550,440,"UPPER"); loop2: 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+j*32,numb,10)); /* sequence */ tex(325,y,itoa(i+17+j*32,numb,10)); if(!j) { tex(30,y,metlist[i]); /* tx parameter title */ tex(350,y,metlist[i+16]); /* user-defined title */ } else { tex(30,y,calclist[i]); tex(350,y,calclist[i+16]); } } texcolor(PALEBLUE); for(i=0;i<=15;i++) /* display limits */ { y=420-20*i; itoa(lolim[i+j*32],lower,10); itoa(hilim[i+j*32],upper,10); tex(200,y,lower); tex(260,y,upper); itoa(lolim[i+16+j*32],lower,10); itoa(hilim[i+16+j*32],upper,10); tex(500,y,lower); tex(560,y,upper); } loop: clkey(); message(WHITE,"USE CURSOR KEYS OR CLICK LEFT TO SELECT LIMIT, Pageup, Pagedown, Esc TO EXIT"); onmouse(); while(!kbhit()) { odapc(); switch(click()) /* mouse button */ { case 1: /* left click */ x=outregs.x.cx; y=479-outregs.x.dx; m=0; if(x>260) m=1; if(x>500) m=2; if(x>560) m=3; n=(420-y)/20; if(n>15||n<0) n=0; goto exec; case 3: /* both click */ k=ESC; goto abort; } } k=caps(); if(k>128) cursor: switch(k) { case LEFT: --m; if(m==-1) m=3; /* wrap */ break; case RIGHT: ++m; if(m==4) m=0; /* wrap */ break; case UP: --n; if(n==-1) n=15; break; case DOWN: ++n; if(n==16) n=0; if(m>1&&n==32) n=0; break; case HOME: n=0; break; case END: n=15; if(m>1) n=31; break; case PDN: ++j; if(j>1) j=0; goto loop2; case PUP: --j; if(j<0) j=1; goto loop2; default: goto key; } else { key: keyboard[0]=k; if(k<128) prompt(keyboard); goto abort; } exec: offmouse(); if(m<2&&n>=16) /* correct for column */ n=n-16; if(m>1&&n<=15) n=n+16; itoa(lolim[nold+j*32],lower,10); /* convert to ascii */ itoa(hilim[nold+j*32],upper,10); 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,lower); break; case 1: x=260; rect(BLACK,x,y,x+40,y-10); text(PALEBLUE,x,y,upper); break; case 2: x=500; rect(BLACK,x,y,x+40,y-10); text(PALEBLUE,x,y,lower); break; case 3: x=560; rect(BLACK,x,y,x+40,y-10); text(PALEBLUE,x,y,upper); break; } nold=n; mold=m; itoa(lolim[n+j*32],lower,10); /* convert to ascii */ itoa(hilim[n+j*32],upper,10); 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,lower); break; case 1: x=260; rect(BLUE,x,y,x+40,y-10); text(WHITE,x,y,upper); break; case 2: x=500; rect(BLUE,x,y,x+40,y-10); text(WHITE,x,y,lower); break; case 3: x=560; rect(BLUE,x,y,x+40,y-10); text(WHITE,x,y,upper); break; } again: clkey(); message(LIGHTGREEN,"ENTER NEW LIMIT, or ESC TO EXIT"); onmouse(); while(!kbhit()) { odapc(); switch(click()) /* mouse button */ { case 1: /* left click */ x=outregs.x.cx; y=479-outregs.x.dx; m=0; if(x>260) m=1; if(x>500) m=2; if(x>560) m=3; n=(420-y)/20; if(n>15||n<0) n=0; goto exec; case 3: /* both click */ k=ESC; goto abort; } } k=caps(); if(k>128) goto cursor; if(k==ESC) goto abort; if(k==CR) goto abort; keyboard[0]=k; string[0]=k; string[1]=0; prompt(string); while(console()!=CR); if(notnum(keyboard)) goto again; value=atol(keyboard); /* convert */ switch(m) { case 0: { rect(BLACK,200,y,240,y-10); lolim[n+j*32]=value; text(GREEN,200,y,keyboard); break; } case 1: { rect(BLACK,260,y,300,y-10); hilim[n+j*32]=value; text(GREEN,260,y,keyboard); break; } case 2: { rect(BLACK,500,y,540,y-10); lolim[n+j*32]=value; text(GREEN,500,y,keyboard); break; } case 3: { rect(BLACK,560,y,600,y-10); hilim[n+j*32]=value; text(GREEN,560,y,keyboard); break; } } goto loop; failed: clkey(); illarg(); fail=1; status[12]|=0x01; /* command failed */ abort: savelim(); /* update hard drive */ refresh=1; return(fail); }