Example #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}");
        }
        public void ParseStatement_WhenBetweenDateTime_ExpectDateTimeParsed()
        {
            // Arrange
            var rangeParser = new RangeParser();

            // Act
            var stopwatch = Stopwatch.StartNew();
            var unaryNode = rangeParser.ParseStatement("{2018-1-2T10:11:11,2018-1-2T10:11:13}");

            stopwatch.Stop();

            // Assert
            this.WriteTimeElapsed(stopwatch);

            Assert.That(unaryNode, Is.Not.Null);

            Assert.That(unaryNode, Is.TypeOf(typeof(RangeOperator)));

            var rangeNode = (RangeOperator)unaryNode;

            Assert.That(rangeNode.Name, Is.Null);

            Assert.That(rangeNode.Name, Is.Null);
            Assert.That(rangeNode.Lower, Is.EqualTo(new DateTime(2018, 1, 2, 10, 11, 11)));
            Assert.That(rangeNode.Upper, Is.EqualTo(new DateTime(2018, 1, 2, 10, 11, 13)));
            Assert.That(rangeNode.LowerInclusive, Is.True);
            Assert.That(rangeNode.UpperInclusive, Is.True);
        }
        public void ParseStatement_WhenGreatThanDateTime_ExpectDateTimeParsed()
        {
            // Arrange
            var rangeParser = new RangeParser();

            // Act
            var stopwatch = Stopwatch.StartNew();
            var unaryNode = rangeParser.ParseStatement("{2018-1-2T10:11:12,*}");

            stopwatch.Stop();

            // Assert
            this.WriteTimeElapsed(stopwatch);

            Assert.That(unaryNode, Is.Not.Null);

            Assert.That(unaryNode, Is.TypeOf(typeof(GreaterThanOperator)));

            var rangeNode = (GreaterThanOperator)unaryNode;

            Assert.That(rangeNode.Name, Is.Null);

            Assert.That(rangeNode.Name, Is.Null);
            Assert.That(rangeNode.Value, Is.EqualTo(new DateTime(2018, 1, 2, 10, 11, 12)));
            Assert.That(rangeNode.Inclusive, Is.True);
        }
        public void ParseStatement_WhenNonInclusiveRange_ExpectCorrectRangeNode()
        {
            // Arrange
            var rangeParser = new RangeParser();

            // Act
            var stopwatch = Stopwatch.StartNew();
            var unaryNode = rangeParser.ParseStatement("[25,50]");

            stopwatch.Stop();

            // Assert
            this.WriteTimeElapsed(stopwatch);

            Assert.That(unaryNode, Is.Not.Null);

            Assert.That(unaryNode, Is.TypeOf(typeof(RangeOperator)));

            var rangeNode = (RangeOperator)unaryNode;

            Assert.That(rangeNode.Name, Is.Null);

            Assert.That(rangeNode.Lower, Is.EqualTo(25));
            Assert.That(rangeNode.Upper, Is.EqualTo(50));

            Assert.That(rangeNode.LowerInclusive, Is.False);
            Assert.That(rangeNode.UpperInclusive, Is.False);
        }
Example #5
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);
        }
Example #6
0
        protected override void Given()
        {
            Companies = new List <Company>
            {
                new Company {
                    Name = "Alpha"
                },
                new Company {
                    Name = "Beta"
                },
                new Company {
                    Name = "Gamma"
                },
                new Company {
                    Name = "Delta"
                },
                new Company {
                    Name = "Omega"
                },
                new Company {
                    Name = "Zeta"
                },
            };

            Parser = new RangeParser();
            Range  = "";
        }
Example #7
0
 protected override void Given()
 {
     Parser        = new RangeParser();
     Range         = "";
     Restriction   = "";
     ExpectedRange = "";
 }
Example #8
0
        protected override void Given()
        {
            Codes = new List <Code>
            {
                new Code {
                    Value = 100
                },
                new Code {
                    Value = 102
                },
                new Code {
                    Value = 104
                },
                new Code {
                    Value = 110
                },
                new Code {
                    Value = 120
                },
                new Code {
                    Value = 130
                },
            };

            Parser = new RangeParser();
            Range  = "";
        }
