Exemple #1
0
        private List <D3Series> QueryCurrentData(Meter meter, Event evt)
        {
            DataGroup dataGroup = OpenSEEController.QueryDataGroup(evt.ID, meter);

            List <D3Series> WaveForm = dataGroup.DataSeries.Where(ds => ds.SeriesInfo.Channel.MeasurementType.Name == "Current"
                                                                  ).Select(
                ds => new D3Series()
            {
                ChannelID   = ds.SeriesInfo.Channel.ID,
                ChartLabel  = OpenSEEController.GetChartLabel(ds.SeriesInfo.Channel),
                LegendGroup = ds.SeriesInfo.Channel.Asset.AssetName,
                DataPoints  = ds.DataPoints.Select(dataPoint => new double[] { dataPoint.Time.Subtract(m_epoch).TotalMilliseconds, dataPoint.Value }).ToList(),
            }).ToList();

            WaveForm.Sort((a, b) => {
                if (a.LegendGroup == b.LegendGroup)
                {
                    return(a.ChartLabel.CompareTo(b.ChartLabel));
                }
                return(a.LegendGroup.CompareTo(b.LegendGroup));
            });

            VICycleDataGroup viCycleDataGroup = OpenSEEController.QueryVICycleDataGroup(evt.ID, meter);

            List <D3Series> result = new List <D3Series>();

            foreach (D3Series w in WaveForm)
            {
                result.Add(w);
                int index = viCycleDataGroup.CycleDataGroups.FindIndex(item => item.RMS.SeriesInfo.ChannelID == w.ChannelID);
                if (index > -1)
                {
                    result.Add(new D3Series
                    {
                        ChannelID   = w.ChannelID,
                        DataPoints  = viCycleDataGroup.CycleDataGroups[index].RMS.DataPoints.Select(dataPoint => new double[] { dataPoint.Time.Subtract(m_epoch).TotalMilliseconds, dataPoint.Value }).ToList(),
                        ChartLabel  = w.ChartLabel + " RMS",
                        LegendGroup = w.LegendGroup,
                    });

                    result.Add(new D3Series
                    {
                        ChannelID   = w.ChannelID,
                        DataPoints  = viCycleDataGroup.CycleDataGroups[index].Phase.Multiply(180.0D / Math.PI).DataPoints.Select(dataPoint => new double[] { dataPoint.Time.Subtract(m_epoch).TotalMilliseconds, dataPoint.Value }).ToList(),
                        ChartLabel  = w.ChartLabel + " Phase",
                        LegendGroup = w.LegendGroup,
                    });
                }
            }


            return(result);
        }
Exemple #2
0
        private List <D3Series> QueryVoltageData(Meter meter, Event evt)
        {
            bool useLL;

            using (AdoDataConnection connection = new AdoDataConnection("systemSettings"))
            {
                useLL = connection.ExecuteScalar <bool?>("SELECT Value FROM Settings WHERE Name = 'useLLVoltage'") ?? false;
            }

            DataGroup dataGroup = OpenSEEController.QueryDataGroup(evt.ID, meter);

            List <D3Series> WaveForm = dataGroup.DataSeries.Where(ds => ds.SeriesInfo.Channel.MeasurementType.Name == "Voltage" && (
                                                                      (useLL && !(ds.SeriesInfo.Channel.Phase.Name == "AB" || ds.SeriesInfo.Channel.Phase.Name == "BC" || ds.SeriesInfo.Channel.Phase.Name == "CA")) ||
                                                                      (!useLL && (ds.SeriesInfo.Channel.Phase.Name == "AB" || ds.SeriesInfo.Channel.Phase.Name == "BC" || ds.SeriesInfo.Channel.Phase.Name == "CA")))
                                                                  ).Select(
                ds => new D3Series()
            {
                ChannelID   = ds.SeriesInfo.Channel.ID,
                ChartLabel  = OpenSEEController.GetChartLabel(ds.SeriesInfo.Channel),
                LegendGroup = ds.SeriesInfo.Channel.Asset.AssetName,
                DataPoints  = ds.DataPoints.Select(dataPoint => new double[] { dataPoint.Time.Subtract(m_epoch).TotalMilliseconds, dataPoint.Value }).ToList(),
            }).ToList();

            WaveForm.Sort((a, b) => {
                if (a.LegendGroup == b.LegendGroup)
                {
                    return(a.ChartLabel.CompareTo(b.ChartLabel));
                }
                return(a.LegendGroup.CompareTo(b.LegendGroup));
            });

            VICycleDataGroup viCycleDataGroup = OpenSEEController.QueryVICycleDataGroup(evt.ID, meter);

            List <D3Series> result = new List <D3Series>();

            foreach (D3Series w in WaveForm)
            {
                result.Add(w);
                int index = viCycleDataGroup.CycleDataGroups.FindIndex(item => item.RMS.SeriesInfo.ChannelID == w.ChannelID);
                if (index > -1)
                {
                    result.Add(new D3Series
                    {
                        ChannelID   = w.ChannelID,
                        DataPoints  = viCycleDataGroup.CycleDataGroups[index].RMS.DataPoints.Select(dataPoint => new double[] { dataPoint.Time.Subtract(m_epoch).TotalMilliseconds, dataPoint.Value }).ToList(),
                        ChartLabel  = w.ChartLabel + " RMS",
                        LegendGroup = w.LegendGroup,
                    });

                    result.Add(new D3Series
                    {
                        ChannelID   = w.ChannelID,
                        DataPoints  = viCycleDataGroup.CycleDataGroups[index].Phase.Multiply(180.0D / Math.PI).DataPoints.Select(dataPoint => new double[] { dataPoint.Time.Subtract(m_epoch).TotalMilliseconds, dataPoint.Value }).ToList(),
                        ChartLabel  = w.ChartLabel + " Phase",
                        LegendGroup = w.LegendGroup,
                    });
                }
            }


            return(result);
        }