예제 #1
0
        //methods
        private List <ISessionColumn> ProcessRawColumns()
        {
            //set up colname and index and do some data clean up for each column in dataset
            TimeSpan p;
            DateTime start = DateTime.Now;

            try
            {
                List <ISessionColumn> thisList = new List <ISessionColumn>();

                foreach (DataColumn dc in _data.Columns)
                {
                    string        thiscolname = dc.ColumnName.Replace(".", "_");
                    SessionColumn column      = new SessionColumn(dc.Ordinal, thiscolname);
                    Console.WriteLine(dc.ColumnName + " " + dc.DataType);
                    thisList.Add((SessionColumn)column);
                }
                p = DateTime.Now - start;
                Console.WriteLine("processing columns takes " + p);
                return(thisList);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #2
0
        private Dictionary <int, Dictionary <double, List <double> > > GetMergeWSParam()
        {
            Dictionary <int, SessionColumn> colOrder = new Dictionary <int, SessionColumn>();

            //assemble parameters for merge ws conditionally
            if (_shearFrom.Values.Contains(null))
            {
                SessionColumn DrvUpperws = (SessionColumn)_collection[_collection.UpperWSComp(_dateStart)];
                SessionColumn DrvLowerws = (SessionColumn)_collection[_collection.LowerWSComp(_dateStart)];
                colOrder.Add(1, DrvUpperws);
                colOrder.Add(2, DrvLowerws);
                _shearFrom = colOrder;
            }
            else
            {
                colOrder = _shearFrom;
            }


            Dictionary <int, Dictionary <double, List <double> > > param = new Dictionary <int, Dictionary <double, List <double> > >();

            foreach (KeyValuePair <int, SessionColumn> kv in _shearFrom)
            {
                param.Add(kv.Key, new Dictionary <double, List <double> >()
                {
                    { kv.Value.Height, WindART.Utils.ExtractDataTableColumn <double>(kv.Value.ColIndex, _collection.Data) }
                });
            }
            return(param);
        }
예제 #3
0
        //public methods


        //private methods
        protected List <ISessionColumn> ProcessColumns(DataTable data)
        {
            //create
            List <ISessionColumn> result = new List <ISessionColumn>();

            foreach (DataColumn dc in data.Columns)
            {
                ISessionColumn S = new SessionColumn(dc.Ordinal, dc.ColumnName);
                result.Add(S);
            }
            return(result);
        }
예제 #4
0
        private int AddShearColumnToTable(string colname, double shearht)
        {
            //add column to datatable and column collection if necessary
            try
            {
                int shearIndex = 0;
                if (!_data.Table.Columns.Contains(colname))
                {
                    // add to datatable
                    DataColumn newcol = new DataColumn(colname);
                    newcol.DataType = typeof(double);
                    _data.Table.Columns.Add(newcol);
                    shearIndex = _data.Table.Columns[colname].Ordinal;

                    //add to col colection
                    ISessionColumn newSessCol = new SessionColumn(shearIndex, colname);
                    newSessCol.ColumnType = SessionColumnType.WSAvgSingleAxisShear;
                    Console.WriteLine("adding shear column " + colname);
                    _collection.Columns.Add(newSessCol);

                    //****metadata collection
                    ISensorConfig config = new SensorConfig();
                    config.Height = shearht;
                    DateTime start = DateTime.Parse(_data[0][_collection.DateIndex].ToString());
                    DateTime end
                        = DateTime.Parse(_data[_data.Count - 1][_collection.DateIndex].ToString());
                    config.StartDate = start;
                    config.EndDate   = end;
                    _collection[colname].addConfig(config);
                }
                else
                {
                    shearIndex = _collection[colname].ColIndex;
                }


                return(shearIndex);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        public bool Add(List <ISessionColumn> columns)
        {
            string compositeSuffix = Settings.Default.CompColName;
            string compositeName;

            //for each child column in each column add a composite column to the datatable
            foreach (ISessionColumn column in columns)
            {
                //add parent col
                compositeName = Enum.GetName(typeof(SessionColumnType), column.ColumnType) + compositeSuffix;

                if (!_data.Columns.Contains(compositeName))
                {
                    Console.WriteLine("adding " + compositeName);
                    if (AddingWDCompCol != null)
                    {
                        AddingWDCompCol("Adding " + compositeName);
                    }
                    //add to datatable
                    DataColumn newCol = new DataColumn();
                    newCol.DataType   = _data.Columns[column.ColIndex].DataType;
                    newCol.ColumnName = compositeName;
                    _data.Columns.Add(newCol);
                    Console.WriteLine("Adding " + compositeName + " at index " + _data.Columns[newCol.ColumnName].Ordinal);
                    //add to sessioncolumn collection
                    ISessionColumn newSessCol = new SessionColumn(_data.Columns[newCol.ColumnName].Ordinal
                                                                  , newCol.ColumnName);

                    newSessCol.ColumnType  = SessionColumnType.WDAvg;
                    newSessCol.IsComposite = true;
                    _collection.Columns.Add(newSessCol);
                    if (AddedWDCompCol != null)
                    {
                        AddedWDCompCol("Successfully added " + compositeName + " at index " + _data.Columns[newCol.ColumnName].Ordinal);
                    }
                }
                //add child columns
                foreach (ISessionColumn child in column.ChildColumns)
                {
                    //build comp column name from each column type and the composite suffix from the app properties
                    compositeName = Enum.GetName(typeof(SessionColumnType), child.ColumnType) + compositeSuffix;
                    if (!_data.Columns.Contains(compositeName))
                    {
                        //add to datatable
                        DataColumn newCol = new DataColumn();
                        newCol.DataType   = _data.Columns[child.ColIndex].DataType;
                        newCol.ColumnName = compositeName;
                        _data.Columns.Add(newCol);
                        Console.WriteLine("adding " + compositeName + " at index " + _data.Columns[newCol.ColumnName].Ordinal);
                        if (AddingWDCompCol != null)
                        {
                            AddingWDCompCol("Adding " + compositeName + " at index " + _data.Columns[newCol.ColumnName].Ordinal);
                        }
                        //add to sessioncolumn collection
                        ISessionColumn newSessCol = new SessionColumn(_data.Columns [newCol.ColumnName].Ordinal, newCol.ColumnName);
                        newSessCol.ColumnType  = child.ColumnType;
                        newSessCol.IsComposite = true;
                        _collection.Columns.Add(newSessCol);
                        if (AddedWDCompCol != null)
                        {
                            AddedWDCompCol("Successfully Added " + compositeName + " at index " + _data.Columns[newCol.ColumnName].Ordinal);
                        }
                    }
                }
            }
            _data.AcceptChanges();
            return(true);
        }
예제 #6
0
        public bool Add(double height, IList <ISessionColumn> columns, DateTime startdate, DateTime enddate)
        {
            string compositeSuffix    = Settings.Default.CompColName;
            string compositeName      = string.Empty;
            string childCompositeName = string.Empty;
            int    compositeIndex     = 0;


            compositeName  = height.ToString();
            compositeName += Enum.GetName(typeof(SessionColumnType), SessionColumnType.WSAvg);
            compositeName += Settings.Default.CompColName;
            compositeName  = compositeName.Replace(".", "_");

            Console.WriteLine("comp parent will be named " + compositeName);
            //for each child column in each column add a composite column to the datatable

            //add parent col

            if (!_data.Columns.Contains(compositeName))
            {
                Console.WriteLine("adding " + compositeName);
                //***datatable
                DataColumn newcol = new DataColumn(compositeName);
                newcol.DataType = typeof(double);
                _data.Columns.Add(newcol);
                compositeIndex = _data.Columns[compositeName].Ordinal;
                ISessionColumn newSessCol = new SessionColumn(compositeIndex, compositeName);
                newSessCol.ColumnType  = SessionColumnType.WSAvg;
                newSessCol.IsComposite = true;
                _collection.Columns.Add(newSessCol);

                //****metadata collection
                //set the height of the composite col using either of the sensor pair
                ISensorConfig config = new SensorConfig();
                config.Height    = height;
                config.StartDate = startdate;
                config.EndDate   = enddate;
                _collection[compositeName].addConfig(config);
            }
            //add child columns
            Console.WriteLine(" number of parent columns " + columns.Count);
            foreach (ISessionColumn column in columns)
            {
                foreach (ISessionColumn child in column.ChildColumns)
                {
                    //    //build comp column name from each column type and the composite suffix from the app properties
                    childCompositeName  = height.ToString();
                    childCompositeName += child.ColumnType;
                    childCompositeName += Settings.Default.CompColName;
                    childCompositeName  = childCompositeName.Replace(".", "_");



                    if (!_data.Columns.Contains(childCompositeName))
                    {
                        Console.WriteLine("adding child comp " + childCompositeName);
                        //add to datatable
                        DataColumn newChildCol = new DataColumn();
                        newChildCol.DataType   = _data.Columns[child.ColIndex].DataType;
                        newChildCol.ColumnName = childCompositeName;
                        _data.Columns.Add(newChildCol);

                        //add to sessioncolumn collection
                        ISessionColumn newCollectionChildCol = new SessionColumn(_data.Columns[newChildCol.ColumnName].Ordinal, newChildCol.ColumnName);
                        newCollectionChildCol.ColumnType  = child.ColumnType;
                        newCollectionChildCol.IsComposite = true;
                        _collection.Columns.Add(newCollectionChildCol);

                        //config
                        ISensorConfig childconfig = new SensorConfig();
                        childconfig.Height    = height;
                        childconfig.StartDate = startdate;
                        childconfig.EndDate   = enddate;
                        _collection[childCompositeName].addConfig(childconfig);
                    }
                }
            }
            _data.AcceptChanges();
            return(true);
        }
예제 #7
0
        protected virtual void setCols()
        {
            try
            {//figure out config dates and get comp columns
                HeightConfigCollection configcollection = new HeightConfigCollection(_collection);
                List <IConfig>         configs          = configcollection.GetConfigs();

                Console.WriteLine(" doing " + _summarytype);

                if (configs.Count > 1)
                {
                    Console.WriteLine("configs found " + configs.Count);
                    foreach (IConfig c in configs)
                    {
                        Console.WriteLine("start date " + c.StartDate);
                    }
                    throw new ApplicationException("Can not process grid. System not yet set up to handle multpile configurations");
                }
                _configstart = configs[0].StartDate;
                Console.WriteLine("start date in summary grid " + _configstart);
                //wscomps
                //SortedDictionary<double, ISessionColumn> wscomps
                //    = _collection.GetColumnsByType(SessionColumnType.WSAvg, _configstart, true);

                _lowerwscompcol = _collection[_collection.LowerWSComp(_configstart)];
                _upperwscompcol = _collection[_collection.UpperWSComp(_configstart)];
                _lowerwsht      = _lowerwscompcol.getConfigAtDate(_configstart).Height;
                _upperwsht      = _upperwscompcol.getConfigAtDate(_configstart).Height;

                //Console.WriteLine("Summary grid found " + wscomps.Values.Count + " ws comps");
                //wdcomp
                List <ISessionColumn> wdcomp =
                    _collection.GetColumnsByType(SessionColumnType.WDAvg);

                var compcol = from c in wdcomp.AsEnumerable()
                              where c.IsComposite
                              select c;

                _wdcompcol = compcol.ToList()[0];

                //Console.WriteLine("Summary grid found " + compcol.ToList().Count  + " wd comps");

                //shear
                if (_shearwscol == null)
                {
                    List <ISessionColumn> shearcol = _collection.GetColumnsByType(_sheartype);
                    _shearwscol = shearcol[0];
                }



                if (_shearwscol.Configs.Count != 0)
                {
                    _shearht = _shearwscol.getConfigAtDate(_configstart).Height;
                }
                else
                {
                    SessionColumn sc = (SessionColumn)_shearwscol;
                    _shearht = sc.Height;
                }

                //Console.WriteLine("Summary grid found " + _collection.GetColumnsByType(_sheartype).Count  + " shear");
            }
            catch (Exception e)
            {
                System.Windows.MessageBox.Show(e.Message);
            }
        }