ALMaSS Skylark ODDox  1.1
The skylark model description following ODdox protocol
WinterWheat Class Reference

WinterWheat class
. More...

#include <WinterWheat.h>

Public Member Functions

virtual bool Do (Farm *a_farm, LE *a_field, FarmEvent *a_ev)
 The one and only method for a crop management plan. All farm actions go through here. More...
 
 WinterWheat ()
 
- Public Member Functions inherited from Crop
virtual ~Crop ()
 
 Crop ()
 
int GetFirstDate (void)
 
void ChooseNextCrop (int a_no_dates)
 Chooses the next crop to grow in a field. More...
 
int GetCropClassification ()
 
void SetCropClassification (int a_classification)
 

Additional Inherited Members

- Protected Member Functions inherited from Crop
void SimpleEvent (long a_date, int a_todo, bool a_lock)
 Adds an event to this crop management. More...
 
void SimpleEvent_ (long a_date, int a_todo, bool a_lock, Farm *a_farm, LE *a_field)
 Adds an event to this crop management without relying on member variables. More...
 
- Protected Attributes inherited from Crop
Farmm_farm
 
LE * m_field
 
FarmEventm_ev
 
int m_first_date
 
int m_count
 
int m_last_date
 
int m_ddegstoharvest
 
int m_CropClassification
 

Detailed Description

WinterWheat class
.

See WinterWheat.h::WinterWheatToDo for a complete list of all possible events triggered codes by the winter wheat management plan. When triggered these events are handled by Farm and are available as information for other objects such as animal and bird models.

Constructor & Destructor Documentation

◆ WinterWheat()

WinterWheat::WinterWheat ( )
inline
121  {
122  // When we start it off, the first possible date for a farm operation is 1st October
123  // This information is used by other crops when they decide how much post processing of
124  // the management is allowed after harvest before the next crop starts.
125  m_first_date=g_date->DayInYear( 1,10 );
126  }

References Crop::m_first_date.

Member Function Documentation

◆ Do()

bool WinterWheat::Do ( Farm a_farm,
LE *  a_field,
FarmEvent a_ev 
)
virtual

The one and only method for a crop management plan. All farm actions go through here.

Called every time something is done to the crop by the farmer in the first instance it is always called with a_ev->todo set to start, but susequently will be called whenever the farmer wants to carry out a new operation.
This method details all the management and relationships between operations necessary to grow and ALMaSS crop - in this case conventional winter wheat.

Inputs to a farm mangement event call.

bool forcing a_eve->m_lock bool probability (if forcing lock is false) Farm management to try (function address) Event type Finish date Flags to set on success Flage value to set Next event Start date for next evemt

Reimplemented from Crop.

