/// <summary> /// Shutdown the ADCP serial port. /// This will stop all the read threads /// for the ADCP serial port. /// </summary> public void DisconnectSerial() { try { if (_serialPort != null) { DisplayStatus(string.Format("Disconnect Serial: {0}", _serialPort.ToString())); // Disconnect the serial port _serialPort.Disconnect(); // Publish that the ADCP serial conneciton is disconnected //PublishAdcpSerialDisconnection(); // Shutdown the serial port _serialPort.Dispose(); } //Status.Status = eAdcpStatus.NotConnected; } catch (Exception e) { Debug.WriteLine("Error disconnecting the serial port.", e); } }
/// <summary> /// Shutdown the ADCP serial port. /// This will stop all the read threads /// for the ADCP serial port. /// </summary> public void DisconnectAdcpSerial() { try { if (_adcpSerialPort != null) { DispalyStatus(string.Format("ADCP Disconnect: {0}", _adcpSerialPort.ToString())); // Disconnect the serial port _adcpSerialPort.Disconnect(); // Unscribe to ADCP SerialPort events _adcpSerialPort.ReceiveAdcpSerialDataEvent -= ReceiveAdcpSerialData; // Publish that the ADCP serial conneciton is disconnected //PublishAdcpSerialDisconnection(); // Shutdown the serial port _adcpSerialPort.Dispose(); } //Status.Status = eAdcpStatus.NotConnected; } catch (Exception e) { Debug.WriteLine("Error disconnecting the serial port.", e); } }
/// <summary> /// Create a connection to the ADCP serial port with /// the given options. If no options are given, return null. /// </summary> /// <param name="options">Options to connect to the serial port.</param> /// <returns>Adcp Serial Port based off the options</returns> public AdcpSerialPort ConnectSerial(SerialOptions options) { // If there is a connection, disconnect if (_serialPort != null) { DisconnectSerial(); } if (options != null) { // Set the connection //Status.Status = eAdcpStatus.Connected; // Create the connection and connect _serialPort = new AdcpSerialPort(options); _serialPort.Connect(); // Publish that the ADCP serial port is new //PublishAdcpSerialConnection(); DisplayStatus(string.Format("Connect Serial: {0}", _serialPort.ToString())); // Set flag //IsAdcpFound = true; return(_serialPort); } return(null); }
/// <summary> /// Create a connection to the ADCP serial port with /// the given options. If no options are given, return null. /// </summary> /// <param name="options">Options to connect to the serial port.</param> /// <returns>Adcp Serial Port based off the options</returns> public AdcpSerialPort ConnectAdcpSerial(SerialOptions options) { // If there is a connection, disconnect if (_adcpSerialPort != null) { DisconnectAdcpSerial(); } if (options != null) { // Set the connection //Status.Status = eAdcpStatus.Connected; // Create the connection and connect _adcpSerialPort = new AdcpSerialPort(options); _adcpSerialPort.Connect(); // Subscribe to receive ADCP data _adcpSerialPort.ReceiveAdcpSerialDataEvent += new AdcpSerialPort.ReceiveAdcpSerialDataEventHandler(ReceiveAdcpSerialData); // Publish that the ADCP serial port is new //PublishAdcpSerialConnection(); DispalyStatus(string.Format("ADCP Connect: {0}", _adcpSerialPort.ToString())); // Set flag //IsAdcpFound = true; return(_adcpSerialPort); } return(null); }