#include /* module defalt9 */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include union REGS inregs,outregs; /*****************************************************************************/ defalt(void) /* install default values */ { char *list1[]= { "FUNCTION KEYS", "MISCELLANEOUS", "METER SCALES", "SIMULATED METERING", "PASSWORD & IDs", "USER-DEFINED STATUS", "USER-DEFINED COMMANDS", "METER WARNING BOUNDARIES", "COLOR PALETTE", 0 }; int i,k,len,m=-1,n=0,nold=0,x,y; if(inlog()||inhist()||insimu()) { clkey(); goto abort; } if(parse[4]!=CR) { if(arg(1,8)) goto abort; n=atoi(&parse[4])-1; doit(n); clkey(); goto abort; } clkey(); clear(); /* clear entire screen */ font(1); text(PALEBLUE,0,479,"DEFAULT VALUE INSTALLATION"); txnumber(); text(WHITE,100,440,"PARAMETER"); texcolor(PALEBLUE); len=list(100,420,20,list1); rect(DARKGREY,0,425,25,25); texcolor(WHITE); for(i=0;i=len)||(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=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; } exec: x=100; y=420-20*nold; offmouse(); rect(BLACK,x,y,x+220,y-15); text(PALEBLUE,x,y,list1[nold]); texcolor(LIGHTGREEN); y=420-20*n; rect(BLUE,x,y,x+220,y-15); text(WHITE,x,y,list1[n]); nold=n; clkey(); message(LIGHTGREEN,"HIT Enter OR CLICK RIGHT TO EXECUTE (EXISTING VALUES WILL BE DESTROYED!)"); onmouse(); while(!kbhit()) { odapc(); switch(click()) /* mouse button */ { case 1: /* left click */ x=outregs.x.cx; y=479-outregs.x.dx; m=(x-1)/80; if(m) m=0; n=(420-y)/20; if((n>=len)||(n<0)) n=0; goto exec; case 2: /* right click */ k=CR; goto exec2; case 3: /* both click */ k=ESC; goto exec2; } } k=caps(); if(k>128) goto cursor; exec2: if(k==ESC) goto abort; offmouse(); if(k!=CR) goto quit; rect(BLACK,350,y,500,y-20); if(doit(n)) text(YELLOW,350,y,"NOT INSTALLED"); else text(YELLOW,350,y,"INSTALLED"); goto loop; abort: refresh=1; } /****************************************************************************/ doit(n) /* install new default values */ { int k,fail=0,i,j; char enter[]={CR,0},string[30]; char *funcs[]= { /* 12 function keys definitions */ "COFF", "COOL", "FLOF", "FILS", "MOF", "MAGS", "DROF", "DRON", "HVOF", "HV", "RCV", "XMT", 0 }; int simet[]= { 200, /* kly1 MAGNET VOLTAGE */ 200, /* kly2 MAGNET VOLTAGE */ 500, /* BEAM VOLTAGE */ 100, /* kly1 MAGNET CURRENT */ 100, /* kly2 MAGNET CURRENT */ 100, /* BODY CURRENT */ 100, /* kly1 FILAMENT VOLTAGE */ 100, /* kly2 FILAMENT VOLTAGE */ 100, /* kly1 FILAMENT CURRENT */ 100, /* kly2 FILAMENT CURRENT */ 100, /* kly1 COLLECTOR CURRENT */ 100, /* kly2 COLLECTOR CURRENT */ 100, /* kly1 VACION CURRENT */ 100, /* kly2 VACION CURRENT */ 100, /* SPARE */ 100, /* SPARE */ 10, /* WASTER FWD POWER */ 400, /* kly1 FWD POWER */ 100, /* kly1 RFL POWER */ 400, /* kly2 FWD POWER */ 100, /* kly2 RFL POWER */ 0, /* WASTER RFL POWER */ 100, /* TURNSTILE DL POWER */ 800, /* ANTENNA FWD POWER */ 100, /* ANTENNA RFL POWER */ 400, /* kly1 RF DRIVE POWER */ 400, /* kly2 RF DRIVE POWER */ 50, /* WASTER FLOW RATE */ 60, /* DELTA TEMP */ 100, /* SPARE */ 450, /* EXCITER INPUT PROOF */ 100 /* SPARE */ }; strncpy(string,dayt,5); string[2]=string[3]; string[3]=string[4]; string[4]=0; getimage(100,200,540,100); boxit("ARE YOU SURE (Y/N)?"); k=caps(); putimage(100,200,540,100); if(k!='Y') { fail=1; goto abort; } switch(n) { case 0: /* function keys */ for(i=0;i<=959;i++) func[i]=0; /* erase old */ for(i=0;i<=11;i++) /* 12 function keys */ { strcpy(string,funcs[i]); strcat(string,enter); strcpy(&func[0]+20*i+240,string); /* shifted */ strcpy(&func[0]+20*i+480,string); /* control */ strcpy(&func[0]+20*i+720,string); /* alt */ } fail=savefunc(); break; case 1: /* miscellaneous */ counter[1]=3; /* security timeout */ counter[2]=0; /* security timer */ counter[3]=0; /* moving average sums */ counter[4]=30; /* auto log storage rate */ counter[5]=15; /* auto log time offset */ counter[6]=60; /* keyboard timeout */ counter[7]=0; /* keyboard timer */ counter[8]=300; /* screen saver timeout */ counter[9]=0; /* screen saver timer */ counter[10]=0; /* auto log time */ counter[11]=0; /* log printer enable */ counter[12]=1; /* sound enable */ counter[13]=20; /* rs232 timeout */ counter[14]=9600; /* COM3 baud rate */ counter[15]=1; /* online ID number */ counter[16]=0; /* alive-and-well toggle */ counter[17]=1; /* rs232 handshake enable */ counter[18]=0; /* auto data dump */ counter[19]=36; /* meter samples */ counter[20]=0; /* tx ID number */ counter[21]=9600; /* COM1 baud rate */ counter[22]=9600; /* COM2 baud rate */ counter[23]=1000; /* log limit */ counter[24]=1822; /* feed forward cal */ counter[25]=18; /* history interval ticks */ counter[26]=0; /* history tick count */ counter[27]=0; /* POWR argument, kw */ counter[28]=0; /* BEAM argument, hvps kv */ counter[29]=0; /* status change flag */ counter[30]=2; /* RS232 transmit delay */ counter[31]=0; /* meter sum counter */ counter[32]=0; /* auto screen enable */ counter[33]=10; /* xoff time-out delay */ counter[34]=0; /* xoff timer */ counter[35]=0; /* drive dac */ counter[36]=0; /* drive balance dac */ counter[37]=0; /* drive phase dac */ counter[38]=0; /* feed forward offset dac */ counter[39]=0; /* feed forward gain dac */ counter[40]=27310; /* filament timer (RS) */ counter[41]=0; /* magnet 1 dac */ counter[42]=0; /* magnet 2 dac */ counter[43]=0; /* beam dac */ counter[44]=0; /* power meter dac */ counter[45]=0; /* store log */ counter[46]=0; /* auto test enable */ counter[47]=1; /* preset power level channel */ counter[48]=3; /* rf fault lockout limit */ counter[49]=0; /* lockout count */ counter[50]=0; /* not used */ counter[51]=0; /* lockout timer */ counter[52]=0; /* cooldown timer */ counter[53]=5; /* raise/lower step size */ counter[54]=0; /* log announce */ counter[55]=100; /* tti time-out limit */ counter[56]=0; /* tti status poll count */ counter[57]=0; /* tti control count */ counter[58]=0; /* tti DAC count */ counter[59]=0; /* tti A/D poll count */ counter[60]=0; /* tti1 time-out count */ counter[61]=0; /* tti2 time-out count */ counter[62]=0; /* tti3 time-out count */ counter[63]=0; /* tti4 time-out count */ counter[64]=0; /* tti5 time-out count */ counter[65]=0; /* tti6 time-out count */ counter[66]=0; /* tti7 time-out count */ counter[67]=0; /* tti8 time-out count */ counter[68]=0; /* tti9 time-out count */ counter[69]=0; /* tti10 time-out count */ counter[70]=0; /* tti11 time-out count */ counter[71]=0; /* tti12 time-out count */ counter[72]=0; /* tti13 time-out count */ counter[73]=0; /* crowbar recovery ticks */ counter[74]=0; /* ODAPC cmd flag */ counter[75]=0; /* feed forward flag */ fail=savemisc(); break; case 2: /* meter multipliers */ scale[0]=500; /* magnet 1 voltage */ /* FS = 250 V */ scale[1]=500; /* magnet 2 voltage */ /* FS = 250 V */ scale[2]=1500; /* beam voltage */ /* FS = 75 KV */ scale[3]=400; /* magnet 1 current */ /* FS = 20 A */ scale[4]=400; /* magnet 2 current */ /* FS = 20 A */ scale[5]=250; /* body current */ /* FS = 125 MA */ scale[6]=400; /* filament 1 voltage */ /* FS = 20 V */ scale[7]=400; /* filament 2 voltage */ /* FS = 20 V */ scale[8]=600; /* filament 1 current */ /* FS = 30 A */ scale[9]=600; /* filament 2 current */ /* FS = 30 A */ scale[10]=400; /* collector 1 current */ /* FS = 20 A */ scale[11]=400; /* collector 2 current */ /* FS = 20 A */ scale[12]=1000; /* vacion 1 current */ /* FS = 5 MA */ scale[13]=1000; /* vacion 2 current */ /* FS = 5 MA */ scale[14]=1000; /* undefined */ scale[15]=1000; /* undefined */ scale[16]=2400; /* combiner fwd pwr*/ /* FS = 1200 kw */ scale[17]=1200; /* klystron 1 fwd pwr */ /* FS = 600 kw */ scale[18]=1000; /* klystron 1 rfl pwr */ /* FS = 5 kw */ scale[19]=1200; /* klystron 2 fwd pwr */ /* FS = 600 kw */ scale[20]=1000; /* klystron 2 rfl pwr */ /* FS = 5 kw */ scale[21]=1000; /* combiner rfl pwr */ /* FS = 5 kw */ scale[22]=1000; /* turnstile fwd pwr */ /* FS = 50 kw */ scale[23]=2400; /* antenna fwd pwr */ /* FS = 1200 kw */ scale[24]=1000; /* antenna rfl pwr */ /* FS = 5 kw */ scale[25]=1000; /* driver 1 power */ /* FS = 5 watts */ scale[26]=1000; /* driver 2 power */ /* FS = 5 watts*/ scale[27]=1000; /* collector 1 flow */ /* FS = 500 gpm */ scale[28]=200; /* delta t */ /* FS = 10 deg C */ scale[29]=1000; /* collector 2 flow */ /* FS = 500 gpm */ scale[30]=1000; /* undefined */ /* FS = */ scale[31]=1000; /* undefined */ /* FS = */ fail=savscale(); break; case 3: /* meter values */ for(i=0;i<32;i++) avmet[i]=simet[i]; calcs(); status[35]|=0x80; /* simulation */ break; case 4: /* password & ID names */ strcpy(password,"1234567890"); for(i=0;i<=19;i++) strcpy(&idents[0]+5*i,"ABCDE"); for(i=0;i<=199;i++) prohibs[i]=0; strcpy(codec,"****"); fail=saveiden(); break; case 5: /* spare status in */ strcpy(string,"SPARE INPUT xx "); for(i=0;i<=15;i++) /* status titles */ { for(j=0;j<=19;j++) dname[j+i*20]=string[j]; itoa(i+1,numb,10); if(!numb[1]) numb[1]=SP; /* replace null with space */ for(j=0;j<=1;j++) dname[12+j+i*20]=numb[j]; } strcpy(string,"HIGH "); for(i=0;i<=15;i++) /* on label */ for(j=0;j<=9;j++) dname1[j+i*10]=string[j]; strcpy(string,"LOW "); for(i=0;i<=15;i++) /* off label */ { for(j=0;j<=9;j++) dname2[j+i*10]=string[j]; dname3[i]=0; dname4[i]=0; } fail=savdname(); break; case 6: /* spare control out */ strcpy(string,"CMDxx"); for(i=0;i<=15;i++) /* command names */ { for(j=0;j<=9;j++) cname[j+i*10]=string[j]; numb[1]=0; itoa(i+1,numb,10); for(j=0;j<=1;j++) cname[3+j+i*10]=numb[j];/* add number to string */ cname1[i]='H'; /* assertion level */ cname2[i]='L'; /* boot level */ cname3[i]='0'; /* duration */ } fail=savcname(); break; case 7: /* meter limits */ for(i=0;i<=63;i++) { lolim[i]=0; hilim[i]=9999; } fail=savelim(); break; case 8: for(i=0;i<=15;i++) { pal[3*i]=rgb[3*i]; pal[3*i+1]=rgb[3*i+1]; pal[3*i+2]=rgb[3*i+2]; if(fail=gxSetPaletteRGB(i,rgb[3*i],rgb[3*i+1],rgb[3*i+2])) break; } fail=savepal(); break; } abort: return(fail); }