www.pudn.com > delta.rar > DELTA.C
#include#include #include #include #include #include #include #include #define TRUE 1 #define FALSE 0 #define EQLIST 0x410 #define strLogoDelta "DELTA ELECTRONICS, INC." #define strLogoDepart "New Products B.U." #define strFileNotFound "File not found" #define strFileEmpty "File Empty" #define strOutOfRange "Value out of range" #define strNotSupported "Not Supported" #define strOkToExit "Ok to exit program Y/N ? " #define UP 72 #define DOWN 80 #define LEFT 75 #define RIGHT 77 #define F1 59 #define F2 60 #define F3 61 void ClrStatusValue(); void BusScopeIn(void); void BusScopeOut(void); void DisplayHotKey(void); void DisplayForm(void); void DisplayCmdFunction(void); void DisplayMenuFunction(void); void Cursor(unsigned char); void ActAddrChange(void); void ProceExec(unsigned char); void StatusRefresh(); void EditSystemConfig(); void WriteMsg(char[], int, unsigned char, unsigned char); void ConfigProc(); void DirectCtrlProc(); void ClrPromptLine(); void DisplayProtocol(); void GetNum(int, char *, unsigned char, int, int); char WindowBufIn[58], WindowBufOut[58], DataInBuff[11]; int ActAddr, COM=0, Protocol=2, BusDataPtrIn, BusDataPtrOut, Empty, endptrIn, endptrOut, NN, ESC, Monitor, videoSeg, HotKeyColor, QUIT; unsigned char Quit; char *ptrCmdBuf=NULL; /* X, Y position */ int ErrMsgX = 1, ErrMsgY = 24, BaudRateX = 17, BaudRateY = 16, ComPortX = 17, ComPortY = 18; char C_Buff[11] = { 'C','\03','\01','?','?','?','?','?','?','?','?' }; char P_Buff[11] = { 'P','\03','\01','?','?','?','?','?','?','?','?' }; char R_Buff[7] = { 'R','\03','\01','?','?','?','?' }; char Q_Buff[7] = { 'Q','\03','\01','?','?','?','?' }; char InitHotKeySet[4] = { 'D','E','L','Q' }; char InverterHotKeySet[9] = { 'Q','S','R','F','V','J','M','P','\0' }; struct UnitAddrInfo { int act; char no[3]; int x; int y; int up; int down; int left; int right; int next; }; struct ComParameter { char baud[5]; int protocol; }; struct ComParameter DataFormat[3] = { {"1200",0x8B}, {"2400",0xAB}, {"4800",0xCB} /* Word length = 8 bits, Stop bit = 1 bit, Parity = odd */ }; struct OpName { char OpCode[11]; }; struct OpName OpStatus[4] = { "STOP ", "FORWARD ", "STOP ", "REVERSE " }; struct ComPort { char com[5]; int portN; }; struct ComPort SerialPort[2] = { {"COM1",0}, {"COM2",1} }; struct UnitAddrInfo SlaveAddr[32] = { {1,"00",32,5,0,1,0,1,0}, {0,"01",35,5,0,1,1,1,0}, {0,"02",38,5,0,1,1,1,0}, {0,"03",41,5,0,1,1,1,0}, {0,"04",44,5,0,1,1,1,0}, {0,"05",47,5,0,1,1,1,0}, {0,"06",50,5,0,1,1,1,0}, {0,"07",53,5,0,1,1,1,0}, {0,"08",56,5,0,1,1,1,0}, {0,"09",59,5,0,1,1,1,0}, {0,"10",62,5,0,1,1,1,0}, {0,"11",65,5,0,1,1,1,0}, {0,"12",68,5,0,1,1,1,0}, {0,"13",71,5,0,1,1,1,0}, {0,"14",74,5,0,1,1,1,0}, {0,"15",77,5,0,1,1,0,0}, {0,"16",32,6,1,0,0,1,0}, {0,"17",35,6,1,0,1,1,0}, {0,"18",38,6,1,0,1,1,0}, {0,"19",41,6,1,0,1,1,0}, {0,"20",44,6,1,0,1,1,0}, {0,"21",47,6,1,0,1,1,0}, {0,"22",50,6,1,0,1,1,0}, {0,"23",53,6,1,0,1,1,0}, {0,"24",56,6,1,0,1,1,0}, {0,"25",59,6,1,0,1,1,0}, {0,"26",62,6,1,0,1,1,0}, {0,"27",65,6,1,0,1,1,0}, {0,"28",68,6,1,0,1,1,0}, {0,"29",71,6,1,0,1,1,0}, {0,"30",74,6,1,0,1,1,0}, {0,"31",77,6,1,0,1,0,0} }; unsigned char Pr_Set[81] = { 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; unsigned int OldCursor; unsigned char Escape; struct ErrInfo { char AlarmCode[2]; char AlarmName[11]; }; struct ErrInfo ErrMsg[15] = { {"00","NORMAL \0"}, {"01","oC \0"}, {"02","oV \0"}, {"03","OH \0"}, {"04","oL \0"}, {"05","oL1 \0"}, {"06","EF \0"}, {"07","CF1 \0"}, {"08","C.F.3 \0"}, {"09","H.P.F \0"}, {"10","ocA \0"}, {"11","ocd \0"}, {"12","ocn \0"}, {"13","G.F.F \0"}, {"14","Lv \0"} }; struct ModelInfo { char PartName[11]; char PartCode[4]; }; struct ModelInfo Model[12] = { {"VFD007A23A", "0100"}, {"VFD015A23A","0200"}, {"VFD022A23A", "0300"}, {"VFD037A23A", "0400"}, {"VFD055A23B","0500"}, {"VFD075A23B", "0600"}, {"VFD007A43A", "1300"}, {"VFD015A43A","1400"}, {"VFD022A43A", "1500"}, {"VFD037A43A", "1600"}, {"VFD055A43B","1700"}, {"VFD075A43B", "1800"} }; void DisplayInitialForm() { int i, j; clrscr(); textattr(BLUE<<4); for (i=1;i<=25;i++) { gotoxy(1,i); for (j=1;j<=80;j++) cprintf(" "); } textattr(LIGHTGRAY+(BLUE<<4)); i=6; j=15; gotoxy(j,i+2); cprintf(" VFD - A "); gotoxy(j,i+9); cprintf(" Copyright(C) 1996 DELTA ELECTRONICS, INC. "); gotoxy(j,i+12); cprintf(" Press anykey to continue !! "); gotoxy(26,10); textattr(YELLOW+(BLUE<<4)); cprintf("RS-485 Serial Interface Monitor"); gotoxy(35,12); cprintf("Version 1.0"); } void DisplayForm() { int i; clrscr(); textattr(YELLOW+(BLUE<<4)); gotoxy(1,1); cprintf("FILENAME: "); gotoxy(1,2); cprintf("RS-485 Serial Interface Monitor for VFD-A"); gotoxy(56,1); cprintf(strLogoDelta); gotoxy(56,2); cprintf(strLogoDepart); gotoxy(13,3); cprintf("MENU"); gotoxy(9,14); cprintf("SYSTEM CONFIG"); gotoxy(3,16); cprintf(" BAUD RATE : "); gotoxy(3,18); cprintf("SERIAL PORT : "); gotoxy(44,3); cprintf("COMMUNICATION ADDRESSES"); gotoxy(34,8); cprintf("COMMAND MENU STATUS PRGM CTRL"); gotoxy(62,10); cprintf("STEP:"); gotoxy(62,12); cprintf("FREQ:"); gotoxy(62,14); cprintf("OPER:"); gotoxy(62,16); cprintf("TIME:"); gotoxy(62,18); cprintf("LOOP:"); gotoxy(1,21); cprintf("Computer->Inverter"); gotoxy(1,22); cprintf("Inverter->Computer"); gotoxy(45,20); cprintf("BUS VIEWER"); textattr(LIGHTGRAY+(BLUE<<4)); ClrPromptLine(); } void DisplayMenuFunction() { textattr(LIGHTGRAY+(BLUE<<4)); gotoxy(3,5); cprintf("Step trace Go"); gotoxy(3,6); cprintf("Int go"); gotoxy(3,7); cprintf(" irect control"); gotoxy(3,8); cprintf("Alter program"); gotoxy(3,9); cprintf(" dit system config"); gotoxy(3,10); cprintf("Edit program control"); gotoxy(3,11); cprintf(" oaded file : "); gotoxy(3,12); cprintf(" uit"); textattr(BLACK+(LIGHTGRAY<<4)); gotoxy(17,11); cprintf("*.PLC"); } void DisplayInitHotKey() { gotoxy(3,11); cprintf("L"); gotoxy(3,12); cprintf("Q"); gotoxy(8,12); cprintf("(Exit to DOS)"); gotoxy(3,9); cprintf("E"); gotoxy(3,7); cprintf("D"); } void DisplayPLCHotKey() { textattr(WHITE+(BLUE<<4)); gotoxy(3,5); cprintf("S"); gotoxy(17,5); cprintf("G"); gotoxy(3,6); cprintf("I"); gotoxy(3,8); cprintf("A"); gotoxy(3,11); cprintf("L"); } void DisplayCmdFunction() { textattr(LIGHTGRAY+(BLUE<<4)); gotoxy(34,10); cprintf("top eset"); gotoxy(34,11); cprintf("wd re"); gotoxy(34,12); cprintf("og (FWD)"); gotoxy(34,13); cprintf("r. modify"); gotoxy(34,14); cprintf("onitor"); } void DisplayHotKey() { textattr(HotKeyColor+(BLUE<<4)); gotoxy(33,10); cprintf("S"); gotoxy(40,10); cprintf("R"); gotoxy(33,11); cprintf("F"); gotoxy(40,11); cprintf("V"); gotoxy(33,12); cprintf("J"); gotoxy(33,13); cprintf("P"); gotoxy(33,14); cprintf("M"); } void DisplayStatusForm() { textattr(WHITE+(BLUE<<4)); gotoxy(51,12); cprintf("F: "); gotoxy(51,14); cprintf("H: "); gotoxy(51,16); cprintf("A: "); textattr(BLUE<<4); gotoxy(54,12); cprintf(" "); gotoxy(54,14); cprintf(" "); gotoxy(54,16); cprintf(" "); } void ClrInverterCmdWindow() { int i,j; for (j=10;j<=14;j++) { gotoxy(33,j); for (i=1;i<=12;i++) printf(" "); } gotoxy(33,16); printf(" "); } void ClrUnitAddrWindow() { int i,j; textattr(BLUE<<4); for (j=1;j<=2;j++) { gotoxy(32,j+4); for (i=1;i<=47;i++) cprintf(" "); } } void WriteMsg(char Msg[15], int Color, unsigned char x, unsigned char y) { gotoxy(x,y); textattr(Color); cprintf(Msg); } void Cursor(unsigned char ON) { union REGS r; if ( ON ) { r.h.ch = 0; r.h.cl = 15; } /* MOV CX,CursorShape */ else { r.h.ch = 0x20; r.h.cl = 0x00; } /* CL=UL(0)...CH=LL(F) */ r.h.ah = 1; /* INT 10H */ int86(0x10,&r,&r); } void GetNum(int l, char *DirBuff, unsigned char Dot, int Position, int C_inst) { unsigned int n; int x,y,i,j,dp,k; char buf1[4],buf2[5],ch, *ptrb1; dp=0; x = wherex(); y = wherey(); i = 0; j = 0; ESC = FALSE; do { ch = getch(); if ( ch == '\b') { if ( buf2[j-1] == '.' ) { dp = 0; l=4; j--; buf1[i] ='\0'; } else { i--; j--; } cprintf("\b \b"); } if (j < 0) { gotoxy(x-1,y); putch(' '); i = 0; j = 0; } else if ( ch == '\x1B') { ESC = TRUE; j = 0; ch = '\r'; } else if ( Dot ) if ( (((ch >= '0') && (ch <= '9')) || (ch == '.')) && (j < l) ) { if ( ch == '.' ) { l = 5; dp = i; } else { buf1[i] = ch; i++; } buf2[j] = ch; j++; putch(ch); } else; else if ( ((ch >= '0') && (ch <= '9')) && (j < l) ) { buf1[i] = ch; i++; buf2[j] = ch; j++; putch(ch); } } while ( ch != '\r'); if ( l == 2 ) { ptrb1 = buf1; NN = atoi(ptrb1); if ( i<=1 ) { *(DirBuff+Position)='0'; *(DirBuff+Position+1)=buf1[0]; } else { *(DirBuff+Position)=buf1[0]; *(DirBuff+Position+1)=buf1[1]; } } else { if ( dp == 0 ) { if ( buf2[0] == '.' ) /* .1, .12, .123, .1234 */ for (k=0;k<=3;k++) { if ( k==3 ) *(DirBuff+Position+k)=buf2[1]; else *(DirBuff+Position+k)='0'; } else /* 1, 12, 123, 1234 */ { if ( i == 4 ) for (k=0;k<=3;k++) *(DirBuff+Position+k)=buf1[k]; else { if ( C_inst || Pr_Set[NN] ) { switch ( i ) { case 1: *(DirBuff+Position+0)='0'; *(DirBuff+Position+1)='0'; *(DirBuff+Position+2)=buf1[0]; *(DirBuff+Position+3)='0'; break; case 2: *(DirBuff+Position+0)='0'; *(DirBuff+Position+1)=buf1[0]; *(DirBuff+Position+2)=buf1[1]; *(DirBuff+Position+3)='0'; break; case 3: *(DirBuff+Position+0)=buf1[0]; *(DirBuff+Position+1)=buf1[1]; *(DirBuff+Position+2)=buf1[2]; *(DirBuff+Position+3)='0'; break; } } else { switch ( i ) { case 1: *(DirBuff+Position+0)='0'; *(DirBuff+Position+1)='0'; *(DirBuff+Position+2)='0'; *(DirBuff+Position+3)=buf1[0]; break; case 2: *(DirBuff+Position+0)='0'; *(DirBuff+Position+1)='0'; *(DirBuff+Position+2)=buf1[0]; *(DirBuff+Position+3)=buf1[1]; break; case 3: *(DirBuff+Position+0)='0'; *(DirBuff+Position+1)=buf1[0]; *(DirBuff+Position+2)=buf1[1]; *(DirBuff+Position+3)=buf1[2]; break; } } } } } else { if ( (i-dp) > 1 ) /* 1.23, 1.234, 12.34 */ { j=0; for (k=0;k<=3;k++) if ( k<(3-dp) ) *(DirBuff+Position+k)='0'; else { *(DirBuff+Position+k)=buf1[0+j]; j++; } } else /* 1.2, 12.3, 123.4 */ { dp=0; for (k=0;k<=3;k++) { if ( (4-i-k) >= 1 ) *(DirBuff+Position+k)='0'; else { *(DirBuff+Position+k)=buf1[0+dp]; dp++; } } } } } } void SendOut(char *CmdData, int Length) { int i, j, ComStatus = 0; delay(150); for (i=0; i 8); return i; } void ShowActAddr() { unsigned char i; for (i=0;i<=31;i++) { if ( SlaveAddr[i].act == 1 ) { textattr(LIGHTGRAY+(BLUE<<4)); gotoxy(SlaveAddr[i].x,SlaveAddr[i].y); cprintf(SlaveAddr[i].no); } else { textattr(LIGHTGRAY+(BLUE<<4)); gotoxy(SlaveAddr[i].x,SlaveAddr[i].y); cprintf(SlaveAddr[i].no); } } } void AddrSelectEnable() { gotoxy(SlaveAddr[ActAddr].x,SlaveAddr[ActAddr].y); textattr(YELLOW+(BLUE<<4)+BLINK); cprintf(SlaveAddr[ActAddr].no); } void AddrSelectDisable() { gotoxy(SlaveAddr[ActAddr].x,SlaveAddr[ActAddr].y); textattr(YELLOW+(BLUE<<4)); cprintf(SlaveAddr[ActAddr].no); } void EntryPromptWindow(char ProSym[7], unsigned char Clr) { textattr(LIGHTGRAY+(BLUE<<4)); if ( Clr ) { gotoxy(33,16); cprintf(" "); } else { textattr(WHITE+(BLUE<<4)); gotoxy(33,16); cprintf(ProSym); } } void AddrNotSpecified() { ClrStatusValue(); gotoxy(50,18); textattr(RED+(LIGHTGRAY<<4)+BLINK); cprintf(" EMPTY! "); textattr(LIGHTGRAY+(BLUE<<4)); } void StatusRefresh() { char Buff[2]; int i, j, Equal; unsigned char *str1=NULL; textattr(LIGHTGRAY+(BLUE<<4)); itoa(ActAddr, Buff, 10); if ( ActAddr<10 ) { R_Buff[3]='0'; R_Buff[4]=Buff[0]; } else { R_Buff[3]=Buff[0]; R_Buff[4]=Buff[1]; } R_Buff[5]='8'; R_Buff[6]='0'; str1=&R_Buff[0]; SendOut(str1,7); ReceiveIn(); if ( Empty ) AddrNotSpecified(); else { i=0; do { Equal = TRUE; for (j=0;j<=3;j++) { if ( DataInBuff[7+j] != Model[i].PartCode[j] ) Equal = FALSE; } i++; } while ( (i <= 11) && ( ! Equal) ); gotoxy(50,10); cprintf(Model[i-1].PartName); if ( ActAddr<10 ) { Q_Buff[3]='0'; Q_Buff[4]=Buff[0]; } else { Q_Buff[3]=Buff[0]; Q_Buff[4]=Buff[1]; } Q_Buff[6]='0'; str1=&Q_Buff[0]; SendOut(str1,7); ReceiveIn(); gotoxy(54,12); for (i=0;i<=3;i++) { cprintf("%c",DataInBuff[7+i]); if ( i==2 ) cprintf("."); } Q_Buff[6]='1'; str1=&Q_Buff[0]; SendOut(str1,7); ReceiveIn(); gotoxy(54,14); for (i=0;i<=3;i++) { cprintf("%c",DataInBuff[7+i]); if ( i==2 ) cprintf("."); } Q_Buff[6]='2'; str1=&Q_Buff[0]; SendOut(str1,7); ReceiveIn(); gotoxy(54,16); for (i=0;i<=3;i++) { cprintf("%c",DataInBuff[7+i]); if ( i==2 ) cprintf("."); } Q_Buff[6]='3'; str1=&Q_Buff[0]; SendOut(str1,7); ReceiveIn(); gotoxy(50,18); i=DataInBuff[7]-48; textattr(LIGHTGRAY+(BLUE<<4)+BLINK); cprintf(OpStatus[i].OpCode); /* if ( DataInBuff[8] & 0x01 ) { EntryPromptWindow("RUN",FALSE); } else { EntryPromptWindow("STOP",FALSE); } if ( DataInBuff[8] & 0x02 ) { gotoxy(33,18); cprintf("REVERSE"); } else { gotoxy(33,18); cprintf("FORWARD"); } */ i=0; do { Equal = TRUE; for (j=0;j<=1;j++) { if ( DataInBuff[9+j] != ErrMsg[i].AlarmCode[j] ) Equal = FALSE; } i++; } while ( (i <= 14) && ( ! Equal) ); if ( i>1 ) { gotoxy(50,18); textattr(HotKeyColor+(BLUE<<4)); cprintf(ErrMsg[i-1].AlarmName); } } } void ActAddrChange() { char ch2; unsigned char Com, *str1, DOT, j; char Buff[2]; int i, Equal; if (SlaveAddr[ActAddr].act) textattr(YELLOW+(BLUE<<4)+BLINK); gotoxy(SlaveAddr[ActAddr].x,SlaveAddr[ActAddr].y); cprintf(SlaveAddr[ActAddr].no); while ( (Com = GetCommand()) != 0 ) if ( Com == 8 ) { ch2 = getch(); switch ( ch2 ) { case UP : if (SlaveAddr[ActAddr].up==1) { if (SlaveAddr[ActAddr].act) textattr(LIGHTGRAY+(BLUE<<4)); else textattr(LIGHTGRAY+(BLUE<<4)); gotoxy(SlaveAddr[ActAddr].x,SlaveAddr[ActAddr].y); cprintf(SlaveAddr[ActAddr].no); SlaveAddr[ActAddr].act=0; ActAddr = ActAddr-16; SlaveAddr[ActAddr].act=1; gotoxy(SlaveAddr[ActAddr].x,SlaveAddr[ActAddr].y); if (SlaveAddr[ActAddr].act) textattr(YELLOW+(BLUE<<4)+BLINK); else textattr(YELLOW+(BLUE<<4)+BLINK); cprintf(SlaveAddr[ActAddr].no); } break; case DOWN : if (SlaveAddr[ActAddr].down==1) { if (SlaveAddr[ActAddr].act) textattr(LIGHTGRAY+(BLUE<<4)); else textattr(LIGHTGRAY+(BLUE<<4)); gotoxy(SlaveAddr[ActAddr].x,SlaveAddr[ActAddr].y); cprintf(SlaveAddr[ActAddr].no); SlaveAddr[ActAddr].act=0; ActAddr = ActAddr+16; SlaveAddr[ActAddr].act=1; gotoxy(SlaveAddr[ActAddr].x,SlaveAddr[ActAddr].y); if (SlaveAddr[ActAddr].act) textattr(YELLOW+(BLUE<<4)+BLINK); else textattr(YELLOW+(BLUE<<4)+BLINK); cprintf(SlaveAddr[ActAddr].no); } break; case LEFT : if (SlaveAddr[ActAddr].left==1) { if (SlaveAddr[ActAddr].act) textattr(LIGHTGRAY+(BLUE<<4)); else textattr(LIGHTGRAY+(BLUE<<4)); gotoxy(SlaveAddr[ActAddr].x,SlaveAddr[ActAddr].y); cprintf(SlaveAddr[ActAddr].no); SlaveAddr[ActAddr].act=0; ActAddr = ActAddr-1; SlaveAddr[ActAddr].act=1; gotoxy(SlaveAddr[ActAddr].x,SlaveAddr[ActAddr].y); if (SlaveAddr[ActAddr].act) textattr(YELLOW+(BLUE<<4)+BLINK); else textattr(YELLOW+(BLUE<<4)+BLINK); cprintf(SlaveAddr[ActAddr].no); } break; case RIGHT : if (SlaveAddr[ActAddr].right==1) { if (SlaveAddr[ActAddr].act) textattr(LIGHTGRAY+(BLUE<<4)); else textattr(LIGHTGRAY+(BLUE<<4)); gotoxy(SlaveAddr[ActAddr].x,SlaveAddr[ActAddr].y); cprintf(SlaveAddr[ActAddr].no); SlaveAddr[ActAddr].act=0; ActAddr = ActAddr+1; SlaveAddr[ActAddr].act=1; gotoxy(SlaveAddr[ActAddr].x,SlaveAddr[ActAddr].y); if (SlaveAddr[ActAddr].act) textattr(YELLOW+(BLUE<<4)+BLINK); else textattr(YELLOW+(BLUE<<4)+BLINK); cprintf(SlaveAddr[ActAddr].no); } break; } delay(10); } else { switch ( Com ) { case 1: C_Buff[6]='0'; /* STOP */ itoa(ActAddr, Buff, 10); if ( ActAddr<10 ) { C_Buff[3]='0'; C_Buff[4]=Buff[0]; } else { C_Buff[3]=Buff[0]; C_Buff[4]=Buff[1]; } str1=&C_Buff[0]; SendOut(str1,11); ReceiveIn(); if ( Empty ) AddrNotSpecified(); break; case 2: C_Buff[6]='8'; /* RESET */ itoa(ActAddr, Buff, 10); if ( ActAddr<10 ) { C_Buff[3]='0'; C_Buff[4]=Buff[0]; } else { C_Buff[3]=Buff[0]; C_Buff[4]=Buff[1]; } str1=&C_Buff[0]; SendOut(str1,11); ReceiveIn(); if ( Empty ) AddrNotSpecified(); break; case 3: AddrSelectDisable(); EntryPromptWindow("FREQ.- ",FALSE); C_Buff[6]='1'; /* FORWARD */ Cursor(TRUE); ptrCmdBuf = C_Buff; GetNum(4, ptrCmdBuf, TRUE, 7, TRUE); Cursor(FALSE); if ( ! ESC ) { itoa(ActAddr, Buff, 10); if ( ActAddr<10 ) { C_Buff[3]='0'; C_Buff[4]=Buff[0]; } else { C_Buff[3]=Buff[0]; C_Buff[4]=Buff[1]; } str1=&C_Buff[0]; SendOut(str1,11); ReceiveIn(); if ( Empty ) AddrNotSpecified(); } AddrSelectEnable(); EntryPromptWindow("",TRUE); break; case 4: AddrSelectDisable(); EntryPromptWindow("FREQ.- ",FALSE); C_Buff[6]='3'; /* REVERSE */ Cursor(TRUE); ptrCmdBuf = C_Buff; GetNum(4, ptrCmdBuf, TRUE, 7, TRUE); Cursor(FALSE); if ( ! ESC ) { itoa(ActAddr, Buff, 10); if ( ActAddr<10 ) { C_Buff[3]='0'; C_Buff[4]=Buff[0]; } else { C_Buff[3]=Buff[0]; C_Buff[4]=Buff[1]; } str1=&C_Buff[0]; SendOut(str1,11); ReceiveIn(); if ( Empty ) AddrNotSpecified(); } AddrSelectEnable(); EntryPromptWindow("",TRUE); break; case 5: C_Buff[6]='4'; /* JOG FWD */ if ( ActAddr<10 ) { C_Buff[3]='0'; C_Buff[4]=Buff[0]; } else { C_Buff[3]=Buff[0]; C_Buff[4]=Buff[1]; } str1=&C_Buff[0]; SendOut(str1,11); ReceiveIn(); if ( Empty ) AddrNotSpecified(); break; case 6: Monitor = TRUE; DisplayStatusForm(); /* Monitor */ textattr(LIGHTGRAY+(BLUE<<4)); itoa(ActAddr, Buff, 10); if ( ActAddr<10 ) { R_Buff[3]='0'; R_Buff[4]=Buff[0]; } else { R_Buff[3]=Buff[0]; R_Buff[4]=Buff[1]; } R_Buff[5]='8'; R_Buff[6]='0'; str1=&R_Buff[0]; SendOut(str1,7); ReceiveIn(); if ( Empty ) AddrNotSpecified(); else { i=0; do { Equal = TRUE; for (j=0;j<=3;j++) { if ( DataInBuff[7+j] != Model[i].PartCode[j] ) Equal = FALSE; } i++; } while ( (i <= 11) && ( ! Equal) ); gotoxy(50,10); cprintf(Model[i-1].PartName); if ( ActAddr<10 ) { Q_Buff[3]='0'; Q_Buff[4]=Buff[0]; } else { Q_Buff[3]=Buff[0]; Q_Buff[4]=Buff[1]; } Q_Buff[6]='0'; str1=&Q_Buff[0]; SendOut(str1,7); ReceiveIn(); gotoxy(54,12); for (i=0;i<=3;i++) { cprintf("%c",DataInBuff[7+i]); if ( i==2 ) cprintf("."); } Q_Buff[6]='1'; str1=&Q_Buff[0]; SendOut(str1,7); ReceiveIn(); gotoxy(54,14); for (i=0;i<=3;i++) { cprintf("%c",DataInBuff[7+i]); if ( i==2 ) cprintf("."); } Q_Buff[6]='2'; str1=&Q_Buff[0]; SendOut(str1,7); ReceiveIn(); gotoxy(54,16); for (i=0;i<=3;i++) { cprintf("%c",DataInBuff[7+i]); if ( i==2 ) cprintf("."); } Q_Buff[6]='3'; str1=&Q_Buff[0]; SendOut(str1,7); ReceiveIn(); gotoxy(50,18); i=DataInBuff[7]-48; textattr(LIGHTGRAY+(BLUE<<4)+BLINK); cprintf(OpStatus[i].OpCode); } break; case 7: AddrSelectDisable(); EntryPromptWindow("Pr.- ",FALSE); Cursor(TRUE); ptrCmdBuf = P_Buff; GetNum(2, ptrCmdBuf, FALSE, 5, FALSE); Cursor(FALSE); if ( ! ESC ) { gotoxy(33,18); cprintf("d "); textattr(LIGHTGRAY+(BLUE<<4)); if ( Pr_Set[NN] ) DOT = TRUE; else DOT = FALSE; Cursor(TRUE); ptrCmdBuf = P_Buff; GetNum(4, ptrCmdBuf, DOT, 7, FALSE); Cursor(FALSE); if ( ! ESC ) { gotoxy(33,18); cprintf(" "); itoa(ActAddr, Buff, 10); if ( ActAddr<10 ) { P_Buff[3]='0'; P_Buff[4]=Buff[0]; } else { P_Buff[3]=Buff[0]; P_Buff[4]=Buff[1]; } str1=&P_Buff[0]; SendOut(str1,11); ReceiveIn(); if ( Empty ) AddrNotSpecified(); } } AddrSelectEnable(); EntryPromptWindow("",TRUE); gotoxy(33,18); cprintf(" "); break; } } } void ConfigSet() { bioscom(0, DataFormat[Protocol].protocol, COM); } void EditSystemConfig() { int i; char ch1, ch2; WriteMsg("F1",HotKeyColor+(LIGHTGRAY<<4),1,24); WriteMsg("-1200",BLACK+(LIGHTGRAY<<4),3,24); WriteMsg("F2",HotKeyColor+(LIGHTGRAY<<4),11,24); WriteMsg("-2400",BLACK+(LIGHTGRAY<<4),13,24); WriteMsg("F3",HotKeyColor+(LIGHTGRAY<<4),21,24); WriteMsg("-4800",BLACK+(LIGHTGRAY<<4),23,24); WriteMsg(DataFormat[Protocol].baud,BLACK+(LIGHTGRAY<<4)+BLINK, BaudRateX, BaudRateY); do { while ( (ch1=getch()) != 0 ); ch2 = getch(); switch (ch2) { case F1: WriteMsg(DataFormat[0].baud,BLACK+(LIGHTGRAY<<4),BaudRateX, BaudRateY); Protocol=0; break; case F2: WriteMsg(DataFormat[1].baud,BLACK+(LIGHTGRAY<<4),BaudRateX, BaudRateY); Protocol=1; break; case F3: WriteMsg(DataFormat[2].baud,BLACK+(LIGHTGRAY<<4),BaudRateX, BaudRateY); Protocol=2; break; } } while ( (ch2 F3) ); ClrPromptLine(); gotoxy(1,24); WriteMsg("F1",HotKeyColor+(LIGHTGRAY<<4),1,24); WriteMsg("-COM1",BLACK+(LIGHTGRAY<<4),3,24); WriteMsg("F2",HotKeyColor+(LIGHTGRAY<<4),11,24); WriteMsg("-COM2",BLACK+(LIGHTGRAY<<4),13,24); WriteMsg(SerialPort[COM].com,BLACK+(LIGHTGRAY<<4)+BLINK, ComPortX, ComPortY); do { while ( (ch1=getch()) != 0 ); ch2 = getch(); switch (ch2) { case F1: WriteMsg(SerialPort[0].com,BLACK+(LIGHTGRAY<<4),ComPortX, ComPortY); COM=SerialPort[0].portN; break; case F2: WriteMsg(SerialPort[1].com,BLACK+(LIGHTGRAY<<4),ComPortX, ComPortY); COM=SerialPort[1].portN; break; } } while ( (ch2 != F1) && (ch2 != F2) ); ClrPromptLine(); ConfigSet(); } void ConfigProc() { textattr(HotKeyColor+(BLUE<<4)); DisplayInitHotKey(); textattr(LIGHTGRAY+(BLUE<<4)); EditSystemConfig(); } void DirectCtrlProc() { DisplayCmdFunction(); DisplayHotKey(); gotoxy(35,16); Cursor(FALSE); ShowActAddr(); ActAddrChange(); } unsigned char InitProcChoice() { char ch; unsigned char i; do { i = 0; ch = getch(); ch = ch & 0xDF; while ( ( ch != InitHotKeySet[i] && i < 4) ) i++; } while ( i>4 ); return i; } void ClrPromptLine() { int i; gotoxy(1,24); for (i=1;i<81;i++) { textattr(LIGHTGRAY<<4); cprintf(" "); } } void ClrStatusWindow() { textattr(BLUE<<4); gotoxy(50,10); cprintf(" "); gotoxy(51,12); cprintf(" "); gotoxy(51,14); cprintf(" "); gotoxy(51,16); cprintf(" "); gotoxy(50,18); cprintf(" "); } void ClrStatusValue() { textattr(BLUE<<4); gotoxy(50,10); cprintf(" "); gotoxy(54,12); cprintf(" "); gotoxy(54,14); cprintf(" "); gotoxy(54,16); cprintf(" "); } void ProceExec(unsigned char ch) { unsigned char YN; switch ( ch ) { case 0: textattr(LIGHTGRAY+(BLUE<<4)); DisplayInitHotKey(); textattr(HotKeyColor+(BLUE<<4)); gotoxy(3,12); cprintf("Q"); DirectCtrlProc(); ClrPromptLine(); textattr(WHITE+(BLUE<<4)); Quit = FALSE; Monitor = FALSE; ClrInverterCmdWindow(); ClrUnitAddrWindow(); ClrStatusWindow(); textattr(HotKeyColor+(BLUE<<4)); DisplayInitHotKey(); break; case 1: EditSystemConfig(); break; case 2: WriteMsg(strNotSupported,HotKeyColor+(LIGHTGRAY<<4)+BLINK,1,24); while ( ! bioskey(1) ); ClrPromptLine(); break; case 3: textattr(LIGHTGRAY+(BLUE<<4)); DisplayInitHotKey(); WriteMsg(strOkToExit,QUIT+(LIGHTGRAY<<4),1,24); Cursor(TRUE); do { YN = getch(); YN = YN & 0xDF; if (YN=='N') Quit = FALSE; else Quit = TRUE; } while ( (YN != 'Y') && (YN != 'N') ); if ( YN == 'N' ) textattr(HotKeyColor+(BLUE<<4)); DisplayInitHotKey(); gotoxy(1,24); Cursor(FALSE); ClrPromptLine(); break; case 4: break; } } void DisplayProtocol() { WriteMsg(DataFormat[2].baud,BLACK+(LIGHTGRAY<<4),BaudRateX,BaudRateY); WriteMsg(SerialPort[COM].com,BLACK+(LIGHTGRAY<<4),ComPortX,ComPortY); } void BusScopeIn() { int startptr,j,k; startptr=BusDataPtrIn; for (j=0;j<=57;j++) { if ( endptrIn<58 ) pokeb(videoSeg,j*2+0x0d48,WindowBufIn[j]); else if ( startptr<58 ) pokeb(videoSeg,j*2+0x0d48,WindowBufIn[startptr]); else pokeb(videoSeg,j*2+0x0d48,WindowBufIn[startptr-58]); startptr++; } endptrIn++; } void BusScopeOut() { int startptr,j,k; startptr=BusDataPtrOut; for (j=0;j<=57;j++) { if ( endptrOut<58 ) pokeb(videoSeg,j*2+0x0ca8,WindowBufOut[j]); else if ( startptr<58 ) pokeb(videoSeg,j*2+0x0ca8,WindowBufOut[startptr]); else pokeb(videoSeg,j*2+0x0ca8,WindowBufOut[startptr-58]); startptr++; } endptrOut++; } void videoTypeSet() { int far *farptr=NULL; unsigned int eq, data; farptr = (int far *) EQLIST; eq = *(farptr); data = (eq>>4) & 3; switch (data) { case 2: videoSeg = 0xb800; HotKeyColor = WHITE; QUIT = RED; break; case 3: videoSeg = 0xb000; HotKeyColor = WHITE; QUIT = BLACK; break; } } void winbufInitialSet() { int i; for (i=0;i<=57;i++) { WindowBufIn[i]='.'; WindowBufOut[i]='.'; } for (i=0;i<=57;i++) { pokeb(videoSeg,1+i*2+0x0ca8,0x07); pokeb(videoSeg,1+i*2+0x0d48,0x07); } BusDataPtrIn=0; BusDataPtrOut=0; endptrIn=0; endptrOut=0; BusScopeIn(); BusScopeOut(); } void main() { int entry, i; char ch, ch3; unsigned int x, y; ActAddr = 0; Empty = FALSE; SaveOldCursor(); Cursor(FALSE); videoTypeSet(); DisplayInitialForm(); while ( ! bioskey(1) ); DisplayForm(); DisplayMenuFunction(); textattr(HotKeyColor+(BLUE<<4)); DisplayInitHotKey(); DisplayProtocol(); ConfigSet(); Quit = TRUE; Monitor = FALSE; winbufInitialSet(); do { ch = InitProcChoice(); ProceExec(ch); } while ( (ch != 3) || ( Quit == FALSE) ); textattr(LIGHTGRAY+(BLACK<<4)); clrscr(); DspOldCursor(); }