示例#1
0
        private void InitFromRegistry(RawFile rawFile)
        {
            raw = rawFile;
            //var lines = rawFile.Contents.Split(ParseHelp.LineSeparators, StringSplitOptions.RemoveEmptyEntries);
            City = Regex.Match(rawFile.Contents, @"(?<=Miasto\ +:\ +)\p{L}", RegexOptions.Compiled).Value;
            DataChannels = rawFile
                .Lines(line => line.StartsWith("Lp."))
                .Select(line => new Channel
                                    {
                                        Id = Int32.Parse(Regex.Matches(line, @"[0-9]+", RegexOptions.Compiled)[0].Value),
                                        Input = Int32.Parse(Regex.Matches(line, @"[0-9]+", RegexOptions.Compiled)[1].Value),
                                        UId = line.Words().Last()
                                    });
            Node = new MetaIntersection
                       {
                           Name = Regex.Match(rawFile.Contents, @"(?<=Skrzyżowanie\ +:\ +)[\p{L}\p{Pd}]", RegexOptions.Compiled).Value,
                           Channels = DataChannels,
                           Intersections = rawFile.GuessIntersections()

                       };

            TimeResolution = rawFile.TimeResolution();

            //TODO: fix, headers lie
            Start = ParseHelp.DateTimeParse(rawFile
                                                .LineStarting(("Data sta"))
                                                .Words()
                                                .Last(),
                                            rawFile
                                                .LineStarting("Czas sta")
                                                .Words()
                                                .Last());
            Finish = ParseHelp.DateTimeParse(rawFile
                                                .LineStarting(("Data ko"))
                                                .Words()
                                                .Last(),
                                            rawFile
                                                .LineStarting("Czas ko")
                                                .Words()
                                                .Last());

            DeclaredRecordCount = Int32.Parse(rawFile.LineStarting("Liczba rekordów odczytanych do PC")
                                                  .Split(ParseHelp.WordSeparators, StringSplitOptions.RemoveEmptyEntries)
                                                  .Last());

            DeclaredChannelCount = Int32.Parse(rawFile.LineStarting("Ilość").Words().Last());

            RecordLines = rawFile.Lines().SkipWhile(line => !line.StartsWith("Rekord:")).Skip(1);
        }
示例#2
0
        private void InitFromLog(RawFile rawFile)
        {
            raw = rawFile;
            City = "Poznań"; // oh well
            DataChannels = rawFile
                .Lines(line => Regex.IsMatch(line, @"\ +\|\ [0-9A-Z]+\ \|", RegexOptions.Compiled))
                .Select(line => line.Words().Skip(1).First())
                .Distinct()
                .Select(uid => new Channel {UId = uid});

            Node = new MetaIntersection
                       {
                           Name = new FileInfo(rawFile.Path).Directory.Name.Replace(" ", ""),
                           Channels = DataChannels,
                           Intersections = rawFile.GuessIntersections()
                       };

            TimeResolution = rawFile.TimeResolution();

            Start = rawFile.LogRecordTimes().Min();
            Finish = rawFile.LogRecordTimes().Max();

            DeclaredRecordCount = -1;
            DeclaredChannelCount = -1;

            RecordLines = null; //TODO: tmp?
        }