protected virtual void Dispose(bool disposing) { if (!m_disposed) { try { if ((object)m_server != null) { m_server.Dispose(); m_server = null; } if ((object)m_logSubscriber != null) { m_logSubscriber.NewLogMessage -= m_logSubscriber_Log; m_logSubscriber = null; } m_parent.ShowUpdateMessage("[SnapDB] Engine terminated"); { } } finally { m_disposed = true; // Prevent duplicate dispose. } } }
public GSFHistorianStream(MigrationUtility parent, string sourceFileName, string instanceName, StreamWriter duplicateDataOutput = null) { m_file = OpenArchiveFile(sourceFileName, ref instanceName); m_instanceName = instanceName; m_duplicateDataOutput = duplicateDataOutput; // Find maximum point ID int maxPointID = FindMaximumPointID(m_file.MetadataFile); // Create new time-sorted data point scanner to read points in this file in sorted order TimeSortedArchiveFileScanner scanner = new TimeSortedArchiveFileScanner(); // Get start and end times from file data and validate TimeTag startTime, endTime; startTime = m_file.Fat.FileStartTime; if (startTime == TimeTag.MaxValue) { startTime = TimeTag.MinValue; } endTime = m_file.Fat.FileEndTime; if (endTime == TimeTag.MinValue) { endTime = TimeTag.MaxValue; } scanner.FileAllocationTable = m_file.Fat; scanner.HistorianIDs = Enumerable.Range(1, maxPointID); scanner.StartTime = startTime; scanner.EndTime = endTime; scanner.ResumeFrom = null; scanner.DataReadExceptionHandler = (sender, e) => parent.ShowUpdateMessage("[GSFHistorian] Exception encountered during data read: {0}", e.Argument.Message); m_enumerator = scanner.Read().GetEnumerator(); m_value = new HistorianValue(); m_key = new HistorianKey(); m_lastKey = new HistorianKey(); }
public SnapDBEngine(MigrationUtility parent, string instanceName, string destinationFilesLocation, string targetFileSize, string directoryNamingMethod, bool readOnly = false) { m_parent = parent; m_logSubscriber = Logger.CreateSubscriber(VerboseLevel.High); m_logSubscriber.NewLogMessage += m_logSubscriber_Log; if (string.IsNullOrEmpty(instanceName)) { instanceName = "PPA"; } else { instanceName = instanceName.Trim(); } // Establish archive information for this historian instance HistorianServerDatabaseConfig archiveInfo = new HistorianServerDatabaseConfig(instanceName, destinationFilesLocation, !readOnly); double targetSize; if (!double.TryParse(targetFileSize, out targetSize)) { targetSize = 1.5D; } archiveInfo.TargetFileSize = (long)(targetSize * SI.Giga); int methodIndex; if (!int.TryParse(directoryNamingMethod, out methodIndex) || !Enum.IsDefined(typeof(ArchiveDirectoryMethod), methodIndex)) { methodIndex = (int)ArchiveDirectoryMethod.YearThenMonth; } archiveInfo.DirectoryMethod = (ArchiveDirectoryMethod)methodIndex; m_server = new HistorianServer(archiveInfo); m_parent.ShowUpdateMessage("[SnapDB] Engine initialized"); }