亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? jcyecomm.java

?? 一個(gè)多機(jī)器人的仿真平臺(tái)
?? JAVA
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
package EDU.cmu.cs.coral.cye;import java.io.*;import Serialio.*;/** * Handles all of the communication between the JCyeSrv class  * and the Cye robot.  Thread is extended, to enable the CyeComm  * object to run in the background and poll the robot at a set frequency. * * If you are creating an instance of this class manually in your code, you * are almost certainly doing something wrong.  This class should only  * be created as a side effect of instantiating a JCyeSrv object. * * @author Brian Chemel and Tucker Balch * * @see java.lang.Thread * @see EDU.cmu.cs.coral.cye.JCyeSrv * @see EDU.cmu.cs.coral.cye.JCyeMsg * @see EDU.cmu.cs.coral.cye.JCyeStatus */public class JCyeComm extends Thread 	{	/*	 * Useful Constants	 */	/**	 * Indicates the connection to the robot is wired (no radio 	 * warm up reqd).	 */	public final static int WIRED = 0;	/**	 * Indicates the connection is via old radio (must wait for warm up).	 */	public final static int OLD_RADIO = 1;	/**	 * Indicates the connection is via new radio (must send a bunch of padding chars).	 */	public final static int NEW_RADIO = 2;	/**	 * Indicates the connection is to an original robot.	 */	public final static byte ORIGINAL_ROBOT = 0;	/**	 * Indicates the connection is to a newer black robot;	 */	public final static byte BLACK_ROBOT = 1;	/**	 * Indicates the connection is to a newer orange robot;	 */	public final static byte ORANGE_ROBOT = 3;	/**	 * Indicates the connection is to a newer yellow robot;	 */	public final static byte YELLOW_ROBOT = 4;	/**	 * Indicates the connection is to a newer chrom robot;	 */	public final static byte CHROME_ROBOT = 5;	/*	 * Useful Constants	 */	    private final static int INIT_ATTEMPTS = 5;	private final static int TX_ATTEMPTS = 10;	private final static int SLEEP_TIME = 100;	private final static int RADIO_WARMUP_TIME = 45;	private final static int TX_DRAIN_TIME = 40;	    private final static int PADDING_CHARS = 40;	    private final static byte PADDING_CHARACTER = (byte)240;	private final static boolean DEBUG = false;	/*	 * Class Data	 */ 	private String dev_name = "/dev/ttyS0";	private int baudrate = 9600;	private SerialPortLocal serPort;	private SerialConfig serCfg;	private int SendMsgNum;	private int AckMsgNum;	private int lastX;	private int lastY;	private int lastH;	private double lastB;	private boolean sawObstacle;	private int connection = WIRED;	private byte id = 0;	/** 	 * The constructor for class <code>JCyeComm</comm>. 	 * Initializes the serial port driver, then carries 	 * out the ISTART/ASTART sequence to initialize the robot.	 *	 * @param d the name of the serial device to open.	 * @param b baud rate (9600 or 19200).	 * @param c connection type (WIRED or OLD_RADIO or NEW_RADIO).	 * @param i ID number.	 */	protected JCyeComm(String d, int b, int c, byte i) throws JCyeException		{		dev_name = d;		if (b == 9600)			baudrate = SerialConfig.BR_9600;		else if (b == 19200)			baudrate = SerialConfig.BR_19200;		else			throw (new JCyeException(" invalid baud rate"));		connection = c;		if ((c != WIRED)&&(c != OLD_RADIO)&&(c != NEW_RADIO))			throw (new JCyeException(" invalid connection type"));		if(DEBUG) {		    System.out.println("Connection type: ");		    switch(c) {		    case(WIRED):			System.out.println(" Wired");			break;		    case(OLD_RADIO):			System.out.println(" Old Radio");			break;		    case(NEW_RADIO):			System.out.println(" New Radio");			break;		    default:			System.out.println(" Unknown");			break;		    }		}		id = i;		SendMsgNum = 0;		AckMsgNum = 0;		try			{			InitializeSerialPort();			}		catch (IOException e)			{			System.err.println(e);			throw (new JCyeException("Couldn't intialize port"));			}		boolean initSuccess = InitializeRobot();		int initRetry = 0;		while((initSuccess == false) && (initRetry < INIT_ATTEMPTS)) {		    initSuccess = InitializeRobot();		    initRetry++;		}		if(initSuccess == false)			{	    		throw (new JCyeException("Error: Unable to initialize serial comm with robot."));			}		}	/**	 * Initialize the <code>JCyeComm</code> object's 	 * <code>SerialPortLocal</code>.  First creates a 	 * <code>SerialConfig</code> object with the proper settings,	 * then uses that to create the <code>SerialPortLocal</code>.	 */	private void InitializeSerialPort() throws IOException		{		    if(DEBUG) {			System.out.println("Initializing serial connection with: ");			System.out.println(" device name: " + dev_name);			System.out.println(" baud rate: " + baudrate);		    } 		// Create a SerialConfig object with the 		// proper settings for OLD radio link		serCfg = new SerialConfig(dev_name);		serCfg.setBitRate(baudrate);		serCfg.setDataBits(serCfg.LN_8BITS);		serCfg.setParity(serCfg.PY_NONE);		serCfg.setStopBits(serCfg.ST_1BITS);		serCfg.setHandshake(serCfg.HS_NONE);		serCfg.setHardFlow(false);		// Create the SerialPortLocal object		serPort = new SerialPortLocal(serCfg);		serPort.setTimeoutRx(100);		serPort.setTimeoutTx(5);		serPort.setDTR(true);		serPort.txFlush();		serPort.rxFlush();		}	/**	 * Initializes the connection with the Cye robot.	 * This consists of sending an ISTART message, and 	 * waiting for the ASTART acknowledgement back from 	 * the robot.	 *	 * @return the success (<code>true</code>) or failure 	 * of the initialization sequence.	 */	private boolean InitializeRobot()		{		// Send ISTART message		JCyeMsg InitMsg = new JCyeMsg(id);		InitMsg.SetRxMsgNum(0);		InitMsg.SetTxMsgNum(0);		InitMsg.Add(InitMsg.CMD_ISTART);		JCyeMsg ackMsg = TransmitUntilAck(InitMsg, TX_ATTEMPTS);		// Look for ASTART message, return false if no valid 		// ASTART response.		if(ackMsg.GetBufByte(2) == ackMsg.CMD_ASTART) return true;		return false;		}	/**	 * Sends a message (represented as an object of class 	 * <code>JCyeMsg</code>) to the Cye robot, and waits 	 * for an acknowledgement or retry failure.	 * 	 * @param Msg the <code>JCyeMsg</code> to send to the robot.	 *	 * @return the acknowledgement message from the robot, 	 *  represented as an object of type <code>JCyeMsg</code>.	 */	protected JCyeMsg SendMsg (JCyeMsg Msg)		{		JCyeMsg reply = TransmitUntilAck(Msg, TX_ATTEMPTS);		return reply;		}	/**	 * The background <code>run</code> method for 	 * <code>JCyeComm</code>.  This method polls the 	 * robot (with a <code>CMD_POLL_REQUEST</code> message,	 * then goes back to sleep for <code>SLEEP_TIME</code> ms.	 */	public void run()		{		while(true) 			{			// If we're idle, poll the robot			JCyeMsg PollMsg = new JCyeMsg(id);			PollMsg.Add(PollMsg.CMD_POLL_REQUEST);			// PollMsg.Add(PollMsg.CMD_REQUEST_STATE);			TransmitUntilAck(PollMsg, 1);    			// Go to sleep for SLEEP_TIME.			try 				{				Thread.sleep(SLEEP_TIME);				}			catch (InterruptedException e) 				{				System.err.println("Error in JCyeComm run.");				System.err.println(e);				}			}		}	/**	 * Transmit a <code>JCyeMsg</code> over the serial port, 	 * with no acknowledgement or retry.  First, call the 	 * <code>JCyeMsg</code>'s <code>toTransmitArray</code> method, 	 * which mashes all of the random message fields down 	 * into a byte array.  Then, spit that flattened byte 	 * array out the serial port.	 *	 * @param Msg the <code>JCyeMsg</code> to transmit.	 */	private void Transmit(JCyeMsg Msg)		{		JCyeMsg txMsg = Msg.toTransmitArray();		int l = txMsg.GetMsgLen() - 1;		try 			{			    if (connection == OLD_RADIO) {				serPort.setDTR(false);				try					{					Thread.sleep(RADIO_WARMUP_TIME);					}				catch (Exception e) {}			    }			    			    if (connection == NEW_RADIO) {				// Write 40 padding chars to sync radio				for(int i = 0; i < PADDING_CHARS; i++) {				    serPort.putByte(PADDING_CHARACTER);				}			    }							    serPort.putData(txMsg.GetMsgBuf(), 0, 				txMsg.GetMsgLen() - 1);			    while(serPort.txBufCount() != 0);			    if (connection == OLD_RADIO) {				try					{					Thread.sleep(TX_DRAIN_TIME);					}				catch (Exception e) {}				serPort.setDTR(true);			    }			}		catch (Exception e) 			{			/*--- Just log the error for now ---*/			System.err.println("Error in JCyeComm Transmit.");			System.err.println(e);			// System.exit(1);			}		}	/**	 * Transmit a <code>JCyeMsg</code> until we receive an 	 * acknowledge message, with a specified number of retry 	 * attempts if we're not immediately successful.	 * This method makes use of the methods <code>Transmit</code> 	 * and <code>Receive</code> to do the dirty work.	 *	 * @param Msg the <code>JCyeMsg</code> to transmit.	 * @param attempts the number of retry attempts permitted 	 * before we return failure.	 *	 * @return the acknowledgement <code>JCyeMsg</code> 	 *  received from the robot. In case of	 *  failure, MsgID will be set to -1.	 */	private synchronized JCyeMsg TransmitUntilAck(JCyeMsg Msg, int attempts)		{		Msg.SetMsgID(Msg.GetBufByte(0));		switch(Msg.GetMsgID()) 			{			case JCyeMsg.CMD_ISTART:    				SendMsgNum = 0;    				Msg.SetTxMsgNum(SendMsgNum);				break;			case JCyeMsg.CMD_POLL_REQUEST:				Msg.SetTxMsgNum(SendMsgNum);				break;			default:				SendMsgNum++;				SendMsgNum &= 0x0F;				Msg.SetTxMsgNum(SendMsgNum);				break;			}		JCyeMsg rxMsg = new JCyeMsg(id);		boolean gotAck = false;		boolean polling = false;		int txFailures = 0;		Msg.SetRxMsgNum(AckMsgNum);		if(DEBUG) 			{			System.out.println("Transmitting Message: ");			System.out.print(" Msg ID:" + Msg.GetMsgID());			if(Msg.GetMsgID() > 32) 				System.out.println(" (" 				+ (char)Msg.GetMsgID() + ")");

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲免费在线观看视频| 91丨国产丨九色丨pron| 欧美日韩中字一区| 自拍偷自拍亚洲精品播放| 国产精品一区三区| 国产日韩欧美综合在线| 麻豆成人久久精品二区三区小说| 欧美三日本三级三级在线播放| 亚洲伦理在线精品| 在线观看亚洲a| 五月天婷婷综合| 精品国产乱码久久久久久浪潮| 日韩av一区二区在线影视| 欧美精品一卡二卡| 久久精品国内一区二区三区| 欧美岛国在线观看| 国产风韵犹存在线视精品| 日本一区二区电影| 91伊人久久大香线蕉| 天堂在线亚洲视频| 久久精品亚洲国产奇米99| 91亚洲精品久久久蜜桃网站| 亚洲国产精品嫩草影院| 欧美tickling网站挠脚心| 成人精品gif动图一区| 偷拍亚洲欧洲综合| 国产目拍亚洲精品99久久精品| 91国产成人在线| 国产电影一区二区三区| 亚洲综合无码一区二区| 日韩一区二区免费高清| 94-欧美-setu| 国产乱码精品一区二区三区av | 97精品久久久久中文字幕| 国产成人夜色高潮福利影视| 亚洲一区二区偷拍精品| 亚洲国产精品t66y| 精品美女一区二区| 在线播放中文一区| 日本韩国欧美三级| k8久久久一区二区三区| 国产原创一区二区| 日本不卡1234视频| 天堂影院一区二区| 亚洲综合男人的天堂| 亚洲欧美二区三区| 国产精品国产三级国产aⅴ入口 | 亚洲高清视频的网址| 亚洲欧洲日韩在线| 中文字幕亚洲一区二区av在线| 久久久亚洲午夜电影| 日韩一区二区三区精品视频| 在线播放国产精品二区一二区四区 | 日韩国产一区二| 亚洲成人第一页| 久热成人在线视频| 国产综合色在线视频区| 国产综合成人久久大片91| 国产福利一区二区三区| proumb性欧美在线观看| 91麻豆.com| 欧美天堂亚洲电影院在线播放| 欧美日韩一区久久| 欧美精品xxxxbbbb| 国产日韩成人精品| 亚洲综合清纯丝袜自拍| 麻豆成人免费电影| 高清不卡在线观看| 欧美网站一区二区| 国产亚洲短视频| 亚洲一区二区视频在线| 看片的网站亚洲| 91福利视频久久久久| 欧美电影免费观看高清完整版在| 中文字幕av不卡| 丝袜美腿亚洲一区| 成人性生交大合| 91精品欧美久久久久久动漫| 久久人人爽爽爽人久久久| 一区二区三区鲁丝不卡| 懂色av一区二区三区免费看| 欧美高清一级片在线| 中文字幕中文字幕一区| 在线观看免费一区| 久久午夜老司机| 国产精品欧美一区喷水| 欧美成人一区二区三区| 国产日韩欧美制服另类| 欧美成人免费网站| 亚洲国产毛片aaaaa无费看| www亚洲一区| 国产精品久久网站| 国内精品免费**视频| 欧美日韩国产一级片| 综合分类小说区另类春色亚洲小说欧美| 免费一区二区视频| 欧美猛男超大videosgay| 国产精品美女www爽爽爽| 激情综合色播五月| 欧美午夜精品免费| 久久久久久久综合色一本| 爽好多水快深点欧美视频| 在线看不卡av| 成人欧美一区二区三区白人| 91亚洲精品一区二区乱码| |精品福利一区二区三区| 色婷婷国产精品久久包臀 | 精品亚洲成av人在线观看| 欧美v亚洲v综合ⅴ国产v| 国内偷窥港台综合视频在线播放| 日韩欧美国产一区二区在线播放| 日本在线播放一区二区三区| 欧美电视剧免费全集观看| 国产精品一区一区| 亚洲欧美日韩国产成人精品影院| 91在线你懂得| 婷婷久久综合九色国产成人| 7777精品伊人久久久大香线蕉经典版下载 | 91黄色激情网站| 日本不卡一区二区三区| 久久影院视频免费| 99re8在线精品视频免费播放| 亚洲第一激情av| 2024国产精品| 欧美日韩免费一区二区三区视频 | 国产日韩欧美一区二区三区乱码 | 国内精品国产成人国产三级粉色| 国产精品午夜春色av| 欧美久久免费观看| 成人在线综合网| 日韩精品免费视频人成| ...av二区三区久久精品| 欧美zozozo| 在线不卡中文字幕播放| av欧美精品.com| 国产精品18久久久久久久久久久久| 亚洲午夜久久久| 亚洲美女视频在线观看| 国产欧美日韩三区| 日韩一区二区三区电影| 欧美人与禽zozo性伦| 91片在线免费观看| 成人黄色一级视频| 99久久免费精品| 成人动漫一区二区在线| 国产成人av一区二区三区在线观看| 另类综合日韩欧美亚洲| 视频一区视频二区中文| 一区二区三区鲁丝不卡| 亚洲一区二区精品3399| 亚洲资源在线观看| 亚洲成人在线免费| 奇米亚洲午夜久久精品| 天天影视涩香欲综合网| 青草av.久久免费一区| 激情文学综合插| 国产成人免费高清| 91婷婷韩国欧美一区二区| 色8久久人人97超碰香蕉987| 日本道色综合久久| 欧美日韩国产大片| 精品国产精品网麻豆系列| 欧美精品一区二区三| 国产精品久久久久久久久久久免费看| 久久综合五月天婷婷伊人| 国产精品夫妻自拍| 爽好久久久欧美精品| 国产盗摄一区二区三区| 欧美性猛交xxxxxx富婆| 精品国产一区久久| 一区二区三区四区在线免费观看| 亚洲不卡av一区二区三区| 国产一级精品在线| 欧美性猛交xxxx乱大交退制版| 精品久久久久久久久久久久久久久 | 欧美亚洲综合网| 亚洲国产经典视频| 日本伊人色综合网| 91成人免费在线视频| 久久色在线视频| 天堂久久一区二区三区| www.99精品| 中文字幕精品一区| 国产在线视频一区二区三区| 欧美做爰猛烈大尺度电影无法无天| 亚洲精品一区二区三区影院| 亚洲图片欧美色图| 91免费版在线| 国产欧美日本一区二区三区| 精品在线播放午夜| 色综合欧美在线视频区| 亚洲欧美在线aaa| 国产jizzjizz一区二区| 国产亚洲欧美色| 国产精品一区二区在线看| 精品国产一区二区亚洲人成毛片| 日韩激情av在线| 欧美日韩精品高清| 日韩精品91亚洲二区在线观看 | 欧美天堂一区二区三区|