Example #1
0
 public void  Dispose()
 {
     if (weOwnSipperFile)
     {
         sipperFile.Dispose();
         sipperFile = null;
     }
 } /* Dispose */
Example #2
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  */
Example #3
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  */