Exemplo n.º 1
0
        /// <summary>
        /// Initialize the values.
        /// </summary>
        private void InitValues()
        {
            IsGps2Visible  = false;
            IsNmea1Visible = false;
            IsNmea2Visible = false;

            if (_pm.IsProjectSelected)
            {
                // Get the previous options if they have already been set
                SelectedAdcpCommPort = _adcpConnection.AdcpSerialPort.SerialOptions.Port;
                SelectedAdcpBaudRate = _adcpConnection.AdcpSerialPort.SerialOptions.BaudRate;

                // Set the selected projects GPS1 options to the last GPS1 options
                // Then make the connection
                if (_adcpConnection.Gps1SerialPort != null)
                {
                    _pm.SelectedProject.Configuration.Gps1SerialOptions = _adcpConnection.Gps1SerialPort.SerialOptions;
                    _SelectedGps1CommPort = _adcpConnection.Gps1SerialPort.SerialOptions.Port;
                    _SelectedGps1BaudRate = _adcpConnection.Gps1SerialPort.SerialOptions.BaudRate;
                    if (_adcpConnection.IsGps1SerialPortEnabled)
                    {
                        _adcpConnection.ReconnectGps1Serial(_pm.SelectedProject.Configuration.Gps1SerialOptions);
                    }
                }

                // Set the selected projects GPS2 options to the last GPS2 options
                // Then make the connection
                if (_adcpConnection.Gps2SerialPort != null)
                {
                    _pm.SelectedProject.Configuration.Gps2SerialOptions = _adcpConnection.Gps2SerialPort.SerialOptions;
                    _SelectedGps2CommPort = _adcpConnection.Gps2SerialPort.SerialOptions.Port;
                    _SelectedGps2BaudRate = _adcpConnection.Gps2SerialPort.SerialOptions.BaudRate;
                    if (_adcpConnection.IsGps2SerialPortEnabled)
                    {
                        _adcpConnection.ReconnectGps2Serial(_pm.SelectedProject.Configuration.Gps2SerialOptions);
                    }
                }

                // Set the selected projects Nmea1 options to the last Nmea1 options
                // Then make the connection
                if (_adcpConnection.Nmea1SerialPort != null)
                {
                    _pm.SelectedProject.Configuration.Nmea1SerialOptions = _adcpConnection.Nmea1SerialPort.SerialOptions;
                    _SelectedNmea1CommPort = _adcpConnection.Nmea1SerialPort.SerialOptions.Port;
                    _SelectedNmea1BaudRate = _adcpConnection.Nmea1SerialPort.SerialOptions.BaudRate;
                    if (_adcpConnection.IsNmea1SerialPortEnabled)
                    {
                        _adcpConnection.ReconnectNmea1Serial(_pm.SelectedProject.Configuration.Nmea1SerialOptions);
                    }
                }

                // Set the selected projects Nmea2 options to the last Nmea2 options
                // Then make the connection
                if (_adcpConnection.Nmea2SerialPort != null)
                {
                    _pm.SelectedProject.Configuration.Nmea2SerialOptions = _adcpConnection.Nmea2SerialPort.SerialOptions;
                    _SelectedNmea2CommPort = _adcpConnection.Nmea2SerialPort.SerialOptions.Port;
                    _SelectedNmea2BaudRate = _adcpConnection.Nmea2SerialPort.SerialOptions.BaudRate;
                    if (_adcpConnection.IsNmea2SerialPortEnabled)
                    {
                        _adcpConnection.ReconnectNmea2Serial(_pm.SelectedProject.Configuration.Nmea2SerialOptions);
                    }
                }

                // Set the product image
                AdcpImageSrc = ProductImage.GetProductImage(_pm.SelectedProject);

                // Based off mode, it will determine what is visible
                switch (_pm.SelectedProject.Configuration.DeploymentOptions.DeploymentMode)
                {
                case DeploymentOptions.AdcpDeploymentMode.VM:
                    IsGps2Visible  = true;
                    IsNmea1Visible = true;
                    IsNmea2Visible = true;
                    break;

                default:
                    IsGps2Visible  = false;
                    IsNmea1Visible = false;
                    IsNmea2Visible = false;
                    break;
                }
            }
        }