コード例 #1
0
 /// <summary>
 ///
 /// </summary>
 public void ApplyResetsIfAny()
 {
     ModelOptionsController.ApplyResetsIfAny(Today);
 }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="inputDataModels"></param>
        public Simulation(Project Project, List <InputModel> inputDataModels, int startYear = 0, int endYear = 0) : this()
        {
            this.Project = Project;

            StartYear = startYear;
            EndYear   = EndYear;

            ErrorList = new List <string>();
            ZerosList = new List <string>();

            CanLog = false;

            RunSilent          = false;
            Force2011CurveNoFn = false;

            //Simulation has to have a Climate, Soil, Vegetion Controllers/Models
            ClimateController    = new ClimateController(this, new List <InputModel>(inputDataModels.Where(x => x.GetType() == typeof(ClimateInputModel))));
            VegetationController = new VegetationController(this, new List <InputModel>(inputDataModels.Where(x => x.GetType().BaseType == (typeof(VegInputModel)))));
            SoilController       = new SoilController(this, new List <InputModel>(inputDataModels.Where(x => x.GetType() == typeof(SoilInputModel))));

            //Optional Controllers/Models
            IrrigationController = FindInputModels(inputDataModels, typeof(IrrigationInputModel)) == null ? null : new IrrigationController(this, FindInputModels(inputDataModels, typeof(IrrigationInputModel)));
            TillageController    = FindInputModels(inputDataModels, typeof(TillageInputModel)) == null ? null : new TillageController(this, FindInputModels(inputDataModels, typeof(TillageInputModel)));
            PesticideController  = FindInputModels(inputDataModels, typeof(PesticideInputModel)) == null ? null : new PesticideController(this, FindInputModels(inputDataModels, typeof(PesticideInputModel)));
            PhosphorusController = FindInputModels(inputDataModels, typeof(PhosphorusInputModel)) == null ? null : new PhosphorusController(this, FindInputModels(inputDataModels, typeof(PhosphorusInputModel)));
            NitrateController    = FindInputModels(inputDataModels, typeof(NitrateInputModel)) == null ? null : new NitrateController(this, FindInputModels(inputDataModels, typeof(NitrateInputModel)));
            SolutesController    = FindInputModels(inputDataModels, typeof(SolutesInputModel)) == null ? null : new SolutesController(this, FindInputModels(inputDataModels, typeof(SolutesInputModel)));
            //ModelOptionsController = FindInputModels(inputDataModels, typeof(ModelOptionsInputModel)) == null ? null : new ModelOptionsController(this, FindInputModels(inputDataModels, typeof(ModelOptionsInputModel)));
            //There is no XML definition found yet
            ModelOptionsController = new ModelOptionsController(this);

            //Add the non-null controllers to the activecontroller list
            List <PropertyInfo> controllers = new List <PropertyInfo>(this.GetType().GetProperties().Where(
                                                                          x => x.PropertyType.BaseType == typeof(HLController) || x.PropertyType.BaseType == typeof(HLObjectController)));

            ActiveControlllers = new List <HLController>();

            ActiveControlllers.Add(this);

            foreach (PropertyInfo p in controllers)
            {
                if (p.GetValue(this) != null)
                {
                    ActiveControlllers.Add((HLController)p.GetValue(this));
                }
            }

            //Instantiate the output controller
            //This is now done in the Project as it has the relevant path and setup information
            OutputModelController = new OutputModelController(this);

            //Set the start date and end dates
            if (StartYear == 0)
            {
                StartDate = new DateTime(ClimateController.InputModel.StartDate.Value.Ticks);
            }
            else
            {
                StartDate = new DateTime(StartYear, 1, 1);
            }

            if (EndYear == 0)
            {
                EndDate = new DateTime(ClimateController.InputModel.EndDate.Value.Ticks);
            }
            else
            {
                EndDate = new DateTime(EndYear, 12, 31);
            }

            Today = StartDate;
        }