示例#1
0
        /// <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);
        }
示例#2
0
        /// <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);
        }
示例#3
0
        /// <summary>
        /// Connect the serial port.
        /// </summary>
        private void Connect()
        {
            // If still connected, disconnect
            if (_serialPort != null)
            {
                Disconnect();
            }

            // Connect and begin receiving data
            _serialPort = new AdcpSerialPort(_serialOption);
            _serialPort.Connect();
            _serialPort.ReceiveRawSerialDataEvent += _serialPort_ReceiveRawSerialDataEvent;

            if (_serialPort.IsAvailable())
            {
                DisplaySerialPortStatusMsg(string.Format("Connected to ADCP on {0} - {1}", _serialOption.Port, _serialOption.BaudRate));
            }
        }