⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 winclass.cpp

📁 一个完整的RTU程序源码,用DOS平台,支持16串口,在天津港用的很多,8个规约103,modbus,cdt,1801,u4f
💻 CPP
📖 第 1 页 / 共 3 页
字号:

	if (keyin_buf.keyinover) {
		switch (pagelineno) {
			case 0:
				check_time.clk.year = ProcessWord(); break;
			case 1:
				check_time.clk.month = ProcessWord(); break;
			case 2:
				check_time.clk.day = ProcessWord(); break;
			case 3:
				check_time.clk.hour = ProcessWord(); break;
			case 4:
				check_time.clk.minute = ProcessWord(); break;
			case 5:
				check_time.clk.second = ProcessWord(); break;
			case 6:
				if (keyin_buf.count == 1 && keyin_buf.keybuf[0] == 'Y') {
					PC_DispStr(startx, starty + 10, "modify time is ok!", BLUE << 4 | YELLOW | BLINK);
					SetClock(&check_time.clk);
				}
				break;
		}
		ResetKeyBuf();
		siginput = FALSE;
	}

	if (sigcursor || sigcreat) {
		if (pagelineno > 6) pagelineno = 0;
		if (pagelineno < 0) pagelineno = 6;

		if (pagelineno == 0) pattern.color = CYAN << 4 | YELLOW;
		else pattern.color = BLUE << 4 | YELLOW;
		pattern.x = startx + 13; pattern.y = starty;
		dprintf(pattern, "%04d", check_time.clk.year);

		if (pagelineno == 1) pattern.color = CYAN << 4 | YELLOW;
		else pattern.color = BLUE << 4 | YELLOW;
		pattern.y = starty + 1;
		dprintf(pattern, "%02d", check_time.clk.month);

		if (pagelineno == 2) pattern.color = CYAN << 4 | YELLOW;
		else pattern.color = BLUE << 4 | YELLOW;
		pattern.y = starty + 2;
		dprintf(pattern, "%02d", check_time.clk.day);

		if (pagelineno == 3) pattern.color = CYAN << 4 | YELLOW;
		else pattern.color = BLUE << 4 | YELLOW;
		pattern.y = starty + 3;
		dprintf(pattern, "%02d", check_time.clk.hour);

		if (pagelineno == 4) pattern.color = CYAN << 4 | YELLOW;
		else pattern.color = BLUE << 4 | YELLOW;
		pattern.y = starty + 4;
		dprintf(pattern, "%02d", check_time.clk.minute);

		if (pagelineno == 5) pattern.color = CYAN << 4 | YELLOW;
		else pattern.color = BLUE << 4 | YELLOW;
		pattern.y = starty + 5;
		dprintf(pattern, "%02d", check_time.clk.second);

		if (pagelineno == 6) pattern.color = CYAN << 4 | YELLOW;
		else pattern.color = BLUE << 4 | YELLOW;
		if (check_time.checktimeflag == TRUE)
			PC_DispChar(pattern.x, starty + 6, 'Y', pattern.color);
		else PC_DispChar(pattern.x, starty + 6, 'N', pattern.color);
		PC_DispStr(startx, starty + 10, "                  ", BLUE << 4 | YELLOW);

		if (sigcursor) sigcursor = FALSE;
	}

	if (siginput || sigcreat) {
		switch (pagelineno) {
			case 0:
				keyin_buf.lenlimit = 4;	break;
			case 6:
				keyin_buf.lenlimit = 1;	break;
			default:
				keyin_buf.lenlimit = 2;	break;
		}
		if (sigcreat) sigcreat = FALSE;
	}

	if (siginput)
		DispKeyInput(startx + 13, starty + pagelineno, keyin_buf.lenlimit, CYAN << 4 | BLACK, FALSE);
}

