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

NLPotatoes class
. More...

#include <NLPotatoes.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...
 
 NLPotatoes ()
 
- 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

NLPotatoes class
.

See NLPotatoes.h::NLPotatoesToDo for a complete list of all possible events triggered codes by the potatoes 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

◆ NLPotatoes()

NLPotatoes::NLPotatoes ( )
inline
98  {
99  // When we start it off, the first possible date for a farm operation is 5th November
100  // This information is used by other crops when they decide how much post processing of
101  // the management is allowed after harvest before the next crop starts.
102  m_first_date=g_date->DayInYear( 5,11 );
103  }

References Crop::m_first_date.

Member Function Documentation

◆ Do()

bool NLPotatoes::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 potatoes.

Reimplemented from Crop.

65 {
66  bool done = false; // The boolean value done indicates when we are totally finished with this plan (i.e. it is set to true).
67  int d1 = 0;
68  // Depending what event has occured jump to the correct bit of code
69  switch (a_ev->m_todo)
70  {
71  case nl_pot_start:
72  {
73  // nl_pot_start just sets up all the starting conditions and reference dates that are needed to start a nl_pot
74  NL_POT_HERBI = false;
75  NL_POT_FUNGI1 = false;
76  NL_POT_FUNGI2 = false;
77  NL_POT_FUNGI3 = false;
78  NL_POT_FUNGI4 = false;
79  NL_POT_FUNGI5 = false;
80 
81 
82  // Set up the date management stuff
83  // The next bit of code just allows for altering dates after harvest if it is necessary
84  // to allow for a crop which starts its management early.
85 
86  // 2 start and stop dates for all 'movable' events for this crop
87  int noDates = 1;
88  a_field->SetMDates(0, 0, g_date->DayInYear(30, 10)); // last possible day of harvest
89  a_field->SetMDates(1, 0, g_date->DayInYear(30, 10));
90 
91 
92  a_field->SetMConstants(0, 1);
93 
94  // Check the next crop for early start, unless it is a spring crop
95  // in which case we ASSUME that no checking is necessary!!!!
96  // So DO NOT implement a crop that runs over the year boundary (i.e. from spring to spring!), at least not without fixing this.
97 
98  //new if: do the check only for non-optimising farms and if year>0. (030713 - ms_rotation used only in the hidden year, so I modified the condition from >7 to >0)
99  //optimising farms not used for now so most of related code is removed (but not in 'start' case)
100  if (!(a_farm->GetType() == tof_OptimisingFarm && g_date->GetYearNumber() > 0)) {
101 
102  if (a_ev->m_startday > g_date->DayInYear(1, 7)) {
103  if (a_field->GetMDates(0, 0) >= a_ev->m_startday)
104  {
105  g_msg->Warn(WARN_BUG, "NLPotatoes::Do(): ", "Harvest too late for the next crop to start!!!");
106  int almassnum = g_landscape_p->BackTranslateVegTypes(a_ev->m_next_tov);
107  g_msg->Warn("Next Crop ", (double)almassnum); // this causes exit
108  }
109  // Now fix any late finishing problems
110  for (int i = 0; i < noDates; i++) {
111  if (a_field->GetMDates(0, i) >= a_ev->m_startday) {
112  a_field->SetMDates(0, i, a_ev->m_startday - 1); //move the starting date
113  }
114  if (a_field->GetMDates(1, i) >= a_ev->m_startday) {
115  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)
116  a_field->SetMDates(1, i, a_ev->m_startday - 1); //move the finishing date
117  }
118  }
119  }
120  // Now no operations can be timed after the start of the next crop.
121 
122  if (!a_ev->m_first_year) {
123  // Are we before July 1st?
124  d1 = g_date->OldDays() + g_date->DayInYear(1, 7);
125  if (g_date->Date() < d1) {
126  // Yes, too early. We assumme this is because the last crop was late
127  printf("Poly: %d\n", a_field->GetPoly());
128  g_msg->Warn(WARN_BUG, "NLPotatoes::Do(): ", "Crop start attempt between 1st Jan & 1st July");
129  int prev = g_landscape_p->BackTranslateVegTypes(a_field->GetOwner()->GetPreviousCrop(a_field->GetRotIndex()));
130  g_msg->Warn(WARN_BUG, "Previous Crop ", prev);
131  int almassnum = g_landscape_p->BackTranslateVegTypes(a_ev->m_next_tov);
132  g_msg->Warn("Next Crop ", (double)almassnum); // this causes exit
133  exit(1);
134  }
135  else {
136  d1 = g_date->OldDays() + m_first_date; // Add 365 for spring crop
137  if (g_date->Date() > d1) {
138  // Yes too late - should not happen - raise an error
139  g_msg->Warn(WARN_BUG, "NLPotatoes::Do(): ", "Crop start attempt after last possible start date");
140  int prev = g_landscape_p->BackTranslateVegTypes(a_field->GetOwner()->GetPreviousCrop(a_field->GetRotIndex()));
141  g_msg->Warn(WARN_BUG, "Previous Crop ", prev);
142  int almassnum = g_landscape_p->BackTranslateVegTypes(a_ev->m_next_tov);
143  g_msg->Warn("Next Crop ", (double)almassnum); // this causes exit
144  exit(1);
145  }
146  }
147  }
148  else {
149  // Is the first year
150  // Some special code to cope with that first start-up year in ALMaSS - ignore for all practical purposes
151  // Code for first spring treatment used
152  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(10, 4), nl_pot_spring_planting, false, a_farm, a_field);
153  break;
154  }
155  }//if
156 
157  // End single block date checking code. Please see next line comment as well.
158  // Reinit d1 to first possible starting date.
159  d1 = g_date->OldDays() + g_date->DayInYear(1, 9);
160  // OK, let's go.
161  // Here we queue up the first event - this differs depending on whether we have a
162  // stock or arable farmer
163  SimpleEvent_(d1, nl_pot_stubble_harrow, false, a_farm, a_field);
164  }
165  break;
166 
167  // This is the first real farm operation
169  if (!a_farm->StubbleHarrowing(a_field, 0.0, g_date->DayInYear(5, 11) - g_date->DayInYear())) {
170  SimpleEvent_(g_date->Date() + 1, nl_pot_stubble_harrow, true, a_farm, a_field);
171  break;
172  }
173  d1 = g_date->Date() + 14;
174  if (d1 < g_date->OldDays() + g_date->DayInYear(15, 10)) {
175  d1 = g_date->OldDays() + g_date->DayInYear(15, 10);
176  }
177  if (a_field->GetSoilType() == 2 || a_field->GetSoilType() == 6) { // on sandy soils (NL ZAND & LOSS)
178  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(15, 3) + 365, nl_pot_ferti_s1_sandy, false, a_farm, a_field);
179  }
180  else SimpleEvent_(d1, nl_pot_winter_plough_clay, false, a_farm, a_field);
181  break;
182 
184  if (!a_farm->FP_Slurry(a_field, 0.0, g_date->DayInYear(30, 4) - g_date->DayInYear())) {
185  SimpleEvent_(g_date->Date() + 1, nl_pot_ferti_p1_sandy, true, a_farm, a_field);
186  break;
187  }
188  SimpleEvent_(g_date->Date() + 1, nl_pot_spring_plough_sandy, false, a_farm, a_field);
189  break;
191  if (a_farm->IsStockFarmer())
192  {
193  if (!a_farm->FA_Slurry(a_field, 0.0, g_date->DayInYear(30, 4) - g_date->DayInYear())) {
194  SimpleEvent_(g_date->Date() + 1, nl_pot_ferti_s1_sandy, true, a_farm, a_field);
195  break;
196  }
197  SimpleEvent_(g_date->Date() + 1, nl_pot_spring_plough_sandy, false, a_farm, a_field);
198  break;
199  }
200  SimpleEvent_(g_date->Date() + 1, nl_pot_ferti_p1_sandy, false, a_farm, a_field);
201  break;
203  if (!a_farm->SpringPlough(a_field, 0.0, g_date->DayInYear(30, 4) - g_date->DayInYear())) {
204  SimpleEvent_(g_date->Date() + 1, nl_pot_spring_plough_sandy, true, a_farm, a_field);
205  break;
206  }
207  d1 = g_date->Date() + 7;
208  if (d1 < g_date->OldDays() + g_date->DayInYear(10, 4)) {
209  d1 = g_date->OldDays() + g_date->DayInYear(10, 4);
210  }
211  if (a_farm->IsStockFarmer()) //Stock Farmer
212  {
213  SimpleEvent_(d1, nl_pot_ferti_s2_sandy, false, a_farm, a_field);
214  }
215  else SimpleEvent_(d1, nl_pot_ferti_p2_sandy, false, a_farm, a_field);
216  break;
218  if (a_ev->m_lock || a_farm->DoIt_prob(0.50))
219  {
220  if (!a_farm->FP_NPK(a_field, 0.0, g_date->DayInYear(30, 4) - g_date->DayInYear())) {
221  SimpleEvent_(g_date->Date() + 1, nl_pot_ferti_p2_sandy, true, a_farm, a_field);
222  break;
223  }
224  }
225  SimpleEvent_(g_date->Date() + 1, nl_pot_bed_forming, false, a_farm, a_field);
226  break;
228  if (a_ev->m_lock || a_farm->DoIt_prob(0.50))
229  {
230  if (!a_farm->FA_NPK(a_field, 0.0, g_date->DayInYear(30, 4) - g_date->DayInYear())) {
231  SimpleEvent_(g_date->Date() + 1, nl_pot_ferti_s2_sandy, true, a_farm, a_field);
232  break;
233  }
234  }
235  SimpleEvent_(g_date->Date() + 1, nl_pot_bed_forming, false, a_farm, a_field);
236  break;
238  if (!a_farm->WinterPlough(a_field, 0.0, g_date->DayInYear(1, 12) - g_date->DayInYear())) {
239  SimpleEvent_(g_date->Date() + 1, nl_pot_winter_plough_clay, true, a_farm, a_field);
240  break;
241  }
242  if (a_farm->IsStockFarmer()) //Stock Farmer
243  {
244  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(10, 4) + 365, nl_pot_ferti_s2_clay, false, a_farm, a_field);
245  }
246  else SimpleEvent_(g_date->OldDays() + g_date->DayInYear(10, 4) + 365, nl_pot_ferti_p2_clay, false, a_farm, a_field);
247  break;
249  if (!a_farm->FP_NPK(a_field, 0.0, g_date->DayInYear(30, 4) - g_date->DayInYear())) {
250  SimpleEvent_(g_date->Date() + 1, nl_pot_ferti_p2_clay, true, a_farm, a_field);
251  break;
252  }
253  SimpleEvent_(g_date->Date() + 1, nl_pot_bed_forming, false, a_farm, a_field);
254  break;
256  if (!a_farm->FA_NPK(a_field, 0.0, g_date->DayInYear(30, 4) - g_date->DayInYear())) {
257  SimpleEvent_(g_date->Date() + 1, nl_pot_ferti_s2_clay, true, a_farm, a_field);
258  break;
259  }
260  SimpleEvent_(g_date->Date() + 1, nl_pot_bed_forming, false, a_farm, a_field);
261  break;
262  case nl_pot_bed_forming:
263  if (!a_farm->BedForming(a_field, 0.0, g_date->DayInYear(9, 5) - g_date->DayInYear())) {
264  SimpleEvent_(g_date->Date() + 1, nl_pot_bed_forming, true, a_farm, a_field);
265  break;
266  }
267  SimpleEvent_(g_date->Date() + 1, nl_pot_spring_planting, false, a_farm, a_field);
268  break;
270  if (!a_farm->SpringSow(a_field, 0.0, g_date->DayInYear(10, 5) - g_date->DayInYear())) {
271  SimpleEvent_(g_date->Date() + 1, nl_pot_spring_planting, true, a_farm, a_field);
272  break;
273  }
274  // Here is a fork leading to four parallel events
275  SimpleEvent_(g_date->Date() + 14, nl_pot_hilling1, false, a_farm, a_field); // Hilling + herbicides = MAIN THREAD
276  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 6), nl_pot_fungicide1, false, a_farm, a_field); // Fungicide thread
277  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 6), nl_pot_insecticide, false, a_farm, a_field); // Insecticide thread
278  if (a_farm->IsStockFarmer()) //Stock Farmer // N thread
279  {
280  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(5, 6), nl_pot_ferti_s3_clay, false, a_farm, a_field);
281  }
282  else SimpleEvent_(g_date->OldDays() + g_date->DayInYear(5, 6), nl_pot_ferti_p3_clay, false, a_farm, a_field);
283  if (a_farm->IsStockFarmer()) //Stock Farmer // microelements thread
284  {
285  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(5, 6), nl_pot_ferti_s4, false, a_farm, a_field);
286  }
287  else SimpleEvent_(g_date->OldDays() + g_date->DayInYear(5, 6), nl_pot_ferti_p4, false, a_farm, a_field);
288  break;
290  if (a_field->GetSoilType() != 2 && a_field->GetSoilType() != 6)// on clay soils (NL KLEI & VEEN)
291  {
292  if (a_ev->m_lock || a_farm->DoIt_prob(0.25))
293  {
294  if (!a_farm->FP_AmmoniumSulphate(a_field, 0.0, g_date->DayInYear(30, 6) - g_date->DayInYear())) {
295  SimpleEvent_(g_date->Date() + 1, nl_pot_ferti_p3_clay, true, a_farm, a_field);
296  break;
297  }
298  }
299  // End of thread
300  break;
301  }
302  if (a_farm->IsStockFarmer()) //Stock Farmer // N thread
303  {
304  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(5, 6), nl_pot_ferti_s3_sandy, false, a_farm, a_field);
305  }
306  else SimpleEvent_(g_date->OldDays() + g_date->DayInYear(5, 6), nl_pot_ferti_p3_sandy, false, a_farm, a_field);
307  break;
309  if (a_field->GetSoilType() != 2 && a_field->GetSoilType() != 6)// on clay soils (NL KLEI & VEEN)
310  {
311  if (a_ev->m_lock || a_farm->DoIt_prob(0.25))
312  {
313  if (!a_farm->FA_AmmoniumSulphate(a_field, 0.0, g_date->DayInYear(30, 6) - g_date->DayInYear())) {
314  SimpleEvent_(g_date->Date() + 1, nl_pot_ferti_s3_clay, true, a_farm, a_field);
315  break;
316  }
317  }
318  // End of thread
319  break;
320  }
321  if (a_farm->IsStockFarmer()) //Stock Farmer // N thread
322  {
323  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(5, 6), nl_pot_ferti_s3_sandy, false, a_farm, a_field);
324  }
325  else SimpleEvent_(g_date->OldDays() + g_date->DayInYear(5, 6), nl_pot_ferti_p3_sandy, false, a_farm, a_field);
326  break;
328  if (!a_farm->FP_AmmoniumSulphate(a_field, 0.0, g_date->DayInYear(30, 6) - g_date->DayInYear())) {
329  SimpleEvent_(g_date->Date() + 1, nl_pot_ferti_p3_sandy, true, a_farm, a_field);
330  break;
331  }
332  // End of thread
333  break;
334 
336  if (!a_farm->FA_AmmoniumSulphate(a_field, 0.0, g_date->DayInYear(30, 6) - g_date->DayInYear())) {
337  SimpleEvent_(g_date->Date() + 1, nl_pot_ferti_s3_sandy, true, a_farm, a_field);
338  break;
339  }
340  // End of thread
341  break;
342 
343  case nl_pot_ferti_p4:
344  if (a_ev->m_lock || a_farm->DoIt_prob(0.25))
345  {
346  if (!a_farm->FP_ManganeseSulphate(a_field, 0.0, g_date->DayInYear(30, 6) - g_date->DayInYear())) {
347  SimpleEvent_(g_date->Date() + 1, nl_pot_ferti_p4, true, a_farm, a_field);
348  break;
349  }
350  }
351  // End of thread
352  break;
353  case nl_pot_ferti_s4:
354  if (a_ev->m_lock || a_farm->DoIt_prob(0.25))
355  {
356  if (!a_farm->FA_ManganeseSulphate(a_field, 0.0, g_date->DayInYear(30, 6) - g_date->DayInYear())) {
357  SimpleEvent_(g_date->Date() + 1, nl_pot_ferti_s4, true, a_farm, a_field);
358  break;
359  }
360  }
361  // End of thread
362  break;
363  case nl_pot_hilling1:
364  if (!a_farm->HillingUp(a_field, 0.0, g_date->DayInYear(25, 5) - g_date->DayInYear())) {
365  SimpleEvent_(g_date->Date() + 1, nl_pot_hilling1, true, a_farm, a_field);
366  break;
367  }
368  SimpleEvent_(g_date->Date() + 3, nl_pot_herbicide1, false, a_farm, a_field);
369  break;
370  case nl_pot_herbicide1:
371  if (a_ev->m_lock || a_farm->DoIt_prob(0.80))
372  {
373  if (!a_farm->HerbicideTreat(a_field, 0.0, g_date->DayInYear(30, 5) - g_date->DayInYear())) {
374  SimpleEvent_(g_date->Date() + 1, nl_pot_herbicide1, true, a_farm, a_field);
375  break;
376  }
377  NL_POT_HERBI = true;
378  }
379  SimpleEvent_(g_date->Date() + 14, nl_pot_herbicide2, false, a_farm, a_field);
380  break;
381  case nl_pot_herbicide2:
382  if (a_ev->m_lock || (a_farm->DoIt_prob(0.625) && NL_POT_HERBI == 1)) // 50% of all farmers
383  {
384  if (!a_farm->HerbicideTreat(a_field, 0.0, g_date->DayInYear(15, 6) - g_date->DayInYear())) {
385  SimpleEvent_(g_date->Date() + 1, nl_pot_herbicide2, true, a_farm, a_field);
386  break;
387  }
388  }
389  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 9), nl_pot_dessication1, false, a_farm, a_field);
390  break;
391  case nl_pot_dessication1:
392  if (!a_farm->HerbicideTreat(a_field, 0.0, g_date->DayInYear(15, 10) - g_date->DayInYear())) {
393  SimpleEvent_(g_date->Date() + 1, nl_pot_dessication1, true, a_farm, a_field);
394  break;
395  }
396  SimpleEvent_(g_date->Date() + 5, nl_pot_dessication2, false, a_farm, a_field);
397  break;
398 
399  case nl_pot_dessication2:
400  if (a_ev->m_lock || a_farm->DoIt_prob(0.75))
401  {
402  if (!a_farm->HerbicideTreat(a_field, 0.0, g_date->DayInYear(20, 10) - g_date->DayInYear())) {
403  SimpleEvent_(g_date->Date() + 1, nl_pot_dessication2, true, a_farm, a_field);
404  break;
405  }
406  }
407  SimpleEvent_(g_date->Date() + 10, nl_pot_harvest, false, a_farm, a_field);
408  break;
409  case nl_pot_fungicide1:
410  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(7, 6) - g_date->DayInYear())) {
411  SimpleEvent_(g_date->Date() + 1, nl_pot_fungicide1, true, a_farm, a_field);
412  break;
413  }
414  SimpleEvent_(g_date->Date() + 7, nl_pot_fungicide2, false, a_farm, a_field);
415  break;
416  case nl_pot_fungicide2:
417  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(14, 6) - g_date->DayInYear())) {
418  SimpleEvent_(g_date->Date() + 1, nl_pot_fungicide2, true, a_farm, a_field);
419  break;
420  }
421  SimpleEvent_(g_date->Date() + 7, nl_pot_fungicide3, false, a_farm, a_field);
422  break;
423  case nl_pot_fungicide3:
424  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(21, 6) - g_date->DayInYear())) {
425  SimpleEvent_(g_date->Date() + 1, nl_pot_fungicide3, true, a_farm, a_field);
426  break;
427  }
428  SimpleEvent_(g_date->Date() + 7, nl_pot_fungicide4, false, a_farm, a_field);
429  break;
430  case nl_pot_fungicide4:
431  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(30, 6) - g_date->DayInYear())) {
432  SimpleEvent_(g_date->Date() + 1, nl_pot_fungicide4, true, a_farm, a_field);
433  break;
434  }
435  SimpleEvent_(g_date->Date() + 7, nl_pot_fungicide5, false, a_farm, a_field);
436  break;
437  case nl_pot_fungicide5:
438  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(7, 7) - g_date->DayInYear())) {
439  SimpleEvent_(g_date->Date() + 1, nl_pot_fungicide5, true, a_farm, a_field);
440  break;
441  }
442  SimpleEvent_(g_date->Date() + 7, nl_pot_fungicide6, false, a_farm, a_field);
443  break;
444  case nl_pot_fungicide6:
445  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(14, 7) - g_date->DayInYear())) {
446  SimpleEvent_(g_date->Date() + 1, nl_pot_fungicide6, true, a_farm, a_field);
447  break;
448  }
449  SimpleEvent_(g_date->Date() + 7, nl_pot_fungicide7, false, a_farm, a_field);
450  break;
451  case nl_pot_fungicide7:
452  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(21, 7) - g_date->DayInYear())) {
453  SimpleEvent_(g_date->Date() + 1, nl_pot_fungicide7, true, a_farm, a_field);
454  break;
455  }
456  SimpleEvent_(g_date->Date() + 7, nl_pot_fungicide8, false, a_farm, a_field);
457  break;
458  case nl_pot_fungicide8:
459  if (a_ev->m_lock || a_farm->DoIt_prob(0.80))
460  {
461  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(31, 7) - g_date->DayInYear())) {
462  SimpleEvent_(g_date->Date() + 1, nl_pot_fungicide8, true, a_farm, a_field);
463  break;
464  }
465  NL_POT_FUNGI1 = true;
466  }
467  SimpleEvent_(g_date->Date() + 7, nl_pot_fungicide9, false, a_farm, a_field);
468  break;
469  case nl_pot_fungicide9:
470  if (a_ev->m_lock || (a_farm->DoIt_prob(1.00) && NL_POT_FUNGI1 == 1))
471  {
472  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(7, 8) - g_date->DayInYear())) {
473  SimpleEvent_(g_date->Date() + 1, nl_pot_fungicide9, true, a_farm, a_field);
474  break;
475  }
476  NL_POT_FUNGI2 = true;
477  }
478  SimpleEvent_(g_date->Date() + 7, nl_pot_fungicide10, false, a_farm, a_field);
479  break;
480  case nl_pot_fungicide10:
481  if (a_ev->m_lock || (a_farm->DoIt_prob(0.875) && NL_POT_FUNGI2 == 1)) // 70% of all farmers
482  {
483  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(14, 8) - g_date->DayInYear())) {
484  SimpleEvent_(g_date->Date() + 1, nl_pot_fungicide10, true, a_farm, a_field);
485  break;
486  }
487  NL_POT_FUNGI3 = true;
488  }
489  SimpleEvent_(g_date->Date() + 7, nl_pot_fungicide11, false, a_farm, a_field);
490  break;
491  case nl_pot_fungicide11:
492  if (a_ev->m_lock || (a_farm->DoIt_prob(1.00) && NL_POT_FUNGI3 == 1))
493  {
494  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(21, 8) - g_date->DayInYear())) {
495  SimpleEvent_(g_date->Date() + 1, nl_pot_fungicide11, true, a_farm, a_field);
496  break;
497  }
498  NL_POT_FUNGI4 = true;
499  }
500  SimpleEvent_(g_date->Date() + 7, nl_pot_fungicide12, false, a_farm, a_field);
501  break;
502  case nl_pot_fungicide12:
503  if (a_ev->m_lock || (a_farm->DoIt_prob(0.857) && NL_POT_FUNGI4 == 1)) // 60% of all farmers
504  {
505  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(31, 8) - g_date->DayInYear())) {
506  SimpleEvent_(g_date->Date() + 1, nl_pot_fungicide12, true, a_farm, a_field);
507  break;
508  }
509  NL_POT_FUNGI5 = true;
510  }
511  SimpleEvent_(g_date->Date() + 7, nl_pot_fungicide13, false, a_farm, a_field);
512  break;
513  case nl_pot_fungicide13:
514  if (a_ev->m_lock || (a_farm->DoIt_prob(1.00) && NL_POT_FUNGI5 == 1))
515  {
516  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(7, 9) - g_date->DayInYear())) {
517  SimpleEvent_(g_date->Date() + 1, nl_pot_fungicide13, true, a_farm, a_field);
518  break;
519  }
520  }
521  SimpleEvent_(g_date->Date() + 7, nl_pot_fungicide14, false, a_farm, a_field);
522  break;
523  case nl_pot_fungicide14:
524  if (a_ev->m_lock || (a_farm->DoIt_prob(1.00) && NL_POT_FUNGI5 == 1))
525  {
526  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(14, 9) - g_date->DayInYear())) {
527  SimpleEvent_(g_date->Date() + 1, nl_pot_fungicide14, true, a_farm, a_field);
528  break;
529  }
530  }
531  SimpleEvent_(g_date->Date() + 7, nl_pot_fungicide15, false, a_farm, a_field);
532  break;
533  case nl_pot_fungicide15:
534  if (a_ev->m_lock || (a_farm->DoIt_prob(1.00) && NL_POT_FUNGI5 == 1))
535  {
536  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(21, 9) - g_date->DayInYear())) {
537  SimpleEvent_(g_date->Date() + 1, nl_pot_fungicide15, true, a_farm, a_field);
538  break;
539  }
540  }
541  // End of thread
542  break;
543  case nl_pot_insecticide:
544  if (a_ev->m_lock || a_farm->DoIt_prob(0.60))
545  {
546  // here we check wheter we are using ERA pesticide or not
547  if (!cfg_pest_potatoes_on.value() ||
548  !g_landscape_p->SupplyShouldSpray()) // Not using pesticide spray
549  {
550  if (!a_farm->InsecticideTreat(a_field, 0.0, g_date->DayInYear(30, 6) - g_date->DayInYear())) {
551  SimpleEvent_(g_date->Date() + 1, nl_pot_insecticide, true, a_farm, a_field);
552  break;
553  }
554  }
555  else {
556  a_farm->ProductApplication(a_field, 0.0, 0, cfg_pest_product_1_amount.value(), ppp_1);
557  }
558  }
559  // End of thread
560  break;
561  case nl_pot_harvest:
562  // We don't move harvest days
563  if (!a_farm->Harvest(a_field, 0.0, a_field->GetMDates(0, 0) - g_date->DayInYear())) {
564  SimpleEvent_(g_date->Date() + 1, nl_pot_harvest, true, a_farm, a_field);
565  break;
566  }
567  done = true;
568  // So we are done, and somwhere else the farmer will queue up the start event of the next crop
569  // END of MAIN THREAD
570  break;
571  default:
572  g_msg->Warn(WARN_BUG, "NLPotatoes::Do(): "
573  "Unknown event type! ", "");
574  exit(1);
575  }
576  return done;
577 }

