Represents the File Allocation Table of an ArchiveFile.
Наследование: ISupportBinaryImage
Пример #1
0
 /// <summary>
 /// Creates a new <see cref="DataPointScanner"/> instance.
 /// </summary>
 /// <param name="dataBlockAllocationTable"><see cref="ArchiveFileAllocationTable"/> for the file to be scanned.</param>
 /// <param name="historianID">Historian ID to scan for.</param>
 /// <param name="startTime">Desired start time.</param>
 /// <param name="endTime">Desired end time.</param>
 /// <param name="includeStartTime">True to include data points equal to the start time; false to exclude.</param>
 /// <param name="dataReadExceptionHandler">Read exception handler.</param>
 public DataPointScanner(ArchiveFileAllocationTable dataBlockAllocationTable, int historianID, TimeTag startTime, TimeTag endTime, bool includeStartTime, EventHandler<EventArgs<Exception>> dataReadExceptionHandler)
 {
     // Find all data blocks for desired point over given time range
     m_dataBlocks = dataBlockAllocationTable.FindDataBlocks(historianID, startTime, endTime, false);
     m_startTime = startTime;
     m_endTime = endTime;
     m_historianID = historianID;
     m_includeStartTime = includeStartTime;
     m_dataReadExceptionHandler = dataReadExceptionHandler;
 }
Пример #2
0
 /// <summary>
 /// Creates a new <see cref="DataPointScanner"/> instance.
 /// </summary>
 /// <param name="dataBlockAllocationTable"><see cref="ArchiveFileAllocationTable"/> for the file to be scanned.</param>
 /// <param name="historianID">Historian ID to scan for.</param>
 /// <param name="startTime">Desired start time.</param>
 /// <param name="endTime">Desired end time.</param>
 /// <param name="includeStartTime">True to include data points equal to the start time; false to exclude.</param>
 /// <param name="dataReadExceptionHandler">Read exception handler.</param>
 public DataPointScanner(ArchiveFileAllocationTable dataBlockAllocationTable, int historianID, TimeTag startTime, TimeTag endTime, bool includeStartTime, EventHandler <EventArgs <Exception> > dataReadExceptionHandler)
 {
     // Find all data blocks for desired point over given time range
     m_dataBlocks               = dataBlockAllocationTable.FindDataBlocks(historianID, startTime, endTime, false);
     m_startTime                = startTime;
     m_endTime                  = endTime;
     m_historianID              = historianID;
     m_includeStartTime         = includeStartTime;
     m_dataReadExceptionHandler = dataReadExceptionHandler;
 }
Пример #3
0
 /// <summary>
 /// Creates a new instance of the <see cref="FixedTableRegion"/>.
 /// </summary>
 /// <param name="parent">Reference to parent <see cref="ArchiveFileAllocationTable"/>.</param>
 public FixedTableRegion(ArchiveFileAllocationTable parent)
 {
     m_parent = parent;
 }
Пример #4
0
 /// <summary>
 /// Creates a new instance of the <see cref="VariableTableRegion"/>.
 /// </summary>
 /// <param name="parent">Reference to parent <see cref="ArchiveFileAllocationTable"/>.</param>
 public VariableTableRegion(ArchiveFileAllocationTable parent)
 {
     m_parent = parent;
 }
Пример #5
0
 /// <summary>
 /// Creates a new instance of the <see cref="FixedTableRegion"/>.
 /// </summary>
 /// <param name="parent">Reference to parent <see cref="ArchiveFileAllocationTable"/>.</param>
 public FixedTableRegion(ArchiveFileAllocationTable parent)
 {
     m_parent = parent;
 }
Пример #6
0
 /// <summary>
 /// Creates a new instance of the <see cref="VariableTableRegion"/>.
 /// </summary>
 /// <param name="parent">Reference to parent <see cref="ArchiveFileAllocationTable"/>.</param>
 public VariableTableRegion(ArchiveFileAllocationTable parent)
 {
     m_parent = parent;
 }
Пример #7
0
        internal void CloseStream()
        {
            m_fat = null;

            if ((object)m_fileStream != null)
            {
                lock (m_fileStream)
                {
                    m_fileStream.Flush();
                    m_fileStream.Close();
                    m_fileStream.Dispose();
                }
                m_fileStream = null;
            }
        }
Пример #8
0
        internal void OpenStream()
        {
            if (File.Exists(m_fileName))
            {
                int attempts = 0;

                while (true)
                {
                    try
                    {
                        attempts++;
                        m_fileStream = new FileStream(m_fileName, FileMode.Open, m_fileAccessMode, FileShare.ReadWrite);
                        m_fat = new ArchiveFileAllocationTable(this);
                        break;
                    }
                    catch
                    {
                        if (attempts >= 4)
                            throw;

                        Thread.Sleep(500);
                    }
                }
            }
            else if (m_fileAccessMode == FileAccess.Read)
            {
                // File does not exist, so we create a placeholder file in the temp directory
                m_fileStream = new FileStream(Path.GetTempFileName(), FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
                m_fat = new ArchiveFileAllocationTable(this);
                m_fat.FileStartTime = TimeTag.MaxValue;
                m_fat.FileEndTime = TimeTag.MaxValue;

                // Manually call file monitoring event if file watchers are not enabled
                if (!m_monitorNewArchiveFiles)
                    FileWatcher_Created(this, new FileSystemEventArgs(WatcherChangeTypes.Created, FilePath.GetAbsolutePath(m_fileName), FilePath.GetFileName(m_fileName)));
            }
            else
            {
                // File does not exist, so we have to create it and initialize it.
                m_fileStream = new FileStream(m_fileName, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
                m_fat = new ArchiveFileAllocationTable(this);
                m_fat.Save(true);

                // Manually call file monitoring event if file watchers are not enabled
                if (!m_monitorNewArchiveFiles)
                    FileWatcher_Created(this, new FileSystemEventArgs(WatcherChangeTypes.Created, FilePath.GetAbsolutePath(m_fileName), FilePath.GetFileName(m_fileName)));
            }
        }