private void StatsTimerElapsed(object source, System.Timers.ElapsedEventArgs e) { if (!Enabled) { WriteTimer.Stop(); return; } if (LogSyncConnectorEnable) { LogConnectorStats(); } if (LogRegionEnable) { LogStats("scene", LogRegionDirectory, LogRegionFilenamePrefix, LogRegionFileTimeMinutes, LogRegionFlushWrites, regionStatFields); } if (LogServerEnable) { LogStatsCombineCategory("server", LogServerDirectory, LogServerFilenamePrefix, LogServerFileTimeMinutes, LogServerFlushWrites, serverStatFields); } if (LogLLUDPBWAggEnabled) { LogLLUDPStats(); } }
public void Dispose() { Enabled = false; LogSyncConnectorEnable = false; if (WriteTimer != null) { WriteTimer.Stop(); WriteTimer.Dispose(); WriteTimer = null; } Close(); }
public override void Disconnect() { try { ClearCmd(); Cmd.Clear(); ReadTimer.Change(-1, -1); WriteTimer.Change(-1, -1); WaitUntilThreadOver(); serialport.Close(); CreateEvent(EventReason.Disconnected, null); } catch (Exception ex) { CreateEvent(EventReason.Disconnected, ex.Message); } finally { PACK.FlushReadBuffer(); PACK.FlushWriteBuffer(); CMD.ClearTask(); serialport = null; } }
public override void Connect(object device) { if (device is SerialPort) { IsUSBSerial = false; serialport = (SerialPort)device; try { serialport.DataBits = 8; serialport.StopBits = StopBits.One; serialport.Parity = Parity.None; serialport.ReadTimeout = 50; serialport.ReceivedBytesThreshold = 1; serialport.DataReceived += new SerialDataReceivedEventHandler(SerialReadThread); serialport.ReadBufferSize = 8192; serialport.WriteBufferSize = 8192; PACK.FlushReadBuffer(); PACK.FlushWriteBuffer(); CMD.ClearTask(); serialport.Open(); WriteTimer.Change(0, 25); ReadTimer.Change(0, 25); SerialChannel = SerialChannelEnum.ChipConnect; CreateEvent(EventReason.ChipConnected, null); // 仅串口连接成功 return; } catch (Exception ex) { Disconnect(); CreateEvent(EventReason.ConnectFailed, ex.Message); return; } } CreateEvent(EventReason.ConnectFailed, "连接的不是串口设备!"); }
private void bWriteStart_Click(object sender, EventArgs e) { WriteTimer.Start(); }
private void bWriteEnd_Click(object sender, EventArgs e) { WriteTimer.Stop(); }
protected override void OnStop() { WriteTimer.Stop(); }
protected override void OnStart(string[] args) { WriteTimer.Start(); }