102 {
103  m_field = a_field; // this is needed because of possible calls to other methods and currently we do not pass parameters.
104  m_farm = a_farm; // this is needed because of possible calls to other methods and currently we do not pass parameters.
105  bool done = false; // The boolean value done indicates when we are totally finished with this plan (i.e. it is set to true).
106 
107  // Depending what event has occured jump to the correct bit of code e.g. for ww_start jump to line 67 below
108  switch (a_ev->m_todo)
109  {
110  case ww_start:
111  {
112  // This is just to hold a local variable in scope and prevent compiler errors
113  // ww_start just sets up all the starting conditions and reference dates that are needed to start a ww
114  // crop off
115  WW_AUTUMN_PLOUGH = false;
116  WW_DECIDE_TO_HERB = 1;
117  WW_DECIDE_TO_FI = 1;
118  // Record whether skylark scrapes are present and adjust flag accordingly
119  if (cfg_WinterWheat_SkScrapes.value()) {
120  a_field->m_skylarkscrapes = true;
121  }
122  else {
123  a_field->m_skylarkscrapes = false;
124  }
125  // Set up the date management stuff
126  // The next bit of code just allows for altering dates after harvest if it is necessary
127  // to allow for a crop which starts its management early.
128 
129  // 5 start and stop dates for all events after harvest for this crop
130  int noDates = 5;
131  a_field->SetMDates(0, 0, g_date->DayInYear(20, 8));
132  // Determined by harvest date - used to see if at all possible
133  a_field->SetMDates(1, 0, g_date->DayInYear(20, 8));
134  a_field->SetMDates(0, 1, 0); // HayTurning start
135  a_field->SetMDates(1, 1, g_date->DayInYear(20, 8));
136  a_field->SetMDates(0, 2, g_date->DayInYear(5, 8));
137  a_field->SetMDates(1, 2, g_date->DayInYear(20, 8)); //was 25, 8
138  a_field->SetMDates(0, 3, g_date->DayInYear(10, 8));
139  a_field->SetMDates(1, 3, g_date->DayInYear(20, 8)); //was 15,9
140  a_field->SetMDates(0, 4, g_date->DayInYear(15, 8));
141  a_field->SetMDates(1, 4, g_date->DayInYear(20, 8)); //was 15, 10
142  // Can be up to 10 of these. If the shortening code is triggered
143  // then these will be reduced in value to 0
144 
145  a_field->SetMConstants(0, 1);
146 
147  // Check the next crop for early start, unless it is a spring crop
148  // in which case we ASSUME that no checking is necessary!!!!
149  // So DO NOT implement a crop that runs over the year boundary (i.e. from spring to spring!), at least not without fixing this.
150 
151  //new if: do the check only for non-optimising farms and if year>0. (030713 - m_rotation used only in the hidden year, so I modified the condition from >7 to >0)
152  int d1;
153  if (!(a_farm->GetType() == tof_OptimisingFarm && g_date->GetYearNumber() > 0)) {
154 
155  if (a_ev->m_startday > g_date->DayInYear(1, 7)) {
156  if (a_field->GetMDates(0, 0) >= a_ev->m_startday)
157  {
158  g_msg->Warn(WARN_BUG, "WinterWheat::Do(): ", "Harvest too late for the next crop to start!!!");
159  int almassnum = g_landscape_p->BackTranslateVegTypes(a_ev->m_next_tov);
160  g_msg->Warn("Next Crop ", (double)almassnum); // this causes exit
161  }
162  // Now fix any late finishing problems
163  for (int i = 0; i < noDates; i++) {
164  if (a_field->GetMDates(0, i) >= a_ev->m_startday) {
165  a_field->SetMDates(0, i, a_ev->m_startday - 1); //move the starting date
166  }
167  if (a_field->GetMDates(1, i) >= a_ev->m_startday) {
168  a_field->SetMConstants(i, 0); //change the default value of the MConst (=1) to 0 (necessary to correctly execute farm events in case the finishing date (MDate) was moved)
169  a_field->SetMDates(1, i, a_ev->m_startday - 1); //move the finishing date
170  }
171  }
172  }
173  // Now no operations can be timed after the start of the next crop.
174 
175  if (!a_ev->m_first_year) {
176  // Are we before July 1st?
177  d1 = g_date->OldDays() + g_date->DayInYear(1, 7);
178  if (g_date->Date() < d1) {
179  // Yes, too early. We assumme this is because the last crop was late
180  printf("Poly: %d\n", a_field->GetPoly());
181  g_msg->Warn(WARN_BUG, "WinterWheat::Do(): ", "Crop start attempt between 1st Jan & 1st July");
182  int prev = g_landscape_p->BackTranslateVegTypes(a_field->GetOwner()->GetPreviousCrop(a_field->GetRotIndex()));
183  g_msg->Warn(WARN_BUG, "Previous Crop ", prev);
184  int almassnum = g_landscape_p->BackTranslateVegTypes(a_ev->m_next_tov);
185  g_msg->Warn("Next Crop ", (double)almassnum); // this causes exit
186  }
187  else {
188  d1 = g_date->OldDays() + m_first_date; // Add 365 for spring crop
189  if (g_date->Date() > d1) {
190  // Yes too late - should not happen - raise an error
191  g_msg->Warn(WARN_BUG, "WinterWheat::Do(): ", "Crop start attempt after last possible start date");
192  g_msg->Warn(WARN_BUG, "Previous Crop ", "");
193  a_field->GetOwner()->GetPreviousCrop(a_field->GetRotIndex());
194  int almassnum = g_landscape_p->BackTranslateVegTypes(a_ev->m_next_tov);
195  g_msg->Warn("Next Crop ", (double)almassnum); // this causes exit
196  }
197  }
198  }
199  else {
200  // Is the first year
201  // Some special code to cope with that first start-up year in ALMaSS - ignore for all practical purposes
202  SimpleEvent(g_date->OldDays() + g_date->DayInYear(1, 4), ww_spring_roll, false);
203  break;
204  }
205  }//if
206 
207  // End single block date checking code. Please see next line comment as well.
208  // Reinit d1 to first possible starting date.
209  d1 = g_date->OldDays() + g_date->DayInYear(21, 8);
210  // OK, let's go.
211  // Here we queue up the first event - this differs depending on whether we have a
212  // stock or arable farmer
213  if (a_farm->IsStockFarmer()) { // StockFarmer
214  SimpleEvent(d1, ww_ferti_s1, false);
215  }
216  else SimpleEvent(d1, ww_ferti_p1, false);
217  }
218  break;
219  // This is the first real farm operation
220  case ww_ferti_p1:
221  // Unless we are forced to do this (probably because we tried once and failed due to bad weather)
222  // then 10% of all threads that reach here will attempt to do ww_feri_p1
223  if (a_ev->m_lock || a_farm->DoIt(10))
224  {
225  // Calls the FP_Slurry application with the number of days after 1,10 as a parameter
226  // the FP_Slurry routine will attempt to apply slurry on a probabilistic basis up to 1,10 when
227  // the operation will be forced
228  // Many other constraints can be added to the FP_Slurry, e.g. temperature might have to be >0 degrees C
229  // Other operations need low wind speed (e.g. spraying insecticide). These differ for each operation
230  if (!a_farm->FP_Slurry(a_field, 0.0, g_date->DayInYear(1, 10) - g_date->DayInYear())) {
231  // If we don't suceed on the first try, then try and try again (until 1/10 when we will suceed)
232  SimpleEvent(g_date->Date() + 1, ww_ferti_p1, true);
233  break;
234  }
235  }
236  // Queue up the next event -in this case autumn ploughing
237  SimpleEvent(g_date->Date(), ww_autumn_plough, false);
238  break;
239  case ww_ferti_s1:
240  if (!a_farm->FA_Slurry(a_field, 0.0, g_date->DayInYear(1, 10) - g_date->DayInYear())) {
241  SimpleEvent(g_date->Date() + 1, ww_ferti_s1, true);
242  break;
243  }
244  // This may cause two applications of fertilizer in one day...which is OK because one is Slurry and one Manure
245  SimpleEvent(g_date->Date(), ww_ferti_s2, false);
246  break;
247  case ww_ferti_s2:
248  if (a_ev->m_lock || a_farm->DoIt(10))
249  {
250  if (!a_farm->FA_Manure(a_field, 0.0,
251  g_date->DayInYear(1, 10) - g_date->DayInYear())) {
252  SimpleEvent(g_date->Date() + 1, ww_ferti_s2, true);
253  break;
254  }
255  }
256  SimpleEvent(g_date->Date(), ww_autumn_plough, false);
257  break;
258  case ww_autumn_plough:
272  // Almost all will autumn plough, but a few will get away with non-inversion
273  if (a_ev->m_lock || a_farm->DoIt(95))
274  {
275  if (!a_farm->AutumnPlough(a_field, 0.0, g_date->DayInYear(1, 10) - g_date->DayInYear())) {
276  SimpleEvent(g_date->Date() + 1, ww_autumn_plough, true);
277  break;
278  }
279  else
280  {
281  // 95% of farmers will do this, but the other 5% won't so we need to remember whether
282  // we are in one or the other group
283  WW_AUTUMN_PLOUGH = true;
284  // Queue up the next event
285  SimpleEvent(g_date->Date() + 1, ww_autumn_harrow, false);
286  break;
287  }
288  }
289  SimpleEvent(g_date->Date() + 1, ww_stubble_harrow1, false);
290  break;
291  case ww_autumn_harrow:
292  if (!a_farm->AutumnHarrow(a_field, 0.0,
293  g_date->DayInYear(10, 10) - g_date->DayInYear())) {
294  SimpleEvent(g_date->Date() + 1, ww_autumn_harrow, true);
295  break;
296  }
297  SimpleEvent(g_date->OldDays() + g_date->DayInYear(10, 9),
298  ww_autumn_sow, false);
299  break;
300  case ww_stubble_harrow1:
301  if (!a_farm->StubbleHarrowing(a_field, 0.0, g_date->DayInYear(10, 10) - g_date->DayInYear())) {
302  SimpleEvent(g_date->Date() + 1, ww_stubble_harrow1, true);
303  break;
304  }
305  SimpleEvent(g_date->OldDays() + g_date->DayInYear(10, 9),
306  ww_autumn_sow, false);
307  break;
308  case ww_autumn_sow:
309  if (!a_farm->AutumnSow(a_field, 0.0,
310  g_date->DayInYear(20, 10) - g_date->DayInYear())) {
311  SimpleEvent(g_date->Date() + 1, ww_autumn_sow, true);
312  break;
313  }
314  SimpleEvent(g_date->Date() + 1, ww_autumn_roll, false);
315  break;
316  case ww_autumn_roll:
317  // If they did plough, then 5% will also do an autumn rolling
318  if ((a_ev->m_lock || a_farm->DoIt(5)) && (WW_AUTUMN_PLOUGH))
319  {
320  if (!a_farm->AutumnRoll(a_field, 0.0,
321  g_date->DayInYear(27, 10) - g_date->DayInYear())) {
322  SimpleEvent(g_date->Date() + 1, ww_autumn_roll, true);
323  break;
324  }
325  }
326  SimpleEvent(g_date->OldDays() + g_date->DayInYear(15, 9),
327  ww_ferti_p2, false);
328  break;
329  // Plant farmers start here.
330  case ww_ferti_p2:
331  if ((a_ev->m_lock || a_farm->DoIt(20)) && (!a_farm->IsStockFarmer()))
332  {
333  if (a_field->GetVegBiomass() > 0)
334  //only apply this when there has been a bit of growth
335  {
336  if (!a_farm->FP_ManganeseSulphate(a_field, 0.0,
337  g_date->DayInYear(30, 10) - g_date->DayInYear()))
338  {
339  SimpleEvent(g_date->Date() + 1, ww_ferti_p2, true);
340  break;
341  }
342  }
343  }
344  SimpleEvent(g_date->OldDays() + g_date->DayInYear(20, 9),
345  ww_herbicide1, false);
346  break;
347  case ww_herbicide1: // The first of the pesticide managements. NB these are externally scalable
348  if (a_ev->m_lock || a_farm->DoIt((int)(80 * cfg_herbi_app_prop.value() * a_farm->Prob_multiplier()))) //modified probability
349  {
350  //new - for decision making
351  TTypesOfVegetation tov = a_field->GetVegType();
352  if (!a_ev->m_lock && !a_farm->Spraying_herbicides(tov)) {
353  Field * pf = dynamic_cast<Field*>(a_field);
354  pf->Add_missed_herb_app();
355  if (a_farm->DoIt(69)) pf->Add_missed_herb_app(); //the 2nd missed application
356  WW_DECIDE_TO_HERB = 0;
357  } //end of the part for dec. making
358  else {
359  if (!a_farm->HerbicideTreat(a_field, 0.0, g_date->DayInYear(5, 10) - g_date->DayInYear())) {
360  SimpleEvent(g_date->Date() + 1, ww_herbicide1, true);
361  break;
362  }
363  }
364  }
365  SimpleEvent(g_date->OldDays() + g_date->DayInYear(1, 4) + 365,
366  ww_spring_roll, false);
367  break;
368  case ww_spring_roll:
369  if (a_ev->m_lock || a_farm->DoIt(5))
370  {
371  if (!a_farm->SpringRoll(a_field, 0.0,
372  g_date->DayInYear(30, 4) - g_date->DayInYear())) {
373  SimpleEvent(g_date->Date() + 1, ww_spring_roll, true);
374  break;
375  }
376  }
377  // Here we split the main thread in to depending on what fertilizer the farmer will use
378  // these rejoin other later on.
379  if (a_farm->IsStockFarmer()) // StockFarmer
380  {
381  SimpleEvent(g_date->Date() + 1, ww_ferti_s3, false);
382  SimpleEvent(g_date->OldDays() + g_date->DayInYear(10, 4), ww_ferti_s4, false);
383  }
384  else SimpleEvent(g_date->OldDays() + g_date->DayInYear(25, 3), ww_ferti_p3, false);
385  // Here we see an example of setting up parallel threads
386  // None of these are the main thread which will lead to the termination of the plan - they
387  // just run along until they peter out e.g. ww_herbicide2
388  // All paths through the plan need the next threads
389  SimpleEvent(g_date->OldDays() + g_date->DayInYear(15, 4),
390  ww_herbicide2, false);
391  SimpleEvent(g_date->OldDays() + g_date->DayInYear(25, 4),
392  ww_GR, false);
393  SimpleEvent(g_date->OldDays() + g_date->DayInYear(20, 4),
394  ww_fungicide, false);
395  SimpleEvent(g_date->OldDays() + g_date->DayInYear(cfg_WW_InsecticideDay.value(), cfg_WW_InsecticideMonth.value()),
396  ww_insecticide1, false);
397  SimpleEvent(g_date->OldDays() + g_date->DayInYear(10, 4),
398  ww_strigling1, false);
399  SimpleEvent(g_date->OldDays() + g_date->DayInYear(1, 5),
400  ww_water1, false);
401  break;
402  case ww_herbicide2:
403  if (a_ev->m_lock || a_farm->DoIt((int)((int)(69 * cfg_herbi_app_prop.value()*WW_DECIDE_TO_HERB * a_farm->Prob_multiplier())))) // was 40 //modified probability
404  {
405  if (!a_farm->HerbicideTreat(a_field, 0.0,
406  g_date->DayInYear(30, 4) - g_date->DayInYear())) {
407  SimpleEvent(g_date->Date() + 1, ww_herbicide2, true);
408  break;
409  }
410  }
411  // End of thread
412  break;
413  case ww_GR:
414  if (a_ev->m_lock || a_farm->DoIt((int)(15 * cfg_greg_app_prop.value())))
415  {
416  if (!a_farm->GrowthRegulator(a_field, 0.0,
417  g_date->DayInYear(10, 5) - g_date->DayInYear())) {
418  SimpleEvent(g_date->Date() + 1, ww_GR, true);
419  break;
420  }
421  }
422  // End of thread
423  break;
424  case ww_fungicide:
425  if (a_ev->m_lock || a_farm->DoIt((int)(55 * cfg_fungi_app_prop1.value() * a_farm->Prob_multiplier()))) //modified probability
426  {
427  //new - for decision making
428  TTypesOfVegetation tov = a_field->GetVegType();
429  if (!a_ev->m_lock && !a_farm->Spraying_fungins(tov)) {
430  Field * pf = dynamic_cast<Field*>(a_field);
431  pf->Add_missed_fi_app();
432  if (a_farm->DoIt(35)) pf->Add_missed_fi_app(); //the 2nd missed application
433  WW_DECIDE_TO_FI = 0;
434  } //end of the part for dec. making
435  else {
436  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(10, 5) - g_date->DayInYear())) {
437  SimpleEvent(g_date->Date() + 1, ww_fungicide, true);
438  break;
439  }
440  }
441  }
442  SimpleEvent(g_date->OldDays() + g_date->DayInYear(20, 5), ww_fungicide2, false);
443  break;
444  case ww_fungicide2:
445  if (a_ev->m_lock || a_farm->DoIt((int)(55 * cfg_fungi_app_prop2.value() * a_farm->Prob_multiplier()))) //modified probability
446  {
447  //new - for decision making
448  TTypesOfVegetation tov = a_field->GetVegType();
449  if (!a_ev->m_lock && !a_farm->Spraying_fungins(tov)) {
450  Field * pf = dynamic_cast<Field*>(a_field);
451  pf->Add_missed_fi_app();
452  if (a_farm->DoIt(35)) pf->Add_missed_fi_app(); //the 2nd missed application
453  WW_DECIDE_TO_FI = 0;
454  } //end of the part for dec. making
455  else {
456  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(10, 6) - g_date->DayInYear())) {
457  SimpleEvent(g_date->Date() + 1, ww_fungicide2, true);
458  break;
459  }
460  }
461  }
462  // End of thread
463  break;
464  case ww_insecticide1:
465  if (a_ev->m_lock || a_farm->DoIt((int)(50 * cfg_ins_app_prop1.value() * a_farm->Prob_multiplier()))) //changed from 16, 22.03.13 //modified probability
466  {
467  //new - for decision making
468  TTypesOfVegetation tov = a_field->GetVegType();
469  if (!a_ev->m_lock && !a_farm->Spraying_fungins(tov)) {
470  Field * pf = dynamic_cast<Field*>(a_field);
471  pf->Add_missed_fi_app();
472  if (a_farm->DoIt(8)) pf->Add_missed_fi_app(); //the 2nd missed application
473  if (a_farm->DoIt(14)) pf->Add_missed_fi_app(); //the 3rd missed application
474  WW_DECIDE_TO_FI = 0;
475  } //end of the part for dec. making
476  else {
477  // Here we check wheter we are using ERA pesticde or not
478  if (!cfg_pest_winterwheat_on.value() || !g_landscape_p->SupplyShouldSpray()) // Not using pesticide spray
479  {
480  if (!a_farm->InsecticideTreat(a_field, 0.0, g_date->DayInYear(15, 5) - g_date->DayInYear())) {
481  SimpleEvent(g_date->Date() + 1, ww_insecticide1, true);
482  break;
483  }
484  }
485  else
486  {
487  a_farm->ProductApplication(a_field, 0.0, 0, cfg_pest_product_1_amount.value(),ppp_1);
488  }
489  }
490  SimpleEvent(g_date->OldDays() + g_date->DayInYear(1, 6), ww_insecticide2, false);
491  break;
492  }
493  break; // End thread
494  case ww_insecticide2:
495  if (a_ev->m_lock || a_farm->DoIt((int)(50 * cfg_ins_app_prop2.value() *WW_DECIDE_TO_FI * a_farm->Prob_multiplier()))) //modified probability
496  {
498  {
499  if (!a_farm->InsecticideTreat(a_field, 0.0, g_date->DayInYear(10, 6) - g_date->DayInYear()))
500  {
501  SimpleEvent(g_date->Date() + 1, ww_insecticide2, true);
502  break;
503  }
504  }
505  else
506  {
507  a_farm->ProductApplication(a_field, 0.0, 0, cfg_pest_product_1_amount.value(), ppp_1);
508  }
509  if ((g_date->Date() + 7) < (g_date->OldDays() + g_date->DayInYear(15, 6)))
510  SimpleEvent(g_date->OldDays() + g_date->DayInYear(15, 6), ww_insecticide3, false);
511  else SimpleEvent(g_date->Date() + 7, ww_insecticide3, false);
512  break;
513  }
514  break;
515  case ww_insecticide3:
516  if (a_ev->m_lock || a_farm->DoIt((int)(50 * cfg_ins_app_prop3.value() *WW_DECIDE_TO_FI * a_farm->Prob_multiplier()))) //modified probability
517  {
519  if (!a_farm->InsecticideTreat(a_field, 0.0, g_date->DayInYear(30, 6) - g_date->DayInYear())) {
520  SimpleEvent(g_date->Date() + 1, ww_insecticide3, true);
521  break;
522  }
523  }
524  else {
525  a_farm->ProductApplication(a_field, 0.0, 0, cfg_pest_product_1_amount.value(), ppp_1);
526  }
527  }
528  // End of thread
529  break;
530  case ww_strigling1:
531  if (a_ev->m_lock || a_farm->DoIt(5))
532  {
533  if (!a_farm->Strigling(a_field, 0.0,
534  g_date->DayInYear(25, 4) - g_date->DayInYear())) {
535  SimpleEvent(g_date->Date() + 1, ww_strigling1, true);
536  break;
537  }
538  else {
539  if ((g_date->Date() + 7) < (g_date->OldDays() + g_date->DayInYear(15, 6)))
540  SimpleEvent(g_date->OldDays() + g_date->DayInYear(25, 4),
541  ww_strigling2, false);
542  else SimpleEvent(g_date->Date() + 7, ww_strigling2, false);
543  }
544  }
545  break;
546  case ww_strigling2:
547  if (!a_farm->Strigling(a_field, 0.0, g_date->DayInYear(5, 5) - g_date->DayInYear())) {
548  SimpleEvent(g_date->Date() + 1, ww_strigling2, true);
549  break;
550  }
551  // End of thread
552  break;
553  case ww_water1:
554  if (a_ev->m_lock || a_farm->DoIt(10)) // **CJT** Soil type 1-4 only
555  {
556  if (!a_farm->Water(a_field, 0.0, g_date->DayInYear(15, 5) - g_date->DayInYear())) {
557  SimpleEvent(g_date->Date() + 1, ww_water1, true);
558  break;
559  }
560  else
561  if ((g_date->Date() + 5) < (g_date->OldDays() + g_date->DayInYear(2, 5)))
562  SimpleEvent(g_date->OldDays() + g_date->DayInYear(2, 5), ww_water2, false);
563  else SimpleEvent(g_date->Date() + 5, ww_water2, false);
564  }
565  break;
566  case ww_water2:
567  if (!a_farm->Water(a_field, 0.0, g_date->DayInYear(1, 6) - g_date->DayInYear())) {
568  SimpleEvent(g_date->Date() + 1, ww_water2, true);
569  break;
570  }
571  // End of thread
572  break;
573  case ww_ferti_p3:
574  if (!a_farm->FP_NPK(a_field, 0.0, g_date->DayInYear(15, 4) - g_date->DayInYear())) {
575  SimpleEvent(g_date->Date() + 1, ww_ferti_p3, true);
576  break;
577  }
578 
579  SimpleEvent(g_date->OldDays() + g_date->DayInYear(25, 4), ww_ferti_p4, false);
580  SimpleEvent(g_date->OldDays() + g_date->DayInYear(1, 4), ww_ferti_p5, false);
581  break;
582  case ww_ferti_p4:
583  if (a_ev->m_lock || a_farm->DoIt(50))
584  {
585  if (!a_farm->FP_NPK(a_field, 0.0, g_date->DayInYear(15, 5) - g_date->DayInYear())) {
586  SimpleEvent(g_date->Date() + 1, ww_ferti_p4, true);
587  break;
588  }
589  }
590  // The Main thread
591  // The Main thread - this will leads to harvest, whilst all the others stop before this point
592  // This thread is only for arable farmers whereas you'll see below the other forks for stock farmers
593 
594  ChooseNextCrop(5);
595 
596  SimpleEvent(g_date->OldDays() + g_date->DayInYear(5, 8), ww_harvest, false);
597  break;
598  case ww_ferti_p5:
599  if (a_ev->m_lock || a_farm->DoIt(20))
600  {
601  if (!a_farm->FP_ManganeseSulphate(a_field, 0.0, g_date->DayInYear(5, 5) - g_date->DayInYear())) {
602  SimpleEvent(g_date->Date() + 1, ww_ferti_p5, true);
603  break;
604  }
605  }
606  break;
607  case ww_ferti_s3:
608  if (!a_farm->FA_Slurry(a_field, 0.0, g_date->DayInYear(30, 4) - g_date->DayInYear())) {
609  SimpleEvent(g_date->Date() + 1, ww_ferti_s3, true);
610  break;
611  }
612  // The Main thread - this will leads to harvest, whilst all the others stop before this point
613 
614  ChooseNextCrop(5);
615 
616  SimpleEvent(g_date->OldDays() + g_date->DayInYear(5, 8), ww_harvest, false);
617  break;
618  case ww_ferti_s4:
619  if (a_ev->m_lock || a_farm->DoIt(75))
620  {
621  if (!a_farm->FA_NPK(a_field, 0.0, g_date->DayInYear(20, 4) - g_date->DayInYear())) {
622  SimpleEvent(g_date->Date() + 1, ww_ferti_s4, true);
623  break;
624  }
625  SimpleEvent(g_date->OldDays() + g_date->DayInYear(21, 4), ww_ferti_s5, false);
626  }
627  break;
628  case ww_ferti_s5:
629  if (a_ev->m_lock || a_farm->DoIt(40))
630  {
631  if (!a_farm->FA_NPK(a_field, 0.0, g_date->DayInYear(1, 5) - g_date->DayInYear())) {
632  SimpleEvent(g_date->Date() + 1, ww_ferti_s5, true);
633  break;
634  }
635  }
636  break;
637  case ww_harvest:
638  if (!a_farm->Harvest(a_field, 0.0, g_date->DayInYear(20, 8) - g_date->DayInYear()))
639  {
640  SimpleEvent(g_date->Date() + 1, ww_harvest, true);
641  break;
642  }
643  SimpleEvent(g_date->Date(), ww_straw_chopping, false);
644  break;
645  case ww_straw_chopping:
646  if (a_ev->m_lock || a_farm->DoIt(75))
647  {
648  if (a_field->GetMConstants(0) == 0) {
649  if (!a_farm->StrawChopping(a_field, 0.0, -1)) { //raise an error
650  g_msg->Warn(WARN_BUG, "WinterWheat::Do(): failure in 'StrawChopping' execution", "");
651  exit(1);
652  }
653  }
654  else {
655  if (!a_farm->StrawChopping(a_field, 0.0, a_field->GetMDates(1, 0) - g_date->DayInYear())) {
656  SimpleEvent(g_date->Date() + 1, ww_straw_chopping, true);
657  break;
658  }
659  else {
660  SimpleEvent(g_date->Date() + a_field->GetMConstants(0), ww_stubble_harrow2, false); //is this ok?
661  }
662  }
663  }
664  else {
665  SimpleEvent(g_date->Date() + a_field->GetMConstants(0), ww_hay_turning, false);
666  }
667  break;
668  case ww_hay_turning:
669  if (a_ev->m_lock || a_farm->DoIt(5))
670  {
671  if (a_field->GetMConstants(1) == 0) {
672  if (!a_farm->HayTurning(a_field, 0.0, -1)) { //raise an error
673  g_msg->Warn(WARN_BUG, "WinterWheat::Do(): failure in 'HayTurning' execution", "");
674  exit(1);
675  }
676  }
677  else {
678  if (!a_farm->HayTurning(a_field, 0.0, a_field->GetMDates(1, 1) - g_date->DayInYear())) {
679  SimpleEvent(g_date->Date() + 1, ww_hay_turning, true);
680  break;
681  }
682  }
683  }
684  SimpleEvent(g_date->OldDays() + a_field->GetMDates(0, 2), ww_hay_baling, false);
685  break;
686  case ww_hay_baling:
687  if (a_field->GetMConstants(2) == 0) {
688  if (!a_farm->HayBailing(a_field, 0.0, -1)) { //raise an error
689  g_msg->Warn(WARN_BUG, "WinterWheat::Do(): failure in 'HayBailing' execution", "");
690  exit(1);
691  }
692  }
693  else {
694  if (!a_farm->HayBailing(a_field, 0.0, a_field->GetMDates(1, 2) - g_date->DayInYear())) {
695  SimpleEvent(g_date->Date() + 1, ww_hay_baling, true);
696  break;
697  }
698  }
699  SimpleEvent(g_date->OldDays() + a_field->GetMDates(0, 3), ww_stubble_harrow2, false);
700  break;
701  case ww_stubble_harrow2:
702  if (a_ev->m_lock || a_farm->DoIt(65))
703  {
704  if (a_field->GetMConstants(3) == 0) {
705  if (!a_farm->StubbleHarrowing(a_field, 0.0, -1)) { //raise an error
706  g_msg->Warn(WARN_BUG, "WinterWheat::Do(): failure in 'StubbleHarrowing' execution", "");
707  exit(1);
708  }
709  }
710  else {
711  if (!a_farm->StubbleHarrowing(a_field, 0.0, a_field->GetMDates(1, 3) - g_date->DayInYear())) {
712  SimpleEvent(g_date->Date() + 1, ww_stubble_harrow2, true);
713  break;
714  }
715  }
716  }
717  SimpleEvent(g_date->OldDays() + a_field->GetMDates(0, 4), ww_grubning, false);
718  break;
719  case ww_grubning:
720  if (a_ev->m_lock || a_farm->DoIt(10)) {
721  if (a_field->GetMConstants(4) == 0) {
722  if (!a_farm->DeepPlough(a_field, 0.0, -1)) { //raise an error //IS THIS OK - PLOUGH?
723  g_msg->Warn(WARN_BUG, "WinterWheat::Do(): failure in 'DeepPlough' execution", "");
724  exit(1);
725  }
726  }
727  else {
728  if (!a_farm->DeepPlough(a_field, 0.0, a_field->GetMDates(1, 4) - g_date->DayInYear())) {
729  SimpleEvent(g_date->Date() + 1, ww_grubning, true);
730  break;
731  }
732  }
733  }
734  done = true;
735  // So we are done, and somewhere else the farmer will queue up the start event of the next crop
736  // END OF MAIN THREAD
737  break;
738  default:
739  g_msg->Warn(WARN_BUG, "WinterWheat::Do(): "
740  "Unknown event type! ", "");
741  exit(1);
742  }
743  return done;
744 }

References Farm::AutumnHarrow(), Farm::AutumnPlough(), Farm::AutumnRoll(), Farm::AutumnSow(), Landscape::BackTranslateVegTypes(), cfg_fungi_app_prop1, cfg_fungi_app_prop2, cfg_greg_app_prop, cfg_herbi_app_prop, cfg_ins_app_prop1, cfg_ins_app_prop2, cfg_ins_app_prop3, cfg_pest_product_1_amount, cfg_pest_winterwheat_on, cfg_WinterWheat_SkScrapes(), cfg_WW_InsecticideDay, cfg_WW_InsecticideMonth, Crop::ChooseNextCrop(), Farm::DeepPlough(), Farm::DoIt(), Farm::FA_Manure(), Farm::FA_NPK(), Farm::FA_Slurry(), Farm::FP_ManganeseSulphate(), Farm::FP_NPK(), Farm::FP_Slurry(), Farm::FungicideTreat(), g_landscape_p, Farm::GetType(), Farm::GrowthRegulator(), Farm::Harvest(), Farm::HayBailing(), Farm::HayTurning(), Farm::HerbicideTreat(), Farm::InsecticideTreat(), Farm::IsStockFarmer(), Crop::m_farm, Crop::m_field, Crop::m_first_date, FarmEvent::m_first_year, FarmEvent::m_lock, FarmEvent::m_next_tov, FarmEvent::m_startday, FarmEvent::m_todo, ppp_1, Farm::Prob_multiplier(), Farm::ProductApplication(), Crop::SimpleEvent(), Farm::Spraying_fungins(), Farm::Spraying_herbicides(), Farm::SpringRoll(), Farm::StrawChopping(), Farm::Strigling(), Farm::StubbleHarrowing(), Landscape::SupplyShouldSpray(), tof_OptimisingFarm, Farm::Water(), ww_autumn_harrow, WW_AUTUMN_PLOUGH, ww_autumn_plough, ww_autumn_roll, ww_autumn_sow, WW_DECIDE_TO_FI, WW_DECIDE_TO_HERB, ww_ferti_p1, ww_ferti_p2, ww_ferti_p3, ww_ferti_p4, ww_ferti_p5, ww_ferti_s1, ww_ferti_s2, ww_ferti_s3, ww_ferti_s4, ww_ferti_s5, ww_fungicide, ww_fungicide2, ww_GR, ww_grubning, ww_harvest, ww_hay_baling, ww_hay_turning, ww_herbicide1, ww_herbicide2, ww_insecticide1, ww_insecticide2, ww_insecticide3, ww_spring_roll, ww_start, ww_straw_chopping, ww_strigling1, ww_strigling2, ww_stubble_harrow1, ww_stubble_harrow2, ww_water1, and ww_water2.


The documentation for this class was generated from the following files:
cfg_pest_product_1_amount
CfgFloat cfg_pest_product_1_amount
ww_hay_baling
Definition: WinterWheat.h:102
Farm::SpringRoll
virtual bool SpringRoll(LE *a_field, double a_user, int a_days)
Carry out a roll event in the spring on a_field.
Definition: farmfuncs.cpp:525
Farm::FA_Slurry
virtual bool FA_Slurry(LE *a_field, double a_user, int a_days)
Spready slurry on a_field owned by an stock farmer.
Definition: farmfuncs.cpp:965
WW_DECIDE_TO_FI
#define WW_DECIDE_TO_FI
Definition: WinterWheat.h:60
Farm::HerbicideTreat
virtual bool HerbicideTreat(LE *a_field, double a_user, int a_days)
Apply herbicide to a_field.
Definition: farmfuncs.cpp:1156
Farm::IsStockFarmer
bool IsStockFarmer(void)
Definition: farm.h:905
ww_ferti_p1
Definition: WinterWheat.h:71
Farm::Strigling
virtual bool Strigling(LE *a_field, double a_user, int a_days)
Carry out a mechanical weeding on a_field.
Definition: farmfuncs.cpp:1545
ww_start
Definition: WinterWheat.h:69
Farm::Harvest
virtual bool Harvest(LE *a_field, double a_user, int a_days)
Carry out a harvest on a_field.
Definition: farmfuncs.cpp:1769
FarmEvent::m_lock
bool m_lock
Definition: farm.h:465
Farm::FP_ManganeseSulphate
virtual bool FP_ManganeseSulphate(LE *a_field, double a_user, int a_days)
Apply Manganse Sulphate to a_field owned by an arable farmer.
Definition: farmfuncs.cpp:727
Farm::ProductApplication
virtual bool ProductApplication(LE *a_field, double a_user, int a_days, double a_applicationrate, PlantProtectionProducts a_ppp)
Apply test pesticide to a_field.
Definition: farmfuncs.cpp:1445
Landscape::SupplyShouldSpray
bool SupplyShouldSpray()
Definition: Landscape.h:357
Farm::FP_NPK
virtual bool FP_NPK(LE *a_field, double a_user, int a_days)
Apply NPK fertilizer, on a_field owned by an arable farmer.
Definition: farmfuncs.cpp:629
cfg_WinterWheat_SkScrapes
CfgBool cfg_WinterWheat_SkScrapes("CROP_WW_SK_SCRAPES", CFG_CUSTOM, false)
Farm::DoIt
bool DoIt(double a_probability)
Return chance out of 0 to 100.
Definition: farm.cpp:800
FarmEvent::m_first_year
bool m_first_year
Definition: farm.h:467
ww_herbicide2
Definition: WinterWheat.h:82
tof_OptimisingFarm
Definition: farm.h:273
Landscape::BackTranslateVegTypes
int BackTranslateVegTypes(TTypesOfVegetation VegReference)
Definition: Landscape.h:1669
ww_stubble_harrow2
Definition: WinterWheat.h:103
Farm::FA_Manure
virtual bool FA_Manure(LE *a_field, double a_user, int a_days)
Spread manure on a_field owned by an stock farmer.
Definition: farmfuncs.cpp:1036
cfg_WW_InsecticideMonth
CfgInt cfg_WW_InsecticideMonth
Farm::GetType
TTypesOfFarm GetType(void)
Definition: farm.h:901
cfg_pest_winterwheat_on
CfgBool cfg_pest_winterwheat_on
Crop::m_first_date
int m_first_date
Definition: farm.h:540
FarmEvent::m_startday
int m_startday
Definition: farm.h:466
Farm::FA_NPK
virtual bool FA_NPK(LE *a_field, double a_user, int a_days)
Apply NPK fertilizer to a_field owned by an stock farmer.
Definition: farmfuncs.cpp:917
ww_harvest
Definition: WinterWheat.h:99
Farm::FungicideTreat
virtual bool FungicideTreat(LE *a_field, double a_user, int a_days)
Apply fungicide to a_field.
Definition: farmfuncs.cpp:1279
ww_grubning
Definition: WinterWheat.h:104
cfg_fungi_app_prop1
CfgFloat cfg_fungi_app_prop1
ww_insecticide3
Definition: WinterWheat.h:88
Crop::SimpleEvent
void SimpleEvent(long a_date, int a_todo, bool a_lock)
Adds an event to this crop management.
Definition: farm.cpp:307
cfg_ins_app_prop2
CfgFloat cfg_ins_app_prop2
ww_ferti_s1
Definition: WinterWheat.h:72
Farm::Prob_multiplier
virtual double Prob_multiplier()
Definition: farm.h:786
Farm::AutumnSow
virtual bool AutumnSow(LE *a_field, double a_user, int a_days)
Carry out a sowing event in the autumn on a_field.
Definition: farmfuncs.cpp:364
ww_fungicide2
Definition: WinterWheat.h:85
ww_hay_turning
Definition: WinterWheat.h:101
TTypesOfVegetation
TTypesOfVegetation
Definition: tov_declaration.h:30
ww_ferti_s5
Definition: WinterWheat.h:98
cfg_WW_InsecticideDay
CfgInt cfg_WW_InsecticideDay
Farm::Spraying_herbicides
virtual bool Spraying_herbicides(TTypesOfVegetation)
Definition: farm.h:784
ww_strigling1
Definition: WinterWheat.h:89
Farm::HayBailing
virtual bool HayBailing(LE *a_field, double a_user, int a_days)
Carry out hay bailing on a_field.
Definition: farmfuncs.cpp:2184
ww_spring_roll
Definition: WinterWheat.h:81
ww_insecticide2
Definition: WinterWheat.h:87
ww_GR
Definition: WinterWheat.h:83
Farm::StrawChopping
virtual bool StrawChopping(LE *a_field, double a_user, int a_days)
Carry out straw chopping on a_field.
Definition: farmfuncs.cpp:2132
ww_ferti_p3
Definition: WinterWheat.h:93
WW_AUTUMN_PLOUGH
#define WW_AUTUMN_PLOUGH
A flag used to indicate autumn ploughing status.
Definition: WinterWheat.h:58
ww_ferti_p2
Definition: WinterWheat.h:79
ww_autumn_roll
Definition: WinterWheat.h:78
FarmEvent::m_next_tov
TTypesOfVegetation m_next_tov
Definition: farm.h:471
ww_herbicide1
Definition: WinterWheat.h:80
Crop::m_farm
Farm * m_farm
Definition: farm.h:537
Crop::m_field
LE * m_field
Definition: farm.h:538
ww_autumn_sow
Definition: WinterWheat.h:77
FarmEvent::m_todo
int m_todo
Definition: farm.h:469
Farm::InsecticideTreat
virtual bool InsecticideTreat(LE *a_field, double a_user, int a_days)
Apply insecticide to a_field.
Definition: farmfuncs.cpp:1348
cfg_ins_app_prop1
CfgFloat cfg_ins_app_prop1
Farm::AutumnRoll
virtual bool AutumnRoll(LE *a_field, double a_user, int a_days)
Carry out a roll event in the autumn on a_field.
Definition: farmfuncs.cpp:288
Farm::FP_Slurry
virtual bool FP_Slurry(LE *a_field, double a_user, int a_days)
Apply slurry to a_field owned by an arable farmer.
Definition: farmfuncs.cpp:701
cfg_ins_app_prop3
CfgFloat cfg_ins_app_prop3
ppp_1
Definition: farm.h:422
ww_fungicide
Definition: WinterWheat.h:84
Farm::Water
virtual bool Water(LE *a_field, double a_user, int a_days)
Carry out a watering on a_field.
Definition: farmfuncs.cpp:1717
Farm::AutumnPlough
virtual bool AutumnPlough(LE *a_field, double a_user, int a_days)
Carry out a ploughing event in the autumn on a_field.
Definition: farmfuncs.cpp:132
cfg_greg_app_prop
CfgFloat cfg_greg_app_prop
Farm::AutumnHarrow
virtual bool AutumnHarrow(LE *a_field, double a_user, int a_days)
Carry out a harrow event in the autumn on a_field.
Definition: farmfuncs.cpp:261
ww_stubble_harrow1
Definition: WinterWheat.h:76
ww_ferti_s4
Definition: WinterWheat.h:97
ww_insecticide1
Definition: WinterWheat.h:86
Farm::DeepPlough
virtual bool DeepPlough(LE *a_field, double a_user, int a_days)
Carry out a deep ploughing event on a_field.
Definition: farmfuncs.cpp:417
ww_strigling2
Definition: WinterWheat.h:90
ww_ferti_p4
Definition: WinterWheat.h:94
WW_DECIDE_TO_HERB
#define WW_DECIDE_TO_HERB
Definition: WinterWheat.h:59
Farm::GrowthRegulator
virtual bool GrowthRegulator(LE *a_field, double a_user, int a_days)
Apply growth regulator to a_field.
Definition: farmfuncs.cpp:1250
ww_autumn_plough
Definition: WinterWheat.h:74
ww_water1
Definition: WinterWheat.h:91
cfg_fungi_app_prop2
CfgFloat cfg_fungi_app_prop2
ww_ferti_s2
Definition: WinterWheat.h:73
ww_ferti_p5
Definition: WinterWheat.h:95
Crop::ChooseNextCrop
void ChooseNextCrop(int a_no_dates)
Chooses the next crop to grow in a field.
Definition: farm.cpp:318
Farm::HayTurning
virtual bool HayTurning(LE *a_field, double a_user, int a_days)
Carry out hay turning on a_field.
Definition: farmfuncs.cpp:2159
ww_straw_chopping
Definition: WinterWheat.h:100
ww_ferti_s3
Definition: WinterWheat.h:96
cfg_herbi_app_prop
CfgFloat cfg_herbi_app_prop
ww_autumn_harrow
Definition: WinterWheat.h:75
ww_water2
Definition: WinterWheat.h:92
Farm::Spraying_fungins
virtual bool Spraying_fungins(TTypesOfVegetation)
Definition: farm.h:785
g_landscape_p
Landscape * g_landscape_p
Definition: Landscape.cpp:258
Farm::StubbleHarrowing
virtual bool StubbleHarrowing(LE *a_field, double a_user, int a_days)
Carry out stubble harrowing on a_field.
Definition: farmfuncs.cpp:2209