示例#1
0
        static void RunFileGenerator(FileGeneratorOptions options, IProgress <string> progress)
        {
            var random = new Random(options.Seed);

            var fileSize   = BytesStringParser.ParseBytesString(options.FileSize ?? throw new ArgumentNullException("File Size cannot be null."));
            var bufferSize = BytesStringParser.ParseBytesString(options.BufferSize ?? throw new ArgumentNullException("Buffer Size cannot be null."));
            var range      = RangeParser.Parse(options.Range);

            if (bufferSize > int.MaxValue)
            {
                throw new ArgumentOutOfRangeException($"Buffer size cannot be greater then {int.MaxValue} bytes.");
            }

            var stopwatch = Stopwatch.StartNew();

            progress.Report($"Starting random file data generation at {DateTime.Now}...");

            RandomFileGenerator.GenerateFile(
                options.OutputFile,
                random,
                options.PossibleStrings.ToArray(),
                range,
                fileSize,
                (int)bufferSize,
                progress);

            stopwatch.Stop();
            progress.Report($"File generated at {DateTime.Now}. Elapsed time: {stopwatch.Elapsed}");
        }
示例#2
0
        public void ValidRange(string source, int min, int max)
        {
            var result = RangeParser.Parse(source);

            Assert.AreEqual(result.Start.Value, min);
            Assert.AreEqual(result.End.Value, max);
        }
示例#3
0
        public void Range_WithListChild()
        {
            //Arrange
            string      range  = "[(- (# l) 1) 0 -2]";
            RangeParser parser = new RangeParser();

            //Act
            RangeNode node = (RangeNode)parser.Parse(range);

            //Assert
            Assert.AreEqual(3, node.Children.Count);
        }
示例#4
0
 public void RangeParserTest()
 {
     var chars = new List<char>();
     var rangeParser = new RangeParser<char>('a', 'z');
     int endInput;
     char value;
     rangeParser.Parse(chars,0,out endInput, out value).IsFalse();
     endInput.Is(0);
     chars.Add('a');
     rangeParser.Parse(chars,0,out endInput, out value).IsTrue();
     endInput.Is(1);
     value.Is('a');
     chars.Add('0');
     rangeParser.Parse(chars,1,out endInput, out value).IsFalse();
     endInput.Is(1);
     value.Is(default(char));
 }
        public void ThrowArgumentException_EmptyString()
        {
            var parser = new RangeParser();

            Assert.Throws <ArgumentException>(() => parser.Parse(null));
        }
示例#6
0
        /*
         */

        static void Main(string[] args)
        {
            List <Log> logs = new List <Log>();

            string inifile = "NovLog.ini";

            if (!File.Exists(inifile))
            {
                Console.Error.WriteLine("Ini-file {0} not found!", inifile);
            }

            // Read ini-file
            FileIniDataParser parser  = new FileIniDataParser();
            IniData           iniData = parser.ReadFile(inifile);

            logDir = iniData["NovLog"]["log-folder"];

            // Iterate over messages
            foreach (SectionData section in iniData.Sections)
            {
                if (section.SectionName == "NovLog")
                {
                    continue;
                }

                Log l = new Log();
                l.name = section.SectionName.ToUpper();

                if (String.Equals(iniData[section.SectionName]["trigger"], "ontime", StringComparison.InvariantCultureIgnoreCase))
                {
                    l.request = String.Format("log {0} ontime {1}", l.name, iniData[section.SectionName]["interval"]);
                }
                else
                {
                    l.request = String.Format("log {0} {1}", l.name, iniData[section.SectionName]["trigger"]);
                }

                logs.Add(l);
            }

            debug = bool.Parse(iniData["NovLog"]["debug"]);
            bool autol5 = bool.Parse(iniData["NovLog"]["auto-L5"]);

            // Open serialport
            SerialPort gps = new SerialPort(iniData["NovLog"]["com-port"]);

            gps.Open();

            string junk;

            if (String.Equals(iniData["NovLog"]["discard-on-start"], "true", StringComparison.InvariantCultureIgnoreCase))
            {
                junk = gps.ReadExisting();
            }

            // Request logs
            gps.Write("unlogall THISPORT_ALL\r\n");
            logs.ForEach(l => gps.Write(l.request + "\r\n"));

            // Test L5
            int[] BlockIIF   = new int[] { 1, 3, 6, 8, 9, 10, 24, 25, 26, 27, 30, 32 };
            int[] L5channels = new int[6];
            int   L5interval = 0;
            int   L5obsCnt   = 0;

            RangeParser rp = new RangeParser();

            rp.ParseL5 = autol5;

            while (true)
            {
                string line = gps.ReadLine().Trim();

                // Check CRC, skip junk
                if (!RangeParser.CRCok(line))
                {
                    continue;
                }

                string[] words = line.Split(',');

                // Find Log-object. If not found, skip line
                Log log = logs.Find(s => s.name.Equals(words[0].TrimStart('#')));
                if (log == null)
                {
                    continue;
                }

                DateTime epoch = FromGpsWeek(int.Parse(words[5]), double.Parse(words[6]));
                if (log.logFileDate != epoch.Date)
                {
                    OpenLogfile(log, epoch);
                }

                log.logFile.WriteLine(line);

                // Process RANGEA special - assign the strongest Block IIR SNR sats to the L5 channels
                if (autol5 && line.StartsWith("#RANGEA"))
                {
                    Epoch e = rp.Parse(line);
                    L5obsCnt += e.Count(s => s.L5 != null);

                    if (--L5interval < 1)
                    {
                        L5interval = 30;
                    }
                    else
                    {
                        continue;
                    }

                    if (debug)
                    {
                        Console.WriteLine("{0} Evaluating L5 channels,  {1} observations since last", DateTime.Now, L5obsCnt);
                    }

                    L5obsCnt = 0;

                    // Check to see that the sats we've assigned to the L5 channels are still being tracked
                    for (int i = 0; i < 6; i++)
                    {
                        if (L5channels[i] == 0)
                        {
                            continue;
                        }

                        if (e.Find(s => s.PRN == L5channels[i]) == null)
                        {
                            if (debug)
                            {
                                Console.WriteLine("Not tracking PRN {0} on channel {1}", L5channels[i], i + 14);
                            }
                            L5channels[i] = 0;
                        }
                    }
                    // Find BlockIIF satellites not already being tracked, that has L1 observations
                    List <Sat> candidates = e.Where(s =>
                                                    BlockIIF.Contains(s.PRN) &&
                                                    !L5channels.Contains(s.PRN) &&
                                                    s.L1 != null &&
                                                    s.System == 'G'
                                                    ).ToList <Sat>();

                    // Sort candidate satellites by SNR on L1
                    Sat[] c  = candidates.OrderBy(s => s.L1.snr).ToArray <Sat>();
                    int   ix = 0;
                    for (int i = 0; i < 6; i++)
                    {
                        if (L5channels[i] == 0)
                        {
                            if (ix > c.Length - 1)
                            {
                                break;
                            }

                            L5channels[i] = c[ix++].PRN;

                            if (debug)
                            {
                                Console.WriteLine("Assigning PRN {0} to channel {1}", L5channels[i], i + 14);
                            }

                            gps.Write(String.Format("assign {0} {1}\r\n", i + 14, L5channels[i]));
                        }
                    }
                }
            }
        }
