Пример #1
0
        private void OnSimulationCommencing(object sender, EventArgs e)
        {
            bool foundGrowCrop = FindParentGrowCrop();

            if (!foundGrowCrop)
            {
                Summary.WriteWarning(this, String.Format("Unable to find a parent IATGrowCrop anywhere above ({0}).", this.Name));
                throw new ApsimXException(this, String.Format("Unable to find a parent IATGrowCrop anywhere above ({0}).", this.Name));
            }

            grandParentCropLand = (IATCropLand)parentGrowCrop.Parent;

            // get finance resource
            Finance finance = Resources.FinanceResource();

            if (finance != null)
            {
                bankAccount = Resources.GetResourceItem(this, typeof(Finance), AccountName, OnMissingResourceActionTypes.Ignore, OnMissingResourceActionTypes.ReportErrorAndStop) as FinanceType;
            }

            // get labour specifications
            labour = Apsim.Children(this, typeof(LabourFilterGroupSpecified)).Cast <LabourFilterGroupSpecified>().ToList();
            if (labour == null)
            {
                labour = new List <LabourFilterGroupSpecified>();
            }

            costDate = CostDateFromHarvestDate();
        }
Пример #2
0
        private void OnSimulationCommencing(object sender, EventArgs e)
        {
            fileCrop = Apsim.Child(Simulation, ModelNameFileCrop) as FileCrop;
            if (fileCrop == null)
            {
                throw new ApsimXException(this, String.Format("Unable to locate model for crop input file {0} (under Simulation) referred to in {1}", this.ModelNameFileCrop, this.Name));
            }


            switch (Store)
            {
            case StoresForCrops.HumanFoodStore:
                LinkedHumanFoodItem = Resources.GetResourceItem(this, typeof(HumanFoodStore), StoreItemName, OnMissingResourceActionTypes.ReportErrorAndStop, OnMissingResourceActionTypes.ReportErrorAndStop) as HumanFoodStoreType;
                break;

            case StoresForCrops.AnimalFoodStore:
                LinkedAnimalFoodItem = Resources.GetResourceItem(this, typeof(AnimalFoodStore), StoreItemName, OnMissingResourceActionTypes.ReportErrorAndStop, OnMissingResourceActionTypes.ReportErrorAndStop) as AnimalFoodStoreType;
                break;

            case StoresForCrops.ProductStore:
                LinkedProductItem = Resources.GetResourceItem(this, typeof(ProductStore), StoreItemName, OnMissingResourceActionTypes.ReportErrorAndStop, OnMissingResourceActionTypes.ReportErrorAndStop) as ProductStoreType;
                break;

            default:
                throw new Exception(String.Format("Store {0} is not supported for {1}", Enum.GetName(typeof(StoresForCrops), Store), this.Name));
            }


            cropLand = (IATCropLand)this.Parent;

            // Retrieve harvest data from the forage file for the entire run.
            HarvestData = fileCrop.GetCropDataForEntireRun(cropLand.LinkedLandItem.SoilType, CropName,
                                                           Clock.StartDate, Clock.EndDate);
            if ((HarvestData == null) || (HarvestData.Count == 0))
            {
                throw new ApsimXException(this, String.Format("Unable to locate in crop file {0} any harvest data for SoilType {1}, CropName {2} between the dates {3} and {4}",
                                                              fileCrop.FileName, cropLand.LinkedLandItem.SoilType, CropName, Clock.StartDate, Clock.EndDate));
            }

            IsTreeCrop = (TreesPerHa == 0) ? false : true;  //using this boolean just makes things more readable.

            unitsToHaConverter = (cropLand.LinkedLandItem.Parent as Land).UnitsOfAreaToHaConversion;
        }
Пример #3
0
        private void OnSimulationCommencing(object sender, EventArgs e)
        {
            bool foundGrowCrop = FindParentGrowCrop();

            if (!foundGrowCrop)
            {
                Summary.WriteWarning(this, String.Format("Unable to find a parent IATGrowCrop anywhere above ({0}).", this.Name));
                throw new ApsimXException(this, String.Format("Unable to find a parent IATGrowCrop anywhere above ({0}).", this.Name));
            }

            grandParentCropLand = (IATCropLand)parentGrowCrop.Parent;

            // get labour specifications
            labour = Apsim.Children(this, typeof(LabourFilterGroupSpecified)).Cast <LabourFilterGroupSpecified>().ToList();
            if (labour == null)
            {
                labour = new List <LabourFilterGroupSpecified>();
            }

            costDate = CostDateFromHarvestDate();
        }