void CWindows::PassWindow(BOOLEAN *flag)
{
	char startx = 25, starty = 10;
	char length = 27, width = 3;

	if (sigcreat) {
		PC_DispWindow(' ', startx, starty, length, width, CYAN << 4, TRUE, BLACK, 0, CYAN << 4 | BLACK);
		PC_DispStr(startx + 2, starty + 1, "Enter password : ", CYAN << 4 | WHITE);
	}

	if (keyin_buf.keyinover) {
		if (!strncmp(yk_display.pwd, keyin_buf.keybuf, 6) ||
			!strncmp(keyin_buf.keybuf, "SYSCON", 6)) {
			*flag = TRUE;
			PC_DispWindow(' ', startx, starty, length + 2, width + 1, BLUE << 4, FALSE, BLACK, 0xff, CYAN << 4 | BLACK);
		}
		else
			PC_DispStr(startx + 18, starty + 1, "       ", CYAN << 4 | CYAN);
		sigcreat = TRUE;
		siginput = FALSE;
		ResetKeyBuf();
		return;
	}

	if (siginput || sigcreat) {
		keyin_buf.lenlimit = 6;
		if (sigcreat == TRUE) sigcreat = FALSE;
	}

	if (siginput)
		DispKeyInput(startx + 19, starty + 1, keyin_buf.lenlimit, CYAN << 4 | WHITE, TRUE);
}

void CWindows::doykopinfo()
{
	int basex = 30;
	tpattern_t pattern;
	if (yk_display.pwdokflag == FALSE) return;

	pattern.x = basex + 12; pattern.y = 17;
	pattern.color = BLUE << 4 | YELLOW;
	if (yk_display.useflag) yk_display.checkresult = ykreg.ykcheckresult;
	switch (yk_display.checkresult) {
		case YKROK:
			dprintf(pattern, "OK      "); break;
		case YKRERROR:
			dprintf(pattern, "ERROR   ");
			reset_yk(WINDOW);
			break;
		case YKRTOUT:
			dprintf(pattern, "TIMEOUT ");
			reset_yk(WINDOW);
			break;
		case YKRNONE:
			dprintf(pattern, "NO CHECK"); break;
	}
	if (yk_display.useflag)
		PC_DispStr(pattern.x, 18, "UNFINISH", BLUE << 4 | YELLOW);
	else PC_DispStr(pattern.x, 18, "FINISH  ", BLUE << 4 | YELLOW);
}

