Esempio n. 1
0
        public ModelSheet Add(Utilities.EnergySource aSource)
        {
            Excel.Worksheet thisSheet = (Excel.Worksheet)Globals.ThisAddIn.Application.ActiveWorkbook.Worksheets.Add
                                            (System.Type.Missing, Globals.ThisAddIn.Application.ActiveWorkbook.Sheets.get_Item(Globals.ThisAddIn.Application.ActiveWorkbook.Sheets.Count), 1, Excel.XlSheetType.xlWorksheet);
            thisSheet.CustomProperties.Add("SheetGUID", System.Guid.NewGuid().ToString());

            thisSheet.Name      = Utilities.ExcelHelpers.CreateValidWorksheetName(Globals.ThisAddIn.Application.ActiveWorkbook, aSource.Name, Globals.ThisAddIn.groupSheetCollection.regressionIteration);
            thisSheet.Tab.Color = 0x50CC11;
            thisSheet.Visible   = Excel.XlSheetVisibility.xlSheetHidden;

            string sheetString = thisSheet.ToString();

            GroupSheet GS = new GroupSheet(thisSheet, false, false, thisSheet.Name);

            Globals.ThisAddIn.groupSheetCollection.Add(GS);

            ModelSheet aSheet = new ModelSheet(thisSheet);

            aSheet.Source = aSource;

            return(aSheet);
        }
Esempio n. 2
0
 public void Add(EnergySource aSource)
 {
     List.Add(aSource);
 }
Esempio n. 3
0
        public void Init()//bool fromRegression
        {
            if (ModelYear != null)
            {
                ExcludeBlanks();
            }

            // set model data
            string yrcol = EnPIResources.yearColName;
            string fltr  = yrcol + "='" + ModelYear + "'";

            ModelData = SourceData.Copy();

            if (ModelYear != null)  //replace all data with just the data for the model year
            {
                ModelData.Clear();

                foreach (DataRow dr in SourceData.Select(fltr))
                {
                    ModelData.ImportRow(dr);
                }

                if (ModelData.Rows.Count < Utilities.Constants.MODEL_MIN_DATAPOINTS)
                {
                    DataRow vr = VariableWarnings.NewRow();
                    vr[2] = "Selected model year contains less than " + Utilities.Constants.MODEL_MIN_DATAPOINTS.ToString() + " data points";
                    VariableWarnings.Rows.Add(vr);
                }
            }

            // set knownXs and knownYs
            knownXs = ModelData.Copy();
            knownYs = ModelData.Copy();

            foreach (DataColumn dc in ModelData.Columns)
            {
                if (!EnergySourceVariables.Contains(dc.ColumnName))
                {
                    knownYs.Columns.Remove(dc.ColumnName);
                }

                if (!IndependentVariables.Contains(dc.ColumnName))
                {
                    knownXs.Columns.Remove(dc.ColumnName);
                }
            }

            if (EnergySourceVariables.Contains(EnPIResources.unadjustedTotalColName))
            {
                knownYs = DataHelper.AddSumColumn(knownYs);
            }


            if (EnergySourceVariables != null)
            {
                // this will create the collection of energy sources and the list of IVs
                foreach (string col in EnergySourceVariables)
                {
                    EnergySource aSource = new EnergySource(col);
                    aSource.knownXs = knownXs;
                    try
                    {
                        double dcol = Convert.ToDouble(col);
                        string col1 = dcol.ToString("#,###0");
                        aSource.Ys = Ys(col1);
                    }

                    catch
                    {
                        aSource.Ys = Ys(col);
                    }
                    aSource.Combinations = AllCombinations();
                    aSource.AddModels();
                    EnergySources.Add(aSource);
                }
            }

            WriteVariableWarnings();
        }