public static ReportBase LoadFileIntoStaticReader( Object context, BackgroundWorker worker, int refreshMS, string zipFileName )
{
Debug.WriteLine( String.Format( "{0}() ThreadID = {1}", System.Reflection.MethodInfo.GetCurrentMethod( ).Name, Thread.CurrentThread.ManagedThreadId ) );
if ( null == worker )
return new rfidSimpleReport( context, OperationOutcome.FailByApplicationError, new ArgumentNullException( "worker", "BackgroundWorker is required" ) );
if ( refreshMS < MIN_REFRESH_MS || refreshMS > MAX_REFRESH_MS )
return new rfidSimpleReport( context, OperationOutcome.FailByApplicationError, new ArgumentOutOfRangeException( "refreshMS", refreshMS, string.Format( "Value must be between {0} and {1}", MIN_REFRESH_MS, MAX_REFRESH_MS ) ) );
if ( zipFileName == null )
return new rfidSimpleReport( context, OperationOutcome.FailByApplicationError, new ArgumentNullException( "zipFileName" ) );
if ( !File.Exists( zipFileName ) )
return new rfidSimpleReport( context, OperationOutcome.FailByApplicationError, new ArgumentOutOfRangeException( "ziFileName", zipFileName, "File does not exit." ) );
try
{
rfidSimpleReport report = new rfidSimpleReport( context, 0 );
LakeChabotReader reader = new LakeChabotReader( false );
reader._staticReaderDir = Directory.CreateDirectory( Path.Combine( Path.GetTempPath( ), Path.GetFileNameWithoutExtension( Path.GetRandomFileName( ) ) ) ).FullName;
worker.ReportProgress( 10, report.GetProgressReport( HighResolutionTimer.Milliseconds ) );
FileCompressor.Decompress( zipFileName, reader._staticReaderDir );
worker.ReportProgress( 20, report.GetProgressReport( HighResolutionTimer.Milliseconds ) );
reader._propertyBagData = new DataFile<PropertyBag>( RFID.RFIDInterface.Properties.Settings.Default.PropertyBagPageSize, Path.Combine( reader._staticReaderDir, "PropertyBagData.df" ) );
reader._antennaCycleData = new SequentialDataFile<AntennaPacket>( RFID.RFIDInterface.Properties.Settings.Default.AntennaCyclePageSize, Path.Combine( reader._staticReaderDir, "AntennaCycleData.df" ) );
worker.ReportProgress( 30, report.GetProgressReport( HighResolutionTimer.Milliseconds ) );
reader._inventoryRoundData = new SequentialDataFile<InventoryRound>( RFID.RFIDInterface.Properties.Settings.Default.InventoryRoundPageSize, Path.Combine( reader._staticReaderDir, "InventoryRoundData.df" ) );
worker.ReportProgress( 40, report.GetProgressReport( HighResolutionTimer.Milliseconds ) );
reader._packetStreamData = new SequentialDataFile<PacketStream>( RFID.RFIDInterface.Properties.Settings.Default.PacketStreamPageSize, Path.Combine( reader._staticReaderDir, "PacketStreamData.df" ) );
worker.ReportProgress( 50, report.GetProgressReport( HighResolutionTimer.Milliseconds ) );
reader._readerCommandData = new SequentialDataFile<ReaderCommand>( RFID.RFIDInterface.Properties.Settings.Default.ReaderCommandPageSize, Path.Combine( reader._staticReaderDir, "ReaderCommandData.df" ) );
reader._readerAntennaCycleData = new SequentialDataFile<ReaderAntennaCycle>( RFID.RFIDInterface.Properties.Settings.Default.ReaderCyclePageSize, Path.Combine( reader._staticReaderDir, "ReaderCycleData.df" ) );
worker.ReportProgress( 60, report.GetProgressReport( HighResolutionTimer.Milliseconds ) );
reader._readerRequestData = new SequentialDataFile<ReaderRequest>( RFID.RFIDInterface.Properties.Settings.Default.ReaderRequestPageSize, Path.Combine( reader._staticReaderDir, "ReaderRequestData.df" ) );
worker.ReportProgress( 70, report.GetProgressReport( HighResolutionTimer.Milliseconds ) );
reader._tagInventoryData = new DataFile<TagInventory>( RFID.RFIDInterface.Properties.Settings.Default.TagInventoryPageSize, Path.Combine( reader._staticReaderDir, "TagInventoryData.df" ) );
reader._tagReadData = new SequentialDataFile<TagRead>( RFID.RFIDInterface.Properties.Settings.Default.TagReadPageSize, Path.Combine( reader._staticReaderDir, "TagReadData.df" ) );
worker.ReportProgress( 80, report.GetProgressReport( HighResolutionTimer.Milliseconds ) );
reader._readRateData = new SequentialDataFile<ReadRate>( RFID.RFIDInterface.Properties.Settings.Default.ReadRatePageSize, Path.Combine( reader._staticReaderDir, "ReadRateData.df" ) );
reader._badPacketData = new SequentialDataFile<BadPacket>( RFID.RFIDInterface.Properties.Settings.Default.BadPacketPageSize, Path.Combine( reader._staticReaderDir, "BadPacketData.df" ) );
reader._inventoryCycleData = new SequentialDataFile<InventoryCycle>( RFID.RFIDInterface.Properties.Settings.Default.InventoryCyclePageSize, Path.Combine( reader._staticReaderDir, "InventoryCycleData.df" ) );
worker.ReportProgress( 90, report.GetProgressReport( HighResolutionTimer.Milliseconds ) );
reader._theReaderID = new rfidReaderID(rfidReaderID.ReaderType.MTI, zipFileName);
reader._recentPacketList = new PacketArrayListGlue( reader );
report.NewReader = reader;
report.OperationCompleted( OperationOutcome.Success,
HighResolutionTimer.Milliseconds );
return report;
}
catch ( Exception e )
{
return new rfidSimpleReport( context, OperationOutcome.FailByApplicationError, e );
}
}