示例#7
0
        static void Main(string[] args)
        {
            // Set cultureinfo to InvariantCulture, use dot as decimal separator in output and input
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            List <Epoch> epochs = new List <Epoch>();

            string      line;
            RangeParser rp = new RangeParser();

            while ((line = Console.ReadLine()) != null)
            {
                Epoch e = rp.Parse(line);
                if (e != null)
                {
                    epochs.Add(e);
                }
            }

            // Output TEC estimate
            foreach (Epoch e in epochs)
            {
                //double codeTEC = 0;
                //double phaseTEC = 0;
                //int codeCnt = 0;
                //int phaseCnt = 0;

                double[] codeTECs  = new double[33];
                double[] phaseTECs = new double[33];

                foreach (Sat s in e)
                {
                    // Only GPS for now
                    if (s.System != 'G')
                    {
                        continue;
                    }

                    // Ignore satellites with only L1 or L2 observations
                    if (s.L1 == null || s.L2 == null)
                    {
                        continue;
                    }

                    // Average - poor results
                    //// Geometry-free combination of pseudorange (Phase)
                    //if (s.L1.adr != 0 && s.L2.adr != 0)
                    //{
                    //    phaseTEC += s.L1.adr - s.L2.adr;
                    //    phaseCnt++;
                    //}

                    // Geometry-free combination of pseudorange (Code)
                    //if(s.L1.psr != 0 && s.L2.psr != 0)
                    //{
                    //    codeTEC += s.L2.psr - s.L1.psr;
                    //    codeCnt++;
                    //}

                    // Plot each SV in its own column
                    // Geometry-free combination of pseudorange (Phase)
                    if (s.L1.adr != 0 && s.L2.adr != 0)
                    {
                        phaseTECs[s.PRN] = s.L1.adr - s.L2.adr;
                    }

                    // Geometry-free combination of pseudorange (Code)
                    if (s.L1.psr != 0 && s.L2.psr != 0)
                    {
                        codeTECs[s.PRN] = s.L2.psr - s.L1.psr;
                    }

                    /*
                     * The data, when plotted, shows "phase jumps". Ambiguities?
                     *
                     * Possible way to solve for this specific case - may/will result in offset of the whole arc:
                     * 1. L1 and L2 need to be dealt with separately - ambiguity on L2 does not necessarily correspond to ambiguity on L1(?)
                     * 2. For each SV
                     * 3. Find first observation. StartIndex
                     * 4. Find last observation. EndIndex
                     * 5. Take "data arc", differentiate, calculate Median Absolute Deviation
                     * 6. Remove outliers, Integrate back
                     * 6. (opt) the Geometry-free combination of low elevation satellites will be larger than high
                     *      elevation satellites - more ionosphere to pass through. Remove qubic fit from data arc?
                     * 7. Write back to observations
                     * 8. Take Geometry-free combinations as before.
                     */

                    //Console.WriteLine("{0};{1};{2}", e.timestamp, codeTEC / codeCnt, phaseTEC/phaseCnt);
                }

                Console.Write("{0};", e.timestamp);
                for (int i = 1; i < 32; i++)
                {
                    Console.Write("{0};{1};", phaseTECs[i], codeTECs[i]);
                }

                Console.WriteLine();
            }
        }
示例#8
0
 public void InvalidRange(string source)
 {
     Assert.Throws <ArgumentException>(() => RangeParser.Parse(source));
 }