/// <summary> /// Loads the data. /// </summary> public void ReloadFromSource(ISystemContext context) { LoadConfiguration(context); if (ArchiveItem.LastLoadTime == DateTime.MinValue || (ArchiveItem.Persistent && ArchiveItem.LastLoadTime.AddSeconds(10) < DateTime.UtcNow)) { var reader = new DataFileReader(); reader.LoadHistoryData(context, ArchiveItem); // set the start of the archive. if (ArchiveItem.DataSet.Tables[0].DefaultView.Count > 0) { _configuration.StartOfArchive.Value = (DateTime)ArchiveItem.DataSet.Tables[0].DefaultView[0].Row[0]; _configuration.StartOfOnlineArchive.Value = _configuration.StartOfArchive.Value; } if (ArchiveItem.Archiving) { // save the pattern used to produce new data. _pattern = new List <DataValue>(); foreach (DataRowView row in ArchiveItem.DataSet.Tables[0].DefaultView) { var value = (DataValue)row.Row[2]; _pattern.Add(value); _nextSampleTime = value.SourceTimestamp.AddMilliseconds(ArchiveItem.SamplingInterval); } // fill in data until the present time. _patternIndex = 0; NewSamples(context); } } }
/// <summary> /// Loads the configuration. /// </summary> public void LoadConfiguration(ISystemContext context) { var reader = new DataFileReader(); if (reader.LoadConfiguration(context, ArchiveItem)) { DataType = (uint)ArchiveItem.DataType; ValueRank = ArchiveItem.ValueRank; Historizing = ArchiveItem.Archiving; _configuration.MinTimeInterval.Value = ArchiveItem.SamplingInterval; _configuration.MaxTimeInterval.Value = ArchiveItem.SamplingInterval; _configuration.Stepped.Value = ArchiveItem.Stepped; var configuration = ArchiveItem.AggregateConfiguration; _configuration.AggregateConfiguration.PercentDataGood.Value = configuration.PercentDataGood; _configuration.AggregateConfiguration.PercentDataBad.Value = configuration.PercentDataBad; _configuration.AggregateConfiguration.UseSlopedExtrapolation.Value = configuration.UseSlopedExtrapolation; _configuration.AggregateConfiguration.TreatUncertainAsBad.Value = configuration.TreatUncertainAsBad; } }