public override void Initialize(MeterDataSet meterDataSet) { MeterInfoDataContext meterInfo = m_dbAdapterContainer.GetAdapter <MeterInfoDataContext>(); DataGroupsResource dataGroupsResource = meterDataSet.GetResource <DataGroupsResource>(); Stopwatch stopwatch = new Stopwatch(); m_dataGroups = dataGroupsResource.DataGroups .Where(dataGroup => dataGroup.Classification == DataClassification.Event) .Where(dataGroup => dataGroup.SamplesPerSecond / m_systemFrequency >= 3.999D) .ToList(); Log.Info(string.Format("Found data for {0} events.", m_dataGroups.Count)); m_viDataGroups = m_dataGroups .Select(dataGroup => { VIDataGroup viDataGroup = new VIDataGroup(dataGroup); dataGroup.Add(viDataGroup.CalculateMissingCurrentChannel(meterInfo)); return(viDataGroup); }) .ToList(); Log.Info(string.Format("Calculating cycle data for all {0} events.", m_dataGroups.Count)); stopwatch.Start(); m_viCycleDataGroups = m_viDataGroups .Select(viDataGroup => Transform.ToVICycleDataGroup(viDataGroup, m_systemFrequency)) .ToList(); Log.Debug(string.Format("Cycle data calculated in {0}.", stopwatch.Elapsed)); }
public override void Initialize(MeterDataSet meterDataSet) { DataGroupsResource dataGroupsResource = meterDataSet.GetResource <DataGroupsResource>(); VIDataGroup viDataGroup; m_dataGroups = new List <DataGroup>(); m_viDataGroups = new List <VIDataGroup>(); m_viCycleDataGroups = new List <VICycleDataGroup>(); Log.Info("Identifying events and calculating cycle data..."); foreach (DataGroup dataGroup in dataGroupsResource.DataGroups) { double samplesPerCycle; if (dataGroup.Classification != DataClassification.Event) { continue; } samplesPerCycle = Math.Round(dataGroup.SamplesPerSecond / m_systemFrequency); if (dataGroup.Samples < samplesPerCycle) { continue; } viDataGroup = new VIDataGroup(dataGroup); if (viDataGroup.DefinedVoltages != 3 || viDataGroup.DefinedCurrents < 3) { continue; } dataGroup.Add(viDataGroup.CalculateMissingCurrentChannel()); m_dataGroups.Add(dataGroup); m_viDataGroups.Add(viDataGroup); m_viCycleDataGroups.Add(ToVICycleDataGroup(dataGroup, m_systemFrequency)); } Log.Info($"Cycle data calculated for {m_dataGroups.Count} events."); }