private void WindowClose(object sender, CancelEventArgs e)
        {
            _gamepadService.Stop();

            if (_robotConnectionService != null)
            {
                Logger.Info("Stopping connection...");
                _robotConnectionService.Dispose();
                _robotConnectionService = null;
            }

            if (_serialPort != null)
            {
                if (_serialPort.IsOpen)
                {
                    _serialPort.DiscardInBuffer();
                }
                _serialPortManager.Close();
                _serialPort.Dispose();
                _serialPort = null;
            }
        }
Пример #2
0
 private void laserOpenCloseSpbtn_Click(object sender, EventArgs e)
 {
     if (laserOpenCloseSpbtn.Text == "Open")
     {
         if (serialPortCom != null && !serialPortCom.SerialPort.IsOpen)
         {
             serialPortCom.SerialPortOpen(laserComListCbx.Text, laserBaudRateCbx.Text,
                                          laserDataBitsCbx.Text, laserStopBitsCbx.Text, laserParityCbx.Text, laserHandshakingcbx.Text);
         }
     }
     else
     {
         if (serialPortCom != null && serialPortCom.SerialPort.IsOpen)
         {
             serialPortCom.Close();
         }
     }
 }
Пример #3
0
 private void ExecuteCloseCOMPortsCommand()
 {
     _serialPortManager.Close();
     IsSerialPortOpened = _serialPortManager.IsOpened;
 }
Пример #4
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     serialPortManager.Close();
 }