Ejemplo n.º 1
0
 /// <summary>
 ///
 /// </summary>
 public void CalculateTotalResidue()
 {
     //TODO: Make the crop residue function more generic -- remove type condition
     if (CurrentCrop != null && CurrentCrop.GetType() == typeof(LAIVegObjectController))
     {
         TotalCropResidue  = 0;
         TotalResidueCover = 0;
         LAIVegObjectController crop = (LAIVegObjectController)CurrentCrop;
         TotalResidueCover = crop.ResidueCover;
         crop.CalculateResidue();
         int count = ChildControllers.Count;
         for (int i = 1; i < count; ++i)
         {
             int index = GetCropIndex(crop) + 1;
             if (index == count)
             {
                 index = 0;
             }
             crop = (LAIVegObjectController)ChildControllers[index];
             TotalResidueCover = Math.Min(1.0, TotalResidueCover + crop.ResidueCover * (1 - TotalResidueCover));
         }
         for (int i = 0; i < count; ++i)
         {
             TotalCropResidue += ((VegObjectController)ChildControllers[i]).ResidueAmount;
         }
     }
     else
     {
         TotalCropResidue  = ((VegObjectController)ChildControllers[0]).CropResidue;
         TotalResidueCover = ((VegObjectController)ChildControllers[0]).ResidueCover;
     }
     TotalResidueCoverPercent = TotalResidueCover * 100.0;
 }