Exemplo n.º 1
0
        /// <summary>
        /// Decode the buffer.  This will create all the datasets based off
        /// the sentences.
        /// </summary>
        /// <param name="buffer">Buffer to decode.</param>
        private DataSet.Ensemble DecodeSentences(List <NmeaSentence> buffer)
        {
            Prti01Sentence prti01     = null;
            Prti02Sentence prti02     = null;
            Prti03Sentence prti03     = null;
            Prti30Sentence prti30     = null;
            Prti31Sentence prti31     = null;
            var            nmeaBuffer = new List <string>();

            foreach (var sentence in buffer)
            {
                // Check for PRTI01
                if (sentence.CommandWord.EndsWith(RTI.Prti01Sentence.CMD_WORD_PRTI01, StringComparison.Ordinal))
                {
                    // Store the sentence to be combined with PRTI01
                    prti01 = new Prti01Sentence(sentence.Sentence, sentence.CommandWord, sentence.Words, sentence.ExistingChecksum);
                }
                // Check for PRTI02
                else if (sentence.CommandWord.EndsWith(RTI.Prti02Sentence.CMD_WORD_PRTI02, StringComparison.Ordinal))
                {
                    prti02 = new Prti02Sentence(sentence.Sentence, sentence.CommandWord, sentence.Words, sentence.ExistingChecksum);
                }
                // Check for PRTI03
                else if (sentence.CommandWord.EndsWith(RTI.Prti03Sentence.CMD_WORD_PRTI03, StringComparison.Ordinal))
                {
                    // Store the sentence to be combined with PRTI02
                    prti03 = new Prti03Sentence(sentence.Sentence, sentence.CommandWord, sentence.Words, sentence.ExistingChecksum);
                }
                // Check for PRTI30
                else if (sentence.CommandWord.EndsWith(RTI.Prti30Sentence.CMD_WORD_PRTI30, StringComparison.Ordinal))
                {
                    // Store the sentence to be combined with PRTI01 and PRTI02
                    prti30 = new Prti30Sentence(sentence.Sentence, sentence.CommandWord, sentence.Words, sentence.ExistingChecksum);
                }
                // Check for PRTI31
                else if (sentence.CommandWord.EndsWith(RTI.Prti31Sentence.CMD_WORD_PRTI31, StringComparison.Ordinal))
                {
                    // Store the sentence to be combined with PRTI01 and PRTI02
                    prti31 = new Prti31Sentence(sentence.Sentence, sentence.CommandWord, sentence.Words, sentence.ExistingChecksum);
                }
                else
                {
                    // If the data was nether PRTI01 or PRTI02, then it must be GPS NMEA data and add it
                    // to the NMEA buffer to be processed with a complete dataset
                    nmeaBuffer.Add(sentence.Sentence + "\r\n");
                }
            }

            return(CreateEnsemble(prti01, prti02, prti03, prti30, prti31, nmeaBuffer));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create the data set using PRTI01.  Then add PRTI02 to the
        /// dataset.  Then send the dataset.
        /// </summary>
        /// <param name="prti01">PRTI01 Sentence.</param>
        /// <param name="prti02">PRTI02 Sentence.</param>
        /// <param name="prti30">PRTI30 Sentence.</param>
        /// <param name="prti31">PRTI31 Sentence.</param>
        private void SendData(Prti01Sentence prti01, Prti02Sentence prti02, Prti30Sentence prti30 = null, Prti31Sentence prti31 = null)
        {
            // Create the dataset
            DataSet.Ensemble adcpData = CreateDataSet(prti01);
            adcpData.AddAdditionalBottomTrackData(prti02);

            if (IsUseBtHpr)
            {
                if (prti30 != null)
                {
                    adcpData.AddAdditionalAncillaryData(prti30);
                    adcpData.AddAdditionalBottomTrackData(prti30);

                    // Setup the serial number
                    if (adcpData.IsEnsembleAvail)
                    {
                        // Remove the temp serial number subsystem
                        adcpData.EnsembleData.SysSerialNumber.RemoveSubsystem(SerialNumber.DVL_Subsystem);

                        // Add the actual subsystem
                        adcpData.EnsembleData.SysSerialNumber.AddSubsystem(prti30.SubsystemConfig.SubSystem);
                    }
                }
            }
            else
            {
                if (prti31 != null)
                {
                    adcpData.AddAdditionalAncillaryData(prti31);
                    adcpData.AddAdditionalBottomTrackData(prti31);

                    // Setup the serial number
                    if (adcpData.IsEnsembleAvail)
                    {
                        // Remove the temp serial number subsystem
                        adcpData.EnsembleData.SysSerialNumber.RemoveSubsystem(SerialNumber.DVL_Subsystem);

                        // Add the actual subsystem
                        adcpData.EnsembleData.SysSerialNumber.AddSubsystem(prti30.SubsystemConfig.SubSystem);
                    }
                }
            }

            // Combine all the messages and convert to a byte array
            string adcpMesg = "";
            if (prti01 != null)
            {
                adcpMesg += prti01.ToString();
            }
            if (prti02 != null)
            {
                adcpMesg += prti02.ToString();
            }
            if (prti30 != null)
            {
                adcpMesg += prti30.ToString();
            }
            if (prti31 != null)
            {
                adcpMesg += prti31.ToString();
            }
            byte[] adcpMesgBA = Encoding.ASCII.GetBytes(adcpMesg);

            // Send the data set
            SendData(adcpData, adcpMesgBA);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Process the valid NMEA sentence.  Check which 
        /// type of DVL message it is and create the data set.
        /// Then send the data set to the CurrentDataSetManager.
        /// </summary>
        /// <param name="sentence">Sentence to process.</param>
        private void ProcessSentence(NmeaSentence sentence)
        {
            // Check for PRTI01
            if (sentence.CommandWord.EndsWith(RTI.Prti01Sentence.CMD_WORD_PRTI01, StringComparison.Ordinal))
            {
                // Check if the previous PRTI01 was used
                // If it was not used, send the data
                if (_prti01 != null)
                {
                    SendData(_prti01);
                    _prti01 = null;
                }

                // Store the sentence to be combined with PRTI02
                _prti01 = new Prti01Sentence(sentence.Sentence, sentence.CommandWord, sentence.Words, sentence.ExistingChecksum);

            }
            // Check for PRTI02
            else if (sentence.CommandWord.EndsWith(RTI.Prti02Sentence.CMD_WORD_PRTI02, StringComparison.Ordinal))
            {
                Prti02Sentence prti02 = new Prti02Sentence(sentence.Sentence, sentence.CommandWord, sentence.Words, sentence.ExistingChecksum);

                // Check if the PRTI01 and PRTI02 match
                // If they match, combine and send
                // If they do not match, send PRTI02
                if (_prti01 != null && _prti01.SampleNumber == prti02.SampleNumber)
                {
                    SendData(_prti01, prti02, _prti30, _prti31);
                    _prti01 = null;
                }
                else
                {
                    SendData(prti02);
                }
            }
            // Check for PRTI03
            else if (sentence.CommandWord.EndsWith(RTI.Prti03Sentence.CMD_WORD_PRTI03, StringComparison.Ordinal))
            {
                // Store the sentence to be combined with PRTI02
                Prti03Sentence prti03 = new Prti03Sentence(sentence.Sentence, sentence.CommandWord, sentence.Words, sentence.ExistingChecksum);
                SendData(prti03);
            }
            // Check for PRTI30
            else if (sentence.CommandWord.EndsWith(RTI.Prti30Sentence.CMD_WORD_PRTI30, StringComparison.Ordinal))
            {
                // Store the sentence to be combined with PRTI01 and PRTI02
                _prti30 = new Prti30Sentence(sentence.Sentence, sentence.CommandWord, sentence.Words, sentence.ExistingChecksum);
            }
            // Check for PRTI31
            else if (sentence.CommandWord.EndsWith(RTI.Prti31Sentence.CMD_WORD_PRTI31, StringComparison.Ordinal))
            {
                // Store the sentence to be combined with PRTI01 and PRTI02
                _prti31 = new Prti31Sentence(sentence.Sentence, sentence.CommandWord, sentence.Words, sentence.ExistingChecksum);
            }
            else
            {
                // If the data was nether PRTI01 or PRTI02, then it must be GPS NMEA data and add it
                // to the NMEA buffer to be processed with a complete dataset
                AddNmeaData(sentence.Sentence + NMEA_END);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Process the valid NMEA sentence.  Check which
        /// type of DVL message it is and create the data set.
        /// Then send the data set to the CurrentDataSetManager.
        /// </summary>
        /// <param name="sentence">Sentence to process.</param>
        private void ProcessSentence(NmeaSentence sentence)
        {
            // Check for PRTI01
            if (sentence.CommandWord.EndsWith(RTI.Prti01Sentence.CMD_WORD_PRTI01, StringComparison.Ordinal))
            {
                // Check if the previous PRTI01 was used
                // If it was not used, send the data
                if (_prti01 != null)
                {
                    SendData(_prti01);
                    _prti01 = null;
                }

                // Store the sentence to be combined with PRTI02
                _prti01 = new Prti01Sentence(sentence.Sentence, sentence.CommandWord, sentence.Words, sentence.ExistingChecksum);
            }
            // Check for PRTI02
            else if (sentence.CommandWord.EndsWith(RTI.Prti02Sentence.CMD_WORD_PRTI02, StringComparison.Ordinal))
            {
                Prti02Sentence prti02 = new Prti02Sentence(sentence.Sentence, sentence.CommandWord, sentence.Words, sentence.ExistingChecksum);

                // Check if the PRTI01 and PRTI02 match
                // If they match, combine and send
                // If they do not match, send PRTI02
                if (_prti01 != null && _prti01.SampleNumber == prti02.SampleNumber)
                {
                    SendData(_prti01, prti02, _prti30, _prti31);
                    _prti01 = null;
                }
                else
                {
                    SendData(prti02);
                }
            }
            // Check for PRTI03
            else if (sentence.CommandWord.EndsWith(RTI.Prti03Sentence.CMD_WORD_PRTI03, StringComparison.Ordinal))
            {
                // Store the sentence to be combined with PRTI02
                Prti03Sentence prti03 = new Prti03Sentence(sentence.Sentence, sentence.CommandWord, sentence.Words, sentence.ExistingChecksum);
                SendData(prti03);
            }
            // Check for PRTI30
            else if (sentence.CommandWord.EndsWith(RTI.Prti30Sentence.CMD_WORD_PRTI30, StringComparison.Ordinal))
            {
                // Store the sentence to be combined with PRTI01 and PRTI02
                _prti30 = new Prti30Sentence(sentence.Sentence, sentence.CommandWord, sentence.Words, sentence.ExistingChecksum);
            }
            // Check for PRTI31
            else if (sentence.CommandWord.EndsWith(RTI.Prti31Sentence.CMD_WORD_PRTI31, StringComparison.Ordinal))
            {
                // Store the sentence to be combined with PRTI01 and PRTI02
                _prti31 = new Prti31Sentence(sentence.Sentence, sentence.CommandWord, sentence.Words, sentence.ExistingChecksum);
            }
            else
            {
                // If the data was nether PRTI01 or PRTI02, then it must be GPS NMEA data and add it
                // to the NMEA buffer to be processed with a complete dataset
                AddNmeaData(sentence.Sentence + NMEA_END);
            }

            // Reset the incoming data timeout
            _incomingDataTimeout = 0;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Create the data set using PRTI01.  Then add PRTI02 to the
        /// dataset.  Then send the dataset.
        /// </summary>
        /// <param name="prti01">PRTI01 Sentence.</param>
        /// <param name="prti02">PRTI02 Sentence.</param>
        /// <param name="prti30">PRTI30 Sentence.</param>
        /// <param name="prti31">PRTI31 Sentence.</param>
        private void SendData(Prti01Sentence prti01, Prti02Sentence prti02, Prti30Sentence prti30 = null, Prti31Sentence prti31 = null)
        {
            // Create the dataset
            DataSet.Ensemble adcpData = CreateDataSet(prti01);
            adcpData.AddAdditionalBottomTrackData(prti02);

            if (IsUseBtHpr)
            {
                if (prti30 != null)
                {
                    adcpData.AddAdditionalAncillaryData(prti30);
                    adcpData.AddAdditionalBottomTrackData(prti30);

                    // Setup the serial number
                    if (adcpData.IsEnsembleAvail)
                    {
                        // Remove the temp serial number subsystem
                        adcpData.EnsembleData.SysSerialNumber.RemoveSubsystem(SerialNumber.DVL_Subsystem);

                        // Add the actual subsystem
                        adcpData.EnsembleData.SysSerialNumber.AddSubsystem(prti30.SubsystemConfig.SubSystem);
                    }
                }
            }
            else
            {
                if (prti31 != null)
                {
                    adcpData.AddAdditionalAncillaryData(prti31);
                    adcpData.AddAdditionalBottomTrackData(prti31);

                    // Setup the serial number
                    if (adcpData.IsEnsembleAvail)
                    {
                        // Remove the temp serial number subsystem
                        adcpData.EnsembleData.SysSerialNumber.RemoveSubsystem(SerialNumber.DVL_Subsystem);

                        // Add the actual subsystem
                        adcpData.EnsembleData.SysSerialNumber.AddSubsystem(prti30.SubsystemConfig.SubSystem);
                    }
                }
            }

            // Combine all the messages and convert to a byte array
            string adcpMesg = "";

            if (prti01 != null)
            {
                adcpMesg += prti01.ToString();
            }
            if (prti02 != null)
            {
                adcpMesg += prti02.ToString();
            }
            if (prti30 != null)
            {
                adcpMesg += prti30.ToString();
            }
            if (prti31 != null)
            {
                adcpMesg += prti31.ToString();
            }
            byte[] adcpMesgBA = Encoding.ASCII.GetBytes(adcpMesg);

            // Send the data set
            SendData(adcpData, adcpMesgBA);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Create the data set using PRTI01.  Then add PRTI02 to the
        /// dataset.  Then send the dataset.
        /// </summary>
        /// <param name="prti01">PRTI01 Sentence.</param>
        /// <param name="prti02">PRTI02 Sentence.</param>
        /// <param name="prti03">PRTI03 Sentence.</param>
        /// <param name="prti30">PRTI30 Sentence.</param>
        /// <param name="prti31">PRTI31 Sentence.</param>
        /// <param name="nmeaBuffer">NMEA buffer.</param>
        /// <returns>Created ensemble.</returns>
        private DataSet.Ensemble CreateEnsemble(Prti01Sentence prti01, Prti02Sentence prti02, Prti03Sentence prti03 = null, Prti30Sentence prti30 = null, Prti31Sentence prti31 = null, List <string> nmeaBuffer = null)
        {
            // Create the dataset
            DataSet.Ensemble ensemble = CreateDataSet(prti01);

            if (prti02 != null)
            {
                ensemble.AddAdditionalBottomTrackData(prti02);
            }

            if (prti03 != null)
            {
                ensemble.AddAdditionalBottomTrackData(prti03);
            }

            if (prti30 != null)
            {
                ensemble.AddAdditionalAncillaryData(prti30);
                ensemble.AddAdditionalBottomTrackData(prti30);

                // Setup the serial number
                if (ensemble.IsEnsembleAvail)
                {
                    // Remove the temp serial number subsystem
                    ensemble.EnsembleData.SysSerialNumber.RemoveSubsystem(SerialNumber.DVL_Subsystem);

                    // Add the actual subsystem
                    ensemble.EnsembleData.SysSerialNumber.AddSubsystem(prti30.SubsystemConfig.SubSystem);
                }
            }

            if (prti31 != null)
            {
                ensemble.AddAdditionalAncillaryData(prti31);
                ensemble.AddAdditionalBottomTrackData(prti31);

                // Setup the serial number
                if (ensemble.IsEnsembleAvail)
                {
                    // Remove the temp serial number subsystem
                    ensemble.EnsembleData.SysSerialNumber.RemoveSubsystem(SerialNumber.DVL_Subsystem);

                    // Add the actual subsystem
                    ensemble.EnsembleData.SysSerialNumber.AddSubsystem(prti30.SubsystemConfig.SubSystem);
                }
            }

            if (nmeaBuffer != null)
            {
                StringBuilder sb = new StringBuilder();
                foreach (var nmea in nmeaBuffer)
                {
                    sb.Append(nmea);
                }

                ensemble.AddNmeaData(sb.ToString());
            }

            return(ensemble);
        }