Example #9
0
        private static bool IsVersionSupported(string range)
        {
            var parser    = new RangeParser();
            var predicate = parser.Evaluate(range);
            var v         = Pcap.LibpcapVersion;
            var version   = new SemanticVersion(v.Major, v.Minor, Math.Max(v.Build, 0));

            return(predicate(version));
        }
        private static ReadResults ReadScores(EntitySelectorParser parser, IStringReader reader)
        {
            ReadResults readResults = reader.Expect('{');

            if (!readResults.Successful)
            {
                return(readResults);
            }

            reader.SkipWhitespace();
            while (reader.CanRead() && reader.Peek() != '}')
            {
                reader.SkipWhitespace();
                readResults = reader.ReadUnquotedString(out _);
                if (!readResults.Successful)
                {
                    return(readResults);
                }

                reader.SkipWhitespace();
                readResults = reader.Expect('=');
                if (!readResults.Successful)
                {
                    return(readResults);
                }

                reader.SkipWhitespace();
                readResults = new RangeParser <int>(reader).Read(int.TryParse, CommandError.InvalidInteger, int.MinValue, int.MaxValue, false, out Range <int> range);
                if (!readResults.Successful)
                {
                    return(readResults);
                }

                parser.AddArgument(new ParsedArgument <Range <int> >(range, false));
                reader.SkipWhitespace();
                if (reader.CanRead())
                {
                    char c = reader.Read();
                    if (c == ',')
                    {
                        continue;
                    }
                    if (c == '}')
                    {
                        return(ReadResults.Success());
                    }
                }
                return(ReadResults.Failure(CommandError.ExpectedCharacter('}').WithContext(reader)));
            }

            reader.SkipWhitespace();
            return(reader.Expect('}'));
        }
Example #11
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);
        }
Example #12
0
        private async Task OnExecuteAsync()
        {
            var fullPath = Path.GetFullPath(OutputFilePath);

            var getRangeResult = RangeParser.TryGetRange(Last, From, To, out var range);

            if (!string.IsNullOrEmpty(getRangeResult?.ErrorMessage))
            {
                ConsoleHelper.WriteError(getRangeResult.ErrorMessage);
                return;
            }

            var sas = Prompt.GetPassword("Shared Access Signature:", ConsoleColor.White, ConsoleColor.DarkBlue);

            Console.CancelKeyPress += ConsoleOnCancelKeyPress;

            try
            {
                ConsoleHelper.WriteDebug(
                    $"Querying 'WADLogsTable' from storage account '{StorageAccountHelper.GetStorageAccountName(sas)}' from {range}...");

                var repository = new Repository(sas);
                var logs       = await repository.GetLogsAsync(range, Token);

                ConsoleHelper.WriteDebug($"Writing {logs.Count} log event(s)...");

                using (var outputFile = File.CreateText(fullPath))
                {
                    outputFile.WriteLine("Generated,Level,Message");
                    foreach (var log in logs)
                    {
                        outputFile.WriteLine(log);
                    }
                }

                Console.WriteLine();
                ConsoleHelper.WriteDebug("Done");
            }
            catch (Exception e)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Exception: {0}", e.GetType());
                Console.WriteLine("Message: {0}", e.Message);
                Console.WriteLine("StackTrace:");
                Console.WriteLine(e.StackTrace);
            }
            finally
            {
                Console.ResetColor();
            }
        }
Example #13
0
 public void MapParserTest()
 {
     var chars = new List<char>();
     var p0 = new RangeParser<char>('A', 'Z');
     var mapParser = new MapParser<char, char, char, string>(
         p0, p0,
         (ch0, ch1) => new string(new[] {ch0, ch1}));
     int endInput;
     string result;
     mapParser.Parse(chars, 0, out endInput, out result).IsFalse();
     chars.Add('A');
     mapParser.Parse(chars,0, out endInput,out result).IsFalse();
     chars.Add('Z');
     mapParser.Parse(chars,0, out endInput, out result).IsTrue();
     result.Is("AZ");
 }
        public void GivenToWithoutFrom_WhenTryGetRange_ThenInvalid()
        {
            // Arrange

            const string last = null;
            const string from = null;
            const string to   = "2018-06-24";

            // Act

            var actual = RangeParser.TryGetRange(last, from, to, out _);

            // Assert

            Assert.NotNull(actual);
        }
        public void GivenNoLastAndNoFrom_WhenTryGetRange_ThenInvalid()
        {
            // Arrange

            const string last = null;
            const string from = null;
            const string to   = null;

            // Act

            var actual = RangeParser.TryGetRange(last, from, to, out _);

            // Assert

            Assert.NotNull(actual);
        }
