예제 #1
0
        public static DataGroup ToDataGroup(Meter meter, List <byte[]> data)
        {
            DataGroup dataGroup = new DataGroup();

            dataGroup.FromData(meter, data);
            VIDataGroup vIDataGroup = new VIDataGroup(dataGroup);

            return(vIDataGroup.ToDataGroup());
        }
예제 #2
0
        public IHttpActionResult GetEventWaveformData(EventDataJSON json)
        {
            if (json != null && json.EventID != null)
            {
                try {
                    int eventID = int.Parse(json.EventID);
                    using (AdoDataConnection connection = new AdoDataConnection("systemSettings"))
                    {
                        Event evt   = new TableOperations <Event>(connection).QueryRecordWhere("ID = {0}", eventID);
                        Meter meter = new TableOperations <Meter>(connection).QueryRecordWhere("ID = {0}", evt.MeterID);
                        meter.ConnectionFactory = () => new AdoDataConnection("systemSettings");
                        List <byte[]> frequencyDomainData = ChannelData.DataFromEvent(eventID, connection);

                        DataGroup dataGroup = new DataGroup();
                        dataGroup.FromData(meter, frequencyDomainData);
                        VIDataGroup vIDataGroup = new VIDataGroup(dataGroup);
                        dataGroup = vIDataGroup.ToDataGroup();
                        DataTable table = new DataTable();

                        table.Columns.Add("Timestamp", typeof(DateTime));
                        foreach (var series in dataGroup.DataSeries)
                        {
                            table.Columns.Add(series.SeriesInfo.Channel.MeasurementType.Name + "(" + series.SeriesInfo.Channel.Phase.Name + ")", typeof(double));
                        }

                        for (int i = 0; i < dataGroup.DataSeries[0].DataPoints.Count(); ++i)
                        {
                            DataRow row = table.NewRow();
                            row["Timestamp"] = dataGroup.DataSeries[0].DataPoints[i].Time;
                            for (int j = 1; j < table.Columns.Count; ++j)
                            {
                                row[table.Columns[j].ColumnName] = dataGroup.DataSeries[j - 1].DataPoints[i].Value;
                            }

                            table.Rows.Add(row);
                        }
                        return(Ok(table));
                    }
                }
                catch (Exception ex)
                {
                    return(InternalServerError(ex));
                }
            }
            else
            {
                return(BadRequest("Please provide event id"));
            }
        }