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

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

?? gpsreader.cs

?? 在wince下接收gps的數(shù)據(jù)
?? CS
?? 第 1 頁 / 共 3 頁
字號:
			}

			// Perform translation
			return _readData ? asciiConverter.GetString(data, translateStartPos, translateCount) : null;
		}

		// *************************************************************
		//   Read mode related methods and properties
		// *************************************************************

		/// <summary>
		/// Indicates whether the COMM Port driver supports reading entire GPS messages at once
		/// The preferred way to read data is to let the driver signal when a carriage-return (\n)
		/// is received and then we read the whole message at once.  Experimentation has shown that 
		/// some of the GPS devices that simulate a serial port do not support this mode.  In that 
		/// case, we need to read the port data character-by-character.
		/// On the GPS devices tested, support for character notification can be verified by attempting
		/// to set the EvtChar (event character) member of the DCB structure using SetCommState and then
		/// reading the DCB back with GetCommState.  If character notification is supported the returned
		/// DCB will contain the EvtChar that was set with SetCommState.  If it is not supported, EvtChar
		/// will contain 0.  Because its not possible to test every GPS in existence there is no way to be
		/// 100% sure that this test will always work but on the devices tested it has been reliable.
		/// </summary>
		/// <returns></returns>
		public bool DriverSupportsMessageMode()
		{
			// Verify that we know the port name
			if (_portName == portNameNotSet)
				throw new ApplicationException("<DriverSupportsMessageMode> Must set Port Name before calling this method") ;

			uint localPortHandle = INVALID_FILE_HANDLE ;
			DCB dcb = new DCB() ;

			// Check to see if port is currently open
			bool openPortLocally = _portHandle == INVALID_FILE_HANDLE ;
			// If port not open then open it, otherwise use current handle
			localPortHandle = openPortLocally ? OpenPort_Raw(_portName) : _portHandle ;
			if (localPortHandle == INVALID_FILE_HANDLE)
				throw new ApplicationException("<DriverSupportsMessageMode> Invalid port: " + _portName) ;

			// Get current port settings
			GetCommState(localPortHandle, dcb) ;
			// Attempt to set event character
			dcb.EvtChar = endOfGPSSentenceMarker ;
			SetCommState(localPortHandle, dcb) ;
			// Read port settings back
			GetCommState(localPortHandle, dcb) ;

			// if port opened locally - close it
			if (openPortLocally)
				CloseHandle(localPortHandle) ;

			// Check to see if driver accepted event character
            return dcb.EvtChar == endOfGPSSentenceMarker ;
		}

		/// <summary>
		/// Preferred Read Mode to use - Defaults to Auto
		/// In Auto, reader will attempt message mode if driver supports it, otherwise uses character-by-character mode
		/// Undefined doesn't make sense in this usage, so if someone tries to set the value to Undefined, make it Auto
		/// </summary>
		public ReadMode PreferredReadMode
		{
			get {return _preferredReadMode;}
			set {_preferredReadMode = (value == ReadMode.Undefined) ? ReadMode.Auto : value ;	}
		}

		/// <summary>
		/// Read Mode that the GPSReader is actually using
		/// Set to Undefined until reading is started
		/// </summary>
		public ReadMode ActiveReadMode
		{
			get {return _activeReadMode;}
		}

		// *************************************************************
		//   Other COMM port related methods
		// *************************************************************

		/// <summary>
		/// This method doesn't actually have anything to do with GPS reading but is helpful for determining
		/// which ports are available on the device
		/// The code simply attempts to open (and immediatly close) all COMM ports between COM1: and COM9:, if it opens
		/// successfully, then it is added to the port list
		/// </summary>
		/// <returns>string array of available ports</returns>
		public static string[] GetPortList()
		{
			ArrayList portList = new ArrayList() ;
			uint hPort = INVALID_FILE_HANDLE ;

			// Walk list of possible ports
			for (int i = 1; i < 10; i++)
			{
				string port = "COM" + i.ToString() + ":" ;
				hPort = OpenPort_Raw(port) ;
				if (hPort != INVALID_FILE_HANDLE)
				{
					portList.Add(port) ;
					CloseHandle(hPort) ;
				}
			}

			// Convert to regular string array
			return (string []) portList.ToArray(typeof(string)) ;
		}

		#region Constants
		private const uint            GENERIC_READ				= 0x80000000;
		private const uint            OPEN_EXISTING				= 3;
		private const uint            INVALID_FILE_HANDLE		= 0xFFFFFFFF ;
		private const uint            EV_RXFLAG					= 0x0002 ;

		private const int             baudRateNotSet			= 0 ;
		private const string          portNameNotSet			= "PortNotSet" ;
		private const ParitySetting   defaultParity				= ParitySetting.NoParity;
		private const StopBitsSetting defaultStopBits			= StopBitsSetting.OneStopBit ;
		private const byte            defaultByteSize			= 8 ;

		private const sbyte			  endOfGPSSentenceMarker	= (sbyte)'\n' ;
		private const int             MAX_MESSAGE				= 256 ;
		#endregion

		#region Private fields

		private string _portName = portNameNotSet ;				// COMM Port Name - must end with ":"
		private int _baudRate = baudRateNotSet ;				// COMM Port Baud Rate
		private ParitySetting _parity = defaultParity ;			// COMM Port Parity - Defaults to NoParity
		private StopBitsSetting _stopBits = defaultStopBits ;	// COMM Port Stop Bits - Defaults to OneStopBit
		private byte _byteSize = defaultByteSize ;				// COM Port Byte Size - Defaults to 8 bits/byte

		private uint _portHandle = INVALID_FILE_HANDLE ;		// COMM Port File Handle
		private Thread _gpsReadThread ;							// Reader Thread
		private bool _readData = false ;						// Indicates whether read loop should continue

		// Read mode indicates how messages should be read.  The most efficient is to read whole messages
		//  from the COMM port but not all GPS drivers support this mode.  The alternative is to manually
		//  build the messages by reading a character at a time from the driver.
		private ReadMode _preferredReadMode = ReadMode.Auto ;	// COMM Port Preferred Read Mode - Auto lets the reader decide
		private ReadMode _activeReadMode = ReadMode.Undefined ; // COMM Port Read Mode being used - Undefined until reading starts

		// gpsSentence is populated by the GPS read thread and consumed by the UI Thread.  No lock
		//  is currently required because the GPS read thread uses Control.Invoke, which is synchronous, to signal the UI thread.
		// If the code is ever changed to use an asynchronous notification then gpsSentence will need to be protected from simulaneous
		//  access.  
		private string gpsSentence ;							// Represents the current GPS Sentence
		
		#endregion

		#region Cleanup
		/// <summary>
		/// Terminates GPS reading as part of dispose process
		/// </summary>
		/// <param name="disposing"></param>
		protected override void Dispose(bool disposing)
		{
			if (disposing)
				ClosePort() ;
			GC.SuppressFinalize(this) ;
		}

		/// <summary>
		/// Catch all cleanup - if StopRead was never called and Dispose wasn't called then
		/// force shutdown as part of Garbage Collection - hopefully this method is never used
		/// </summary>
		~GPSReader()
		{
			ClosePort() ;
		}
		#endregion

		#region Event Dispatch Helper Methods
		/// <summary>
		/// Raise Events back to listeners
		/// These are helper methods to raise events to the UI layer.  Because updating UI elements from
		///  background threads is considered unsafe, these methods are initiated from the background reader
		///  thread using this.Invoke which causes these methods to run on the same thread that the GPSReader
		///  class was originally created on (usually the same thread as the application UI).  These methods
		///  now do a regular event fire to notify the UI of the actual event.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void DispatchGPSMessage(object sender, EventArgs e)
		{
			GPSEventArgs arg = new GPSEventArgs(this.gpsSentence) ;

			if (OnGPSMessage != null)
				OnGPSMessage(this, arg) ;
		}

		private void DispatchGPSReadStart(object sender, EventArgs e)
		{
			if (OnGPSReadStart != null)
				OnGPSReadStart(this, EventArgs.Empty) ;
		}

		private void DispatchGPSReadStop(object sender, EventArgs e)
		{
			if (OnGPSReadStop != null)
				OnGPSReadStop(this, EventArgs.Empty) ;
		}
		#endregion

		#region COMM Port Housekeeping Methods

		/// <summary>
		/// Open COMM Port
		/// Configures the Port communication values and timeouts
		/// </summary>
		private void OpenPort()
		{
			if (_portHandle == INVALID_FILE_HANDLE)  // Only open if not yet opened
			{
				_portHandle = OpenPort_Raw(_portName) ;		
				if (_portHandle == INVALID_FILE_HANDLE)
					throw new ApplicationException("<OpenPort> Unable to Open Port: " + _portName) ;

				System.Threading.Thread.Sleep(100) ;	// Some experiments showed problems when the state
														//  was set without a short pause after Open

				_activeReadMode = DetermineActiveReadMode() ;  // Determine Read Mode to use

				ConfigurePort(_baudRate, _parity, _byteSize, _stopBits) ;
				SetReadTimeOuts() ;
			}
		}

		/// <summary>
		/// Determine the active read mode to use based on the preferred read mode and driver capability
		/// Defaults to character mode because works with all drivers
		/// Will attempt message mode if Message or Auto preferred - will downgrade to Character if not supported
		/// </summary>
		/// <returns>ReadMode to use</returns>
		private ReadMode DetermineActiveReadMode()
		{
			ReadMode returnVal = ReadMode.Character ;	// Default to character - everyone supports it

			// If Message mode or Auto preferred - Set active to Message Mode if the driver supports it
			if (_preferredReadMode == ReadMode.Message || _preferredReadMode == ReadMode.Auto)
			{
				if (DriverSupportsMessageMode())
					returnVal = ReadMode.Message ;
			}

			return returnVal ;
		}

		/// <summary>
		/// Close COMM port
		/// </summary>
		private void ClosePort()
		{
			if (_portHandle != INVALID_FILE_HANDLE)
			{
				CloseHandle(_portHandle) ;
				_portHandle = INVALID_FILE_HANDLE ;
			}
		}

		/// <summary>
		/// Set COMM port configuration values
		///  Baud Rate, Parity (default: NoParity), Bits per Byte (default: 8) and Stop Bits (default: OneStopBit)
		///  If using MessageMode, the event character is set to carriage-return (\n) 
		/// </summary>
		/// <param name="baudRate"></param>
		/// <param name="parity"></param>
		/// <param name="byteSize"></param>
		/// <param name="stopBits"></param>
		private void ConfigurePort(int baudRate, ParitySetting parity, byte byteSize, StopBitsSetting stopBits)
		{
			DCB dcb = new DCB() ;
	
			dcb.BaudRate = (uint) baudRate ;
			dcb.Parity = parity ;
			dcb.ByteSize = byteSize;
			dcb.StopBits = stopBits;
			dcb.EvtChar = _activeReadMode == ReadMode.Message ? (sbyte)'\n' : (sbyte)0 ;

			SetCommState (_portHandle, dcb); 
		}

		/// <summary>
		/// Sets COMM Port read timeout values
		/// Hands off to the proper SetReadTimeOuts method based on the active read mode
		/// </summary>
		private void SetReadTimeOuts()
		{
			if (_activeReadMode == ReadMode.Message)
				SetReadTimeOuts_MessageMode() ;
			else
				SetReadTimeOuts_CharacterMode() ;
		}

		/// <summary>
		/// Sets COMM Port read timeout values
		/// Using minimal timeout values because we don't try to read from the COMM port
		///  until we are signaled that a carriage-return ('\n') has been recevied.  As a
		///  result we already know that we have all of the data so no need to wait to see what
		///  comes.
		/// </summary>
		private void SetReadTimeOuts_MessageMode()
		{
			COMMTIMEOUTS timeOuts = new COMMTIMEOUTS();

			timeOuts.ReadIntervalTimeout = 10 ; 
			timeOuts.ReadTotalTimeoutMultiplier = 0 ; 
			timeOuts.ReadTotalTimeoutConstant = 0 ; 
			timeOuts.WriteTotalTimeoutMultiplier = 0 ;
			timeOuts.WriteTotalTimeoutConstant = 0 ;
			SetCommTimeouts(_portHandle, timeOuts) ;
		}

		/// <summary>
		/// Use long timeout multiplier so that we wait efficiently between GPS messages.  The
		/// interval timeout doesn't matter for us because we read the data one character at a
		/// time in character mode.
		/// </summary>
		private void SetReadTimeOuts_CharacterMode()
		{
			COMMTIMEOUTS timeOuts = new COMMTIMEOUTS();

			timeOuts.ReadIntervalTimeout = 0 ; 
			timeOuts.ReadTotalTimeoutMultiplier = 2000 ; 
			timeOuts.ReadTotalTimeoutConstant = 0 ; 
			timeOuts.WriteTotalTimeoutMultiplier = 0 ;
			timeOuts.WriteTotalTimeoutConstant = 0 ;
			SetCommTimeouts(_portHandle, timeOuts) ;
		}
		#endregion

		#region Wrappers over Win32 Methods
		/// <summary>
		/// Wrapper method to simplify the opening of the COMM port
		///  Port name must be of the form COMx: - the colon is required
		/// </summary>
		/// <param name="portName"></param>
		/// <returns></returns>
		private static uint OpenPort_Raw(string portName)
		{
			return CreateFile(portName, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, IntPtr.Zero);
		}

		/// <summary>
		/// Wrapper method to simplify reading a GPS sentence from the COMM port
		///  Method blocks until the COMM port driver receives a CR ('\n') or the COMM port is closed
		///  Return value indicates if any data was read - A 'false' return value occurs in one of 3 scenarios
		///  1. COMM port was closed, which usually indicates that StopRead has been called
		///  2. An error has occurred on the COMM port
		///  3. The read has timed out - this should never happen because we don't read until
		///     were notified by the COMM port driver that the carriage-return ('\n') has arrived
		/// </summary>
		/// <param name="hPort"></param>
		/// <param name="numBytes"></param>
		/// <param name="buffer"></param>
		/// <param name="numBytesRead"></param>

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩中文另类| 久久综合成人精品亚洲另类欧美| 午夜久久久久久久久久一区二区| 久久中文娱乐网| 在线观看av一区二区| 激情久久五月天| 亚洲成人激情av| 中文字幕免费观看一区| 欧美一区二区在线不卡| 色诱亚洲精品久久久久久| 狠狠色丁香久久婷婷综合_中| 亚洲综合视频网| 成人欧美一区二区三区| 精品国产乱码久久久久久久| 日本高清无吗v一区| 成人18视频在线播放| 精品一二线国产| 日韩成人免费在线| 亚欧色一区w666天堂| 中文字幕佐山爱一区二区免费| 精品国精品自拍自在线| 欧美卡1卡2卡| 色婷婷国产精品久久包臀| 国产成人免费在线视频| 国产综合久久久久影院| 日韩成人午夜精品| 亚洲v精品v日韩v欧美v专区| 亚洲欧美日韩精品久久久久| 国产亚洲精品福利| 2020国产精品自拍| 精品久久人人做人人爰| 日韩欧美电影一区| 欧美一区二区视频在线观看| 在线成人免费视频| 欧美二区在线观看| 欧美日本韩国一区二区三区视频| 一本大道久久a久久精二百 | 日韩欧美国产一二三区| 在线这里只有精品| 在线免费视频一区二区| 色妞www精品视频| 一本色道久久综合狠狠躁的推荐| 99久久伊人久久99| 99国内精品久久| 91视视频在线观看入口直接观看www| 国产91色综合久久免费分享| 国产精品99久| 91视频91自| 欧美性色aⅴ视频一区日韩精品| 日本韩国欧美国产| 在线电影一区二区三区| 日韩欧美亚洲国产另类| 精品国精品自拍自在线| 国产欧美日韩综合精品一区二区| 中文字幕成人网| 亚洲三级理论片| 亚洲午夜一区二区| 毛片av一区二区| 国产传媒日韩欧美成人| 成人av电影在线网| 欧美影院精品一区| 精品久久国产字幕高潮| 欧美国产日韩a欧美在线观看| 亚洲欧美日本在线| 天堂在线一区二区| 国产一区二区三区美女| 久久久久久夜精品精品免费| 日本一区二区视频在线观看| 亚洲色欲色欲www在线观看| 香蕉久久夜色精品国产使用方法| 另类综合日韩欧美亚洲| 国产盗摄精品一区二区三区在线| 91麻豆精品秘密| 88在线观看91蜜桃国自产| 久久综合九色综合欧美就去吻| 欧美激情一区二区三区蜜桃视频| 亚洲少妇中出一区| 久久精品理论片| 99精品视频在线观看| 欧美色网站导航| 国产日韩欧美在线一区| 亚洲风情在线资源站| 国产剧情在线观看一区二区| 日本韩国一区二区三区| 亚洲精品一区二区三区99| 最新不卡av在线| 精彩视频一区二区三区| 一本色道久久综合精品竹菊| 欧美成人精品3d动漫h| 亚洲特黄一级片| 黑人巨大精品欧美一区| 欧美亚洲动漫精品| 欧美国产综合色视频| 五月天国产精品| 91亚洲精品一区二区乱码| 日韩欧美久久一区| 亚洲国产sm捆绑调教视频| 国产福利一区二区三区视频| 欧美日韩一区二区电影| 国产精品无遮挡| 老司机一区二区| 欧美人妇做爰xxxⅹ性高电影| 粉嫩av一区二区三区在线播放| 欧美三级乱人伦电影| 中文字幕一区二区三区蜜月| 蜜臂av日日欢夜夜爽一区| 欧美性生活久久| 国产精品免费aⅴ片在线观看| 蜜臀久久久久久久| 欧美在线高清视频| 国产精品久久久久三级| 国产综合久久久久影院| 欧美精品99久久久**| 亚洲男人天堂一区| 成人免费视频app| 久久你懂得1024| 久久99精品一区二区三区| 欧美日韩情趣电影| 一区二区在线观看av| 99精品国产一区二区三区不卡| 2020国产精品自拍| 精品一区二区在线免费观看| 91精品国产综合久久久蜜臀图片| 亚洲精品成人天堂一二三| 成人爽a毛片一区二区免费| 国产亚洲欧美在线| 国产精品一区二区黑丝| 亚洲精品一区二区三区四区高清| 丝袜亚洲另类丝袜在线| 欧美高清你懂得| 日韩电影在线免费| 91麻豆精品国产91久久久更新时间| 艳妇臀荡乳欲伦亚洲一区| 在线视频国产一区| 亚洲精品国产精品乱码不99| 91在线观看美女| 亚洲精品视频在线看| 91国偷自产一区二区开放时间 | 欧美本精品男人aⅴ天堂| 日本最新不卡在线| 欧美精品三级日韩久久| 欧美aaaaaa午夜精品| 日韩精品中文字幕一区二区三区| 日本午夜一区二区| 日韩精品一区二区三区中文不卡| 久久精品国产一区二区三| 精品美女在线播放| 成人午夜又粗又硬又大| 一区在线中文字幕| 在线观看欧美精品| 日韩黄色免费网站| 2023国产精华国产精品| 不卡高清视频专区| 一区二区三区影院| 91精品国产综合久久福利| 国产综合色视频| 亚洲视频免费在线观看| 91国在线观看| 美日韩黄色大片| 久久久三级国产网站| av激情综合网| 亚洲成人黄色影院| 久久久三级国产网站| 99re在线精品| 免费欧美在线视频| 国产日韩成人精品| 精品视频123区在线观看| 久久不见久久见中文字幕免费| 久久精品欧美日韩| 欧洲av一区二区嗯嗯嗯啊| 美女视频网站久久| 中文字幕一区二区在线观看| 有坂深雪av一区二区精品| 91精品国产综合久久精品app| 国产一二精品视频| 亚洲国产乱码最新视频| 久久免费电影网| 在线一区二区三区四区| 蜜桃视频在线观看一区| 国产精品护士白丝一区av| 欧美一区二区视频在线观看2020| 国产精品亚洲人在线观看| 亚洲成人一区二区| 国产日韩欧美电影| 欧美一区二区三区在| 99在线精品一区二区三区| 免费高清视频精品| 亚洲欧美激情一区二区| 日韩精品专区在线影院观看| 色就色 综合激情| 国产一区二区三区黄视频| 亚洲国产日韩精品| 中文字幕精品一区| 日韩欧美国产三级| 欧美性xxxxxx少妇| 99九九99九九九视频精品| 国产一区二区在线电影| 五月天激情综合| 亚洲精品水蜜桃| 成人欧美一区二区三区小说|