/// <summary> /// Monitors the connection to with the arduino /// </summary> private void monitorConnection() { while (true) { string tempCom = autoFindComm.GetCommPort(); if (tempCom != _currentCommPort) { if (tempCom != String.Empty) { if (!connected) { Connect(tempCom); } else { Disconnect(); Connect(tempCom); } RequestModel(); RequestPartPresent(); } else { Disconnect(); } _currentCommPort = tempCom; if (CommPortChanged != null) { CommPortChanged(_currentCommPort); } } Thread.Sleep(1000); } }
private iPhBtnHardwareControl() { this.serial = new SerialCommunication(); AutoFindCom autofindComm = new AutoFindCom(); this.serial.PortName = autofindComm.GetCommPort(); serial.PortConnected += new SerialDataPortEventHandler(serial_PortConnected); serial.DataReceived += new SerialDataReceivedEventHandler(serial_DataReceived); timer.Elapsed += new ElapsedEventHandler(timer_Elapsed); disconnectedTimer.Elapsed += new ElapsedEventHandler(disconnectedTimer_Elapsed); connectingTimer.Elapsed += new ElapsedEventHandler(connectingTimer_Elapsed); disconnectedTimer.Start(); }
/// <summary> /// Constructor /// </summary> public SickDistanceSensor() { foundComm = commFinder.GetCommPort(); measurementThread = new Thread(new ThreadStart(MeasurementThreadMethod)); }
private void SetConnectionStatusLabelText() { connectionStatusLabel.Text = (control.ConnectionState == iPhBtnHardwareControl.CONN_STATE.CONNECTED)? "Connected on " + autofindComm.GetCommPort():"Disconnected"; }