예제 #1
0
        static void Main(string[] args)
        {
            string         fileName;
            PhysicalParser parser;
            Record         record;

            if (args.Length < 1)
            {
                Console.WriteLine("Usage:");
                Console.WriteLine("    PQDIFDump FILENAME");
                Environment.Exit(0);
            }

            fileName = args[0];
            parser   = new PhysicalParser(fileName);
            parser.Open();

            while (parser.HasNextRecord())
            {
                record = parser.NextRecord();
                Console.WriteLine(record);
                Console.WriteLine();
            }

            Console.ReadLine();
        }
예제 #2
0
        /// <summary>
        /// Determines whether there are any more
        /// <see cref="ObservationRecord"/>s to be
        /// read from the PQDIF file.
        /// </summary>
        /// <returns>true if there is another observation record to be read from PQDIF file; false otherwise</returns>
        public bool HasNextObservationRecord()
        {
            Record     physicalRecord;
            RecordType recordType;

            // Read records from the file until we encounter an observation record or end of file
            while ((object)m_nextObservationRecord == null && m_physicalParser.HasNextRecord())
            {
                physicalRecord = m_physicalParser.NextRecord();
                recordType     = physicalRecord.Header.TypeOfRecord;

                switch (recordType)
                {
                case RecordType.DataSource:
                    // Keep track of the latest data source record in order to associate it with observation records
                    m_currentDataSourceRecord = DataSourceRecord.CreateDataSourceRecord(physicalRecord);
                    m_allDataSourceRecords.Add(m_currentDataSourceRecord);
                    break;

                case RecordType.MonitorSettings:
                    // Keep track of the latest monitor settings record in order to associate it with observation records
                    m_currentMonitorSettingsRecord = MonitorSettingsRecord.CreateMonitorSettingsRecord(physicalRecord);
                    break;

                case RecordType.Observation:
                    // Found an observation record!
                    m_nextObservationRecord = ObservationRecord.CreateObservationRecord(physicalRecord, m_currentDataSourceRecord, m_currentMonitorSettingsRecord);
                    break;

                case RecordType.Container:
                    // The container record is parsed when the file is opened; it should never be encountered here
                    throw new InvalidOperationException("Found more than one container record in PQDIF file.");

                default:
                    // Ignore unrecognized record types as the rest of the file might be valid.
                    //throw new ArgumentOutOfRangeException(string.Format("Unknown record type: {0}", physicalRecord.Header.RecordTypeTag));
                    break;
                }
            }

            return((object)m_nextObservationRecord != null);
        }