Example #16
0
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        /// <typeparam name="TEntity">The type of the entity.</typeparam>
        /// <param name="parserOptions">The parser options.</param>
        /// <returns>The IEntityParser.</returns>
        private static object Initialize <TEntity>(ParserOptions parserOptions)
        {
            var tokenSplitter = new TokenSplitter();

            var rangeParser  = new RangeParser();
            var equalsParser = new EqualsParser();

            var entityParser = new EntityParser <TEntity>();
            var typeSplitter = new TypeSplitter();

            var whereStatementParser = new WhereStatementParser <TEntity>(rangeParser, equalsParser, entityParser, typeSplitter);
            var whereParser          = new WhereParser(whereStatementParser, parserOptions);
            var orderByParser        = new OrderByParser <TEntity>(entityParser);
            var pageParser           = new PageParser();
            var selectParser         = new SelectParser <TEntity>(entityParser);

            return(new StatementParser(tokenSplitter, whereParser, pageParser, orderByParser, selectParser));
        }
Example #17
0
        public void ParseWhere_WhenTwoParts_ExpectBinaryNode()
        {
            // Arrange
            var rangeParser          = new RangeParser();
            var equalsParser         = new EqualsParser();
            var entityParser         = new EntityParser <CustomEntity>();
            var typeSplitter         = new TypeSplitter();
            var whereStatementParser = new WhereStatementParser <CustomEntity>(rangeParser, equalsParser, entityParser, typeSplitter);
            var whereParser          = new WhereParser(whereStatementParser, new ParserOptions());

            // Act
            var stopwatch = Stopwatch.StartNew();
            var whereNode = whereParser.ParseWhere("testKey:testValue and testKey2:[23,2]");

            stopwatch.Stop();

            // Assert
            this.WriteTimeElapsed(stopwatch);

            var next1 = new WhereNode
            {
                Conjunctive = Conjunctives.None,
                Next        = null,
                Statement   = new WhereStatement {
                    As = null, Value = new RangeOperator {
                        Statement = "testKey2:[23,2]", Name = "testKey2", Lower = 23, LowerInclusive = false, Upper = 2, UpperInclusive = false
                    }
                }
            };

            var expected = new WhereNode
            {
                Conjunctive = Conjunctives.And,
                Next        = next1,
                Statement   = new WhereStatement {
                    As = null, Value = new EqualsOperator {
                        Statement = "testKey:testValue", Name = "testKey", CaseInsensitive = false, Value = "testValue", IsNot = false
                    }
                }
            };

            whereNode.ShouldDeepEqual(expected);
        }
        public void GivenFrom_WhenTryGetRange_ThenExpected()
        {
            // Arrange

            const string last = null;
            const string from = "2018-06-24";
            const string to   = null;

            // Act

            var actual = RangeParser.TryGetRange(last, from, to, out var actualRange);

            // Assert

            Assert.Null(actual);
            Assert.NotNull(actualRange);

            actualRange.From.Should().NotBe(default(DateTime));
            actualRange.To.Should().BeNull();
        }
Example #19
0
        private Func <SemanticVersion, bool> GetExlusiveVersionComparer(string range)
        {
            // Range should be one of the following formats: "(x.y.z, a.b.c)", "(x.y.z,)", "(, x.y.z)"
            Regex r     = new Regex(@"\((?<low>.*)?,(?<high>.*)?\)", RegexOptions.Compiled);
            var   match = r.Match(range);

            if (!match.Success)
            {
                Log.Error($"Could not find semantic version comparer for version range {range}");
                return(v => false);
            }

            string low  = match.Groups["low"].Value.Trim();
            string high = match.Groups["high"].Value.Trim();

            string expression = string.Empty;

            if (!string.IsNullOrEmpty(low))
            {
                expression = $"> {low}";
            }

            if (!string.IsNullOrEmpty(high))
            {
                if (string.IsNullOrEmpty(expression))
                {
                    expression = $"< {high}";
                }
                else
                {
                    expression += $" && < {high}";
                }
            }

            RangeParser parser = new RangeParser();

            return(parser.Evaluate(expression));
        }
