示例#1
0
 private void OnSystemUpdate()
 {
     systemUpdateTS = 0;
     SystemUpdateEvent.Rise(this, new EventArgs());
 }
示例#2
0
 private void pCore_RadialErrorExeedsThresholdEventHandler(object sender, EventArgs e)
 {
     IsRadialErrorExeedsThreshold = true;
     SystemUpdateEvent.Rise(this, new EventArgs());
 }
示例#3
0
        public RWLT_Core(SerialPortSettings rwltPortSettings, double radialErrorThreshold, double simplexSize,
                         int courseEstimatorFIFOSize, int trkFilterFIFOSize)
        {
            #region parameters

            var basesIDs = Enum.GetValues(typeof(BaseIDs));
            foreach (BaseIDs baseID in basesIDs)
            {
                if (baseID != BaseIDs.BASE_INVALID)
                {
                    BaseBatVoltages.Add(baseID, new AgingValue <double>(4, 10, svoltageFormatter));
                    BaseMSRs.Add(baseID, new AgingValue <double>(4, 10, msrFormatter));
                }
            }

            HDOPState = new AgingValue <DOPState>(4, 10, x => x.ToString().ToUpperInvariant());
            TBAState  = new AgingValue <TBAQuality>(4, 10, x => x.ToString().Replace('_', ' ').ToUpperInvariant());

            TargetLatitude            = new AgingValue <double>(4, 10, latlonFormatter);
            TargetLongitude           = new AgingValue <double>(4, 10, latlonFormatter);
            TargetLocationRadialError = new AgingValue <double>(4, 10, rerrFormatter);
            TargetPressure            = new AgingValue <double>(6, 10, prsFormatter);
            TargetTemperature         = new AgingValue <double>(60, 120, tempFormatter);
            TargetBatVoltage          = new AgingValue <double>(30, 120, svoltageFormatter);
            TargetDepth = new AgingValue <double>(6, 10, dptdstFormatter);
            TargetAlarm = new AgingValue <PingerCodeIDs>(600, 6000, pAlmFormatter);

            DistanceToTarget       = new AgingValue <double>(4, 10, dptdstFormatter);
            ForwardAzimuthToTarget = new AgingValue <double>(4, 10, courseFormatter);
            ReverseAzimuthToTarget = new AgingValue <double>(4, 10, courseFormatter);

            TargetCourse = new AgingValue <double>(4, 10, courseFormatter);

            AUXLatitude  = new AgingValue <double>(4, 10, latlonFormatter);
            AUXLongitude = new AgingValue <double>(4, 10, latlonFormatter);
            AUXTrack     = new AgingValue <double>(4, 10, courseFormatter);
            AUXSpeed     = new AgingValue <double>(4, 10, speedFormatter);

            CEP   = new AgingValue <double>(4, 300, x => string.Format(CultureInfo.InvariantCulture, "{0:F03} m", x));
            DRMS  = new AgingValue <double>(4, 300, x => string.Format(CultureInfo.InvariantCulture, "{0:F03} m", x));
            DRMS2 = new AgingValue <double>(4, 300, x => string.Format(CultureInfo.InvariantCulture, "{0:F03} m", x));
            DRMS3 = new AgingValue <double>(4, 300, x => string.Format(CultureInfo.InvariantCulture, "{0:F03} m", x));

            #endregion

            #region trkFilter

            trkFilter = new TrackFilter(trkFilterFIFOSize);

            #endregion

            #region pCore

            pCore = new PCore2D <GeoPoint3DT>(radialErrorThreshold, simplexSize, Algorithms.WGS84Ellipsoid, courseEstimatorFIFOSize);
            pCore.RadialErrorExeedsThrehsoldEventHandler += new EventHandler(pCore_RadialErrorExeedsThresholdEventHandler);
            pCore.TargetLocationUpdatedExHandler         += new EventHandler <TargetLocationUpdatedExEventArgs>(pCore_TargetLocationUpdatedExEventHandler);
            pCore.BaseQualityUpdatedHandler += new EventHandler <BaseQualityUpdatedEventArgs>(pCore_BaseQualityUpdatedEventHandler);

            #endregion

            #region basesProcessor

            baseProcessor = new RWLT_BaseProcessor(4, 2.0);

            #endregion

            #region NMEA

            if (!nmeaSingleton)
            {
                NMEAParser.AddManufacturerToProprietarySentencesBase(ManufacturerCodes.RWL);
                NMEAParser.AddProprietarySentenceDescription(ManufacturerCodes.RWL, "A", "x,x.x,x.x,x.x,x.x,x,x.x,x.x,x.x");
            }

            #endregion

            #region inPort

            inPort = new NMEASerialPort(rwltPortSettings);
            inPort.NewNMEAMessage += (o, e) =>
            {
                LogEvent.Rise(o, new LogEventArgs(LogLineType.INFO, string.Format("{0} (IN) >> {1}", inPort.PortName, e.Message)));
                NMEAListener.ProcessIncoming(0, e.Message);
            };

            inPort.PortError += (o, e) => LogEvent.Rise(o, new LogEventArgs(LogLineType.ERROR, string.Format("{0} (IN) >> {1}", inPort.PortName, e.EventType.ToString())));

            #endregion

            #region NMEAListener

            NMEAListener = new NMEAMultipleListener();
            NMEAListener.NMEAProprietaryUnsupportedSentenceParsed += new EventHandler <NMEAUnsupportedProprietaryEventArgs>(NMEAPSentenceReceived);
            NMEAListener.RMCSentenceReceived += new EventHandler <RMCMessageEventArgs>(GNSS_RMCSentenceReceived);

            #endregion

            #region timer

            timer        = new PrecisionTimer();
            timer.Period = 100;
            timer.Tick  += (o, e) =>
            {
                if (++systemUpdateTS > systemUpdateLimit)
                {
                    systemUpdateTS = 0;
                    SystemUpdateEvent.Rise(this, new EventArgs());
                }

                if (inPort.IsOpen && (++inPortTimeoutTS > inPortTimeoutLimit))
                {
                    inPortTimeoutTS = 0;
                    InPortTimeout   = true;
                    LogEvent.Rise(this, new LogEventArgs(LogLineType.ERROR, string.Format("{0} (IN) >> TIMEOUT", inPort.PortName)));
                }

                if (AUXGNSSUsed && auxGNSSPort.IsOpen && (++AUXGNSSTimeoutTS > AUXGNSSTimeoutLimit))
                {
                    AUXGNSSTimeoutTS = 0;
                    AUXGNSSTimeout   = true;
                    LogEvent.Rise(this, new LogEventArgs(LogLineType.ERROR, string.Format("{0} (AUX) >> TIMEOUT", auxGNSSPort.PortName)));
                }
            };

            timer.Start();

            #endregion

            statHelper = new List <GeoPoint>();
        }