void CWindows::doykop()
{
	int i;
	int basex = 30;
	tpattern_t pattern;
	INT8U *item[] = {"YK OBJECT : ", "YK TYPE   : ",
							"PRESET?   : ", "EXECUTE?  : ", "ESCAPE?   : "};

	if (yk_display.pwdokflag == FALSE) PassWindow(&yk_display.pwdokflag);
	if (yk_display.pwdokflag == TRUE) {
		if (sigcreat == TRUE) {
			for (i = 0; i < 5; i++)
				PC_DispStr(basex, i + 8, item[i], BLUE << 4 | LIGHTRED);
			PC_DispStr(basex, 17, "YK RETURN : ", BLUE << 4 | YELLOW);
			PC_DispStr(basex, 18, "YK FINISH : ", BLUE << 4 | YELLOW);
			yk_display.preset = yk_display.exec = yk_display.esc = FALSE;
			yk_display.checkresult = YKRNONE;
			yk_display.ykobj = 0x00;
			yk_display.ykcmd = YKCTRIP;
		}

		if (keyin_buf.keyinover == TRUE) {
			switch (pagelineno) {
				case 0:
					yk_display.ykobj = ProcessInt(); break;
				case 1:
					if (keyin_buf.count == 1 && keyin_buf.keybuf[0] == '0')
						yk_display.ykcmd = YKCTRIP;
					if (keyin_buf.count == 1 && keyin_buf.keybuf[0] == '1')
						yk_display.ykcmd = YKCCLOSE;
					break;
				case 2:
					if (keyin_buf.count == 1 && keyin_buf.keybuf[0] == 'Y') {
						yk_display.preset = TRUE;
						if (yk_display.exec == FALSE && yk_display.esc == FALSE && yk_display.useflag == FALSE) {
							if (!make_yk_preset(yk_display.ykcmd, yk_display.ykobj, WINDOW)) {
								yk_display.checkresult = YKRERROR;
								yk_display.useflag = FALSE;
							}
							yk_display.useflag = TRUE;
						}
					}
					else yk_display.preset = FALSE;
					break;
				case 3:
					if (keyin_buf.count == 1 && keyin_buf.keybuf[0] == 'Y') {
						yk_display.exec = TRUE;
						if (yk_display.useflag == TRUE && yk_display.preset == TRUE
							&& yk_display.esc == FALSE && yk_display.checkresult == YKROK) {
							make_yk_exe(YKCEXEC, yk_display.ykobj, WINDOW);
							yk_display.useflag = FALSE;
						}
					}
					else yk_display.exec = FALSE;
					break;
				case 4:
					if (keyin_buf.count == 1 && keyin_buf.keybuf[0] == 'Y') {
						yk_display.esc=TRUE;
						if (yk_display.useflag == TRUE && yk_display.preset == TRUE
							&& yk_display.exec == FALSE && yk_display.checkresult == YKROK) {
							make_yk_exe(YKCESC, yk_display.ykobj, WINDOW);
							yk_display.useflag = FALSE;
						}
					}
					else yk_display.esc=FALSE;
					break;
			}
			siginput = FALSE;
			ResetKeyBuf();
		}

		if (sigcursor || sigcreat) {
			if (!yk_display.useflag) yk_display.checkresult = YKRNONE;
			if (pagelineno > 4) pagelineno = 0;
			if (pagelineno < 0) pagelineno = 4;
			pattern.x = basex + 12;
			if (pagelineno == 0) pattern.color = CYAN << 4 | WHITE;
			else pattern.color = BLUE << 4 | WHITE;
			pattern.y = 8;
			dprintf(pattern, "%03d", yk_display.ykobj);

			if (pagelineno == 1) pattern.color = CYAN << 4 | WHITE;
			else pattern.color = BLUE << 4 | WHITE;
			if (yk_display.ykcmd == YKCCLOSE) PC_DispChar(basex + 12, 9, '1', pattern.color);
			else PC_DispChar(basex + 12, 9, '0', pattern.color);

			if (pagelineno == 2) pattern.color = CYAN << 4 | WHITE;
			else pattern.color = BLUE << 4 | WHITE;
			if (yk_display.preset == TRUE) PC_DispChar(basex + 12, 10, 'Y', pattern.color);
			else PC_DispChar(basex + 12, 10, 'N', pattern.color);

			if (pagelineno == 3) pattern.color = CYAN << 4 | WHITE;
			else pattern.color = BLUE << 4 | WHITE;
			if (yk_display.exec == TRUE) PC_DispChar(basex + 12, 11, 'Y', pattern.color);
			else PC_DispChar(basex + 12, 11, 'N', pattern.color);

			if (pagelineno == 4) pattern.color = CYAN << 4 | WHITE;
			else pattern.color = BLUE << 4 | WHITE;
			if (yk_display.esc == TRUE) PC_DispChar(basex + 12, 12, 'Y', pattern.color);
			else PC_DispChar(basex + 12, 12, 'N', pattern.color);
			if (sigcursor) sigcursor = FALSE;
		}
		if (siginput || sigcreat) {
			switch (pagelineno) {
				case 0:
					keyin_buf.lenlimit = 3; break;
				default:
					keyin_buf.lenlimit = 1;	break;
			}
			if (sigcreat) sigcreat = FALSE;
		}
		if (siginput)
			DispKeyInput(basex + 12, 8 + pagelineno, keyin_buf.lenlimit, CYAN << 4 | BLACK, FALSE);
	}
}

void CWindows::showwindow()
{
	INT16U menuid = mainmenuno << 8 | itemmenuno;

	if (sigcreat) {
		PC_DispWindow(' ', 0, 1, 80, 23, BLUE << 4, FALSE, BLACK, 1, BLUE << 4 | LIGHTGRAY);

		switch (menuid) {
			case 0x0000: PC_DispStr(2, 1, " Port ", BLUE << 4 | WHITE); break;
			case 0x0001: PC_DispStr(2, 1, " Sample Data ", BLUE << 4 | WHITE); break;
			case 0x0002: PC_DispStr(2, 1, " Protocol Parameter ", BLUE << 4 | WHITE); break;
			case 0x0003: PC_DispStr(2, 1, " Machine Type ", BLUE << 4 | WHITE); break;

			case 0x0100: PC_DispStr(2, 1, " YX Info ", BLUE << 4 | WHITE); break;
			case 0x0101: PC_DispStr(2, 1, " YC Info ", BLUE << 4 | WHITE); break;
			case 0x0102: PC_DispStr(2, 1, " YM Info ", BLUE << 4 | WHITE); break;
			case 0x0103: PC_DispStr(2, 1, " YK Info ", BLUE << 4 | WHITE); break;
			case 0x0104: PC_DispStr(2, 1, " Port Info ", BLUE << 4 | WHITE); break;
			case 0x0105: PC_DispStr(2, 1, " SOE LOG ", BLUE << 4 | WHITE); break;
			case 0x0106: PC_DispStr(2, 1, " Hardware ", BLUE << 4 | WHITE); break;

			case 0x0200: PC_DispStr(2, 1, " Manual YK ", BLUE << 4 | WHITE); break;
			case 0x0201: PC_DispStr(2, 1, " Modify Time ", BLUE << 4 | WHITE); break;
			case 0x0202: PC_DispStr(2, 1, " System Reset ", BLUE << 4 | WHITE); break;

			case 0x0300: PC_DispStr(2, 1, " Port Message : ", BLUE << 4 | WHITE); break;
			case 0x0301: PC_DispStr(2, 1, " Hardware Message ", BLUE << 4 | WHITE); break;
			case 0x0303: PC_DispStr(2, 1, " Boot Log ", BLUE << 4 | WHITE); break;

			case 0x0400: PC_DispStr(2, 1, " YX Define ", BLUE << 4 | WHITE); break;
			case 0x0401: PC_DispStr(2, 1, " YC Define ", BLUE << 4 | WHITE); break;
			case 0x0402: PC_DispStr(2, 1, " YM Define ", BLUE << 4 | WHITE); break;
			case 0x0403: PC_DispStr(2, 1, " YK Define ", BLUE << 4 | WHITE); break;
		}
		UpdateWindow();
	}
}

