예제 #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="crop"></param>
 /// <returns></returns>
 public bool CanPlantCrop(VegObjectController crop)
 {
     // Here are a few notes to try and get your head around the logic here.
     // First of all check to see if we leave left sufficient gap between this new
     // rotation and the previous rotation of this crop.
     // Case 1:
     // First test to see if this is the CurrentCrop.
     // If so, then make sure that we HAVENT exceeded max rotation count. Then we must
     // see if actually meet the planting criteria. If any of these fail, then return
     // "false" so that we can test another crop. Otherwise return "true" to tell the
     // sim to replant the CurrentCrop
     // Case 2:
     // If this is NOT the CurrentCrop - we had better first check that the CurrentCrop
     // is still expected to be in rotation. Then check to see that the sowing criteria
     // has been met. Return "true" if all good, otherwise return "false" so we can test
     // another crop. If we run out of crops, then the CurrentCrop stays in fallow.
     if (crop.IsSequenceCorrect() && crop.DoesCropMeetSowingCriteria())
     {
         if (crop == CurrentCrop)
         {
             return(crop.IsCropUnderMaxContinuousRotations());
         }
         else if (CurrentCrop.HasCropHadSufficientContinuousRotations())
         {
             return(crop.HasCropBeenAbsentForSufficientYears(sim.today));
         }
     }
     return(false);
 }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="newcount"></param>
        public void SetCropCount(int newcount)
        {
            //int startcount;
            VegObjectController firstcrop = GetCrop(0);

            if (UseLAIModel())
            {
                if (firstcrop != null && firstcrop.GetType() == typeof(CoverVegObjectController))
                {
                    RemoveSomeCropObjects(0);
                }
                if (newcount > CropList.Count)
                {
                    AddSomeCropObjects(newcount);
                }
                else if (newcount < CropList.Count)
                {
                    RemoveSomeCropObjects(newcount);
                }
            }
            else
            {
                if (firstcrop != null && firstcrop.GetType() == typeof(LAIVegObjectController))
                {
                    RemoveSomeCropObjects(0);
                }
                AddSomeCropObjects(newcount);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool IsHarvestDayForCrop(int id)
        {
            VegObjectController CurrentCrop = Sim.VegetationController.CurrentCrop;

            if (CurrentCrop != null)
            {
                return(CurrentCrop.CropIndex == id && CurrentCrop.TodayIsPlantDay);
            }
            return(false);
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public bool IsHarvestDay()
        {
            VegObjectController CurrentCrop = Sim.VegetationController.CurrentCrop;

            if (CurrentCrop != null)
            {
                return(CurrentCrop.TodayIsPlantDay);
            }
            return(false);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="crop"></param>
 public void CheckApplicationBasedOnDAS(VegObjectController crop)
 {
     if (ApplicationIndex == 0 && crop.DaysSincePlanting >= InputModel.TriggerDaysFirst)
     {
         ProductRateApplied = InputModel.ProductRate;
         ++ApplicationIndex;
     }
     else if (ApplicationIndex > 0 && crop.DaysSincePlanting >= InputModel.TriggerDaysFirst + InputModel.TriggerDaysSubsequent * ApplicationIndex)
     {
         ProductRateApplied = InputModel.SubsequentProductRate;
         ++ApplicationIndex;
     }
 }
예제 #6
0
        /// <summary>
        ///
        /// </summary>
        void SortCurrentCropList()
        {
            int _crop_count = CropList.Count;

            SortedCropList.Clear();
            int startindex = GetCropIndex(CurrentCrop);

            for (int i = 0; i < _crop_count; ++i)
            {
                int index = startindex + i;
                index = (index < _crop_count ? index : index - _crop_count);
                VegObjectController crop = GetCrop(index);
                SortedCropList.Add(crop);
            }
        }
예제 #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="newcount"></param>
        public void AddSomeCropObjects(int newcount)
        {
            VegObjectController firstcrop = GetCrop(0);

            for (int i = CropList.Count; i < newcount; ++i)
            {
                if (UseLAIModel())
                {
                    CropList.Add(new LAIVegObjectController(sim));
                }
                else
                {
                    CropList.Add(new CoverVegObjectController(sim));
                }
            }
        }
예제 #8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="veg"></param>
 /// <returns></returns>
 public int GetCropIndex(VegObjectController veg)
 {
     return(CropList.IndexOf(veg));
 }
예제 #9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="veg"></param>
 /// <returns></returns>
 public int GetCropIndex(VegObjectController veg)
 {
     return(ChildControllers.IndexOf(veg));
 }