#include /* module calendr9 */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /****************************************************************************/ calendar(void) /* send time and date to screen */ { int color,x=580,filtime,filsec,filmin; /* (RS) */ int cooltime,coolsec,coolmin; /* (RS) */ char string[6]; /* (RS) */ if(logno||histno) { rect(BLACK,x,469,x+50,479); /* erase old time */ text(WHITE,x,479,tyme); /* display time */ rect(BLACK,x,455,x+50,465); /* erase old date */ text(WHITE,x,465,dayt); /* display date */ goto key; } if(!remo) { _strtime(tyme); /* get time if not a log */ _strdate(dayt); /* get date */ } if(strcmp(tyme,oltyme)) /* update time if changed */ { font(3); color=BLACK; if(tyme[6]=='0'&&tyme[7]=='0') color=BLUE; /* minute change */ if(tyme[3]=='0'&&tyme[4]=='0'&&color==YELLOW) color=GREEN; /* hour change */ rect(color,x,469,x+50,479); /* erase old time */ text(WHITE,x,479,tyme); /* display time */ if(screen==1&&counter[40]<27310&&counter[40]>0) /* filament warm-up timer */ { filtime=(int)((double)counter[40]/18.2); /* (RS) */ filsec=filtime%60; /* (RS) */ filmin=filtime/60; /* (RS) */ itoa(filmin,numb,10); /* (RS) */ if(filmin<10) /* (RS) */ { /* (RS) */ strcpy(string,"0"); /* (RS) */ strcat(string,numb); /* (RS) */ } /* (RS) */ else strcpy(string,numb); /* (RS) */ strcat(string,":"); /* (RS) */ itoa(filsec,numb,10); /* (RS) */ if(filsec<10) /* (RS) */ strcat(string,"0"); /* (RS) */ strcat(string,numb); /* (RS) */ rect(BLACK,362,322,398,338); text(YELLOW,367,336,string); /* (RS) */ } if(screen==1&&counter[52]) /* filament cool-down timer */ { cooltime=(int)((double)counter[52]/18.2); /* (RS) */ coolsec=cooltime%60; /* (RS) */ coolmin=cooltime/60; /* (RS) */ itoa(coolmin,numb,10); /* (RS) */ if(coolmin<10) /* (RS) */ { /* (RS) */ strcpy(string,"0"); /* (RS) */ strcat(string,numb); /* (RS) */ } /* (RS) */ else strcpy(string,numb); /* (RS) */ strcat(string,":"); /* (RS) */ itoa(coolsec,numb,10); /* (RS) */ if(coolsec<10) /* (RS) */ strcat(string,"0"); /* (RS) */ strcat(string,numb); /* (RS) */ rect(BLACK,62,382,98,398); text(YELLOW,70,395,string); /* (RS) */ } if(screen==5&&counter[73]) /* crowbar trigger cool-down timer */ { rect(BLACK,32,178,48,162); text(YELLOW,35,175,itoa((int)((double)counter[73]/18.2),numb,10)); } autolog(); } if(strcmp(dayt,oldayt)) /* update date if changed */ { font(3); rect(BLACK,x,455,x+50,465); /* erase old date */ text(WHITE,x,465,dayt); /* display date */ } strcpy(oltyme,tyme); strcpy(oldayt,dayt); key: if(keyboard[0]||remotbuf[0]) /* keyboard active? */ { counter[7]=timer(keystart); /* find elapsed time */ if(counter[7]>counter[6]) /* timed out? */ { status[35]|=0x08; counter[7]=0; /* activity timer */ clrkey(); /* clear all comm buffers */ erase(); /* clear prompt line */ } } } /***************************************************************************/ stamp(void) /* refresh time and date on screen */ { oltyme[0]=0; oldayt[0]=0; calendar(); txnumber(); } /***************************************************************************/ clocker(void) /* update clock-keyed parameters */ { if(logno||histno||(status[35]&0x80)||(status[35]&0x10)) goto abort; /* not real-time, or simu or boot */ if(!(status[36]&0x10)&&(status[8]&0x03)) /* fault or no tube sel? */ if((++counter[26]>=counter[25])&&(histen)) /* (RS) */ { counter[26]=0; ramhist(); /* store history */ } abort: ; } /***************************************************************************/ autolog(void) /* store log by clock */ { int i,mins,past; if(logno||histno||(status[35]&0x80)||status[35]&0x10) goto abort; /* not real-time, or simu or boot */ mins=10*(int)(tyme[3]&0x0F)+(int)(tyme[4]&0x0F); for(i=0;i<60;i++) { past=counter[4]*i+counter[5]; if(past>59) break; if((mins==past)&&(mins!=counter[10])) { counter[10]=mins; /* avoid multiple stores */ status[35]|=0x20; /* log stored by clock */ break; } } abort: ; } /***************************************************************************/ settime(void) /* change calendar-clock time */ { struct dostime_t time; strncpy(numb,&parse[4],2); numb[2]=0; time.hour=atoi(numb); strncpy(numb,&parse[6],2); time.minute=atoi(numb); strncpy(numb,&parse[8],2); time.second=atoi(numb); _dos_settime(&time); clkey(); status[36]|=0x40; /* manual time change bit */ } /***************************************************************************/ setdate(void) /* change calendar-clock date */ { struct dosdate_t date; strncpy(numb,&parse[4],2); numb[2]=0; date.month=atoi(numb); strncpy(numb,&parse[6],2); date.day=atoi(numb); strcpy(numb,"19"); strncat(numb,&parse[8],2); numb[4]=0; date.year=atoi(numb); _dos_setdate(&date); clkey(); status[36]|=0x80; /* manual date change bit */ } /***************************************************************************/ txnumber(void) /* display tx ID no. in upper right */ { char string[20]; int color; color=getcolor(); font(3); strcpy(string,"723 "); strcat(string,itoa(counter[20],numb,10)); box(BLUE,520,479,560,468,WHITE,string); if(logno) { strcpy(string,"LOG NO "); strcat(string,itoa(logno,numb,10)); text(RED,510,465,string); } if(histno) { strcpy(string,"HISTORY "); strcat(string,itoa(histno,numb,10)); text(RED,510,465,string); } if(status[35]&0x80) text(RED,510,465,"SIMULATION"); if(remo) text(PALEBLUE,520,450,"REMOTE"); setcolor(color); }