private VICycleDataGroup GetVICycleDataGroup() { EventDataTableAdapter eventDataAdapter = m_dbAdapterContainer.GetAdapter <EventDataTableAdapter>(); MeterData.EventDataRow eventDataRow = eventDataAdapter.GetDataBy(m_eventID)[0]; DataGroup dataGroup = new DataGroup(); dataGroup.FromData(eventDataRow.FrequencyDomainData); return(new VICycleDataGroup(dataGroup)); }
private VICycleDataGroup GetVICycleDataGroup() { MeterInfoDataContext meterInfo = m_dbAdapterContainer.GetAdapter <MeterInfoDataContext>(); EventTableAdapter eventAdapter = m_dbAdapterContainer.GetAdapter <EventTableAdapter>(); EventDataTableAdapter eventDataAdapter = m_dbAdapterContainer.GetAdapter <EventDataTableAdapter>(); MeterData.EventRow eventRow = eventAdapter.GetDataByID(m_eventID)[0]; MeterData.EventDataRow eventDataRow = eventDataAdapter.GetDataBy(m_eventID)[0]; Meter meter = meterInfo.Meters.Single(m => m.ID == eventRow.MeterID); DataGroup dataGroup = new DataGroup(); dataGroup.FromData(meter, eventDataRow.FrequencyDomainData); return(new VICycleDataGroup(dataGroup)); }
/// <summary> /// FetchMeterEventCycleData /// </summary> /// <param name="EventInstanceID"></param> /// <param name="MeasurementName"></param> /// <param name="theset"></param> /// <returns></returns> private eventSet FetchMeterEventCycleData(string EventInstanceID, string MeasurementName, eventSet theset) { DataGroup eventDataGroup = new DataGroup(); List <DataGroup> cycleCurves; List <MeterData.EventDataRow> cycleDataRows; if (MeasurementName != "Voltage" && MeasurementName != "Current") { return(theset); } using (MeterInfoDataContext meterInfo = new MeterInfoDataContext(ConnectionString)) using (EventTableAdapter eventAdapter = new EventTableAdapter()) using (EventDataTableAdapter cycleDataAdapter = new EventDataTableAdapter()) { cycleDataAdapter.Connection.ConnectionString = ConnectionString; eventAdapter.Connection.ConnectionString = ConnectionString; theset.Yaxis0name = MeasurementName; theset.Yaxis1name = ""; MeterData.EventRow theevent = eventAdapter.GetDataByID(Convert.ToInt32(EventInstanceID)).First(); Meter themeter = meterInfo.Meters.Single(m => theevent.MeterID == m.ID); Line theline = meterInfo.Lines.Single(l => theevent.LineID == l.ID); cycleDataRows = cycleDataAdapter.GetDataBy(Convert.ToInt32(EventInstanceID)).ToList(); cycleCurves = cycleDataRows.Select(ToDataSeries).ToList(); //RMS, Phase angle, Peak, and Error //VAN, VBN, VCN, IAN, IBN, ICN, IR char typeChar = MeasurementName == "Voltage" ? 'V' : 'I'; // Defines the names of the series that will be added to theset in the order that they will appear string[] seriesOrder = new string[] { "RMS", "Peak", "Angle" } .SelectMany(category => new string[] { "AN", "BN", "CN" }.Select(phase => string.Format("{0} {1}{2}", category, typeChar, phase))) .ToArray(); // Defines the names of the series as they appear in cycleCurves string[] seriesNames = { "RMS VAN", "Angle VAN", "Peak VAN", "Error VAN", "RMS VBN", "Angle VBN", "Peak VBN", "Error VBN", "RMS VCN", "Angle VCN", "Peak VCN", "Error VCN", "RMS IAN", "Angle IAN", "Peak IAN", "Error IAN", "RMS IBN", "Angle IBN", "Peak IBN", "Error IBN", "RMS ICN", "Angle ICN", "Peak ICN", "Error ICN", "RMS IR", "Angle IR", "Peak IR", "Error IR" }; // Lookup table to find a DataSeries by name Dictionary <string, DataSeries> seriesNameLookup = cycleCurves[0].DataSeries .Select((series, index) => new { Name = seriesNames[index], Series = series }) .ToDictionary(obj => obj.Name, obj => obj.Series); int i = 0; if (cycleCurves.Count > 0) { foreach (string seriesName in seriesOrder) { DataSeries theseries = seriesNameLookup[seriesName]; int datacount = theseries.DataPoints.Count(); signalDetail theitem = new signalDetail(); theitem.name = seriesName; theitem.data = new double[datacount]; theitem.type = "line"; theitem.yAxis = 0; if (theitem.name.Contains("Angle")) { theitem.showInTooltip = false; theitem.visible = false; theitem.showInLegend = false; } if (theitem.name.Contains("RMS")) { theitem.showInTooltip = false; theitem.visible = false; } if (theitem.name.Contains("Peak")) { theitem.showInTooltip = false; theitem.visible = false; } int j = 0; DateTime beginticks = theseries.DataPoints[0].Time; foreach (FaultData.DataAnalysis.DataPoint thepoint in theseries.DataPoints) { double elapsed = thepoint.Time.Subtract(beginticks).TotalSeconds; //theset.xAxis[j] = elapsed.ToString(); theitem.data[j] = thepoint.Value; j++; } theset.data.Add(theitem); } } } return(theset); }
/// <summary> /// FetchMeterEventCycleData /// </summary> /// <param name="EventInstanceID"></param> /// <param name="MeasurementName"></param> /// <param name="theset"></param> /// <returns></returns> private eventSet FetchMeterEventCycleData(string EventInstanceID, string MeasurementName, eventSet theset) { DataGroup eventDataGroup = new DataGroup(); List<DataGroup> cycleCurves; List<MeterData.EventDataRow> cycleDataRows; if (MeasurementName != "Voltage" && MeasurementName != "Current") return theset; using (MeterInfoDataContext meterInfo = new MeterInfoDataContext(ConnectionString)) using (EventTableAdapter eventAdapter = new EventTableAdapter()) using (EventDataTableAdapter cycleDataAdapter = new EventDataTableAdapter()) { cycleDataAdapter.Connection.ConnectionString = ConnectionString; eventAdapter.Connection.ConnectionString = ConnectionString; theset.Yaxis0name = MeasurementName; theset.Yaxis1name = ""; MeterData.EventRow theevent = eventAdapter.GetDataByID(Convert.ToInt32(EventInstanceID)).First(); Meter themeter = meterInfo.Meters.Single(m => theevent.MeterID == m.ID); Line theline = meterInfo.Lines.Single(l => theevent.LineID == l.ID); cycleDataRows = cycleDataAdapter.GetDataBy(Convert.ToInt32(EventInstanceID)).ToList(); cycleCurves = cycleDataRows.Select(ToDataSeries).ToList(); //RMS, Phase angle, Peak, and Error //VAN, VBN, VCN, IAN, IBN, ICN, IR char typeChar = MeasurementName == "Voltage" ? 'V' : 'I'; // Defines the names of the series that will be added to theset in the order that they will appear string[] seriesOrder = new string[] { "RMS", "Peak", "Angle" } .SelectMany(category => new string[] { "AN", "BN", "CN" }.Select(phase => string.Format("{0} {1}{2}", category, typeChar, phase))) .ToArray(); // Defines the names of the series as they appear in cycleCurves string[] seriesNames = { "RMS VAN", "Angle VAN", "Peak VAN", "Error VAN", "RMS VBN", "Angle VBN", "Peak VBN", "Error VBN", "RMS VCN", "Angle VCN", "Peak VCN", "Error VCN", "RMS IAN", "Angle IAN", "Peak IAN", "Error IAN", "RMS IBN", "Angle IBN", "Peak IBN", "Error IBN", "RMS ICN", "Angle ICN", "Peak ICN", "Error ICN", "RMS IR", "Angle IR", "Peak IR", "Error IR" }; // Lookup table to find a DataSeries by name Dictionary<string, DataSeries> seriesNameLookup = cycleCurves[0].DataSeries .Select((series, index) => new { Name = seriesNames[index], Series = series }) .ToDictionary(obj => obj.Name, obj => obj.Series); int i = 0; if (cycleCurves.Count > 0) { foreach (string seriesName in seriesOrder) { DataSeries theseries = seriesNameLookup[seriesName]; int datacount = theseries.DataPoints.Count(); signalDetail theitem = new signalDetail(); theitem.name = seriesName; theitem.data = new double[datacount]; theitem.type = "line"; theitem.yAxis = 0; if (theitem.name.Contains("Angle")) { theitem.showInTooltip = false; theitem.visible = false; theitem.showInLegend = false; } if (theitem.name.Contains("RMS")) { theitem.showInTooltip = false; theitem.visible = false; } if (theitem.name.Contains("Peak")) { theitem.showInTooltip = false; theitem.visible = false; } int j = 0; DateTime beginticks = theseries.DataPoints[0].Time; foreach (FaultData.DataAnalysis.DataPoint thepoint in theseries.DataPoints) { double elapsed = thepoint.Time.Subtract(beginticks).TotalSeconds; //theset.xAxis[j] = elapsed.ToString(); theitem.data[j] = thepoint.Value; j++; } theset.data.Add(theitem); } } } return (theset); }