Example #1
0
        private void port_NewNMEAMessage(object sender, NewNMEAMessageEventArgs e)
        {
            try
            {
                var sentence = NMEAParser.Parse(e.Message);

                if (sentence is NMEAProprietarySentence)
                {
                    NMEAProprietarySentence snt = ((NMEAProprietarySentence)(sentence));

                    if (snt.SentenceIDString == "0")
                    {
                        // ACK - analyze error code
                        Process_ACK(snt.parameters);
                    }
                    else if (snt.SentenceIDString == "5")
                    {
                        // local data value
                        Process_LOC_DATA(snt.parameters);
                    }
                    else if (snt.SentenceIDString == "3")
                    {
                        // settings field value
                        Process_FLD_Value(snt.parameters);
                    }
                    else if (snt.SentenceIDString == "!")
                    {
                        // device info
                        Process_DEVICE_INFO(snt.parameters);
                    }
                    else if (snt.SentenceIDString == "!!")
                    {
                        Process_DEVICE_INFO_RN(snt.parameters);
                    }
                    else if (snt.SentenceIDString == "I")
                    {
                        // track point val
                        Process_TRACK_POINT_VAL(snt.parameters);
                    }
                    else if (snt.SentenceIDString == "L")
                    {
                        // waypoint value
                        Process_WAYPOINT_VAL(snt.parameters);
                    }
                }
                else
                {
                    // TODO: write log
                }
            }
            catch (Exception ex)
            {
                // TODO: write log
            }
        }
Example #2
0
        private void port_NewNMEAMessage(object sender, NewNMEAMessageEventArgs e)
        {
            InvokeAppendText(commLogTxb, logger.Write(string.Format(">> {0}", e.Message)));
            try
            {
                var parseResult = NMEAParser.Parse(e.Message);

                if (parseResult is NMEAProprietarySentence)
                {
                    NMEAProprietarySentence pSentence = (parseResult as NMEAProprietarySentence);

                    if (pSentence.Manufacturer == ManufacturerCodes.TNT)
                    {
                        if (pSentence.SentenceIDString == "!")
                        {
                            Parse_DEVICE_INFO(pSentence.parameters);
                        }
                        else if (pSentence.SentenceIDString == "0")
                        {
                            Parse_ACK(pSentence.parameters);
                        }
                        else if (pSentence.SentenceIDString == "5")
                        {
                            Parse_LOC_DATA_VAL(pSentence.parameters);
                        }
                        else if (pSentence.SentenceIDString == "9")
                        {
                            Parse_SETTINGS(pSentence.parameters);
                        }
                        else
                        {
                            InvokeAppendText(commLogTxb, logger.Write(string.Format("ERROR: Unsupported sentence: \"{0}\"", pSentence.SentenceIDString)));
                        }
                    }
                    else
                    {
                        InvokeAppendText(commLogTxb, logger.Write(string.Format("ERROR: Unsupported manufacturer: \"{0}\"", pSentence.Manufacturer)));
                    }
                }
                else
                {
                    InvokeAppendText(commLogTxb, logger.Write(string.Format("ERROR: Unsupported sentence: \"{0}\"", (parseResult as NMEAStandartSentence).SentenceID)));
                }
            }
            catch (Exception ex) { InvokeAppendText(commLogTxb, logger.Write(ex)); }
        }
Example #3
0
        private void port_NewNMEAMessage(object sender, NewNMEAMessageEventArgs e)
        {
            try
            {
                var parseResult = NMEAParser.Parse(e.Message);

                if (parseResult is NMEAProprietarySentence)
                {
                    NMEAProprietarySentence sentence = (parseResult as NMEAProprietarySentence);

                    if (sentence.Manufacturer == ManufacturerCodes.TNT)
                    {
                        if (sentence.SentenceIDString == "!")
                        {
                            // DEVICE INFO
                            DEVICE_INFO_Parse(sentence.parameters);
                        }
                        else if (sentence.SentenceIDString == "0")
                        {
                            // ACK
                            ACK_Parse(sentence.parameters);
                        }
                        else if (sentence.SentenceIDString == "5")
                        {
                            // LOC_DATA_VAL
                            LOC_DATA_VAL_Parse(sentence.parameters);
                        }
                        else if (sentence.SentenceIDString == "9")
                        {
                            // SETTINGS_VAL
                            SETTINGS_VAL_Parse(sentence.parameters);
                        }
                    }
                    else
                    {
                        // WTF?
                    }
                }
            }
            catch (Exception ex)
            {
                // WTF?
            }
        }
Example #4
0
 public NMEAUnsupportedProprietaryEventArgs(int sourceID, NMEAProprietarySentence sentence)
 {
     SourceID = sourceID;
     Sentence = sentence;
 }
