Beispiel #1
0
 public void  Dispose()
 {
     if (weOwnSipperFile)
     {
         sipperFile.Dispose();
         sipperFile = null;
     }
 } /* Dispose */
Beispiel #2
0
        public SipperFileBuffered(Stream _stream,
                                  InstrumentDataManager _dataManger
                                  )
        {
            // We will first make sure that '_fileName' exists.
            sipperFile = OpenAppropriateFormat(_stream, _dataManger);
            if (sipperFile == null)
            {
                throw new Exception("SipperFileBuffered:   Could not determine format of stream.");
            }

            weOwnSipperFile = true;
            Initialization();
        }
Beispiel #3
0
        public SipperFileBuffered(string _fileName,
                                  InstrumentDataManager _dataManger
                                  )
        {
            try
            {
                sipperFile = OpenAppropriateFormat(_fileName, _dataManger);
            }
            catch (IOException ioException)
            {
                throw ioException;
            }

            if (sipperFile == null)
            {
                throw new Exception("SipperFileBuffered:   Could not determine format of file[" + _fileName + "]");
            }

            weOwnSipperFile = true;
            Initialization();
        }
Beispiel #4
0
 public SipperFileBuffered(SipperBaseFile _sipperFile)
 {
     weOwnSipperFile = false;
     sipperFile      = _sipperFile;
     Initialization();
 }
Beispiel #5
0
        } /* OpenAppropriateFormat  */

        private SipperBaseFile  OpenAppropriateFormat(Stream _stream,
                                                      InstrumentDataManager _dataManger
                                                      )
        {
            //*******************************************************
            // First Lets try Sipper3 format

            bool validSipper2      = false;
            bool validSipper3      = false;
            bool validSipperSimple = false;
            bool validLarcos4Bit   = false;

            long startPos = _stream.Position;


            // We will first try to see if a Sipper3 file.
            try
            {
                sipperFile   = new Sipper3File(_stream, _dataManger);
                validSipper3 = sipperFile.ValidateFormat();
            }
            catch (Exception)
            {
                validSipper3 = false;
                sipperFile   = null;
            }
            if ((sipperFile != null) && (validSipper3))
            {
                return(sipperFile);
            }
            if (sipperFile != null)
            {
                //sipperFile.Dispose ();
                //sipperFile = null;
            }



            //*******************************************************
            // Try 4Bit Larcos Format
            try
            {
                _stream.Seek(0, SeekOrigin.Begin);
                sipperFile      = new SipperBuff4Bit(_stream, _dataManger);
                validLarcos4Bit = sipperFile.ValidateFormat();
            }
            catch (IOException ioException)
            {
                throw  new IOException("OpenAppropriateFormat  Could not open file", ioException);
            }
            catch (Exception)
            {
                validLarcos4Bit = false;
                sipperFile      = null;
            }

            if ((sipperFile != null) && (validLarcos4Bit))
            {
                return(sipperFile);
            }



            //*******************************************************
            // Try SipperSimple format.
            _stream.Position = startPos;
            try
            {
                sipperFile        = new SipperFileSimple(_stream, _dataManger);
                validSipperSimple = sipperFile.ValidateFormat();
            }
            catch (Exception)
            {
                validSipperSimple = false;
                sipperFile        = null;
            }
            if ((sipperFile != null) && (validSipperSimple))
            {
                return(sipperFile);
            }


            // Now we will try to see if valid  Sipper2 format
            try
            {
                sipperFile   = new Sipper2File(_stream, _dataManger);
                validSipper2 = sipperFile.ValidateFormat();
            }
            catch (Exception)
            {
                validSipper2 = false;
                sipperFile   = null;
            }

            if ((sipperFile != null) && (validSipper2))
            {
                return(sipperFile);
            }


            if (sipperFile != null)
            {
                sipperFile.Dispose();
            }

            sipperFile = null;

            return(null);
        } /* OpenAppropriateFormat  */
Beispiel #6
0
        } /* CalculateTargetCols */

        private SipperBaseFile  OpenAppropriateFormat(string _fileName,
                                                      InstrumentDataManager _dataManger
                                                      )
        {
            // First Lets try Sipper3 format

            bool validSipper2      = false;
            bool validSipper3      = false;
            bool validSipperSimple = false;
            bool validLarcos4Bit   = false;


            // We will first try to see if a Sipper3 file.
            try
            {
                sipperFile   = new Sipper3File(_fileName, _dataManger);
                validSipper3 = sipperFile.ValidateFormat();
            }
            catch (IOException ioException)
            {
                throw  new IOException("OpenAppropriateFormat  Could not open file", ioException);
            }
            catch (Exception)
            {
                validSipper3 = false;
                sipperFile   = null;
            }

            if ((sipperFile != null) && (validSipper3))
            {
                return(sipperFile);
            }

            if (sipperFile != null)
            {
                sipperFile.Dispose();
                sipperFile = null;
            }


            // Try 4Bit Larcos Format
            try
            {
                sipperFile      = new SipperBuff4Bit(_fileName, _dataManger);
                validLarcos4Bit = sipperFile.ValidateFormat();
            }
            catch (IOException ioException)
            {
                throw  new IOException("OpenAppropriateFormat  Could not open file", ioException);
            }
            catch (Exception)
            {
                validLarcos4Bit = false;
                sipperFile      = null;
            }

            if ((sipperFile != null) && (validLarcos4Bit))
            {
                return(sipperFile);
            }

            if (sipperFile != null)
            {
                sipperFile.Dispose();
                sipperFile = null;
            }


            // Now try the Simple Sipper Format.
            try
            {
                sipperFile        = new SipperFileSimple(_fileName, _dataManger);
                validSipperSimple = sipperFile.ValidateFormat();
            }
            catch (Exception)
            {
                validSipperSimple = false;
                sipperFile        = null;
            }

            if ((sipperFile != null) && (validSipperSimple))
            {
                return(sipperFile);
            }

            if (sipperFile != null)
            {
                sipperFile.Dispose();
            }

            sipperFile = null;



            // Now we will try to see if valid  Sipper2 format
            try
            {
                sipperFile   = new Sipper2File(_fileName, _dataManger);
                validSipper2 = sipperFile.ValidateFormat();
            }
            catch (Exception)
            {
                validSipper2 = false;
                sipperFile   = null;
            }

            if ((sipperFile != null) && (validSipper2))
            {
                return(sipperFile);
            }


            if (sipperFile != null)
            {
                sipperFile.Dispose();
            }

            sipperFile = null;

            return(null);
        } /* OpenAppropriateFormat  */