Exemplo n.º 1
0
        private void AddData()
        {
            Series tempSeries = new Series(this, "", TimeInterval.Irregular);

            // tempSeries is not a "valid" series.  just taking advantage
            // of insert and lookup functions
            tempSeries.Table.Columns.Remove("flag"); // this was added by constructor above..

            int colIndex = 1;                        // skip date column

            do
            {
                Series  s   = m_seriesList[m_columnToSeries[colIndex]];
                DataRow row = null;

                for (int i = 0; i < s.Count; i++)
                {
                    Point pt  = s[i];
                    int   idx = tempSeries.IndexOf(pt.DateTime);
                    if (idx < 0)
                    {// need new row..
                        row           = NewRow();
                        row[0]        = pt.DateTime;
                        row[colIndex] = Point.DoubleOrNull(ref pt);
                        if (s.HasFlags)
                        {
                            row[colIndex + 1] = pt.Flag;
                        }
                        // find spot to insert
                        int sz = tempSeries.Count;
                        if (sz == 0 || pt.DateTime > tempSeries.MaxDateTime)
                        {   // append
                            Rows.Add(row);
                        }
                        else
                        {
                            int j = tempSeries.LookupIndex(pt.DateTime);
                            Rows.InsertAt(row, j);
                        }
                    }
                    else
                    { // using existing row
                        row           = Rows[idx];
                        row[colIndex] = Point.DoubleOrNull(ref pt);
                        if (s.HasFlags)
                        {
                            row[colIndex + 1] = pt.Flag;
                        }
                        continue;
                    }
                }
                colIndex++;
                if (s.HasFlags)
                {
                    colIndex++;
                }
            } while (colIndex < Columns.Count - 1);
        }
Exemplo n.º 2
0
        private DataTable CreateTimeSeriesCompositeTable()
        {
            /*
             * Example:   series with 2 tables.
             *
             * table1:  Date,uslev,flag
             * table2:  Date,uslev,flag
             *
             * Output:  Date,uslev,flag1,uslev2,flag2
             **/
            if (Count == 0)
            {
                return(new Series().Table.Copy());
            }
            if (Count == 1)
            {
                // if data is read-write original reference is needed in table
                return(this[0].Table);
            }
            DataTable table = CreateCompositeSchema();

            Series tempSeries = new Series(table, "", TimeInterval.Irregular);

            // tempSeries is not a "valid" series.  just taking advantage
            // of insert and lookup functions

            for (int seriesIndex = 0; seriesIndex < Count; seriesIndex++)
            {
                Series  s   = this[seriesIndex];
                DataRow row = null;

                for (int i = 0; i < s.Count; i++)
                {
                    Point pt  = s[i];
                    int   idx = tempSeries.IndexOf(pt.DateTime);
                    if (idx < 0)
                    {// need new row..
                        row    = table.NewRow();
                        row[0] = pt.DateTime;
                        row[1 + seriesIndex] = Point.DoubleOrNull(ref pt);
                    }
                    else
                    { // using existing row
                        row = table.Rows[idx];
                        row[1 + seriesIndex] = Point.DoubleOrNull(ref pt);
                        continue;
                    }

                    // find spot to insert
                    int sz = tempSeries.Count;
                    if (sz == 0 || pt.DateTime > tempSeries.MaxDateTime)
                    { // append
                        table.Rows.Add(row);
                        continue;
                    }

                    int j = tempSeries.LookupIndex(pt.DateTime);
                    table.Rows.InsertAt(row, j);
                }
            }



            return(table);
        }