Example #5
0
        private void port_NewNMEAMessageReceived(object sender, NewNMEAMessageEventArgs e)
        {
            bool         isParsed = false;
            NMEASentence result   = null;

            OnInfoEvent(string.Format(">> {0}", e.Message));

            try
            {
                result   = NMEAParser.Parse(e.Message);
                isParsed = true;
            }
            catch (Exception ex)
            {
                OnInfoEvent(string.Format("\"{0}\" caused \"{1}\", TargetSite: {2}", e.Message, ex.Message, ex.TargetSite));
            }

            if (isParsed)
            {
                if (result is NMEAProprietarySentence)
                {
                    NMEAProprietarySentence pResult = (result as NMEAProprietarySentence);

                    if (pResult.Manufacturer == ManufacturerCodes.UWV)
                    {
                        ICs sentenceID = uWAVE.ICsByMessageID(pResult.SentenceIDString);

                        if (sentenceID != ICs.IC_INVALID)
                        {
                            if (parsers.ContainsKey(sentenceID))
                            {
                                parsers[sentenceID](pResult.parameters);
                            }
                            else
                            {
                                // skip unsupported sentence
                                if (UnknownSentenceReceived != null)
                                {
                                    UnknownSentenceReceived.Rise(this, new UnknownSentenceEventArgs(result));
                                }
                                else
                                {
                                    OnInfoEvent(string.Format("WARNING: unsupported sentence identifier \"{0}\" (\"{1}\") in \"{2}\"", sentenceID, pResult.SentenceIDString, e.Message));
                                }
                            }
                        }
                        else
                        {
                            // skip unknown sentence ID
                            if (UnknownSentenceReceived != null)
                            {
                                UnknownSentenceReceived.Rise(this, new UnknownSentenceEventArgs(result));
                            }
                            else
                            {
                                OnInfoEvent(string.Format("WARNING: unsupported sentence identifier \"{0}\" in \"{1}\"", pResult.SentenceIDString, e.Message));
                            }
                        }
                    }
                    else
                    {
                        // skip unsupported manufacturer ID
                        if (UnknownSentenceReceived != null)
                        {
                            UnknownSentenceReceived.Rise(this, new UnknownSentenceEventArgs(result));
                        }
                        else
                        {
                            OnInfoEvent(string.Format("WARNING: unsupported manufacturer identifier \"{0}\" in \"{1}\"", pResult.SentenceIDString, e.Message));
                        }
                    }
                }
                else
                {
                    // skip standard sentence
                    if (UnknownSentenceReceived != null)
                    {
                        UnknownSentenceReceived.Rise(this, new UnknownSentenceEventArgs(result));
                    }
                    else
                    {
                        OnInfoEvent(string.Format("WARNING: unsupported standard sentence \"{0}\"", e.Message));
                    }
                }
            }
        }
