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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? commbase.cs

?? 用C#語言編寫
?? CS
?? 第 1 頁 / 共 4 頁
字號:
			public long InQueueSize {get{return (long)inQueueSize;}}
			/// <summary>
			/// Total size of output queue (0 means information unavailable)
			/// </summary>
			public long OutQueueSize {get{return (long)outQueueSize;}}

			public override string ToString()
			{
				StringBuilder m = new StringBuilder("The reception queue is ", 60);
				if (inQueueSize == 0)
				{
					m.Append("of unknown size and ");
				}
				else
				{
					m.Append(inQueueSize.ToString() + " bytes long and ");
				}
				if (inQueue == 0)
				{
					m.Append("is empty.");
				}
				else if (inQueue == 1)
				{
					m.Append("contains 1 byte.");
				}
				else
				{
					m.Append("contains ");
					m.Append(inQueue.ToString());
					m.Append(" bytes.");
				}
				m.Append(" The transmission queue is ");
				if (outQueueSize == 0)
				{
					m.Append("of unknown size and ");
				}
				else
				{
					m.Append(outQueueSize.ToString() + " bytes long and ");
				}
				if (outQueue == 0)
				{
					m.Append("is empty");
				}
				else if (outQueue == 1)
				{
					m.Append("contains 1 byte. It is ");
				}
				else
				{
					m.Append("contains ");
					m.Append(outQueue.ToString());
					m.Append(" bytes. It is ");
				}
				if (outQueue > 0)
				{
					if (ctsHold || dsrHold || rlsdHold || xoffHold || xoffSent)
					{
						m.Append("holding on");
						if (ctsHold) m.Append(" CTS");
						if (dsrHold) m.Append(" DSR");
						if (rlsdHold) m.Append(" RLSD");
						if (xoffHold) m.Append(" Rx XOff");
						if (xoffSent) m.Append(" Tx XOff");
					}
					else
					{
						m.Append("pumping data");
					}
				}
				m.Append(". The immediate buffer is ");
				if (immediateWaiting)
					m.Append("full.");
				else
					m.Append("empty.");
				return m.ToString();
			}
		}

		/// <summary>
		/// Get the status of the queues
		/// </summary>
		/// <returns>Queue status object</returns>
		protected QueueStatus GetQueueStatus() 
		{
			Win32Com.COMSTAT cs;
			Win32Com.COMMPROP cp;
			uint er;

			CheckOnline();
			if (!Win32Com.ClearCommError(hPort, out er, out cs)) ThrowException("Unexpected failure");
			if (!Win32Com.GetCommProperties(hPort, out cp)) ThrowException("Unexpected failure");
			return new QueueStatus(cs.Flags, cs.cbInQue, cs.cbOutQue, cp.dwCurrentRxQueue, cp.dwCurrentTxQueue);
		}

		// JH 1.3. Added for this version.
		/// <summary>
		/// Test if the line is congested (data being queued for send faster than it is being dequeued)
		/// This detects if baud rate is too slow or if handshaking is not allowing enough transmission
		/// time. It should be called at reasonably long fixed intervals. If data has been sent during
		/// the interval, congestion is reported if the queue was never empty during the interval.
		/// </summary>
		/// <returns>True if congested</returns>
		protected bool IsCongested()
		{
			bool e;
			if (!dataQueued) return false;
			lock(empty) {e = empty[0]; empty[0] = false;}
			dataQueued = false;
			return !e;
		}

		/// <summary>
		/// True if the RTS pin is controllable via the RTS property
		/// </summary>
		protected bool RTSavailable { get { return (stateRTS < 2);}}
		
		/// <summary>
		/// Set the state of the RTS modem control output
		/// </summary>
		protected bool RTS 
		{
			set {
				if (stateRTS > 1) return;
				CheckOnline();
				if (value)
				{
					if (Win32Com.EscapeCommFunction(hPort, Win32Com.SETRTS))
						stateRTS = 1;
					else
						ThrowException("Unexpected Failure");
				}
				else
				{
					if (Win32Com.EscapeCommFunction(hPort, Win32Com.CLRRTS))
						//JH 1.3: Was 1, should be 0:
						stateRTS = 0;
					else
						ThrowException("Unexpected Failure");
				}
			}
			get {
				return (stateRTS == 1);
			}
		}

		/// <summary>
		/// True if the DTR pin is controllable via the DTR property
		/// </summary>
		protected bool DTRavailable { get { return (stateDTR < 2);}}
		
		/// <summary>
		/// The state of the DTR modem control output
		/// </summary>
		protected bool DTR {
			set {
				if (stateDTR > 1) return;
				CheckOnline();
				if (value)
				{
					if (Win32Com.EscapeCommFunction(hPort, Win32Com.SETDTR))
						stateDTR = 1;
					else
						ThrowException("Unexpected Failure");
				}
				else
				{
					if (Win32Com.EscapeCommFunction(hPort, Win32Com.CLRDTR))
						stateDTR = 0;
					else
						ThrowException("Unexpected Failure");
				}
			}
			get {
				return (stateDTR == 1);
			}
		}

		/// <summary>
		/// Assert or remove a break condition from the transmission line
		/// </summary>
		protected bool Break {
			set {
				if (stateBRK > 1) return;
				CheckOnline();
				if (value)
				{
					if (Win32Com.EscapeCommFunction(hPort, Win32Com.SETBREAK))
						stateBRK = 0;
					else
						ThrowException("Unexpected Failure");
				}
				else
				{
					if (Win32Com.EscapeCommFunction(hPort, Win32Com.CLRBREAK))
						stateBRK = 0;
					else
						ThrowException("Unexpected Failure");
				}
			}
			get {
				return (stateBRK == 1);
			}
		}

		/// <summary>
		/// Override this to provide settings. (NB this is called during Open method)
		/// </summary>
		/// <returns>CommBaseSettings, or derived object with required settings initialised</returns>
		protected virtual CommBaseSettings CommSettings() {return new CommBaseSettings();}

		/// <summary>
		/// Override this to provide processing after the port is openned (i.e. to configure remote
		/// device or just check presence).
		/// </summary>
		/// <returns>false to close the port again</returns>
		protected virtual bool AfterOpen() {return true;}

		/// <summary>
		/// Override this to provide processing prior to port closure.
		/// </summary>
		/// <param name="error">True if closing due to an error</param>
		protected virtual void BeforeClose(bool error) {}
		
		/// <summary>
		/// Override this to process received bytes.
		/// </summary>
		/// <param name="ch">The byte that was received</param>
		protected virtual void OnRxChar(byte ch) {}

		/// <summary>
		/// Override this to take action when transmission is complete (i.e. all bytes have actually
		/// been sent, not just queued).
		/// </summary>
		protected virtual void OnTxDone() {}

		/// <summary>
		/// Override this to take action when a break condition is detected on the input line.
		/// </summary>
		protected virtual void OnBreak() {}

		//JH 1.3: Deleted OnRing() which was never called: use OnStatusChange instead (Thanks Jim Foster)

		/// <summary>
		/// Override this to take action when one or more modem status inputs change state
		/// </summary>
		/// <param name="mask">The status inputs that have changed state</param>
		/// <param name="state">The state of the status inputs</param>
		protected virtual void OnStatusChange(ModemStatus mask, ModemStatus state) {}

		/// <summary>
		/// Override this to take action when the reception thread closes due to an exception being thrown.
		/// </summary>
		/// <param name="e">The exception which was thrown</param>
		protected virtual void OnRxException(Exception e) {}

		private void ReceiveThread() {
			byte[] buf = new Byte[1];
			uint gotbytes;
			bool starting;

			starting = true;
			AutoResetEvent sg = new AutoResetEvent(false);
			Win32Com.OVERLAPPED ov = new Win32Com.OVERLAPPED();

			IntPtr unmanagedOv;
			IntPtr uMask;
			uint eventMask = 0;
			unmanagedOv = Marshal.AllocHGlobal(Marshal.SizeOf(ov));
			uMask = Marshal.AllocHGlobal(Marshal.SizeOf(eventMask));

			ov.Offset = 0; ov.OffsetHigh = 0;
			ov.hEvent = sg.Handle;
			Marshal.StructureToPtr(ov, unmanagedOv, true);

			try
			{
				while(true) 
				{
					if (!Win32Com.SetCommMask(hPort, Win32Com.EV_RXCHAR | Win32Com.EV_TXEMPTY | Win32Com.EV_CTS | Win32Com.EV_DSR
						| Win32Com.EV_BREAK | Win32Com.EV_RLSD | Win32Com.EV_RING | Win32Com.EV_ERR))
					{
						throw new CommPortException("IO Error [001]");
					}
					Marshal.WriteInt32(uMask, 0);
					//JH 1.2: Tells the main thread that this thread is ready for action.
					if (starting) {startEvent.Set(); starting = false;}
					if (!Win32Com.WaitCommEvent(hPort, uMask, unmanagedOv)) 
					{
						if (Marshal.GetLastWin32Error() == Win32Com.ERROR_IO_PENDING) 
						{
							sg.WaitOne();
						}
						else
						{
							throw new CommPortException("IO Error [002]");
						}
					}
					eventMask = (uint)Marshal.ReadInt32(uMask);
					if ((eventMask & Win32Com.EV_ERR) != 0)
					{
						UInt32 errs;
						if (Win32Com.ClearCommError(hPort, out errs, IntPtr.Zero))
						{
							//JH 1.2: BREAK condition has an error flag and and an event flag. Not sure if both
							//are always raised, so if CE_BREAK is only error flag ignore it and set the EV_BREAK
							//flag for normal handling. Also made more robust by handling case were no recognised
							//error was present in the flags. (Thanks to Fred Pittroff for finding this problem!)
							int ec = 0;
							StringBuilder s = new StringBuilder("UART Error: ", 40);
							if ((errs & Win32Com.CE_FRAME) != 0) {s = s.Append("Framing,"); ec++;}
							if ((errs & Win32Com.CE_IOE) != 0) {s = s.Append("IO,"); ec++;}
							if ((errs & Win32Com.CE_OVERRUN) != 0) {s = s.Append("Overrun,"); ec++;}
							if ((errs & Win32Com.CE_RXOVER) != 0) {s = s.Append("Receive Cverflow,"); ec++;}
							if ((errs & Win32Com.CE_RXPARITY) != 0) {s = s.Append("Parity,"); ec++;}
							if ((errs & Win32Com.CE_TXFULL) != 0) {s = s.Append("Transmit Overflow,"); ec++;}
							if (ec > 0)
							{
								s.Length = s.Length - 1;
								throw new CommPortException(s.ToString());
							}
							else
							{
								if (errs == Win32Com.CE_BREAK)
								{
									eventMask |= Win32Com.EV_BREAK;
								}
								else
								{
									throw new CommPortException("IO Error [003]");
								}
							}
						}
						else
						{
							throw new CommPortException("IO Error [003]");
						}
					}
					if ((eventMask & Win32Com.EV_RXCHAR) != 0) 
					{
						do 
						{
							gotbytes = 0;
							if (!Win32Com.ReadFile(hPort, buf, 1, out gotbytes, unmanagedOv)) 
							{
								//JH 1.1: Removed ERROR_IO_PENDING handling as comm timeouts have now
								//been set so ReadFile returns immediately. This avoids use of CancelIo
								//which was causing loss of data. Thanks to Daniel Moth for suggesting this
								//might be a problem, and to many others for reporting that it was!

								int x = Marshal.GetLastWin32Error();

								throw new CommPortException("IO Error [004]");
							}
							if (gotbytes == 1) OnRxChar(buf[0]);
						} while (gotbytes > 0);
					}
					if ((eventMask & Win32Com.EV_TXEMPTY) != 0)
					{
						//JH1.3:
						lock(empty) empty[0] = true;
						OnTxDone();
					}
					if ((eventMask & Win32Com.EV_BREAK) != 0) OnBreak();
			
					uint i = 0;
					if ((eventMask & Win32Com.EV_CTS) != 0) i |= Win32Com.MS_CTS_ON;
					if ((eventMask & Win32Com.EV_DSR) != 0) i |= Win32Com.MS_DSR_ON;
					if ((eventMask & Win32Com.EV_RLSD) != 0) i |= Win32Com.MS_RLSD_ON;
					if ((eventMask & Win32Com.EV_RING) != 0) i |= Win32Com.MS_RING_ON;
					if (i != 0)
					{
						uint f;
						if (!Win32Com.GetCommModemStatus(hPort, out f)) throw new CommPortException("IO Error [005]");
						OnStatusChange(new ModemStatus(i), new ModemStatus(f));
					}
				}
			}
			catch (Exception e)
			{
				//JH 1.3: Added for shutdown robustness (Thanks to Fred Pittroff, Mark Behner and Kevin Williamson!), .
				Win32Com.CancelIo(hPort);
				if (uMask != IntPtr.Zero) Marshal.FreeHGlobal(uMask);
				if (unmanagedOv != IntPtr.Zero) Marshal.FreeHGlobal(unmanagedOv);

				if (!(e is ThreadAbortException))
				{
					rxException = e;
					OnRxException(e);
				}
			}
		}

		private bool CheckOnline()
		{
			if ((rxException != null) && (!rxExceptionReported))
			{
				rxExceptionReported = true;
				ThrowException("rx");
			}
			if (online) 
			{

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲激情av在线| 粉嫩高潮美女一区二区三区| 91丝袜呻吟高潮美腿白嫩在线观看| 久久电影国产免费久久电影 | 一区二区在线观看免费视频播放 | 久久不见久久见免费视频1| 日韩精品欧美精品| 石原莉奈一区二区三区在线观看 | 欧美调教femdomvk| 欧美日韩另类国产亚洲欧美一级| 欧美视频一区在线| 69堂精品视频| 精品精品国产高清a毛片牛牛 | 亚洲综合在线电影| 一区二区三区精密机械公司| 午夜国产不卡在线观看视频| 五月婷婷久久综合| 黄色日韩三级电影| 丁香五精品蜜臀久久久久99网站 | 国产日韩av一区二区| 国产精品电影一区二区三区| 一区2区3区在线看| 日韩高清国产一区在线| 狠狠色丁香久久婷婷综| 国产精品99久久久久久宅男| 成人av网站在线观看免费| 一本一道综合狠狠老| 欧美乱妇15p| 精品成人一区二区| 综合久久一区二区三区| 亚洲高清久久久| 激情久久五月天| 99久久99久久精品免费观看| 欧美日韩一二三区| 久久久三级国产网站| 亚洲欧洲一区二区在线播放| 亚洲午夜久久久久中文字幕久| 日韩电影在线一区二区| 国产成人av福利| 欧美三电影在线| 久久日一线二线三线suv| 国产乱码精品1区2区3区| 成人精品视频一区| 欧美日韩dvd在线观看| 精品国产乱子伦一区| 亚洲美女淫视频| 精品一区二区三区欧美| 91麻豆swag| 久久久五月婷婷| 香蕉加勒比综合久久| 成人午夜在线播放| 欧美疯狂性受xxxxx喷水图片| 国产亚洲精品aa| 丝袜亚洲另类丝袜在线| 成人高清视频免费观看| 日韩一区二区三区在线| 亚洲精品一二三| 国产精品自拍一区| 51午夜精品国产| 国产精品短视频| 国产一区二区三区四| 欧美日韩一区二区三区在线 | 激情六月婷婷综合| 欧美性猛片aaaaaaa做受| 久久久久9999亚洲精品| 日韩av一级片| 色偷偷成人一区二区三区91 | 视频一区视频二区中文| 成人高清视频在线| 精品国产乱码久久久久久影片| 亚洲一二三四在线观看| 成人性生交大片| 精品国产乱码久久久久久牛牛| 亚洲成在线观看| 99riav一区二区三区| 国产亚洲一区二区在线观看| 日韩福利电影在线| 欧美日韩免费高清一区色橹橹| 中文字幕字幕中文在线中不卡视频| 国产制服丝袜一区| 日韩精品一区二区三区在线观看| 亚洲高清视频在线| 日本高清无吗v一区| 国产精品久久久久毛片软件| 韩日av一区二区| 日韩你懂的在线播放| 日韩电影在线免费观看| 欧美三区在线观看| 成人激情免费电影网址| 26uuu国产电影一区二区| 麻豆视频一区二区| 欧美一区二区在线免费播放| 午夜精品福利在线| 欧美片在线播放| 丝袜美腿亚洲色图| 欧美日韩国产高清一区二区| 一区二区三区四区精品在线视频| 一本大道久久精品懂色aⅴ| 中文字幕一区二区三区精华液 | 在线成人av影院| 亚洲1区2区3区4区| 91精品久久久久久久91蜜桃| 青青草97国产精品免费观看无弹窗版 | 日韩激情av在线| 欧美老年两性高潮| 日本人妖一区二区| 日韩一区二区中文字幕| 看国产成人h片视频| 欧美电视剧免费全集观看| 久草在线在线精品观看| 国产午夜亚洲精品羞羞网站| 丰满放荡岳乱妇91ww| 亚洲人妖av一区二区| 色综合久久久网| 亚洲国产精品精华液网站| 91麻豆精品国产91久久久久久| 美女视频一区二区三区| 久久久欧美精品sm网站| 国产91丝袜在线观看| 中文字幕一区二区三| 91国偷自产一区二区使用方法| 亚洲电影一级黄| 日韩一二在线观看| 国产不卡视频在线观看| 国产成人免费视频网站| 亚洲人一二三区| 在线综合亚洲欧美在线视频| 国产乱色国产精品免费视频| 国产精品人成在线观看免费| 在线亚洲免费视频| 麻豆久久一区二区| 国产精品国产精品国产专区不片| 欧美亚洲国产一区在线观看网站| 五月婷婷另类国产| 国产日韩三级在线| 一本大道av一区二区在线播放| 日韩精品一二区| 国产亚洲欧美中文| 在线免费精品视频| 国产一区二区三区免费播放 | 伦理电影国产精品| 中文字幕中文字幕在线一区 | 久久精品男人天堂av| 色久优优欧美色久优优| 美腿丝袜亚洲色图| 一色屋精品亚洲香蕉网站| 91精品国产综合久久久久| 成人性生交大片免费看视频在线| 亚洲第一成年网| 国产精品日日摸夜夜摸av| 欧美喷水一区二区| 99精品视频在线播放观看| 日本中文字幕不卡| 一区视频在线播放| 精品入口麻豆88视频| 色88888久久久久久影院按摩| 久久97超碰色| 一二三区精品视频| 欧美激情在线看| 91精品福利在线一区二区三区| 成人a级免费电影| 美女被吸乳得到大胸91| 亚洲综合色成人| 国产精品三级电影| 亚洲电影在线免费观看| 国产精品系列在线| 日韩精品一区二区在线观看| 欧美亚州韩日在线看免费版国语版| 国产在线播放一区三区四| 香蕉加勒比综合久久| 亚洲欧洲三级电影| 国产日韩欧美在线一区| 日韩精品一区二区三区在线 | 日韩午夜激情av| 91成人免费电影| 成人av网在线| 国产高清无密码一区二区三区| 日韩精品成人一区二区在线| 一区二区三区免费观看| 国产精品国产三级国产普通话蜜臀 | 成人av第一页| 国产精品资源站在线| 久久精品理论片| 午夜精品久久久久久久久久久| 亚洲蜜臀av乱码久久精品蜜桃| 中文字幕国产一区| 久久日韩粉嫩一区二区三区| 日韩欧美国产wwwww| 欧美日韩国产精品自在自线| 91久久久免费一区二区| 99久久久久免费精品国产| 国产999精品久久| 国产不卡视频一区二区三区| 狠狠色丁香九九婷婷综合五月| 秋霞影院一区二区| 美女视频第一区二区三区免费观看网站| 视频一区二区中文字幕| 亚洲高清免费观看高清完整版在线观看| 亚洲精品久久7777| 亚洲激情图片一区|