#include /* module user9 */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include /***************************************************************************/ user(void) /* user defined status screen */ { char *pointer,string[30]; unsigned char byte,olbyte,level,mask1; int i,y,color; screen=13; font(3); clkey(); if(screen!=oldscrn) refresh=1; if(refresh) { clear(); /* clear entire screen */ oldayt[0]=0; font(0); text(PALEBLUE,100,479,"USER-DEFINED I/O"); txnumber(); rect(DARKGREY,0,405,130,85); rect(DARKGREY,215,405,300,85); texcolor(WHITE); for(i=0;i<=15;i++) { y=400-20*i; pointer=&dname[0]+20*i; strncpy(string,pointer,20); string[20]=0; tex(5,y,string); /* status titles */ pointer=&cname[0]+10*i; strncpy(string,pointer,10); string[10]=0; tex(220,y,string); /* command names */ } } for(i=0;i<=15;i++) /* real-time states */ { y=400-20*i; if(i==0||i==8) mask1=1; else mask1=mask1<<1; if(i<=7) { byte=status[24]; /* input status */ olbyte=statup[24]; level=control[1]&mask1; /* output status */ } else { byte=status[25]; /* input status */ olbyte=statup[25]; level=control[2]&mask1; /* output status */ } if(refresh||((byte&mask1)!=(olbyte&mask1))) { if(byte&mask1) /* input status */ { pointer=&dname1[0]+10*i; /* true */ if(dname3[i]==0) color=PALEBLUE; if(dname3[i]==1) color=YELLOW; if(dname3[i]==3) color=RED; } else { pointer=&dname2[0]+10*i; /* false */ if(dname4[i]==0) color=PALEBLUE; if(dname4[i]==1) color=YELLOW; if(dname4[i]==2) color=RED; } strncpy(string,pointer,10); string[10]=0; rect(BLACK,140,y,170,y-20); text(color,140,y,string); /* input state label */ } /*---------------------------------------------------------------------------*/ if(level) /* output state */ strcpy(string,"HIGH"); else strcpy(string,"LOW"); rect(BLACK,310,y,340,y-20); text(PALEBLUE,310,y,string); /* control output label */ } refresh=0; oldscrn=screen; }