References Landscape::BackTranslateVegTypes(), cfg_pest_potatoes_on, cfg_pest_product_1_amount, Farm::FP_Slurry(), g_landscape_p, Farm::GetType(), Crop::m_first_date, FarmEvent::m_first_year, FarmEvent::m_lock, FarmEvent::m_next_tov, FarmEvent::m_startday, FarmEvent::m_todo, nl_pot_bed_forming, nl_pot_dessication1, nl_pot_dessication2, nl_pot_ferti_p1_sandy, nl_pot_ferti_p2_clay, nl_pot_ferti_p2_sandy, nl_pot_ferti_p3_clay, nl_pot_ferti_p3_sandy, nl_pot_ferti_p4, nl_pot_ferti_s1_sandy, nl_pot_ferti_s2_clay, nl_pot_ferti_s2_sandy, nl_pot_ferti_s3_clay, nl_pot_ferti_s3_sandy, nl_pot_ferti_s4, NL_POT_FUNGI1, NL_POT_FUNGI2, NL_POT_FUNGI3, NL_POT_FUNGI4, NL_POT_FUNGI5, nl_pot_fungicide1, nl_pot_fungicide10, nl_pot_fungicide11, nl_pot_fungicide12, nl_pot_fungicide13, nl_pot_fungicide14, nl_pot_fungicide15, nl_pot_fungicide2, nl_pot_fungicide3, nl_pot_fungicide4, nl_pot_fungicide5, nl_pot_fungicide6, nl_pot_fungicide7, nl_pot_fungicide8, nl_pot_fungicide9, nl_pot_harvest, NL_POT_HERBI, nl_pot_herbicide1, nl_pot_herbicide2, nl_pot_hilling1, nl_pot_insecticide, nl_pot_spring_planting, nl_pot_spring_plough_sandy, nl_pot_start, nl_pot_stubble_harrow, nl_pot_winter_plough_clay, ppp_1, Crop::SimpleEvent_(), Farm::StubbleHarrowing(), Landscape::SupplyShouldSpray(), and tof_OptimisingFarm.


