Пример #1
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;
            }
        }
Пример #2
0
        public ISensorConfig CreateConfigType(SessionColumnType _coltype)
        {
            try
            {
                switch (_coltype)
                {
                case SessionColumnType.WSAvg:
                {
                    WindSpeedConfig result = new WindSpeedConfig();
                    return(result);
                }

                default:
                {
                    SensorConfig result = new SensorConfig();
                    return(result);
                }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Пример #3
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);
        }