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

📄 station.java

📁 Java Op Processor java vhdl processor
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		int i, j;		powerOn();		Display.line1();		Display.intVal(cnt);		Display.data(' ');		Display.data(Texte.chkms);		// wait for boot		for (i=0; i<BOOT_TIME; ++i) {			if (cmdAll(BBSys.CMD_STATUS)) {				break;			}			Timer.wd();			Clock.loop();			Timer.sleepWd(100);			Msg.flush();		// flush the input buffer		}		if (i==BOOT_TIME) {			chkNewMS();			bootErr();		}		Timer.sleepWd(200);		// for shure		if (!cmdAll(BBSys.CMD_SET_STATE, BBSys.MS_RDY)) {			comErr();		}		Timer.wd();		Timer.sleepWd(100);		// wait for error detection after set MS_RDY		if (!cmdAll(BBSys.CMD_ERRNR)) {			comErr();		}		for (i=0; i<cnt; ++i) {			if (ret[i] != 0) {				error(ret[i], i+1);	// endless loop			}		}		Timer.wd();		if (!cmdAll(BBSys.CMD_STATUS)) {			comErr();		}		// not MS_RDY means some strange error !!!		// should never happen		for (i=0; i<cnt; ++i) {			if (ret[i] != BBSys.MS_RDY) {				error(Err.MS_ERR, i+1);	// endless loop			}		}		Timer.wd();		// see, if there are more MS than configured		for (i=cnt+1; i<=16; ++i) {			if (cmd(i, BBSys.CMD_STATUS)>=0) {				error(Err.WRONG_MS_CNT);			}		}		return true;	}/***	init all MS for real action.*/	private static boolean initMS() {		getTemp();		return setVals();	}	private static void getTemp() {		int i;		if (cmdAll(BBSys.CMD_TEMP)) {			for (i=0; i<cnt; ++i) {				temp[i] = Temp.calc((ret[i]<<3)+17000);				Timer.wd();			}		}	}	private static boolean setVals() {				boolean ok = true;		int i;		if (!cmdAll(BBSys.CMD_SET_DOWNCNT, downCnt)) {			comErr();		}		if (!cmdAll(BBSys.CMD_SET_UPCNT, upCnt)) {			comErr();		}		if (!cmdAll(BBSys.CMD_SET_MAXCNT, maxCnt)) {			comErr();		}		Timer.wd();		return true;	}/***	check all MS and state of Leitung.*/	public static void chkMS() {		boot();		chkLtg();		Timer.wd();		powerOff();	}/***	all MS in service mode*/	public static void serviceUp() {		for (int i=0; i<cnt; ++i) {			maxCnt[i] = 0;				// keine Ueberw. im Serv.mode		}		boot();		initMS();		if (!cmdAll(BBSys.CMD_SET_STATE, BBSys.MS_SERVICE)) {			comErr();		}		Menu.msg(Texte.serviceUp, Texte.posein);		powerOff();	}	public static void serviceDown() {		for (int i=0; i<cnt; ++i) {			maxCnt[i] = 0;				// keine Ueberw. im Serv.mode		}		boot();		initMS();		if (!cmdAll(BBSys.CMD_SET_STATE, BBSys.MS_SERVICE)) {			comErr();		}		Menu.msg(Texte.serviceDown, Texte.posein);		powerOff();	}/***	set values*/	public static void servAfterUp(int nr) {		downCnt[nr] = servCnt[nr];		maxCnt[nr] = lastCnt[nr];		if (downCnt[nr]<MIN_SENS_CNT) {			downCnt[nr] = MIN_SENS_CNT;			maxCnt[nr] = 0;			Menu.msgMast(nr+1, Texte.sukl);		} else if (downCnt[nr]>MAX_SENS_CNT) {			downCnt[nr] = MAX_SENS_CNT;			maxCnt[nr] = 0;			Menu.msgMast(nr+1, Texte.sugr);		}		Timer.wd();		Config.setMSmaxCnt(nr+1, maxCnt[nr]);		Config.setMSdwnCnt(nr+1, downCnt[nr]);		Timer.wd();	}	public static void servAfterDown(int nr) {		upCnt[nr] = servCnt[nr];		maxCnt[nr] = maxCnt[nr]-lastCnt[nr];		if (upCnt[nr]<MIN_SENS_CNT) {			upCnt[nr] = MIN_SENS_CNT;			maxCnt[nr] = 0;			Menu.msgMast(nr+1, Texte.sokl);		} else if (upCnt[nr]>MAX_SENS_CNT) {			upCnt[nr] = MAX_SENS_CNT;			maxCnt[nr] = 0;			Menu.msgMast(nr+1, Texte.sogr);		}		Timer.wd();		Config.setMSmaxCnt(nr+1, maxCnt[nr]);		Config.setMSupCnt(nr+1, upCnt[nr]);		Timer.wd();	}/***	save data on mast 1.*/	public static void backZs() {		boot();		if (cmd(1, BBSys.CMD_SET_STATE, BBSys.MS_DBG)<0) {			comErr();		}		Display.cls();		Display.line1(Texte.backZs);		int startPage = Flash.MS_DATA>>7;		int pages = (Flash.MS_DATA_LEN+127)/128;		int data;////	longer Msg timeout becaus CMD_FL_PROG takes long (about 15ms).//	restart after program//		Msg.slow = true;					// longer Msg timeout		for (int i=0; i<pages; ++i) {			boolean error = false;			if (cmd(1, BBSys.CMD_FL_PAGE, startPage+i)<0) { comErr(); }			for (int j=0; j<128; ++j) {				Timer.wd();				data = Flash.read(Flash.MS_DATA+i*128+j) & 0xff;				if ((data = Msg.exchg(1, BBSys.CMD_FL_DATA, data))<0) {		// only one try! addr autoincrement					error = true;					Timer.sleepWd(50);								// to ignore late replays					--i;											// program pgae again					break;				}			}			if (!error) {				if (Msg.exchg(1, BBSys.CMD_FL_PROG, 0)<0) { comErr(); }			}					}		powerOff();	}/***	restore data from mast 1.*/	public static void restZs() {		boot();		if (cmd(1, BBSys.CMD_SET_STATE, BBSys.MS_DBG)<0) {			comErr();		}		Display.cls();		Display.line1(Texte.restZs);		int startPage = Flash.MS_DATA>>7;		int pages = (Flash.MS_DATA_LEN+127)/128;		int data;		Msg.slow = true;		if (cmd(1, BBSys.CMD_FL_PAGE, startPage)<0) { comErr(); }		for (int i=0; i<Flash.MS_DATA_LEN; ++i) {			Timer.wd();			data = Msg.exchg(1, BBSys.CMD_FL_READ, 0);			if (data<0) { comErr(); }			Flash.write(Flash.MS_DATA+i, data);					}		powerOff();	}	private static void getServCnt() {		int i;		if (!cmdAll(BBSys.CMD_SERVICECNT)) {			comErr();		}		for (i=0; i<cnt; ++i) {			servCnt[i] = ret[i];		}	}/***	now go up!*/	public static void up() {		int i, val;		if (!boot()) return;		if (!initMS()) return;		ltg = LUNKNOWN;		Display.line1(Texte.goesUp);		Display.line2(Texte.empty);		Relais.resLu();		JopSys.wr(BBSys.BIT_LED_FO, BBSys.IO_LED);		Log.write(Log.UP_STARTED);		// reset cnt// TODO last realy known value!!!		if (!cmdAll(BBSys.CMD_SETCNT, 0)) {			comErr();		}		if (!cmdAll(BBSys.CMD_UP)) {			comErr();		}		Timer.wd();		runningLoop(BBSys.MS_UP);		getTemp();		if (isUp()) {			Display.line1(Texte.isUp);			Relais.setLo();			Log.write(Log.IS_UP);		}		Display.line2(Texte.empty);		powerOff();	}/***	now go down!*/	public static void down() {		int i, val;		if (!boot()) return;		if (!initMS()) return;		ltg = LUNKNOWN;		Display.line1(Texte.goesDown);		Display.line2(Texte.empty);		Relais.resLo();		JopSys.wr(BBSys.BIT_LED_FU, BBSys.IO_LED);		Log.write(Log.DOWN_STARTED);		// set cnt// TODO last realy known value!!!		if (!cmdAll(BBSys.CMD_SETCNT, maxCnt)) {			comErr();		}		if (!cmdAll(BBSys.CMD_DOWN)) {			comErr();		}		Timer.wd();		runningLoop(BBSys.MS_DOWN);		getTemp();		if (Station.isDown()) {			Display.line1(Texte.isDown);			Relais.setLu();			Log.write(Log.IS_DOWN);		}		Display.line2(Texte.empty);		powerOff();	}/***	Leitung faehrt.*/	private static void runningLoop(int dir) {		int i, val, min, max;		boolean running;		int cntStopped = 0;		// wait for autom stop of all		do {			cntStopped = 0;			if (!cmdAll(BBSys.CMD_STATUS)) {				comErr();			}			for (i=0; i<cnt; ++i) {				val = ret[i];				if (val==dir) {					;						// still runnig ... OK				} else if (val==BBSys.MS_RDY) {					++cntStopped;			// MS stopped				} else if (val==BBSys.MS_ERR) {					val = cmd(i+1, BBSys.CMD_ERRNR);					if (val>0) {						error(val, i+1);					} else {						error(Err.MS_ERR, i+1);					}				} else {					error(Err.MS_ERR, i+1);		// something wrong				}			}			max = -9999;			min = 9999;			if (!cmdAll(BBSys.CMD_CNT)) {				comErr();			}//Display.line2();			for (i=0; i<cnt; ++i) {				val = ret[i];				val = (val<<20)>>20;		// sign//Display.intVal(val);//Display.data(' ');				lastCnt[i] = val;				if (val<min) min = val;				if (val>max) max = val;			}			val = max-min;			if (val>MAX_DIFF) {				error(Err.MAX_DIFF);			} else if (val>CONTROL_DIFF && cntStopped==0) {				control(dir, min, max);			}// display maximum differenz for nowif (val<100 && val>0) {Display.line2();Display.data('0'+val/10);Display.data('0'+val%10);}			Clock.loop();			Timer.wd();		} while (cntStopped!=cnt);		getServCnt();		chkLtg();	}/***	control of MS.*	Send CMD_PAUSE to the 'fastest' stations.*/	private static void control(int dir, int min, int max) {		int i;		if (dir==BBSys.MS_UP) {			for (i=0; i<cnt; ++i) {				if (lastCnt[i] > min+CONTROL_DIFF) {					cmd(i+1, BBSys.CMD_PAUSE);				}			}		} else if (dir==BBSys.MS_DOWN) {			for (i=0; i<cnt; ++i) {				if (lastCnt[i] < max-CONTROL_DIFF) {					cmd(i+1, BBSys.CMD_PAUSE);				}			}		}	}}

⌨️ 快捷键说明

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