예제 #1
0
        /// <summary>
        /// 
        /// </summary>
        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 );
            }
        }
예제 #2
0
        public ReportBase SaveDataToFile( Object context, BackgroundWorker worker, int refreshMS, string Filename )
        {
            if ( IsDisposed )
                throw new ObjectDisposedException( "LakeChabotReader" );

            if ( TableResult != TableState.Ready )
                //return new rfidOperationReport(context, OperationOutcome.FailByContext, new rfidException(rfidErrorCode.TablesAreNotReady, "You must build the post-capture views before saving."));
                return new rfidSimpleReport( context, OperationOutcome.FailByContext, new rfidException( rfidErrorCode.TablesAreNotReady, "You must build the post-capture views before saving." ) );

            try
            {
                rfidSimpleReport report = new rfidSimpleReport( context, HighResolutionTimer.Milliseconds );

                string tempDirectory = Directory.CreateDirectory( Path.Combine( Path.GetTempPath( ), Path.GetFileNameWithoutExtension( Path.GetRandomFileName( ) ) ) ).FullName;

                string[ ] fileNameArray =
                {
                    Path.Combine(tempDirectory, "PropertyBagData.df"),
                    Path.Combine(tempDirectory,	"AntennaCycleData.df"),
                    Path.Combine(tempDirectory, "InventoryRoundData.df"),
                    Path.Combine(tempDirectory,	"PacketStreamData.df"),
                    Path.Combine(tempDirectory, "ReaderCommandData.df"),
                    Path.Combine(tempDirectory,	"ReaderCycleData.df"),
                    Path.Combine(tempDirectory, "ReaderRequestData.df"),
                    Path.Combine(tempDirectory,	"TagInventoryData.df"),
                    Path.Combine(tempDirectory,	"TagReadData.df"),
                    Path.Combine(tempDirectory, "ReadRateData.df"),
                    Path.Combine(tempDirectory,	"BadPacketData.df"),
                    Path.Combine(tempDirectory, "InventoryCycleData.df"),
                };

                PropertyBagData.CommitPageAndCopyFile( fileNameArray[ 0 ] );

                AntennaCycleData.CommitPageAndCopyFile( fileNameArray[ 1 ] );
                worker.ReportProgress( 10, report.GetProgressReport( HighResolutionTimer.Milliseconds ) );

                InventoryRoundData.CommitPageAndCopyFile( fileNameArray[ 2 ] );
                worker.ReportProgress( 15, report.GetProgressReport( HighResolutionTimer.Milliseconds ) );
                Thread.Sleep( 20 );

                PacketStreamData.CommitPageAndCopyFile( fileNameArray[ 3 ] );
                worker.ReportProgress( 20, report.GetProgressReport( HighResolutionTimer.Milliseconds ) );
                Thread.Sleep( 20 );

                ReaderCommandData.CommitPageAndCopyFile( fileNameArray[ 4 ] );
                worker.ReportProgress( 20, report.GetProgressReport( HighResolutionTimer.Milliseconds ) );
                Thread.Sleep( 20 );

                ReaderAntennaCycleData.CommitPageAndCopyFile( fileNameArray[ 5 ] );
                worker.ReportProgress( 30, report.GetProgressReport( HighResolutionTimer.Milliseconds ) );

                ReaderRequestData.CommitPageAndCopyFile( fileNameArray[ 6 ] );
                worker.ReportProgress( 30, report.GetProgressReport( HighResolutionTimer.Milliseconds ) );
                Thread.Sleep( 20 );

                TagInventoryData.CommitPageAndCopyFile( fileNameArray[ 7 ] );
                worker.ReportProgress( 40, report.GetProgressReport( HighResolutionTimer.Milliseconds ) );
                Thread.Sleep( 20 );

                TagReadData.CommitPageAndCopyFile( fileNameArray[ 8 ] );
                worker.ReportProgress( 40, report.GetProgressReport( HighResolutionTimer.Milliseconds ) );
                Thread.Sleep( 20 );

                ReadRateData.CommitPageAndCopyFile( fileNameArray[ 9 ] );
                worker.ReportProgress( 40, report.GetProgressReport( HighResolutionTimer.Milliseconds ) );
                Thread.Sleep( 20 );

                BadPacketData.CommitPageAndCopyFile( fileNameArray[ 10 ] );
                worker.ReportProgress( 50, report.GetProgressReport( HighResolutionTimer.Milliseconds ) );

                InventoryCycleData.CommitPageAndCopyFile( fileNameArray[ 11 ] );
                worker.ReportProgress( 60, report.GetProgressReport( HighResolutionTimer.Milliseconds ) );
                Thread.Sleep( 20 );

                String zipFileName = Path.GetTempFileName( );
                File.Delete( zipFileName );
                zipFileName = Path.ChangeExtension( zipFileName, ".rfi" );

                FileCompressor.Compress( zipFileName, true, fileNameArray );

                worker.ReportProgress( 80, report.GetProgressReport( HighResolutionTimer.Milliseconds ) );

                File.Copy( zipFileName, Filename, true );

                worker.ReportProgress( 90, report.GetProgressReport( HighResolutionTimer.Milliseconds ) );

                File.Delete( zipFileName );
                Directory.Delete( tempDirectory );

                report.OperationCompleted( OperationOutcome.Success,
                                           String.Format( "Successfuly opened {0}", Filename ),
                                           HighResolutionTimer.Milliseconds );
                return report;
            }
            catch ( Exception e )
            {
                return new rfidSimpleReport( context, OperationOutcome.FailByApplicationError, e );
            }
        }