private static Channel ParseSeries(SeriesDefinition seriesDefinition) { ChannelDefinition channelDefinition = seriesDefinition.ChannelDefinition; // Populate series properties Series series = new Series(); series.Channel = new Channel(); series.SeriesType = new SeriesType(); series.SourceIndexes = string.Empty; // Populate channel properties Channel channel = series.Channel; channel.Series = new List <Series>() { series }; channel.MeasurementType = new MeasurementType(); channel.MeasurementCharacteristic = new MeasurementCharacteristic(); channel.Phase = new openXDA.Model.Phase(); channel.Name = channelDefinition.ChannelName; channel.HarmonicGroup = 0; channel.Series.Add(series); if (seriesDefinition.HasElement(SeriesDefinition.SeriesNominalQuantityTag)) { channel.PerUnitValue = seriesDefinition.SeriesNominalQuantity; } // Populate measurement type properties QuantityMeasured quantityMeasured = channelDefinition.QuantityMeasured; channel.MeasurementType.Name = quantityMeasured.ToString(); // Populate characteristic properties Guid quantityTypeID = channelDefinition.QuantityTypeID; Guid quantityCharacteristicID = seriesDefinition.QuantityCharacteristicID; // Workaround for bad quantity characteristic in files produced by PQube Classic if (quantityTypeID == QuantityType.Phasor && quantityCharacteristicID == QuantityCharacteristic.Instantaneous) { quantityCharacteristicID = QuantityCharacteristic.RMS; } channel.MeasurementCharacteristic.Name = QuantityCharacteristic.ToName(quantityCharacteristicID) ?? quantityCharacteristicID.ToString(); channel.MeasurementCharacteristic.Description = QuantityCharacteristic.ToString(quantityCharacteristicID); // Popuplate phase properties Phase phase = channelDefinition.Phase; channel.Phase.Name = phase.ToString(); // Populate series type properties series.SeriesType.Name = SeriesValueType.ToString(seriesDefinition.ValueTypeID) ?? seriesDefinition.ValueTypeName ?? seriesDefinition.ValueTypeID.ToString(); series.SeriesType.Description = seriesDefinition.ValueTypeName; return(channel); }
private static Channel ParseSeries(SeriesDefinition seriesDefinition) { ChannelDefinition channelDefinition = seriesDefinition.ChannelDefinition; QuantityMeasured quantityMeasured = channelDefinition.QuantityMeasured; Phase phase = channelDefinition.Phase; // Populate series properties Series series = new Series(); series.Channel = new Channel(); series.SeriesType = new SeriesType(); series.SourceIndexes = string.Empty; // Populate channel properties Channel channel = series.Channel; channel.Series = new List <Series>() { series }; channel.MeasurementType = new MeasurementType(); channel.MeasurementCharacteristic = new MeasurementCharacteristic(); channel.Phase = new openXDA.Model.Phase(); channel.Name = channelDefinition.ChannelName; channel.HarmonicGroup = 0; channel.Series.Add(series); if (seriesDefinition.HasElement(SeriesDefinition.SeriesNominalQuantityTag)) { channel.PerUnitValue = seriesDefinition.SeriesNominalQuantity; } // Populate measurement type properties channel.MeasurementType.Name = quantityMeasured.ToString(); // Populate characteristic properties channel.MeasurementCharacteristic.Name = QuantityCharacteristic.ToName(seriesDefinition.QuantityCharacteristicID) ?? seriesDefinition.QuantityCharacteristicID.ToString(); channel.MeasurementCharacteristic.Description = QuantityCharacteristic.ToString(seriesDefinition.QuantityCharacteristicID); // Popuplate phase properties channel.Phase.Name = phase.ToString(); // Populate series type properties series.SeriesType.Name = SeriesValueType.ToString(seriesDefinition.ValueTypeID) ?? seriesDefinition.ValueTypeName ?? seriesDefinition.ValueTypeID.ToString(); series.SeriesType.Description = seriesDefinition.ValueTypeName; return(channel); }
private Disturbance ToDisturbance(DataSeries rms, Range <int> range, Phase phase) { double nominalValue = rms.SeriesInfo.Channel.PerUnitValue ?? GetLineVoltage(rms); Disturbance disturbance = new Disturbance(); disturbance.EventType = m_eventType; disturbance.Phase = phase; disturbance.StartIndex = range.Start; disturbance.EndIndex = range.End; disturbance.StartTime = rms[range.Start].Time; disturbance.EndTime = rms[range.End].Time; disturbance.Magnitude = GetMagnitude(rms.ToSubSeries(range.Start, range.End)); disturbance.PerUnitMagnitude = disturbance.Magnitude / nominalValue; return(disturbance); }
private Channel ParseChannel(Meter meter, GSF.PQDIF.Logical.ChannelDefinition channeldef, AdoDataConnection connection) { Channel channel = new Channel(); channel.MeterID = meter.ID; channel.Name = channeldef.ChannelName; GSF.PQDIF.Logical.QuantityMeasured quantity = channeldef.QuantityMeasured; Guid quantityType = channeldef.QuantityTypeID; GSF.PQDIF.Logical.Phase phase = channeldef.Phase; if (isRMS(quantityType)) { channel.SignalType = SignalType.RMS; } else if (isPOW(quantityType)) { channel.SignalType = SignalType.PointOnWave; } else { channel.SignalType = SignalType.other; } Boolean isV = quantity == QuantityMeasured.Voltage; Boolean isI = quantity == QuantityMeasured.Current; Boolean isA = (phase == Phase.AN) || (phase == Phase.AB); Boolean isB = (phase == Phase.BN) || (phase == Phase.BC); Boolean isC = (phase == Phase.CN) || (phase == Phase.CA); Boolean isN = phase == Phase.Residual; string measurementname = MeasurementType.other; if (isV && isA) { measurementname = MeasurementType.VoltageA; } else if (isV && isB) { measurementname = MeasurementType.VoltageB; } else if (isV && isC) { measurementname = MeasurementType.VoltageC; } else if (isI && isA) { measurementname = MeasurementType.CurrentA; } else if (isI && isB) { measurementname = MeasurementType.CurrentB; } else if (isI && isC) { measurementname = MeasurementType.CurrentC; } else if (isV && isN) { measurementname = MeasurementType.other; } else if (isI && isN) { measurementname = MeasurementType.other; } GSF.Data.Model.TableOperations <Channel> channelTable = new GSF.Data.Model.TableOperations <Channel>(connection); channel.MeasurementType = measurementname; channelTable.AddNewRecord(channel); channel.ID = ModelID.GetID <Channel>(connection); return(channel); }