Esempio n. 1
0
        /// <summary>
        /// Receive the ensemble and decode it to output the data.
        /// </summary>
        /// <param name="ens">Ensemble.</param>
        /// <param name="origDataFormat">Original Data format.</param>
        public void ReceiveEnsemble(DataSet.Ensemble ens, AdcpCodec.CodecEnum origDataFormat)
        {
            // Set the buffer size to display data
            // To much data will make the system run slower
            int dataOutputMax = 5000;

            // If the HeadingOffset is set or
            // If they want to retransform the data or
            // They are replacing the heading with GPS heading,
            // The data needs to be retransformed to use the new heading.
            // Retransform the data with the new heading
            // Apply HDT heading if requried and available
            // This will also apply the heading offset
            if (_options.IsRetransformData || _options.IsUseGpsHeading || _options.HeadingOffset != 0)
            {
                // Retransform the Profile datas
                Transform.ProfileTransform(ref ens, origDataFormat, 0.25f, _options.SelectedHeadingSource, _options.HeadingOffset);

                // Retransform the Bottom Track data
                // This will also create the ship data
                Transform.BottomTrackTransform(ref ens, origDataFormat, 0.90f, 10.0f, _options.SelectedHeadingSource, _options.HeadingOffset);

                // WaterMass transform data
                // This will also create the ship data
                if (ens.IsInstrumentWaterMassAvail)
                {
                    Transform.WaterMassTransform(ref ens, origDataFormat, 0.90f, 10.0f, _options.SelectedHeadingSource, _options.HeadingOffset, _options.ShipXdcrOffset);
                }
            }

            // Remove the ship speed
            RemoveShipSpeed(ref ens);

            // Encode the data
            string output = EncodeVelocity(ens);

            // Display data
            DataOutput += output;

            // Send data to serial port
            SendDataToSerial(output);

            // Write data to file if turned on
            WriteData(output);

            // Keep the Buffer to a set limit
            if (DataOutput.Length > dataOutputMax)
            {
                DataOutput = DataOutput.Substring(DataOutput.Length - dataOutputMax);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Receive the ensemble and decode it to output the data.
        /// </summary>
        /// <param name="ens">Ensemble.</param>
        public void ReceiveEnsemble(DataSet.Ensemble ens)
        {
            int dataOutputMax = 5000;

            // If the HeadingOffset is set or
            // If the the want to retransform the data or
            // The are replacing the heading with GPS heading,
            // The data needs to be retransformed to use the new heading.
            // Retransform the data with the new heading
            // Apply HDT heading if requried and available
            // This will also apply the heading offset
            if (_IsRetransformData || _IsUseGpsHeading || _HeadingOffset != 0)
            {
                // Retransform the Profile datas
                Transform.ProfileTransform(ref ens, 0.25f, _IsUseGpsHeading, _HeadingOffset);

                // Retransform the Bottom Track data
                // This will also create the ship data
                Transform.BottomTrackTransform(ref ens, 0.90f, 10.0f, _IsUseGpsHeading, _HeadingOffset);

                // WaterMass transform data
                // This will also create the ship data
                if (ens.IsInstrumentWaterMassAvail)
                {
                    Transform.WaterMassTransform(ref ens, 0.90f, 10.0f, _IsUseGpsHeading, _HeadingOffset, _ShipXdcrOffset);
                }
            }

            if (_SelectedFormat == ENCODING_VMDAS)
            {
                VmDasAsciiCodec.VmDasAsciiOutput output = _codecVmDas.Encode(ens, _MinBin, _MaxBin);

                // Display data
                DataOutput = output.Ascii;

                // Max size of data output buffer
                dataOutputMax = 5000;

                // Send data to serial port
                SendDataToSerial(output.Ascii);

                // Write data to file if turned on
                WriteData(output.Ascii);

                // Update the Min and Max Bin selection
                if (_MinBin != output.BinSelected.MinBin)
                {
                    MinBin = output.BinSelected.MinBin;
                }

                if (_MaxBin != output.BinSelected.MaxBin)
                {
                    MaxBin = output.BinSelected.MaxBin;
                }
            }
            else if (_SelectedFormat == ENCODING_PD6_PD13)
            {
                // PD6 or PD13
                EnsToPd6_13Codec.Pd6_13Data output = _codecPd6_13.Encode(ens);

                // Output all the strings
                foreach (var line in output.Data)
                {
                    // Output to display
                    DataOutput += line;

                    // Output to the serial port
                    // Trim it because the serial port adds a carrage return
                    SendDataToSerial(line.Trim());

                    // Write data to file if turned on
                    WriteData(line.Trim());
                }

                // Max size of data output buffer
                dataOutputMax = 1000;
            }
            else if (_SelectedFormat == ENCODING_Binary_ENS)
            {
                // Convert to binary array
                byte[] rawEns = ens.Encode();

                // Output to display
                DataOutput += ens.ToString();

                // Output data to the serial port
                _serialPort.SendData(rawEns, 0, rawEns.Length);

                // Write data to file if turned on
                WriteData(rawEns);

                // Max size of data output buffer
                dataOutputMax = 10000;
            }
            else if (_SelectedFormat == ENCODING_PD0)
            {
                byte[] pd0 = null;

                switch (_SelectedCoordTransform)
                {
                case PD0.CoordinateTransforms.Coord_Beam:
                    pd0 = ens.EncodePd0Ensemble(PD0.CoordinateTransforms.Coord_Beam);
                    break;

                case PD0.CoordinateTransforms.Coord_Instrument:
                    pd0 = ens.EncodePd0Ensemble(PD0.CoordinateTransforms.Coord_Instrument);
                    break;

                case PD0.CoordinateTransforms.Coord_Ship:
                    pd0 = ens.EncodePd0Ensemble(PD0.CoordinateTransforms.Coord_Ship);
                    break;

                case PD0.CoordinateTransforms.Coord_Earth:
                    pd0 = ens.EncodePd0Ensemble(PD0.CoordinateTransforms.Coord_Earth);
                    break;
                }

                // Output to display
                DataOutput += System.Text.ASCIIEncoding.ASCII.GetString(pd0);

                // Output data to serial port
                _serialPort.SendData(pd0, 0, pd0.Length);

                // Write data to file if turned on
                WriteData(pd0);

                // Max output buffer size
                dataOutputMax = 10000;
            }
            else if (_SelectedFormat == ENCODING_RETRANSFORM_PD6)
            {
            }

            if (DataOutput.Length > dataOutputMax)
            {
                DataOutput = DataOutput.Substring(DataOutput.Length - dataOutputMax);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Receive the ensemble and decode it to output the data.
        /// </summary>
        /// <param name="ens">Ensemble.</param>
        /// <param name="origDataFormat">Original Data Format.</param>
        public void ReceiveEnsemble(DataSet.Ensemble ens, AdcpCodec.CodecEnum origDataFormat)
        {
            // Set the buffer size to display data
            // To much data will make the system run slower
            int dataOutputMax = 5000;

            // Set the maximum bin for bin list
            if (ens.IsEnsembleAvail)
            {
                // If it different from what is now
                if (BinList.Count != ens.EnsembleData.NumBins)
                {
                    // Subtract 1 because 0 based
                    NumBins = ens.EnsembleData.NumBins - 1;

                    // Clear and repopulate
                    BinList.Clear();
                    for (int x = 0; x < ens.EnsembleData.NumBins; x++)
                    {
                        BinList.Add(x);
                    }
                }
            }

            // If the HeadingOffset is set or
            // If they want to retransform the data or
            // They are replacing the heading with GPS heading,
            // The data needs to be retransformed to use the new heading.
            // Retransform the data with the new heading
            // Apply HDT heading if requried and available
            // This will also apply the heading offset
            if (_options.IsRetransformData || _options.IsUseGpsHeading || _options.HeadingOffset != 0)
            {
                // Retransform the Profile datas
                Transform.ProfileTransform(ref ens, origDataFormat, 0.25f, _options.SelectedHeadingSource, _options.HeadingOffset);

                // Retransform the Bottom Track data
                // This will also create the ship data
                Transform.BottomTrackTransform(ref ens, origDataFormat, 0.90f, 10.0f, _options.SelectedHeadingSource, _options.HeadingOffset);

                // WaterMass transform data
                // This will also create the ship data
                if (ens.IsInstrumentWaterMassAvail)
                {
                    Transform.WaterMassTransform(ref ens, origDataFormat, 0.90f, 10.0f, _options.SelectedHeadingSource, _options.HeadingOffset, _options.ShipXdcrOffset);
                }
            }

            // Remove the Ship speed from the data
            RemoveShipSpeed(ref ens);

            // Water Track
            if (_options.IsCalculateWaterTrack)
            {
                _manualWT.Calculate(ref ens, _options.WtMinBin, _options.WtMaxBin);
            }

            if (_options.SelectedFormat == DataOutputViewOptions.ENCODING_VMDAS)
            {
                VmDasAsciiCodec.VmDasAsciiOutput output = _codecVmDas.Encode(ens, _options.VmDasMinBin, _options.VmDasMaxBin);

                // Display data
                DataOutput = output.Ascii;

                // Max size of data output buffer
                dataOutputMax = 5000;

                // Send data to serial port
                SendDataToSerial(output.Ascii);

                // Write data to file if turned on
                WriteData(output.Ascii);

                // Update the Min and Max Bin selection
                if (_options.VmDasMinBin != output.BinSelected.MinBin)
                {
                    MinBin = output.BinSelected.MinBin;
                }

                if (_options.VmDasMaxBin != output.BinSelected.MaxBin)
                {
                    MaxBin = output.BinSelected.MaxBin;
                }
            }
            else if (_options.SelectedFormat == DataOutputViewOptions.ENCODING_PD6_PD13)
            {
                // PD6 or PD13
                EnsToPd6_13Codec.Pd6_13Data output = _codecPd6_13.Encode(ens);

                // Output all the strings
                foreach (var line in output.Data)
                {
                    // Output to display
                    DataOutput += line;

                    // Output to the serial port
                    // Trim it because the serial port adds a carrage return
                    SendDataToSerial(line, false);

                    // Write data to file if turned on
                    WriteData(line.Trim());
                }

                // Max size of data output buffer
                dataOutputMax = 1000;
            }
            else if (_options.SelectedFormat == DataOutputViewOptions.ENCODING_Binary_ENS)
            {
                // Convert to binary array
                byte[] rawEns = ens.Encode();

                // Output to display
                DataOutput += ens.ToString();

                // Output data to the serial port
                _serialPort.SendData(rawEns, 0, rawEns.Length);

                // Write data to file if turned on
                WriteData(rawEns);

                // Max size of data output buffer
                dataOutputMax = 10000;
            }
            else if (_options.SelectedFormat == DataOutputViewOptions.ENCODING_PD0)
            {
                byte[] pd0 = null;

                switch (_options.SelectedCoordTransform)
                {
                case PD0.CoordinateTransforms.Coord_Beam:
                    pd0 = ens.EncodePd0Ensemble(PD0.CoordinateTransforms.Coord_Beam);
                    break;

                case PD0.CoordinateTransforms.Coord_Instrument:
                    pd0 = ens.EncodePd0Ensemble(PD0.CoordinateTransforms.Coord_Instrument);
                    break;

                case PD0.CoordinateTransforms.Coord_Ship:
                    pd0 = ens.EncodePd0Ensemble(PD0.CoordinateTransforms.Coord_Ship);
                    break;

                case PD0.CoordinateTransforms.Coord_Earth:
                    pd0 = ens.EncodePd0Ensemble(PD0.CoordinateTransforms.Coord_Earth);
                    break;
                }

                // Output to display
                DataOutput += System.Text.ASCIIEncoding.ASCII.GetString(pd0);

                // Output data to serial port
                _serialPort.SendData(pd0, 0, pd0.Length);

                // Write data to file if turned on
                WriteData(pd0);

                // Max output buffer size
                dataOutputMax = 10000;
            }
            else if (_options.SelectedFormat == DataOutputViewOptions.ENCODING_RETRANSFORM_PD6)
            {
            }

            // Keep the Buffer to a set limit
            if (DataOutput.Length > dataOutputMax)
            {
                DataOutput = DataOutput.Substring(DataOutput.Length - dataOutputMax);
            }
        }