예제 #1
0
        // Static Methods

        public static Firmware Parse(string[] lines, ref int index)
        {
            const string FirmwareIDRegex = @"FID=(\S+)";
            const string ChecksumRegex = @"CID=(?:0x)?(\S+)";

            Firmware firmware = new Firmware();
            Match firmwareIDMatch;
            Match checksumMatch;

            // Firmware ID and checksum are on the same line --
            // match both regular expressions with the first line
            firmwareIDMatch = Regex.Match(lines[index], FirmwareIDRegex);
            checksumMatch = Regex.Match(lines[index], ChecksumRegex);

            // Get the firmware ID
            if (firmwareIDMatch.Success)
                firmware.ID = firmwareIDMatch.Groups[1].Value;

            // Get the firmware checksum
            if (checksumMatch.Success)
                firmware.Checksum = Convert.ToInt32(checksumMatch.Groups[1].Value, 16);

            // If either match was a success, advance to the next line
            if (firmwareIDMatch.Success || checksumMatch.Success)
                index++;

            return firmware;
        }
예제 #2
0
파일: EventReport.cs 프로젝트: xj0229/gsf
        public static EventReport Parse(double systemFrequency, string[] lines, ref int index)
        {
            EventReport eventReport = new EventReport();
            int         firmwareIndex;

            // Parse the report header
            eventReport.Header = Header.Parse(lines, ref index);

            // Skip to the next nonblank line
            EventFile.SkipBlanks(lines, ref index);

            // Get the index of the line where
            // the firmware information is located
            firmwareIndex = index;

            // Parse the firmware and event number
            eventReport.Firmware    = Firmware.Parse(lines, ref firmwareIndex);
            eventReport.EventNumber = ParseEventNumber(lines, ref index);
            index = Math.Max(firmwareIndex, index);

            // Skip to the next nonblank line
            EventFile.SkipBlanks(lines, ref index);

            // Parse the analog section of the report
            eventReport.AnalogSection = AnalogSection.Parse(eventReport.Header.EventTime, systemFrequency, lines, ref index);

            if (lines.Length < index)
            {
                // skip digitals for now
                while (!lines[index].ToLower().Contains("group settings") && index < lines.Length)
                {
                    ++index;
                }
                ++index;
                // Parse Group settings
                eventReport.GroupSetting = Settings.Parse(lines, ref index);
                EventFile.SkipBlanks(lines, ref index);

                // Parse Logic control equations
                ++index;
                EventFile.SkipBlanks(lines, ref index);
                eventReport.ControlEquations = ControlEquation.Parse(lines, ref index);
                EventFile.SkipBlanks(lines, ref index);

                // Parse Global Settings
                eventReport.GlobalSetting = Settings.Parse(lines, ref index);
            }
            return(eventReport);
        }