#include /* module trend9 */ #include #include #include #include #include #include #include #include #include #include #include #include #include /*--------------------------------------------------------------------------- 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 KLY 2 COLLECTOR FLOW 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 each log is structured as 8 bytes of ascii time of day, followed by 8 bytes of ascii date, followed by nb binary status bytes, followed by 64 metering bytes (32 integers), for a total of nb+80 bytes. */ /*****************************************************************************/ trend(void) /* trend analysis */ { char string[30]; char *list1[]= { "NONE", "CLOCK", 0 }; unsigned char byte0,byte1; int meterval,block,i,fail,index,k,len,m=0,n=0,nold=0,x,y; int color,metno=1,mult=1; if(parse[4]!=CR) { if(arg(1,32)) goto abort; metno=atoi(&parse[4]); } clkey(); clear(); font(1); text(PALEBLUE,160,479,"TREND ANALYSIS"); txnumber(); text(PALEBLUE,0,460,"Key:"); tex(0,440,"Log Nos:"); backdata(); /* backup real-time status */ loop1: text(WHITE,80,420,"STORAGE KEY"); texcolor(PALEBLUE); len=list(100,400,20,list1); message(WHITE,"USE CURSOR KEYS TO SELECT, Esc TO EXIT"); k=caps(); if(k>128) cursor: switch(k) { case LEFT: --m; if(m==-1) m=0; /* wrap */ break; case RIGHT: ++m; if(m==1) m=0; /* wrap */ break; case UP: --n; if(n==-1) n=len-1; /* wrap */ break; case DOWN: ++n; if(n==len) n=0; /* wrap */ break; case HOME: n=0; break; case END: n=len-1; break; default: goto quit; } else { quit: keyboard[0]=k; if(k<128) prompt(keyboard); goto abort; } x=100; y=400-20*nold; rect(BLACK,x,y,x+220,y-10); text(PALEBLUE,x,y,list1[nold]); y=400-20*n; rect(BLUE,x,y,x+220,y-10); text(WHITE,x,y,list1[n]); nold=n; clkey(); message(LIGHTGREEN,"HIT Enter TO SELECT"); k=caps(); if(k>128) goto cursor; if(k==ESC) goto abort; if(k!=CR) goto quit; rect(BLACK,50,460,200,450); text(PALEBLUE,50,460,list1[n]); /* key name */ nextmet: rect(BLACK,0,0,639,420); /* clear screen */ logno=1; strcpy(string,itoa(metno,numb,10)); /* meter no */ strcat(string," "); strcat(string,metlist[metno-1]); /* meter name */ rect(BLACK,180,450,400,430); font(2); text(PALEBLUE,180,450,string); font(3); setcolor(WHITE); texcolor(WHITE); if((metno==1)||(metno==2)) { vaxis(0,50,40,10,0,20,0); mult=5; } else if(metno==3) { vaxis(0,50,40,10,0,100,1); mult=1; } else if((metno==4)||(metno==5)) { vaxis(0,50,40,10,0,20,1); mult=5; } else if(metno==6) { vaxis(0,50,40,10,0,100,1); mult=10; } else if((metno==7)||(metno==8)) { vaxis(0,50,40,10,0,20,1); mult=5; } else if((metno==9)||(metno==10)) { vaxis(0,50,40,10,0,25,1); mult=4; } else if((metno==11)||(metno==12)) { vaxis(0,50,40,10,0,20,1); mult=5; } else if((metno==13)||(metno==14)) { vaxisl(0,50,80,5,2); mult=2; } else if((metno==28)||(metno==30)) { vaxis(0,50,120,4,0,100,0); mult=3; } else { vaxis(0,50,40,10,0,100,0); mult=1; } loop4: for(i=0;i<=9;i++) /* horizontal lines */ line(40,40+40*i,560,40+40*i); block=counter[0]-logno+1; if(block>120) block=120; if(fail=getblock(logno,block)) goto bye; rect(BLACK,50,440,120,430); itoa(logno,numb,10); strcpy(string,numb); strcat(string," to "); itoa(logno+block-1,numb,10); strcat(string,numb); text(PALEBLUE,50,440,string); for(i=0;i(mult*hilim[metno-1])) color=YELLOW; if(y<479&&y>39) rect(color,x,y,x+2,y+2); /* dot */ cont: ; } logno=logno+120; if(logno32) metno=1; /* wrap */ goto nextmet; /* next meter curve */ } if(k==UP) { rect(BLACK,0,0,639,420); /* clear screen */ goto loop1; /* change key */ } abort: keyboard[0]=k; prompt(keyboard); bye: restdata(); /* restore database */ logno=0; refresh=1; return(fail); }