Example #20
0
        public void ParseStatement_WhenNonInclusiveWildcardUpper_ExpectCorrectGreaterThanNode()
        {
            // Arrange
            var rangeParser = new RangeParser();

            // Act
            var stopwatch = Stopwatch.StartNew();
            var unaryNode = rangeParser.ParseStatement("[10,*]");

            stopwatch.Stop();

            // Assert
            this.WriteTimeElapsed(stopwatch);

            Assert.That(unaryNode, Is.Not.Null);

            Assert.That(unaryNode, Is.TypeOf(typeof(GreaterThanOperator)));

            var rangeNode = (GreaterThanOperator)unaryNode;

            Assert.That(rangeNode.Name, Is.Null);
            Assert.That(rangeNode.Value, Is.EqualTo(10));
            Assert.That(rangeNode.Inclusive, Is.False);
        }
Example #21
0
        public void ParseWhere_WhenSimpleQuery_ExpectNodeBack()
        {
            // Arrange
            var rangeParser          = new RangeParser();
            var equalsParser         = new EqualsParser();
            var entityParser         = new EntityParser <CustomEntity>();
            var typeSplitter         = new TypeSplitter();
            var whereStatementParser = new WhereStatementParser <CustomEntity>(rangeParser, equalsParser, entityParser, typeSplitter);
            var whereParser          = new WhereParser(whereStatementParser, new ParserOptions());

            // Act
            var stopwatch = Stopwatch.StartNew();
            var whereNode = whereParser.ParseWhere("testKey:testValue");

            stopwatch.Stop();

            // Assert
            this.WriteTimeElapsed(stopwatch);

            var equalsOperator = whereNode;

            Assert.That(equalsOperator, Is.Not.Null);

            var expected = new WhereNode
            {
                Conjunctive = Conjunctives.None,
                Next        = null,
                Statement   = new WhereStatement {
                    As = null, Value = new EqualsOperator {
                        Statement = "testKey:testValue", Name = "testKey", CaseInsensitive = false, Value = "testValue", IsNot = false
                    }
                }
            };

            whereNode.ShouldDeepEqual(expected);
        }
Example #22
0
 protected override void Given()
 {
     Parser = new RangeParser();
     Range = "";
 }
Example #23
0
 public void OrParserTest()
 {
     var chars = new List<char>();
     var p1 = new RangeParser<char>('A', 'Z');
     var p2 = new RangeParser<char>('a', 'z');
     var orParser = new OrParser<char, char, char, char>(
         p1, _ => _,
         p2, _ => _);
     int endInput;
     char result;
     orParser.Parse(chars, 0, out endInput, out result).IsFalse();
     chars.Add('0');
     orParser.Parse(chars, 0, out endInput, out result).IsFalse();
     chars.Add('a');
     orParser.Parse(chars, 1, out endInput, out result).IsTrue();
     result.Is('a');
     chars.Add('C');
     orParser.Parse(chars, 2, out endInput, out result).IsTrue();
     result.Is('C');
     chars.Add('0');
     orParser.Parse(chars, 3, out endInput, out result).IsFalse();
 }
Example #24
0
 protected override void Given()
 {
     Parser = new RangeParser();
     Range  = "";
 }
Example #25
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));
        }
Example #27
0
 private static object InternalCount(MutableString/*!*/ self, MutableString[]/*!*/ ranges) {
     BitArray map = new RangeParser(ranges).Parse();
     int count = 0;
     for (int i = 0; i < self.Length; i++) {
         if (map.Get(self.GetChar(i)))
             count++;
     }
     return ScriptingRuntimeHelpers.Int32ToObject(count);
 }
Example #28
0
 public void InvalidRange(string source)
 {
     Assert.Throws <ArgumentException>(() => RangeParser.Parse(source));
 }
Example #29
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();
            }
        }
Example #30
0
        protected override void Given()
        {
            Companies = new List<Company>
                {
                    new Company { Name = "Alpha"},
                    new Company { Name = "Beta"},
                    new Company { Name = "Gamma"},
                    new Company { Name = "Delta"},
                    new Company { Name = "Omega"},
                    new Company { Name = "Zeta"},
                };

            Parser = new RangeParser();
            Range = "";
        }
Example #31
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]));
                        }
                    }
                }
            }
        }
Example #32
0
        protected override void Given()
        {
            Codes = new List<Code>
                {
                    new Code { Value = 100},
                    new Code { Value = 102},
                    new Code { Value = 104},
                    new Code { Value = 110},
                    new Code { Value = 120},
                    new Code { Value = 130},
                };

            Parser = new RangeParser();
            Range = "";
        }
Example #33
0
 protected override void Given()
 {
     Parser = new RangeParser();
     Range = "";
     Restriction = "";
     ExpectedRange = "";
 }
Example #34
0
 private static MutableString/*!*/ InternalDelete(MutableString/*!*/ self, MutableString[]/*!*/ ranges) {
     BitArray map = new RangeParser(ranges).Parse();
     MutableString result = self.CreateInstance().TaintBy(self);
     for (int i = 0; i < self.Length; i++) {
         if (!map.Get(self.GetChar(i))) {
             result.Append(self.GetChar(i));
         }
     }
     return result;
 }
Example #35
0
        private async Task OnExecuteAsync()
        {
            var outputFilePath = Path.GetFullPath(OutputFilePath);

            var getRangeResult = RangeParser.TryGetRange(Last, From, To, out var range);

            if (!string.IsNullOrEmpty(getRangeResult?.ErrorMessage))
            {
                ConsoleHelper.WriteError(getRangeResult.ErrorMessage);
                return;
            }

            var sas = Prompt.GetPassword("Shared Access Signature:", ConsoleColor.White, ConsoleColor.DarkBlue);

            Console.CancelKeyPress += ConsoleOnCancelKeyPress;

            try
            {
                if (Prefix.Last() != '/')
                {
                    Prefix += "/";
                }

                ConsoleHelper.WriteDebug($"Querying storage account '{StorageAccountHelper.GetStorageAccountName(sas)}' from {range}");

                var from = range.From;
                var to   = range.To ?? DateTime.UtcNow;

                var datePrefixes = PrefixService.BuildBlobPrefixes(from, to, Prefix);

                var repository = new Repository(sas, Container);

                var blobs = new List <CloudBlockBlob>();

                foreach (var datePrefix in datePrefixes)
                {
                    blobs.AddRange(await repository.ListLogBlobsAsync(datePrefix, CancellationToken.None));
                }

                var tempDirectory = Path.Combine(Path.GetTempPath(), "wad-to-csv",
                                                 Path.GetRandomFileName().Replace(".", string.Empty));
                Directory.CreateDirectory(tempDirectory);

                var filtered = PrefixService.Filter(blobs, from, to, Prefix);

                await repository.DownloadLogBlobsAsync(filtered, tempDirectory, CancellationToken.None);

                CsvWriter.Write(from, to, tempDirectory, outputFilePath);

                Console.WriteLine();
                ConsoleHelper.WriteDebug("Done");
            }
            catch (Exception e)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Exception: {0}", e.GetType());
                Console.WriteLine("Message: {0}", e.Message);
                Console.WriteLine("StackTrace:");
                Console.WriteLine(e.StackTrace);
            }
            finally
            {
                Console.ResetColor();
            }
        }
Example #36
0
        private static MutableString SqueezeMutableString(MutableString/*!*/ str, MutableString[]/*!*/ ranges) {
            // if squeezeAll is true then there should be no ranges, and vice versa
            Assert.NotNull(str, ranges);

            // convert the args into a map of characters to be squeezed (same algorithm as count)
            BitArray map = null;
            if (ranges.Length > 0) {
                map = new RangeParser(ranges).Parse();
            }

            // Do the squeeze in place
            int j = 1, k = 1;
            while (j < str.Length) {
                if (str.GetChar(j) == str.GetChar(j-1) && (ranges.Length == 0 || map.Get(str.GetChar(j)))) {
                    j++;
                } else {
                    str.SetChar(k, str.GetChar(j));
                    j++; k++;
                }
            }
            if (j > k) {
                str.Remove(k, j - k);
            }

            // if not modified return null
            return j == k ? null : str;
        }
Example #37
0
 public SerializableWatermark()
 {
     sf          = new StringFormat();
     font        = (Font)fDefaultFont.Clone();
     rangeParser = new RangeParser();
 }