Example #6
0
        private void nmeaPort_NewMessage(object sender, NewNMEAMessageEventArgs e)
        {
            NMEAProprietarySentence nmeaMsg = new NMEAProprietarySentence();
            bool isParsed = false;

            InvokeWriteLogString(string.Format("<< {0}", e.Message));

            #region try parse

            try
            {
                var tempMsg = NMEAParser.Parse(e.Message);

                if (tempMsg is NMEAProprietarySentence)
                {
                    nmeaMsg  = (tempMsg as NMEAProprietarySentence);
                    isParsed = true;
                }
                else
                {
                    InvokeWriteLogString(string.Format("Skipping sentence {0}", (tempMsg as NMEAStandartSentence).SentenceID));
                }
            }
            catch (Exception ex)
            {
                ProcessException(ex, false);
            }

            #endregion

            if (isParsed)
            {
                timer.Stop();
                if (nmeaMsg.Manufacturer == ManufacturerCodes.UCN)
                {
                    if (nmeaMsg.SentenceIDString == "L")
                    {
                        repeats = 0;
                        UCNL_SRV_CMD cmdID = (UCNL_SRV_CMD)(int)nmeaMsg.parameters[0];

                        switch (cmdID)
                        {
                        case UCNL_SRV_CMD.DEV_INFO_VAL:
                        {
                            // $PUCNL,x,x,c--c
                            InvokeWriteLogString(Utils.ParseDevInfoStr((string)nmeaMsg.parameters[2]));
                            action = UCNL_FW_ACTION.INVOKE_FW_REQ;

                            if (isExtraPauseBeforeFWUPDATE)
                            {
                                MessageBox.Show("Turn off S_MODE in your device and press OK", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }


                            RequestFWUpdate(IsRedNAVRedNODE);
                            break;
                        }

                        case UCNL_SRV_CMD.ACK:
                        {
                            // $PUCNL,x,x,c--c
                            InvokeWriteLogString("DEVICE: Firmware update mode ON\r\n");
                            nmeaPort.IsRawModeOnly = true;

                            if (InitialBaudrate != BaudRate.baudRate115200)
                            {
                                action = UCNL_FW_ACTION.PORT_REOPENING;
                                ReopenPort();
                            }
                            else
                            {
                                action = UCNL_FW_ACTION.FW_UPDATE_INIT;
                                RequestTransferSize();
                            }

                            break;
                        }
                        }
                    }
                }
                else
                {
                    InvokeWriteLogString(string.Format("Skipping sentence {0}", nmeaMsg.SentenceIDString));
                }
            }
        }
Example #7
0
        private void gtrPort_NewNMEAMessage(object sender, NewNMEAMessageEventArgs e)
        {
            logger.Write(string.Format("{0} (RedGTR) >> {1}", gtrPort.PortName, e.Message));

            try
            {
                var result = NMEAParser.Parse(e.Message);

                if (result is NMEAProprietarySentence)
                {
                    NMEAProprietarySentence pResult = result as NMEAProprietarySentence;

                    if (pResult.Manufacturer == ManufacturerCodes.TNT)
                    {
                        if (pResult.SentenceIDString == "0") // ACK
                        {
                            Parse_ACK(pResult.parameters);
                        }
                        else if (pResult.SentenceIDString == "!") // Device info
                        {
                            Parse_DEVICE_INFO(pResult.parameters);
                        }
                        else if (pResult.SentenceIDString == "5")
                        {
                            Parse_LOC_DATA_VAL(pResult.parameters);
                        }
                        else if (pResult.SentenceIDString == "9")
                        {
                            Parse_REM_RECEIVED(pResult.parameters);
                        }
                        else if (pResult.SentenceIDString == "B")
                        {
                            Parse_REM_TOUT(pResult.parameters);
                        }
                        else if (pResult.SentenceIDString == "C")
                        {
                            Parse_REM_PONG(pResult.parameters);
                        }
                        else if (pResult.SentenceIDString == "D")
                        {
                            Parse_REM_PONGEX(pResult.parameters);
                        }
                        else if (pResult.SentenceIDString == "O")
                        {
                            Parse_PRETMP_VAL(pResult.parameters);
                        }
                    }
                    else
                    {
                        // not supported manufacturer code
                    }
                }
                else
                {
                    NMEAStandartSentence sSentence = result as NMEAStandartSentence;

                    if (sSentence.SentenceID == SentenceIdentifiers.RMC)
                    {
                        Parse_RMC(sSentence.parameters);
                    }
                }
            }
            catch (Exception ex)
            {
                ProcessException(ex, false);
            }
        }
Example #8
0
        private void port_NewNMEAMessage(object sender, NewNMEAMessageEventArgs e)
        {
            if (LogEvent != null)
            {
                LogEvent(this, new LogEventArgs(LogLineType.INFO, string.Format("<< {0}", e.Message)));
            }

            try
            {
                var sentence = NMEAParser.Parse(e.Message);

                if (sentence is NMEAProprietarySentence)
                {
                    NMEAProprietarySentence snt = ((NMEAProprietarySentence)(sentence));

                    if (snt.SentenceIDString == "0")
                    {
                        // ACK - analyze error code
                        Process_ACK(snt.parameters);
                    }
                    else if (snt.SentenceIDString == "5")
                    {
                        // local data value
                        Process_LOC_DATA(snt.parameters);
                    }
                    else if (snt.SentenceIDString == "!")
                    {
                        // device info
                        Process_DEVICE_INFO(snt.parameters);
                    }
                    else if (snt.SentenceIDString == "C")
                    {
                        Process_FIX_UPDATE(snt.parameters);
                    }
                    else if (snt.SentenceIDString == "M")
                    {
                        Process_BUOYS_STATUS(snt.parameters);
                    }
                    else if (snt.SentenceIDString == "N")
                    {
                        Process_DPTTMP(snt.parameters);
                    }
                    else if (snt.SentenceIDString == "O")
                    {
                        Process_PRETMP(snt.parameters);
                    }
                    else
                    {
                        if (LogEvent != null)
                        {
                            LogEvent(this, new LogEventArgs(LogLineType.ERROR, string.Format("Unsupported sentence ID: {0}", snt.SentenceIDString)));
                        }
                    }
                }
                else
                {
                    NMEAStandartSentence snt = ((NMEAStandartSentence)(sentence));

                    if (snt.SentenceID == SentenceIdentifiers.GGA)
                    {
                        Process_GGA(snt.parameters);
                    }
                    else if (snt.SentenceID == SentenceIdentifiers.RMC)
                    {
                        Process_RMC(snt.parameters);
                    }
                    else if (snt.SentenceID == SentenceIdentifiers.MTW)
                    {
                        Process_MTW(snt.parameters);
                    }
                    else
                    {
                        if (LogEvent != null)
                        {
                            LogEvent(this, new LogEventArgs(LogLineType.ERROR, string.Format("Unsupported sentence ID: {0}", snt.SentenceID)));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if (LogEvent != null)
                {
                    LogEvent(this, new LogEventArgs(LogLineType.ERROR, ex));
                }
            }
        }
Example #9
0
        private void inPort_NewNMEAMessage(object sender, NewNMEAMessageEventArgs e)
        {
            NMEASentence parsedSentence = null;
            bool         isParsed       = false;

            logger.Write(string.Format("{0} >> {1}", inPort.PortName, e.Message));

            try
            {
                parsedSentence = NMEAParser.Parse(e.Message);
                isParsed       = true;
            }
            catch (Exception ex)
            {
                ProcessException(ex, false);
            }

            if (isParsed && (parsedSentence is NMEAProprietarySentence))
            {
                NMEAProprietarySentence pResult = (parsedSentence as NMEAProprietarySentence);
                if ((pResult.Manufacturer == ManufacturerCodes.VLB) &&
                    (pResult.SentenceIDString == "L"))
                {
                    // $PVLBL,ownLat,ownLon,ownDepth,ownBatV,targetDataID,targetDataValue,propagationTime,MSR
                    double        ownLat  = doubleNullChecker(pResult.parameters[0]);
                    double        ownLon  = doubleNullChecker(pResult.parameters[1]);
                    double        ownDpt  = doubleNullChecker(pResult.parameters[2]);
                    double        ownBatV = doubleNullChecker(pResult.parameters[3]);
                    RC_CODES_Enum dataID  = (RC_CODES_Enum)Enum.ToObject(typeof(RC_CODES_Enum), intNullChecker(pResult.parameters[4]));
                    double        dataVal = doubleNullChecker(pResult.parameters[5]);
                    double        pTime   = doubleNullChecker(pResult.parameters[6]);
                    double        msr     = doubleNullChecker(pResult.parameters[7]);

                    if ((!double.IsNaN(ownLat)) && (!double.IsNaN(ownLon)))
                    {
                        ownLatitude.Value  = ownLat;
                        ownLongitude.Value = ownLon;

                        if (!is_g_updated)
                        {
                            g            = UCNLPhysics.PHX.PHX_GravityConstant_Calc(ownLat);
                            is_g_updated = true;
                            logger.Write(string.Format(CultureInfo.InvariantCulture, "Gravity constant updated: {0:F04} m/s^2", g));
                        }
                    }

                    if (!double.IsNaN(ownDpt))
                    {
                        ownDepth.Value = ownDpt;
                    }

                    if (!double.IsNaN(ownBatV))
                    {
                        ownBatteryVoltage.Value = ownBatV;
                    }

                    if (!double.IsNaN(pTime))
                    {
                        targetPTime.Value = pTime;
                    }

                    if (!double.IsNaN(msr))
                    {
                        targetMSR.Value = msr;
                    }

                    if (!double.IsNaN(dataVal))
                    {
                        if (dataID == RC_CODES_Enum.RC_DPT_GET)
                        {
                            targetDepth.Value = dataVal;
                        }
                        else if (dataID == RC_CODES_Enum.RC_TMP_GET)
                        {
                            targetTemperature.Value = dataVal;
                            TryUpdateSoundSpeed();
                        }
                        else if (dataID == RC_CODES_Enum.RC_BAT_V_GET)
                        {
                            targetBatVoltage.Value = dataVal;
                        }
                    }

                    if (!double.IsNaN(ownLat) && !double.IsNaN(ownLon) && !double.IsNaN(ownDpt))
                    {
                        if (!double.IsNaN(pTime) &&
                            targetDepth.IsInitializedAndNotObsolete)
                        {
                            vlblCore.TargetDepth = targetDepth.Value;
                            vlblCore.AddMeasurement(new VLBLTOAMeasurement(ownLat, ownLon, ownDpt, pTime * soundSpeedMps));

                            UpdateTrack("Measurements", new GeoPoint3D(ownLat, ownLon, ownDpt));
                        }
                        else
                        {
                            UpdateTrack("Rover", new GeoPoint3D(ownLat, ownLon, ownDpt));
                        }
                    }
                }
            }
        }