Exemplo n.º 1
0
        private void OnCLEMInitialiseActivity(object sender, EventArgs e)
        {
            if (Area == 0 & AreaRequested > 0)
            {
                ResourceRequestList = new List <ResourceRequest>();
                ResourceRequestList.Add(new ResourceRequest()
                {
                    AllowTransmutation = false,
                    Required           = AreaRequested, // * (double)unitsOfArea,
                    ResourceType       = typeof(Land),
                    ResourceTypeName   = LandItemNameToUse,
                    ActivityModel      = this,
                    Reason             = "Assign",
                    FilterDetails      = null
                }
                                        );
            }

            gotLandRequested = TakeResources(ResourceRequestList, false);


            //Now the Land has been allocated we have an Area
            if (gotLandRequested)
            {
                //Assign the area actually got after taking it. It might be less than AreaRequested (if partial)
                Area = ResourceRequestList.FirstOrDefault().Provided;
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Method used to perform activity if it can occur as soon as resources are available.
 /// </summary>
 public override void PerformActivity()
 {
     if (ResourceRequestList.Count() > 0)
     {
         Area = ResourceRequestList.FirstOrDefault().Available;
     }
     return;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Method used to perform activity if it can occur as soon as resources are available.
 /// </summary>
 public override void DoActivity()
 {
     // days provided from labour set in the only request in the resourceResquestList
     // receive payment for labour if bank type exists
     if (bankType != null)
     {
         bankType.Add(ResourceRequestList.FirstOrDefault().Available *DailyRate, "Off farm labour", this.Name);
     }
 }
 /// <summary>
 /// Method used to perform activity if it can occur as soon as resources are available.
 /// </summary>
 public override void PerformActivity()
 {
     // if occurred
     if (this.NextDueDate.Year == Clock.Today.Year & this.NextDueDate.Month == Clock.Today.Month)
     {
         ResourceRequest thisRequest = ResourceRequestList.FirstOrDefault();
         if (thisRequest != null)
         {
             // update next due date
             this.NextDueDate = this.NextDueDate.AddMonths(this.PaymentInterval);
         }
     }
 }
Exemplo n.º 5
0
        private void OnCLEMInitialiseResource(object sender, EventArgs e)
        {
            if (Area == 0 & AreaRequested > 0)
            {
                ResourceRequestList = new List <ResourceRequest>();
                ResourceRequestList.Add(new ResourceRequest()
                {
                    AllowTransmutation = false,
                    Required           = AreaRequested,
                    ResourceType       = typeof(Land),
                    ResourceTypeName   = LandTypeNameToUse,
                    ActivityModel      = this,
                    Reason             = "Assign",
                    FilterDetails      = null
                }
                                        );
            }
            // if we get here we assume some land has been supplied
            if (ResourceRequestList != null || ResourceRequestList.Count() > 0)
            {
                gotLandRequested = TakeResources(ResourceRequestList, false);
            }

            //Now the Land has been allocated we have an Area
            if (gotLandRequested)
            {
                //get the units of area for this run from the Land resource parent.
                unitsOfArea2Ha = Resources.Land().UnitsOfAreaToHaConversion;

                // locate Pasture Type resource
                LinkedNativeFoodType = Resources.GetResourceItem(this, typeof(GrazeFoodStore), FeedTypeName, OnMissingResourceActionTypes.ReportErrorAndStop, OnMissingResourceActionTypes.ReportErrorAndStop) as GrazeFoodStoreType;

                //Assign the area actually got after taking it. It might be less than AreaRequested (if partial)
                Area = ResourceRequestList.FirstOrDefault().Provided;

                LinkedNativeFoodType.Area = Area;

                soilIndex = ((LandType)ResourceRequestList.FirstOrDefault().Resource).SoilType;

                LinkedNativeFoodType.CurrentEcologicalIndicators.LandConditionIndex = LandConditionIndex.StartingValue;
                LinkedNativeFoodType.CurrentEcologicalIndicators.GrassBasalArea     = GrassBasalArea.StartingValue;
                LinkedNativeFoodType.CurrentEcologicalIndicators.StockingRate       = StartingStockingRate;
                StockingRateSummed = StartingStockingRate;

                //Now we have a stocking rate and we have starting values for Land Condition and Grass Basal Area
                //get the starting pasture data list from GRASP
                GetPastureDataList_TodayToNextEcolCalculation();

                SetupStartingPasturePools(StartingAmount);
            }
        }
Exemplo n.º 6
0
        private void OnCLEMInitialiseResource(object sender, EventArgs e)
        {
            // activity is performed in CLEMUpdatePasture not CLEMGetResources and has no labour
            this.AllocationStyle = ResourceAllocationStyle.Manual;

            // locate Land Type resource for this forage.
            LinkedLandItem     = Resources.GetResourceItem(this, LandTypeNameToUse, OnMissingResourceActionTypes.ReportErrorAndStop, OnMissingResourceActionTypes.ReportErrorAndStop) as LandType;
            LandConditionIndex = Apsim.Children(this, typeof(Relationship)).Where(a => a.Name == "LandConditionIndex").FirstOrDefault() as Relationship;
            GrassBasalArea     = Apsim.Children(this, typeof(Relationship)).Where(a => a.Name == "GrassBasalArea").FirstOrDefault() as Relationship;
            FileGRASP          = Apsim.ChildrenRecursively(ZoneCLEM.Parent).Where(a => a.Name == ModelNameFileGRASP).FirstOrDefault() as IFileGRASP;

            if (UseAreaAvailable)
            {
                LinkedLandItem.TransactionOccurred += LinkedLandItem_TransactionOccurred;
            }
            if (Area == 0 && AreaRequested > 0)
            {
                ResourceRequestList = new List <ResourceRequest>
                {
                    new ResourceRequest()
                    {
                        AllowTransmutation = false,
                        Required           = UseAreaAvailable ? LinkedLandItem.AreaAvailable : AreaRequested,
                        ResourceType       = typeof(Land),
                        ResourceTypeName   = LandTypeNameToUse.Split('.').Last(),
                        ActivityModel      = this,
                        Reason             = "Assign",
                        FilterDetails      = null
                    }
                };
            }

            // if we get here we assume some land has been supplied
            if (ResourceRequestList != null && ResourceRequestList.Count() > 0)
            {
                CheckResources(ResourceRequestList, Guid.NewGuid());
                gotLandRequested = TakeResources(ResourceRequestList, false);
            }

            //Now the Land has been allocated we have an Area
            if (gotLandRequested)
            {
                //get the units of area for this run from the Land resource parent.
                unitsOfArea2Ha = Resources.Land().UnitsOfAreaToHaConversion;

                // locate Pasture Type resource
                LinkedNativeFoodType = Resources.GetResourceItem(this, FeedTypeName, OnMissingResourceActionTypes.ReportErrorAndStop, OnMissingResourceActionTypes.ReportErrorAndStop) as GrazeFoodStoreType;

                //Assign the area actually got after taking it. It might be less than AreaRequested (if partial)
                Area = ResourceRequestList.FirstOrDefault().Provided;

                // ensure no other activity has set the area of this GrazeFoodStore
                LinkedNativeFoodType.Manager = this as IPastureManager;

                soilIndex = ((LandType)ResourceRequestList.FirstOrDefault().Resource).SoilType;

                LinkedNativeFoodType.CurrentEcologicalIndicators.LandConditionIndex = LandConditionIndex.StartingValue;
                LinkedNativeFoodType.CurrentEcologicalIndicators.GrassBasalArea     = GrassBasalArea.StartingValue;
                LinkedNativeFoodType.CurrentEcologicalIndicators.StockingRate       = StartingStockingRate;
                StockingRateSummed = StartingStockingRate;

                //Now we have a stocking rate and we have starting values for Land Condition and Grass Basal Area
                //get the starting pasture data list from GRASP
                GetPastureDataList_TodayToNextEcolCalculation();

                SetupStartingPasturePools(StartingAmount);
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Method used to perform activity if it can occur as soon as resources are available.
 /// </summary>
 public override void PerformActivity()
 {
     // days provided from labour set in the only request ins the resourceResquestList
     // receive payment for labour
     bankType.Add(ResourceRequestList.FirstOrDefault().Available *DailyRate, this.Name, this.Name);
 }