Пример #1
0
        private static void PrintDailyRows1(PageData page, Run runOld)
        {
            var allUniverse     = runOld.SavedUniverses;
            var lastUniverse    = GetLastUniverse(runOld);
            var finalLeafNumber = (int)lastUniverse.Crop_.LeafNumber;

            if (allUniverse != null && allUniverse.Count > 1)
            {
                var nbUniverse = allUniverse.Count;

                ///<Behnam>

                var sowDate = runOld.SavedUniverses[nbUniverse - 1].Crop_.getDateOfStage(GrowthStage.ZC_00_Sowing);
                var sowDay  = (int)(sowDate.Value - runOld.SavedUniverses[0].CurrentDate).TotalDays;

                for (var i = 1; i < nbUniverse; ++i)
                {
                    var universe = allUniverse[i];
                    if (i >= sowDay)
                    {
                        page.Add(PrintDailyCropRow1(universe).Add(PrintDailyLeafRow1(universe, finalLeafNumber)));
                    }

                    ///</Behnam>
                }
            }
        }
Пример #2
0
        private void AddToBlackList_Click(object sender, RoutedEventArgs e)
        {
            ProxyInfo proxy = (ProxyInfo)((Button)sender).Tag;

            foreach (IProxyClient client in Context.Get <IProxyClientSearcher>().SelectedClients.Where(item => item.Proxy == proxy))
            {
                client.Proxy = null;
            }

            Context.Get <IBlackListManager>().Add(proxy);
            PageData.Remove(proxy);

            if (Paging.Page < Paging.PageCount)
            {
                int index = Paging.Page.Value * Context.Get <AllSettings>().PageSize;
                PageData.Add(FilteredData[index]);
            }

            if (PageData.Count == 0 && Paging.Page > 1)
            {
                Paging.Page--;
            }

            Data.Remove(proxy);
            FilteredData.Remove(proxy);

            Context.Get <IRatingManager>().UpdateRatingDataAsync(proxy, 1);

            UpdateStatusString();
        }
Пример #3
0
        private static void PrintDailyRows2(PageData page, Run runOld)
        {
            var allUniverse     = runOld.SavedUniverses;
            var lastUniverse    = GetLastUniverse(runOld);
            var finalLeafNumber = lastUniverse.Crop_.CreatedLeavesNumber;

            if (allUniverse != null && allUniverse.Count > 0)
            {
                var nbUniverse = allUniverse.Count;
                for (var i = 1; i < nbUniverse; ++i)
                {
                    var universe = allUniverse[i];
                    page.Add(PrintDailyCropRow2(universe).Add(PrintDailyLeafRow2(universe, finalLeafNumber)));
                }
            }
        }
Пример #4
0
        internal override PageData MultiRunHeader()
        {
            var line = new LineData();

            line.Add(FileContainer.ManagementID)
            .Add(FileContainer.NonVarietyID)
            .Add(FileContainer.RunOptionID)
            .Add(FileContainer.SiteID)
            .Add(FileContainer.SoilID)
            .Add(FileContainer.VarietyID)
            .Add("Sowing")
            .Add("Emergence")
            .Add("Anthesis")
            .Add("End cell division")
            .Add("End grain fill")
            .Add("Maturity")
            .Add("Final leaf number")
            .Add("Anthesis GAI")
            .Add("Crop DM at anthesis, MgDM/ha")
            .Add("Total yield, MgDM/ha")
            .Add("Grain yield, MgDM/ha")
            .Add("CropN at anthesis, kgN/ha")
            .Add("CropN at maturity, kgN/ha")
            .Add("GrainN, kgN/ha")
            .Add("DM harvest index")
            .Add("N harvest index")
            .Add("AvSoilN, kgN/ha")
            .Add("N leaching, kgN/ha")
            .Add("NUE, kgDM/kgN")
            .Add("GrainDM, mgDM/grain")
            .Add("GrainN, mgN/grain")
            .Add("GPC, %")
            .Add("Grain number, grain/m2")
            .Add("AlbGlo, mgN/grain")
            .Add("Amp, mgN/grain")
            .Add("Gli, mgN/grain")
            .Add("Glu, mgN/grain")
            .Add("%Gli, % total N")
            .Add("%Glu, % total N")
            .Add("Gli/Glu");
            var page = new PageData();

            page.Add(line);
            return(page);
        }
Пример #5
0
 private static void PrintDailyHeader2(PageData page, Run runOld)
 {
     page.Add(PrintDailyHeaderCrop21().Add(PrintDailyHeaderLeaf21()));
     page.Add(PrintDailyHeaderCrop22().Add(PrintDailyHeaderLeaf22(runOld)));
 }
Пример #6
0
 private static void PrintDailyHeader1(PageData page, Run runOld)
 {
     page.Add(PrintDailyHeaderCrop11().Add(PrintDailyHeaderLeaf11(runOld)));
     page.Add(PrintDailyHeaderCrop12().Add(PrintDailyHeaderLeaf12(runOld)));
 }
Пример #7
0
        public override void StepRun(bool serialize, int i, string variety = null, string parameterName = null, double parameterValue = 0)
        {
            #region get items

            string miName, piName, riName, roiName, siiName, soiName, viName, exName;

            if (MultiRuns.Count > 0)
            {
                var item = MultiRuns[i];
                miName  = item.ManagementItemSelected;
                piName  = item.ParameterItemSelected;
                riName  = RunItem.Name;
                roiName = item.RunOptionItemSelected;
                siiName = item.SiteItemSelected;
                soiName = item.SoilItemSelected;
                viName  = item.VarietyItemSelected;
                exName  = item.ExperimentSelected;
            }
            else
            {
                miName  = RunItem.Normal.ManagementItem;
                piName  = RunItem.Normal.ParameterItem;
                riName  = RunItem.Name;
                roiName = RunItem.Normal.RunOptionItem;
                siiName = RunItem.Normal.SiteItem;
                soiName = RunItem.Normal.SoilItem;
                viName  = RunItem.Normal.VarietyItem;
                exName  = RunItem.Normal.ExperimentItem;
            }

            ManagementItem    mi  = null;
            CropParameterItem pi  = null;
            RunOptionItem     roi = null;
            SiteItem          sii = null;
            SoilItem          soi = null;
            CropParameterItem vi  = null;
            RunCore.GetItems(riName, miName, piName, roiName, siiName, soiName, viName, ref mi, ref pi, ref roi, ref sii, ref soi, ref vi);

            #endregion

            #region override some parameters

            if (variety != null)
            {
                if (variety == viName)
                {
                    vi.ParamValue[parameterName] = parameterValue;
                }
            }

            #endregion

            if (!multiYear)
            {
                switch (roi.OutputPattern)
                {
                case "V13": ProjectFile.OutputVersion = OutputVersion.V13; break;

                case "V15": ProjectFile.OutputVersion = OutputVersion.V15; break;

                case "Cus": ProjectFile.OutputVersion = OutputVersion.Cus; break;

                case "Maize": ProjectFile.OutputVersion = OutputVersion.Maize; break;
                }

                ///<Behnam>
                ///<Comment>
                ///Modifications related to estimating sowing window and forcing the model
                ///to put daily outputs into one file if the names of the daily output files
                ///are identical for two successive years.
                ///</Comment>

                var yy = sii.MaxSowingDate.Year - sii.MinSowingDate.Year;
                mi.SowingDate     = new DateTime(mi.SowingDate.Year, mi.SowingDate.Month, mi.SowingDate.Day);
                sii.MinSowingDate = new DateTime(mi.SowingDate.Year, sii.MinSowingDate.Month, sii.MinSowingDate.Day);
                sii.MaxSowingDate = new DateTime(mi.SowingDate.Year + yy, sii.MaxSowingDate.Month, sii.MaxSowingDate.Day);

                Run.isFirstYear = true;
                ///</Behnam>
                //Debug
                var excelPage = RunCore.Run(riName, exportNormalRuns, false, mi, pi, roi, sii, soi, vi);

                ///<Behnam>
                if (i == 0)
                {
                    Book.Clear();
                    var outputFile = OutputFile.ExtractMultiRunHeader();
                    outputFile.Title = OutputFileName;
                    Book.Add(outputFile);
                }


                if (exportNormalRuns)
                {
                    var dailyOutputFileName = OutputPatternVarDef.OutputPatternValue(dailyOutputPattern, miName, piName, riName, roiName, siiName, soiName, viName, exName) + RunItem.Normal.OutputExtention;
                    dailyOutputFileName = dailyOutputFileName.Replace(VarMultiYearSowingYear, "");
                    excelPage.Title     = dailyOutputFileName;
                    Book.Add(excelPage);
                    if (serialize)
                    {
                        RunCore.Save(excelPage, AbsoluteOutputDirectory + "\\" + dailyOutputFileName);
                    }


                    if (i == 0)
                    {
                        warningFile       = OutputFile.ExtractWarningsHeader();
                        warningFile.Title = "warnings";
                    }

                    LineData line = OutputFile.ExtractWarningsMultiRun(RunCore.RunInstance);
                    if (line != null)
                    {
                        warningFile.Add(line);
                    }
                }

                if (i == 0 && ProjectFile.OutputVersion == OutputVersion.Cus)
                {
                    Run.SecondLine = false;
                    Book[0].Add(OutputFile.ExtractMultiRunLine(RunCore.RunInstance));
                }
                ///</Behnam>
                Book[0].Add(OutputFile.ExtractMultiRunLine(RunCore.RunInstance));

                /// Behnam (2016.06.01): Added to write the summaty file after each run is finished.
                /// Other way, if one simulations is not completed, the summary file is not pronted at all.
                if (serialize)
                {
                    RunCore.Save(Book[0], AbsoluteOutputPath);
                }
            }
            else
            {
                mi = mi.Clone();

                ///<Behnam>
                switch (roi.OutputPattern)
                {
                case "V13": ProjectFile.OutputVersion = OutputVersion.V13; break;

                case "V15": ProjectFile.OutputVersion = OutputVersion.V15; break;

                case "Cus": ProjectFile.OutputVersion = OutputVersion.Cus; break;

                case "Maize": ProjectFile.OutputVersion = OutputVersion.Maize; break;
                }

                for (var j = firstYear; j <= lastYear; ++j)
                {
                    foreach (var dateApp in mi.DateApplications)
                    {
                        dateApp.Date = new DateTime(j + (dateApp.Date.Year - mi.SowingDate.Year), dateApp.Date.Month, dateApp.Date.Day);
                    }

                    var yy = sii.MaxSowingDate.Year - sii.MinSowingDate.Year;
                    mi.SowingDate     = new DateTime(j, mi.SowingDate.Month, mi.SowingDate.Day);
                    sii.MinSowingDate = new DateTime(j, sii.MinSowingDate.Month, sii.MinSowingDate.Day);
                    sii.MaxSowingDate = new DateTime(j + yy, sii.MaxSowingDate.Month, sii.MaxSowingDate.Day);

                    Run.isFirstYear = (j == firstYear);

                    var excelPage = RunCore.Run(riName, exportNormalRuns, false, mi, pi, roi, sii, soi, vi);

                    if (i == 0 && j == firstYear)
                    {
                        Book.Clear();
                        var outputFile = OutputFile.ExtractMultiRunHeader();
                        outputFile.Title = OutputFileName;
                        Book.Add(outputFile);
                    }

                    if (exportNormalRuns)
                    {
                        var dailyOutputFileName = OutputPatternVarDef.OutputPatternValue(dailyOutputPattern, miName, piName, riName, roiName, siiName, soiName, viName, exName) + RunItem.Normal.OutputExtention;
                        dailyOutputFileName = dailyOutputFileName.Replace(VarMultiYearSowingYear, sii.MinSowingDate.Year.ToString());
                        excelPage.Title     = dailyOutputFileName;
                        Book.Add(excelPage);

                        if (j == firstYear || (j != firstYear && oldDailyOutputFileName != dailyOutputFileName))
                        {
                            if (serialize)
                            {
                                RunCore.Save(excelPage, AbsoluteOutputDirectory + "\\" + dailyOutputFileName, true);
                            }
                        }
                        else
                        {
                            if (serialize)
                            {
                                RunCore.Save(excelPage, AbsoluteOutputDirectory + "\\" + dailyOutputFileName, false);
                            }
                        }
                        oldDailyOutputFileName = dailyOutputFileName;
                    }

                    if (i == 0 && j == firstYear && ProjectFile.OutputVersion == OutputVersion.Cus)
                    {
                        Run.SecondLine = false;
                        Book[0].Add(OutputFile.ExtractMultiRunLine(RunCore.RunInstance));
                    }
                    Book[0].Add(OutputFile.ExtractMultiRunLine(RunCore.RunInstance));

                    /// Behnam (2016.06.01): Added to write the summaty file after each run is finished.
                    /// Other way, if one simulations is not completed, the summary file is not pronted at all.
                    if (serialize)
                    {
                        RunCore.Save(Book[0], AbsoluteOutputPath);
                    }
                    ///</Behnam>

                    //Warnings
                    if (i == 0 && j == firstYear)
                    {
                        warningFile       = OutputFile.ExtractWarningsHeader();
                        warningFile.Title = "warnings";
                    }

                    LineData line = OutputFile.ExtractWarningsMultiRun(RunCore.RunInstance);
                    if (line != null)
                    {
                        warningFile.Add(line);
                    }
                }
            }
            if (i == (MultiRuns.Count - 1))
            {
                Book.Add(warningFile);
            }
        }