void CWindows::boot_info()
{
	if (sigcreat) {
		int i;
		tpattern_t pattern;
		char startx = 10, starty = 3;

		sigcreat = FALSE;
		pattern.color = BLUE << 4 | YELLOW;
		pattern.x = 50; pattern.y = 2;
		dprintf(pattern, "TOTAL_BOOT_RECORD : %d", BOOT_LOG_SIZE);

		pattern.color = BLUE << 4 | LIGHTRED;
		pattern.x = startx; pattern.y = starty - 1;
		dprintf(pattern, " No        Boot Time");

		for (i = 0; i < boot_record_count; i++) {
			if (i % 2) pattern.color = GRID_COLOR1 << 4 |  YELLOW;
			else pattern.color = GRID_COLOR2 << 4 | YELLOW;
			pattern.y = i + starty;
			dprintf(pattern, " %2u   %04d.%02d.%02d %02d:%02d:%02d", i + 1, boot_time[i].year,	boot_time[i].month,
						 boot_time[i].day,	boot_time[i].hour, boot_time[i].minute, boot_time[i].second);
		}
	}
}

void CWindows::WinMessage()
{
	tpattern_t pattern;
	if (sigcreat) {
		message_win.xmax = 79; message_win.xmin = 1;
		message_win.tymin = 3; message_win.rymax = 22;
		message_win.win_update = TRUE;
	}

	if (sigcursor || sigcreat) {
		pattern.color = BLUE << 4 | WHITE;
		pattern.x = 18; pattern.y = 1;
		dprintf(pattern, "PORT%-2d ", message_win.port_no + 1);
		pattern.x = 45;
		dprintf(pattern,"%s",protocol_name[PortSet[message_win.port_no].Protocol]);

		if (message_win.pause_flag)
			PC_DispStr(25, 1, "PAUSE ", BLUE << 4 | WHITE);
		else PC_DispStr(25, 1, "FLOW  ", BLUE << 4 | WHITE);

		if (message_win.displaymode)
			PC_DispStr(31, 1, "NO CHECK ", BLUE << 4 | WHITE);
		else
			PC_DispStr(31, 1, "CHECKED  ", BLUE << 4 | WHITE);

		message_win.poll = IsPolling(message_win.port_no);
		if (message_win.win_update) {
			if (message_win.poll == FALSE) {
				PC_DispStr(40, 1, "CDT ", BLUE << 4 | WHITE);
				switch (message_win.win_type) {
					case 0:
						message_win.tymax = 16; message_win.rymin = 18;
						break;
					case 1:
						message_win.tymax = 22; message_win.rymin = 0xff;
						break;
					case 2:
						message_win.tymax = 12; message_win.rymin = 14;
						break;
					case 3:
						message_win.tymax = 8; message_win.rymin = 10;
						break;
					case 4:
						message_win.tymax = 0xff; message_win.rymin = 3;
						break;
				}
				message_win.tx = message_win.xmin;
				message_win.ty = message_win.tymin;
				message_win.rx = message_win.xmin;
				message_win.ry = message_win.rymin;
				if (message_win.tymax != 0xff) {
					PC_DispStr(message_win.xmin, message_win.tymin - 1, "

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -