Exemple #1
0
        public void CodeTest()
        {
            // SmsAwsPreParser parser = new SmsAwsPreParser();
            var          smsAwsParser = new SmsAwsParser();
            const string s            = "(S:JABALALKAWR;D:050914;T:170000;PR:0.6;TA:1.1)";
            var          results      = smsAwsParser.ParseMessage(s);

            Assert.True(results.Count == 2);

            ValidateResults(results);

            var testTime = new DateTime(2005, 9, 14, 17, 0, 0);
            var msg      = smsAwsParser.ParseMessageIntoMeasMsg(s);

            Assert.True(msg.Station == "JABALALKAWR");
            var meas = new Meas();

            Assert.True(msg.GetMeasByName("PR", ref meas));
            //Assert.True(((Meas)(msg.MeasList[0])).ObsTime ==  testTime);
            Assert.True(meas.ObsTime == testTime);
            Assert.True(msg.Count == 2);

            // Test starts here
            var tmp = SmsAwsParser.Code(msg);

            Assert.True(tmp.Length > 0);
            results = smsAwsParser.ParseMessage(tmp);
            Assert.True(results.Count == 2);
            ValidateResults(results);
        } // ParserTest1
Exemple #2
0
 private bool ParseVariables(string[] variables, string[] data, ref MeasMsg measMsg)
 {
     try
     {
         int dataLen      = data.GetLength(0);
         int varLen       = variables.GetLength(0);
         int loopMaxIndex = Math.Min(dataLen, varLen);
         //if (dataLen > varLen)
         //    return false;
         for (var i = 0; i < loopMaxIndex; i++)
         {
             if (variables[i].Length > 0)
             {
                 var meas = new Meas(variables[i], dateTime, data[i], MeasStatus.c*K);
                 measMsg.AddMeas(meas);
                 if (variables[i] == "WSAVG1M")
                 {
                     meas = new Meas("WS", dateTime, data[i], MeasStatus.c*K);
                     measMsg.AddMeas(meas);
                 }
                 else if (variables[i] == "WDAVG1M")
                 {
                     meas = new Meas("WD", dateTime, data[i], MeasStatus.c*K);
                     measMsg.AddMeas(meas);
                 }
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         ExceptionHandler.HandleException("WXT.ParseVariables", ex);
         return(false);
     }
 }
Exemple #3
0
        public void Load(Meas[] _MMeas, double _gain, SignalViewPars _pars, Color _color_dead, double[] _borders, bool _IsOn)
        {
            pars = _pars;
            IsOn = _IsOn;
            DataPointCollection pp = series.Points;

            pp.Clear();
            box.Visible    = IsOn;
            series.Enabled = IsOn;
            bline.Visible  = IsOn;
            bline1.Visible = IsOn;
            if (!IsOn)
            {
                return;
            }

            series.Color   = _pars.SColor;
            series.Enabled = _pars.View;
            box.Checked    = _pars.View;
            box.ForeColor  = _pars.View ? _pars.SColor : Color.Black;
            if (_MMeas == null)
            {
                return;
            }
            for (int i = 0; i < _MMeas.Length; i++)
            {
                double v = 0;
                Meas   m = _MMeas[i];
                switch (type)
                {
                case EType.Source:
                    v = m.Source;
                    break;

                case EType.Median:
                    v = m.Median;
                    break;

                case EType.Filter:
                    v = m.Filter;
                    break;

                case EType.FilterIn:
                    v = -m.FilterIn;
                    break;
                }
                v *= _gain;
                DataPoint p = new DataPoint(i, v);
                p.Color = m.Dead ? _color_dead : _pars.SColor;
                pp.Add(p);
            }
            bline.SetBorders(_borders);
            bline.Visible = box.Checked;
            bline1.SetBorders(new double[2] {
                -_borders[0], -_borders[1]
            });
            bline1.Visible = box.Checked;
        }
Exemple #4
0
        public static Meas RoundObsValueIfNumeric(Meas meas, int decimals)
        {
            string newValue = Conversion.RoundNumericalValue(meas.ObsValue, decimals);

            if (newValue == string.Empty)
            {
                newValue = "///";
            }
            return(new Meas(meas.Name, meas.ObsTime, newValue, meas.Status, meas.Station));
        }
Exemple #5
0
        public void SmsAwsParserTestWithNoStationOrDateTime()
        {
            // SmsAwsPreParser parser = new SmsAwsPreParser();
            var smsAwsParser = new SmsAwsParser()
            {
                indexOfFirstValue = 0
            };

            Assert.True(smsAwsParser.indexOfFirstValue == 0);

            var s       = string.Empty;
            var results = smsAwsParser.ParseMessage(s);

            Assert.True(results.Count == 0);

            s       = "(PR:0.6;TA:1.1)";
            results = smsAwsParser.ParseMessage(s);
            Assert.True(results.Count == 2);

            s       = "(S:;D:140901;T:170000;PR:0.6;TA:1.1)";
            results = smsAwsParser.ParseMessage(s);
            Assert.True(results.Count == 5);

            s       = "(S:JABALALKAWR;T:170000;PR:0.6;TA:1.1)";
            results = smsAwsParser.ParseMessage(s);
            Assert.True(results.Count == 4);

            s       = "(S:JABALALKAWR;D:140901;250000;PR:0.6;TA:1.1)";
            results = smsAwsParser.ParseMessage(s);
            Assert.True(results.Count == 2);

            s       = "(S:JABALALKAWR;D:140901;T:170000;PR:0.6;TA:1.1)";
            results = smsAwsParser.ParseMessage(s);
            Assert.True(results.Count == 5);

            s       = "(S:JABALALKAWR;D:140901;T:170000;PR:0.6;TA:1.1;)";
            results = smsAwsParser.ParseMessage(s);
            Assert.True(results.Count == 5);

            ValidateResults(results);


            var msg = smsAwsParser.ParseMessageIntoMeasMsg(s);

            Assert.True(msg.Station == "S1");
            var meas = new Meas();

            Assert.True(msg.GetMeasByName("PR", ref meas));
            //Assert.True(((Meas)(msg.MeasList[0])).ObsTime ==  testTime);
            TimeSpan diff = meas.ObsTime.Subtract(DateTime.Now);

            Assert.True(diff.TotalSeconds < 2);
            Assert.True(msg.Count == 5);
        } // ParserTest1
Exemple #6
0
        public void SmsAwsParserTest()
        {
            // SmsAwsPreParser parser = new SmsAwsPreParser();
            var smsAwsParser = new SmsAwsParser();

            Assert.True(smsAwsParser.indexOfFirstValue == 3);
            var s       = string.Empty;
            var results = smsAwsParser.ParseMessage(s);

            Assert.True(results.Count == 0);

            s       = "(PR:0.6;TA:1.1)";
            results = smsAwsParser.ParseMessage(s);
            Assert.True(results.Count == 0);

            s       = "(S:;D:050914;T:170000;PR:0.6;TA:1.1)";
            results = smsAwsParser.ParseMessage(s);
            Assert.True(results.Count == 0);

            s       = "(S:JABALALKAWR;T:170000;PR:0.6;TA:1.1)";
            results = smsAwsParser.ParseMessage(s);
            Assert.True(results.Count == 0);

            s       = "(S:JABALALKAWR;D:050914;250000;PR:0.6;TA:1.1)";
            results = smsAwsParser.ParseMessage(s);
            Assert.True(results.Count == 0);

            s       = "(S:JABALALKAWR;D:050914;T:170000;PR:0.6;TA:1.1)";
            results = smsAwsParser.ParseMessage(s);
            Assert.True(results.Count == 2);

            s       = "(S:JABALALKAWR;D:050914;T:170000;PR:0.6;TA:1.1;)";
            results = smsAwsParser.ParseMessage(s);
            Assert.True(results.Count == 2);

            s       = "(S:JABALALKAWR;D:050914;T:170000;PR:0.6;TIMEOFWS:12:00:00;)";
            results = smsAwsParser.ParseMessage(s);
            Assert.True(results.Count == 2);

            ValidateResults(results);

            var testTime = new DateTime(2005, 9, 14, 17, 0, 0);
            var msg      = smsAwsParser.ParseMessageIntoMeasMsg(s);

            Assert.True(msg.Station == "JABALALKAWR");
            var meas = new Meas();

            Assert.True(msg.GetMeasByName("PR", ref meas));
            //Assert.True(((Meas)(msg.MeasList[0])).ObsTime ==  testTime);
            Assert.True(meas.ObsTime == testTime);
            Assert.True(msg.Count == 2);
        } // ParserTest1
Exemple #7
0
        public void ArgTest()
        {
            var sb = new StringBuilder();

            sb.Append("(S:PTU;D:130827;T:103302;WSAVG2M:2.4;WDAVG2M:325;WSMAX2M:3.4;WDMAX2M:320;WGUSTTIME2M:10:32:25;WDGUST2M:316;WSAVG10M:2.6;WDAVG10M:300;WSMAX10M:3.6;WDMAX10M:313;WGUSTTIME10M:10:25:10;WDGUST10M:287;WSAVG1H:2.3;WDAVG1H:287;WSMAX1H:4.1;WDMAX1H:285;WGUSTTIME1H:10:10:14;WDGUST1H:276;WDMIN2M:290;WDMIN10M:276;WSMIN10M:2.1;WSMIN2M:2.2;EXTDC:13.4;VBATT:13.2)");
            var msg = sb.ToString();

            var smsAwsParser = new SmsAwsParser();
            var result       = smsAwsParser.ParseMessageIntoMeasMsg(msg);
            var meas         = new Meas();
            var ok           = result.GetMeasByName("WGUSTTIME10M", ref meas);

            Assert.True(ok);

            Assert.True(result.Count == 24);
        }
Exemple #8
0
        public void TestAwacNMEAParser_PNORS()
        {
            // SmsAwsPreParser parser = new SmsAwsPreParser();
            var awacNmeaParser = new AwacNMEAParser();

            var s       = String.Empty;
            var measMsg = awacNmeaParser.Parse(s);

            Assert.True(measMsg == null);



            var testTime = new DateTime(2010, 1, 1, 13, 0, 0);

            DateTimeEx.Now = testTime;
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            const string msg = "$PNORS,073010,050000,00,B0,13.4,1520.6,114.9,-0.5,1.6,22.314,18.92,1039,0*0B";

            measMsg = awacNmeaParser.Parse(msg);
            stopWatch.Stop();
            Debug.WriteLine("Time :" + stopWatch.ElapsedTicks);

            int count = Enum.GetValues(typeof(AwacNMEAParser.VarNameSensorMessage)).Length;

            Assert.True(measMsg.Count == count, "result count");
            Assert.True(measMsg.Time == DateTimeEx.Now);


            Assert.True(measMsg.Station == String.Empty);
            var meas2 = new Meas();

            Assert.True(measMsg.GetMeasByName(AwacNMEAParser.VarNameSensorMessage.AWAC_SENSOR_DATE.ToString(), ref meas2));
            Assert.True(meas2.ObsTime == testTime);


            string measValue;

            Assert.True((measMsg.GetMeasObsValueByName(AwacNMEAParser.VarNameSensorMessage.AWAC_SENSOR_ANALOG2.ToString(), out measValue)));
            Assert.True(measValue == "0");

            Assert.True((measMsg.GetMeasObsValueByName(AwacNMEAParser.VarNameSensorMessage.AWAC_SENSOR_ANALOG1.ToString(), out measValue)));
            Assert.True(measValue == "1039");
        } // Test
Exemple #9
0
        public void LatviaTest()
        {
            var sb = new StringBuilder();

            sb.Append(" (S:AWS;D:160114;T:133656;MAN.DW.SQUALL.DIRECTION:;MAN.DW.SPOUT.DIRECTION:;MAN.DW.SPOUT.PRECIPITATION:;MAN.DW.SNOW.CHARACTER:;MAN.DW.SQUALL.START:48960;MAN.DW.ICE.DIAMETER:;MAN.DW.ICE.TYPE:;MAN.DW.HAIL.OCCURRENCE:;MAN.DW.HAIL.MAX.DIAMETER:;MAN.DW.SNOW.EVOLUTION:;MAN.DW.SNOW.OCCURRENCE:;MAN.DW.SNOW.OBSCURATION:;MAN.DW.SPOUT.CHARACTER:;MAN.DW.SQUALL.WEATHER:8;MAN.DW.SQUALL.CHARACTER:;MAN.DW.SPOUT.WEATHER:;MAN.DW.SPOUT.OCCURRENCE:;MAN.DW.MIST.LOW.CLOUDTYPE:;MAN.DW.MIST.CLOUDLAYER:;MAN.DW.MIST.PHENOMENON:;MAN.DW.THUNDER.PRECIPITATION:;MAN.DW.THUNDER.DIRECTION:;MAN.DW.FOG.WITHPRECIPITATION:;MAN.DW.ICE.OCCURRENCE:;MAN.DW.SPOUT.INTENSITY:)਍");
            var msg = sb.ToString();

            var smsAwsParser = new SmsAwsParser();

            var result = smsAwsParser.ParseMessageIntoMeasMsg(msg);

            result.Channel = 0;

            var meas = new Meas();
            var ok   = result.GetMeasByName("MAN.DW.SQUALL.DIRECTION", ref meas);

            Assert.True(ok);
        }
Exemple #10
0
        public void TestAwacNMEAParser_PNORW()
        {
            // SmsAwsPreParser parser = new SmsAwsPreParser();
            var awacNmeaParser = new AwacNMEAParser();

            var s       = String.Empty;
            var measMsg = awacNmeaParser.Parse(s);

            Assert.True(measMsg == null);

            var testTime = new DateTime(2010, 1, 1, 13, 0, 0);

            DateTimeEx.Now = testTime;
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            const string msg = "$PNORW,073010,051001,3,4,0.55,0.51,0.63,0.82,2.76,3.33,2.97,55.06,78.91,337.62,0.48,22.35,0,1,0.27,129.11,0000*4E";

            measMsg = awacNmeaParser.Parse(msg);
            stopWatch.Stop();
            Debug.WriteLine("Time :" + stopWatch.ElapsedTicks);

            int count = Enum.GetValues(typeof(AwacNMEAParser.VarWaveMessage)).Length;

            Assert.True(measMsg.Count == count, "result count");
            Assert.True(measMsg.Time == DateTimeEx.Now);


            Assert.True(measMsg.Station == String.Empty);
            var meas2 = new Meas();

            Assert.True(measMsg.GetMeasByName(AwacNMEAParser.VarWaveMessage.AWAC_WAVE_NEAR_SURFACE_DIR.ToString(), ref meas2));
            Assert.True(meas2.ObsTime == testTime);


            string measValue;

            Assert.True((measMsg.GetMeasObsValueByName(AwacNMEAParser.VarWaveMessage.AWAC_WAVE_NEAR_SURFACE_DIR.ToString(), out measValue)));
            Assert.True(measValue == "129.11");

            Assert.True((measMsg.GetMeasObsValueByName(AwacNMEAParser.VarWaveMessage.AWAC_WAVE_NEAR_SURFACE_SPEED.ToString(), out measValue)));
            Assert.True(measValue == "0.27");
        } // Test
Exemple #11
0
        public void DisdroSmsAwsMsg()
        {
            // SmsAwsPreParser parser = new SmsAwsPreParser();
            var smsAwsParser = new SmsAwsParser();
            var sb           = new StringBuilder();

            var s       = string.Empty;
            var results = smsAwsParser.ParseMessage(s);

            Assert.True(results.Count == 0);

            sb.Append("      DCP_MSG   repþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ   L  ø  Qô  ‡!  ¼N  ñ{ý   ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ     |  æ  P  º  $  ŽûOWZ1   î   L   Z(S:Station3;D:120307;T:125300;PR1H:/;LAT:60.000000;LON:25.000000;QUAL:/;R1MIN:/;Z1MIN:/)");
            sb.Append(@"ûOWZm  [      Z(S:Station3;D:120307;T:125400;PR1H:7;LAT:60.000000;LON:25.000000;QUAL:/;R1MIN:/;Z1MIN:/)");
            sb.Append(@"ûOWZ©  È   î   Z(S:Station3;D:120307;T:125500;PR1H:/;LAT:60.000000;LON:25.000000;QUAL:/;R1MIN:/;Z1MIN:/)");
            sb.Append(@"ûOWZå  5  [   Z(S:Station3;D:120307;T:125600;PR1H:/;LAT:60.000000;LON:25.000000;QUAL:/;R1MIN:/;Z1MIN:/)");
            sb.Append(@"ûOW[   ¢  È   Z(S:Station3;D:120307;T:125700;PR1H:/;LAT:60.000000;LON:25.000000;QUAL:/;R1MIN:/;Z1MIN:/)");
            sb.Append(@"ûOW[\    5   Z(S:Station3;D:120307;T:125800;PR1H:/;LAT:60.000000;LON:25.000000;QUAL:/;R1MIN:/;Z1MIN:/)");
            sb.Append(@"ûOW[™  |  ¢   Z(S:Station3;D:120307;T:125900;PR1H:/;LAT:60.000000;LON:25.000000;QUAL:/;R1MIN:/;Z1MIN:/)");
            sb.Append(@"ûOW[Ô  í     ^(S:Station3;D:120307;T:130000;PR1H:0.000;LAT:60.000000;LON:25.000000;QUAL:/;R1MIN:/;Z1MIN:/)");
            sb.Append(@"ûOW\  ^  |   ^(S:Station3;D:120307;T:130100;PR1H:0.000;LAT:60.000000;LON:25.000000;QUAL:/;R1MIN:/;Z1MIN:/)");
            s       = sb.ToString();
            results = smsAwsParser.ParseMessage(s);
            Assert.True(results.Count == 70);


            var testTime     = new DateTime(2012, 3, 7, 12, 54, 0);
            var multiMeasMsg = smsAwsParser.ParseMessageIntoMultipleMeasMsg(s);

            foreach (var msg in multiMeasMsg.MeasMsgList)
            {
                Assert.True(msg.Station == "Station3");
                var meas = new Meas();
                Assert.True(msg.GetMeasByName("PR1H", ref meas));
                //Assert.True(((Meas)(msg.MeasList[0])).ObsTime ==  testTime);
                // Assert.True(meas.ObsTime == testTime);
                if (meas.ObsTime == testTime)
                {
                    Assert.True(meas.ObsValue == "7");
                    Assert.True(msg.Count == 6);
                }
            }
        } // ParserTest1
Exemple #12
0
        private void ParseDataItem(string start, string dataValue, MeasMsg measMsg)
        {
            if (!engineeringUnits.ContainsKey(start))
            {
                return;
            }
            if (!wxtNameToOcName.ContainsKey(start))
            {
                return;
            }
            int index = dataValue.IndexOf(engineeringUnits[start]);

            if (index == -1)
            {
                return;
            }
            var finalDataValue = dataValue.Substring(0, index);

            var meas = new Meas(wxtNameToOcName[start], dateTime, finalDataValue, MeasStatus.c*K);

            measMsg.AddMeas(meas);
        }
Exemple #13
0
        public void GetMeasByName()
        {
            var s = GetTestMeasMsg;

            var measMsg = new MeasMsg();

            Assert.True(measMsg.Initialise(s));
            Assert.True(measMsg.Count == 9);

            Meas m = new Meas();

            Assert.True(measMsg.GetMeasByName("TA", ref m));
            Assert.True(m.ObsValue == "0");
            Assert.True(measMsg.GetMeasByName("PA", ref m));
            Assert.True(m.ObsValue == "1008.42");
            Assert.False(measMsg.GetMeasByName("hafhafdghadfh", ref m));

            double paValue = -1;

            Assert.True(measMsg.GetNumericObsValueByName("PA", ref paValue));
            Assert.True(paValue == 1008.42);

            Assert.False(measMsg.GetNumericObsValueByName("XX", ref paValue));
        }
Exemple #14
0
        public void InitRange(ResultDef _resultDef, int _iz0, int _iz1, int _is, double _gain)
        {
            chart1.Series.SuspendUpdates();
            Clear();
            TypeSize ts = ParAll.ST.TSSet.Current;

            resultDef = _resultDef;
            iz0       = _iz0;
            iz1       = _iz1;
            ise       = _is;
            Color DeviderColor      = ParAll.ST.Some.SignalsView.DeviderColor;
            DataPointCollection p   = chart1.Series[0].Points;
            DataPointCollection pIn = chart1.Series[0].Points;
            int ip     = 0;
            int ipIn   = 0;
            int istrip = 0;

            chart1.ChartAreas[0].AxisX.StripLines.Clear();
            DefCL dcl  = new DefCL(_resultDef.Tp);
            bool  IsIn = dcl.IsFinterIn;

            for (int ii = _iz0; ii <= _iz1; ii++)
            {
                Meas[] MMeas = _resultDef.MZone[ii].MSensor[ise].MMeas;
                if (istrip > 0)
                {
                    StripLine sl = new StripLine();
                    sl.BorderColor    = DeviderColor;
                    sl.BorderWidth    = 2;
                    sl.IntervalOffset = ip;
                    chart1.ChartAreas[0].AxisX.StripLines.Add(sl);
                }
                istrip++;
                for (int i = 0; i < MMeas.Length; i++)
                {
                    Meas      m  = MMeas[i];
                    DataPoint dp = new DataPoint(ip, m.FilterABC * _gain);
                    dp.Color = m.Dead ? Classer.GetColor(EClass.None) : Classer.GetColor(m.Class);
                    dp.Tag   = new PointSubj(ii, ise, i);
                    p.Add(dp);
                    ip++;
                    if (IsIn)
                    {
                        pIn.AddXY(ipIn, -m.FilterInABC * _gain);
                        p[ipIn].Color = m.Dead ? Classer.GetColor(EClass.None) : Classer.GetColor(m.ClassIn);
                        ipIn++;
                    }
                }
                istrip++;
            }
            if (bline != null)
            {
                bline.Visible = false;
            }
            if (blineIn != null)
            {
                blineIn.Visible = false;
            }
            bline   = new BorderLine(chart1.ChartAreas[0].AxisY, Classer.GetColor(EClass.Brak), Classer.GetColor(EClass.Class2));
            blineIn = new BorderLine(chart1.ChartAreas[0].AxisY, Classer.GetColor(EClass.Brak), Classer.GetColor(EClass.Class2));
            bline.SetBorders(dcl.Borders);
            bline.Visible = true;

            if (IsIn)
            {
                double[] borders = new double[2];
                borders[0] = -dcl.Border1In;
                borders[1] = -dcl.Border2In;
                blineIn.SetBorders(borders);
                blineIn.Visible = true;
            }
            chart1.ChartAreas[0].AxisY.Maximum = 100;
            if (IsIn)
            {
                chart1.ChartAreas[0].AxisY.Minimum = -100;
            }
            else
            {
                chart1.ChartAreas[0].AxisY.Minimum = 0;
            }
            if (cursor.Visible)
            {
                OnMove(cursor.Position);
            }
            chart1.Series[0].Enabled = true;
            chart1.Series[1].Enabled = IsIn;
            chart1.Series.ResumeUpdates();
        }
Exemple #15
0
        public void TestAwacNMEAParser_PNORC()
        {
            // SmsAwsPreParser parser = new SmsAwsPreParser();
            var awacNmeaParser = new AwacNMEAParser();

            awacNmeaParser.CellDirectionVariables = new List <string>()
            {
                "CELL_DIR_1", "CELL_DIR_2", "CELL_DIR_3", "CELL_DIR_4"
            };
            awacNmeaParser.CellSpeedVariables = new List <string>()
            {
                "CELL_SPEED_1", "CELL_SPEED_2", "CELL_SPEED_3", "CELL_SPEED_4"
            };
            awacNmeaParser.CellDepthVariables = new List <string>()
            {
                "CELL_DEPTH_1", "CELL_DEPTH_2", "CELL_DEPTH_3", "CELL_DEPTH_4"
            };

            var s       = String.Empty;
            var measMsg = awacNmeaParser.Parse(s);

            Assert.True(measMsg == null);

            var testTime = new DateTime(2010, 1, 1, 13, 0, 0);

            DateTimeEx.Now = testTime;
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            const string msg = "$PNORC,073010,050000,1,0.10,-0.11,-0.01,0.15,137.2,C,88,83,87,,,*37";

            measMsg = awacNmeaParser.Parse(msg);
            stopWatch.Stop();
            Debug.WriteLine("Time :" + stopWatch.ElapsedTicks);

            int count = 2;

            Assert.True(measMsg.Count == count, "result count");
            Assert.True(measMsg.Time == DateTimeEx.Now);

            // data from cell 1 => awacNmeaParser.CellSpeedVariables[0] / .CellDirectionVariables[0] used
            Assert.True(measMsg.Station == String.Empty);
            var meas2 = new Meas();

            Assert.True(measMsg.GetMeasByName(awacNmeaParser.CellSpeedVariables[0], ref meas2));
            Assert.True(meas2.ObsTime == testTime);
            Assert.True(meas2.ObsValue == "0.15");

            Assert.True(measMsg.GetMeasByName(awacNmeaParser.CellDirectionVariables[0], ref meas2));
            Assert.True(meas2.ObsTime == testTime);
            Assert.True(meas2.ObsValue == "137.2");

            //string measValue;

            //Assert.True((measMsg.GetMeasObsValueByName(AwacNMEAParser.VarCurrentVelocityMessage.AWAC_CURR_VELOCITY_AMPLITUDE_3.ToString(), out measValue)));
            //Assert.True(measValue == "87");

            //Assert.True((measMsg.GetMeasObsValueByName(AwacNMEAParser.VarCurrentVelocityMessage.AWAC_CURR_VELOCITY_AMPLITUDE_2.ToString(), out measValue)));
            //Assert.True(measValue == "83");
        } // Test
Exemple #16
0
        public void TestAwacNMEAParser_PNORI()
        {
            // SmsAwsPreParser parser = new SmsAwsPreParser();
            var awacNmeaParser = new AwacNMEAParser();

            awacNmeaParser.CellDirectionVariables = new List <string>()
            {
                "CELL_DIR_1", "CELL_DIR_2", "CELL_DIR_3", "CELL_DIR_4"
            };
            awacNmeaParser.CellSpeedVariables = new List <string>()
            {
                "CELL_SPEED_1", "CELL_SPEED_2", "CELL_SPEED_3", "CELL_SPEED_4"
            };
            awacNmeaParser.CellDepthVariables = new List <string>()
            {
                "CELL_DEPTH_1", "CELL_DEPTH_2", "CELL_DEPTH_3", "CELL_DEPTH_4"
            };

            var s       = String.Empty;
            var measMsg = awacNmeaParser.Parse(s);

            Assert.True(measMsg == null);

            var testTime = new DateTime(2010, 1, 1, 13, 0, 0);

            DateTimeEx.Now = testTime;
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            const string msg = "$PNORI,3,WAV6103,3,20,0.51,2.00,0*16";

            measMsg = awacNmeaParser.Parse(msg);
            stopWatch.Stop();
            Debug.WriteLine("Time :" + stopWatch.ElapsedTicks);

            int count = Enum.GetValues(typeof(AwacNMEAParser.VarNameInfoMessage)).Length + awacNmeaParser.CellDepthVariables.Count;

            Assert.True(measMsg.Count == count, "result count");
            Assert.True(measMsg.Time == DateTimeEx.Now);


            Assert.True(measMsg.Station == String.Empty);
            var meas2 = new Meas();

            Assert.True(measMsg.GetMeasByName(AwacNMEAParser.VarNameInfoMessage.AWAC_INFO_INSTRUMENT.ToString(), ref meas2));
            Assert.True(meas2.ObsTime == testTime);


            string measValue;

            Assert.True((measMsg.GetMeasObsValueByName(AwacNMEAParser.VarNameInfoMessage.AWAC_INFO_INSTRUMENT.ToString(), out measValue)));
            Assert.True(measValue == "AWAC");

            Assert.True((measMsg.GetMeasObsValueByName(AwacNMEAParser.VarNameInfoMessage.AWAC_INFO_HEADID.ToString(), out measValue)));
            Assert.True(measValue == "WAV6103");

            Assert.True((measMsg.GetMeasObsValueByName(AwacNMEAParser.VarNameInfoMessage.AWAC_INFO_NUMBEAMS.ToString(), out measValue)));
            Assert.True(measValue == "3");

            Assert.True((measMsg.GetMeasObsValueByName(AwacNMEAParser.VarNameInfoMessage.AWAC_INFO_NUMCELLS.ToString(), out measValue)));
            Assert.True(measValue == "20");

            string blanking;

            Assert.True((measMsg.GetMeasObsValueByName(AwacNMEAParser.VarNameInfoMessage.AWAC_INFO_BLANKING.ToString(), out blanking)));
            Assert.True(blanking == "0.51");
            double blankingD = Double.Parse(blanking);

            string cellSize;

            Assert.True((measMsg.GetMeasObsValueByName(AwacNMEAParser.VarNameInfoMessage.AWAC_INFO_CELLSIZE.ToString(), out cellSize)));
            Assert.True(cellSize == "2");
            double cellSizeD = Double.Parse(cellSize);

            Assert.True((measMsg.GetMeasObsValueByName(AwacNMEAParser.VarNameInfoMessage.AWAC_INFO_COORD.ToString(), out measValue)));
            Assert.True(measValue == "ENU");

            for (int i = 0; i < awacNmeaParser.CellDepthVariables.Count; i++)
            {
                double dMeas;
                Assert.True(measMsg.GetNumericDoubleObsValueByName(awacNmeaParser.CellDepthVariables[i], out dMeas));
                Assert.True(meas2.ObsTime == testTime);
                double tmp = (blankingD + (i + 1) * cellSizeD);
                Assert.True(Math.Abs(dMeas - tmp) < 0.1);
            }
        } // Test