private void OnCLEMEndOfTimeStep(object sender, EventArgs e) { // rotate harvest if needed if (HarvestData.Count() > 0 && Clock.Today.Year * 100 + Clock.Today.Month == HarvestData.First().Year * 100 + HarvestData.First().Month) { // don't rotate activities that may have just had their enabled status changed in this timestep if (this.ActivityEnabled & Status != ActivityStatus.Ignored) { parentManagementActivity.RotateCrop(); } } }
private void OnCLEMStartOfTimeStep(object sender, EventArgs e) { // get next harvest and store previous harvest while (HarvestData.Count() > 0 && Clock.Today.Year * 100 + Clock.Today.Month > HarvestData.First().Year * 100 + HarvestData.First().Month) { PreviousHarvest = HarvestData.FirstOrDefault(); HarvestData.RemoveAt(0); } NextHarvest = HarvestData.FirstOrDefault(); }
private void OnCLEMEndOfTimeStep(object sender, EventArgs e) { // rotate harvest if needed if ((this.ActivityEnabled & Status != ActivityStatus.Ignored) && HarvestData.Count() > 0 && Clock.Today.Year * 100 + Clock.Today.Month == HarvestData.First().Year * 100 + HarvestData.First().Month) { // don't rotate if no harvest tags or harvest type is not equal to "last" if (!HarvestTagsUsed || NextHarvest.HarvestType == "last") { // don't rotate activities that may have just had their enabled status changed in this timestep //if(this.ActivityEnabled & Status != ActivityStatus.Ignored) //{ parentManagementActivity.RotateCrop(); //} } } }
private void OnCLEMEndOfTimeStep(object sender, EventArgs e) { // rotate harvest if needed if (HarvestData.Count() > 0 && Clock.Today.Year * 100 + Clock.Today.Month == HarvestData.First().Year * 100 + HarvestData.First().Month) { if (this.ActivityEnabled) { parentManagementActivity.RotateCrop(); } } }
private void OnCLEMStartOfTimeStep(object sender, EventArgs e) { // if harvest tags provided for this crop then they will be used to define previous, next etc // while date month > harvest record look for previous and delete past events if (HarvestData.Count() > 0) { int clockYrMth = CalculateYearMonth(Clock.Today); int position; // passed -1, current 0, future 1 do { int harvestYrMth = CalculateYearMonth(HarvestData.First().HarvestDate); position = (clockYrMth > harvestYrMth) ? -1 : ((clockYrMth == harvestYrMth) ? 0 : 1); // check for valid sequence if (HarvestTagsUsed && HarvestData.FirstOrDefault().HarvestType != "") { if (previousTag == HarvestData.FirstOrDefault().HarvestType) { string warn = $"Invalid sequence of HarvetTags detected in [a={this.Name}]\r\nEnsure tags are ordered first, last in sequence."; if (!Warnings.Exists(warn)) { Summary.WriteWarning(this, warn); Warnings.Add(warn); } } previousTag = HarvestData.FirstOrDefault().HarvestType; } switch (position) { case -1: if (HarvestTagsUsed) { switch (HarvestData.FirstOrDefault().HarvestType) { case "first": if (!performedHarvest) { InsideMultiHarvestSequence = true; StartCurrentSequenceHarvest = HarvestData.FirstOrDefault(); EndCurrentSequenceHarvest = HarvestData.Where(a => a.HarvestType == "last").FirstOrDefault(); } break; case "last": // hit tagged last to delete as we've passed this date so out of multi harvest sequence InsideMultiHarvestSequence = false; PreviousHarvest = HarvestData.FirstOrDefault(); break; default: break; } } else { PreviousHarvest = HarvestData.FirstOrDefault(); } HarvestData.RemoveAt(0); break; case 0: performedHarvest = true; if (HarvestTagsUsed) { switch (HarvestData.FirstOrDefault().HarvestType) { case "first": // hit tagged first for current time step InsideMultiHarvestSequence = true; StartCurrentSequenceHarvest = HarvestData.FirstOrDefault(); PreviousHarvest = null; EndCurrentSequenceHarvest = HarvestData.Where(a => a.HarvestType == "last").FirstOrDefault(); break; default: NextHarvest = HarvestData.FirstOrDefault(); PreviousHarvest = null; break; } } else { NextHarvest = HarvestData.FirstOrDefault(); PreviousHarvest = null; } break; case 1: if (HarvestTagsUsed) { switch (HarvestData.FirstOrDefault().HarvestType) { case "first": // hit tagged first for next harvest NextHarvest = HarvestData.FirstOrDefault(); break; default: NextHarvest = HarvestData.FirstOrDefault(); break; } } else { NextHarvest = HarvestData.FirstOrDefault(); } break; default: break; } } while (HarvestData.Count > 0 && position == -1); } }