The documentation for this class was generated from the following files:
nl_pot_ferti_p4
Definition: NLPotatoes.h:59
nl_pot_ferti_s3_clay
Definition: NLPotatoes.h:56
nl_pot_stubble_harrow
Definition: NLPotatoes.h:43
nl_pot_herbicide2
Definition: NLPotatoes.h:62
nl_pot_fungicide8
Definition: NLPotatoes.h:70
nl_pot_ferti_p2_sandy
Definition: NLPotatoes.h:50
nl_pot_fungicide1
Definition: NLPotatoes.h:63
FarmEvent::m_lock
bool m_lock
Definition: farm.h:465
nl_pot_harvest
Definition: NLPotatoes.h:81
Landscape::SupplyShouldSpray
bool SupplyShouldSpray()
Definition: Landscape.h:357
nl_pot_fungicide9
Definition: NLPotatoes.h:71
NL_POT_FUNGI1
#define NL_POT_FUNGI1
Definition: NLPotatoes.h:29
FarmEvent::m_first_year
bool m_first_year
Definition: farm.h:467
tof_OptimisingFarm
Definition: farm.h:273
Landscape::BackTranslateVegTypes
int BackTranslateVegTypes(TTypesOfVegetation VegReference)
Definition: Landscape.h:1669
NL_POT_FUNGI3
#define NL_POT_FUNGI3
Definition: NLPotatoes.h:31
Farm::GetType
TTypesOfFarm GetType(void)
Definition: farm.h:901
nl_pot_ferti_s4
Definition: NLPotatoes.h:60
nl_pot_ferti_s2_clay
Definition: NLPotatoes.h:46
Crop::m_first_date
int m_first_date
Definition: farm.h:540
FarmEvent::m_startday
int m_startday
Definition: farm.h:466
nl_pot_herbicide1
Definition: NLPotatoes.h:61
cfg_pest_product_1_amount
CfgFloat cfg_pest_product_1_amount
nl_pot_ferti_p3_clay
Definition: NLPotatoes.h:55
nl_pot_ferti_s2_sandy
Definition: NLPotatoes.h:51
nl_pot_fungicide3
Definition: NLPotatoes.h:65
nl_pot_winter_plough_clay
Definition: NLPotatoes.h:44
cfg_pest_potatoes_on
CfgBool cfg_pest_potatoes_on
NL_POT_FUNGI2
#define NL_POT_FUNGI2
Definition: NLPotatoes.h:30
nl_pot_ferti_s1_sandy
Definition: NLPotatoes.h:48
nl_pot_ferti_p3_sandy
Definition: NLPotatoes.h:57
nl_pot_dessication2
Definition: NLPotatoes.h:80
nl_pot_hilling1
Definition: NLPotatoes.h:54
NL_POT_FUNGI5
#define NL_POT_FUNGI5
Definition: NLPotatoes.h:33
nl_pot_fungicide4
Definition: NLPotatoes.h:66
nl_pot_bed_forming
Definition: NLPotatoes.h:52
FarmEvent::m_next_tov
TTypesOfVegetation m_next_tov
Definition: farm.h:471
FarmEvent::m_todo
int m_todo
Definition: farm.h:469
nl_pot_spring_plough_sandy
Definition: NLPotatoes.h:49
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
ppp_1
Definition: farm.h:422
nl_pot_start
Definition: NLPotatoes.h:41
nl_pot_fungicide12
Definition: NLPotatoes.h:74
nl_pot_fungicide13
Definition: NLPotatoes.h:75
nl_pot_spring_planting
Definition: NLPotatoes.h:53
nl_pot_fungicide7
Definition: NLPotatoes.h:69
nl_pot_fungicide10
Definition: NLPotatoes.h:72
nl_pot_ferti_p1_sandy
Definition: NLPotatoes.h:47
nl_pot_dessication1
Definition: NLPotatoes.h:79
nl_pot_fungicide11
Definition: NLPotatoes.h:73
nl_pot_insecticide
Definition: NLPotatoes.h:78
nl_pot_fungicide15
Definition: NLPotatoes.h:77
nl_pot_fungicide6
Definition: NLPotatoes.h:68
nl_pot_fungicide14
Definition: NLPotatoes.h:76
NL_POT_HERBI
#define NL_POT_HERBI
A flag used to indicate autumn ploughing status.
Definition: NLPotatoes.h:28
nl_pot_ferti_s3_sandy
Definition: NLPotatoes.h:58
nl_pot_ferti_p2_clay
Definition: NLPotatoes.h:45
nl_pot_fungicide5
Definition: NLPotatoes.h:67
NL_POT_FUNGI4
#define NL_POT_FUNGI4
Definition: NLPotatoes.h:32
nl_pot_fungicide2
Definition: NLPotatoes.h:64
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
Crop::SimpleEvent_
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.
Definition: farm.cpp:312