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

NLTulips class
. More...

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

NLTulips class
.

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

◆ NLTulips()

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

References Crop::m_first_date.

Member Function Documentation

◆ Do()

bool NLTulips::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 tulips.

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_tu_start:
72  {
73  // nl_tu_start just sets up all the starting conditions and reference dates that are needed to start a nl_ca
74  NL_TU_AUTUMN_PLOUGH = false;
75  NL_TU_FERTI_DONE = false;
76  NL_TU_STRAW_REMOVED = false;
78 
79 
80  // Set up the date management stuff
81  // The next bit of code just allows for altering dates after harvest if it is necessary
82  // to allow for a crop which starts its management early.
83 
84  // 2 start and stop dates for all 'movable' events for this crop
85  int noDates = 1;
86  a_field->SetMDates(0, 0, g_date->DayInYear(20, 7)); // last possible day of harvest
87  a_field->SetMDates(1, 0, g_date->DayInYear(20, 7));
88 
89  a_field->SetMConstants(0, 1);
90 
91  // Check the next crop for early start, unless it is a spring crop
92  // in which case we ASSUME that no checking is necessary!!!!
93  // So DO NOT implement a crop that runs over the year boundary (i.e. from spring to spring!), at least not without fixing this.
94 
95  //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)
96  //optimising farms not used for now so most of related code is removed (but not in 'start' case)
97  if (!(a_farm->GetType() == tof_OptimisingFarm && g_date->GetYearNumber() > 0)) {
98 
99  if (a_ev->m_startday > g_date->DayInYear(1, 7)) {
100  if (a_field->GetMDates(0, 0) >= a_ev->m_startday)
101  {
102  g_msg->Warn(WARN_BUG, "NLTulips::Do(): ", "Harvest too late for the next crop to start!!!");
103  int almassnum = g_landscape_p->BackTranslateVegTypes(a_ev->m_next_tov);
104  g_msg->Warn("Next Crop ", (double)almassnum); // this causes exit
105  }
106  // Now fix any late finishing problems
107  for (int i = 0; i < noDates; i++) {
108  if (a_field->GetMDates(0, i) >= a_ev->m_startday) {
109  a_field->SetMDates(0, i, a_ev->m_startday - 1); //move the starting date
110  }
111  if (a_field->GetMDates(1, i) >= a_ev->m_startday) {
112  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)
113  a_field->SetMDates(1, i, a_ev->m_startday - 1); //move the finishing date
114  }
115  }
116  }
117  // Now no operations can be timed after the start of the next crop.
118 
119  if (!a_ev->m_first_year) {
120  // Are we before July 1st?
121  d1 = g_date->OldDays() + g_date->DayInYear(1, 7);
122  if (g_date->Date() < d1) {
123  // Yes, too early. We assumme this is because the last crop was late
124  printf("Poly: %d\n", a_field->GetPoly());
125  g_msg->Warn(WARN_BUG, "NLTulips::Do(): ", "Crop start attempt between 1st Jan & 1st July");
126  int prev = g_landscape_p->BackTranslateVegTypes(a_field->GetOwner()->GetPreviousCrop(a_field->GetRotIndex()));
127  g_msg->Warn(WARN_BUG, "Previous Crop ", prev);
128  int almassnum = g_landscape_p->BackTranslateVegTypes(a_ev->m_next_tov);
129  g_msg->Warn("Next Crop ", (double)almassnum); // this causes exit
130  exit(1);
131  }
132  else {
133  d1 = g_date->OldDays() + m_first_date; // Add 365 for spring crop
134  if (g_date->Date() > d1) {
135  // Yes too late - should not happen - raise an error
136  g_msg->Warn(WARN_BUG, "NLTulips::Do(): ", "Crop start attempt after last possible start date");
137  int prev = g_landscape_p->BackTranslateVegTypes(a_field->GetOwner()->GetPreviousCrop(a_field->GetRotIndex()));
138  g_msg->Warn(WARN_BUG, "Previous Crop ", prev);
139  int almassnum = g_landscape_p->BackTranslateVegTypes(a_ev->m_next_tov);
140  g_msg->Warn("Next Crop ", (double)almassnum); // this causes exit
141  exit(1);
142  }
143  }
144  }
145  else {
146  // Is the first year
147  // Some special code to cope with that first start-up year in ALMaSS - ignore for all practical purposes
148  // Code for first spring treatment used
149  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(25, 2), nl_tu_fungicide1, false, a_farm, a_field);
150  break;
151  }
152  }//if
153 
154  // End single block date checking code. Please see next line comment as well.
155  // Reinit d1 to first possible starting date.
156  d1 = g_date->OldDays() + g_date->DayInYear(1, 9);
157  // OK, let's go.
158  // Here we queue up the first event - this differs depending on whether we have field on snady or clay soils
159  if (a_farm->IsStockFarmer()) //Stock Farmer
160  {
161  SimpleEvent_(d1, nl_tu_ferti_s1, false, a_farm, a_field);
162  }
163  else SimpleEvent_(d1, nl_tu_ferti_p1, false, a_farm, a_field);
164  }
165  break;
166 
167  // This is the first real farm operation
168  case nl_tu_ferti_p1:
169  if (a_ev->m_lock || a_farm->DoIt_prob(0.90))
170  {
171  if (!a_farm->FP_Manure(a_field, 0.0, g_date->DayInYear(31, 10) - g_date->DayInYear())) {
172  SimpleEvent_(g_date->Date() + 1, nl_tu_ferti_p1, true, a_farm, a_field);
173  break;
174  }
175  }
176  d1 = g_date->Date() + 1;
177  if (d1 < g_date->OldDays() + g_date->DayInYear(15, 9)) {
178  d1 = g_date->OldDays() + g_date->DayInYear(15, 9);
179  }
180  SimpleEvent_(d1, nl_tu_autumn_plough, false, a_farm, a_field);
181  break;
182  case nl_tu_ferti_s1:
183  if (a_ev->m_lock || a_farm->DoIt_prob(0.90))
184  {
185  if (!a_farm->FA_Manure(a_field, 0.0, g_date->DayInYear(31, 10) - g_date->DayInYear())) {
186  SimpleEvent_(g_date->Date() + 1, nl_tu_ferti_s1, true, a_farm, a_field);
187  break;
188  }
189  }
190  d1 = g_date->Date() + 1;
191  if (d1 < g_date->OldDays() + g_date->DayInYear(15, 9)) {
192  d1 = g_date->OldDays() + g_date->DayInYear(15, 9);
193  }
194  SimpleEvent_(d1, nl_tu_autumn_plough, false, a_farm, a_field);
195  break;
196  case nl_tu_autumn_plough:
197  if (a_ev->m_lock || a_farm->DoIt_prob(0.80))
198  {
199  if (!a_farm->AutumnPlough(a_field, 0.0, g_date->DayInYear(31, 10) - g_date->DayInYear())) {
200  SimpleEvent_(g_date->Date() + 1, nl_tu_autumn_plough, true, a_farm, a_field);
201  break;
202  }
203  SimpleEvent_(g_date->Date() + 10, nl_tu_bed_forming, false, a_farm, a_field);
204  break;
205  }
206  SimpleEvent_(g_date->Date() + 1, nl_tu_autumn_heavy_stubble_cultivator, false, a_farm, a_field);
207  break;
209  if (!a_farm->StubbleCultivatorHeavy(a_field, 0.0, g_date->DayInYear(31, 10) - g_date->DayInYear())) {
210  SimpleEvent_(g_date->Date() + 1, nl_tu_autumn_heavy_stubble_cultivator, true, a_farm, a_field);
211  break;
212  }
213  SimpleEvent_(g_date->Date() + 10, nl_tu_bed_forming, false, a_farm, a_field);
214  break;
215  case nl_tu_bed_forming:
216  if (!a_farm->BedForming(a_field, 0.0, g_date->DayInYear(15, 11) - g_date->DayInYear())) {
217  SimpleEvent_(g_date->Date() + 1, nl_tu_bed_forming, true, a_farm, a_field);
218  break;
219  }
220  SimpleEvent_(g_date->Date() + 3, nl_tu_fungicide0, false, a_farm, a_field);
221  break;
222  case nl_tu_fungicide0:
223  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(15, 11) - g_date->DayInYear())) {
224  SimpleEvent_(g_date->Date() + 1, nl_tu_fungicide0, true, a_farm, a_field);
225  break;
226  }
227  SimpleEvent_(g_date->Date() + 3, nl_tu_planting, false, a_farm, a_field);
228  break;
229  case nl_tu_planting:
230  if (!a_farm->AutumnSow(a_field, 0.0, g_date->DayInYear(30, 11) - g_date->DayInYear())) {
231  SimpleEvent_(g_date->Date() + 1, nl_tu_planting, true, a_farm, a_field);
232  break;
233  }
234  // Here is a fork leading to four parallel events
235  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(20, 1) + 365, nl_tu_herbicide1, false, a_farm, a_field); // Herbicide thread
236  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(15, 3) + 365, nl_tu_insecticide1, false, a_farm, a_field); // Insecticide thread
237  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 3) + 365, nl_tu_fungicide1, false, a_farm, a_field); // Fungicide thread = MAIN THREAD
238  SimpleEvent_(g_date->Date() + 10, nl_tu_straw_covering, false, a_farm, a_field); // Flower management
239  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(25, 4) + 365, nl_tu_irrigation, false, a_farm, a_field); // Flower management
240  if (a_farm->IsStockFarmer()) //Stock Farmer
241  {
242  SimpleEvent_(g_date->Date() + 5, nl_tu_ferti_s2, false, a_farm, a_field); // Fertilizers thread
243  }
244  else SimpleEvent_(g_date->Date() + 5, nl_tu_ferti_p2, false, a_farm, a_field);
245  break;
246  case nl_tu_ferti_p2:
247  if (a_ev->m_lock || a_farm->DoIt_prob(0.40))
248  {
249  if (!a_farm->FP_PK(a_field, 0.0, g_date->DayInYear(30, 11) - g_date->DayInYear())) {
250  SimpleEvent_(g_date->Date() + 1, nl_tu_ferti_p2, true, a_farm, a_field);
251  break;
252  }
253  }
254  NL_TU_FERTI_DONE = true;
255  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(20, 1) + 365, nl_tu_ferti_p3, false, a_farm, a_field);
256  break;
257  case nl_tu_ferti_s2:
258  if (a_ev->m_lock || a_farm->DoIt_prob(0.40))
259  {
260  if (!a_farm->FA_PK(a_field, 0.0, g_date->DayInYear(30, 11) - g_date->DayInYear())) {
261  SimpleEvent_(g_date->Date() + 1, nl_tu_ferti_s2, true, a_farm, a_field);
262  break;
263  }
264  }
265  NL_TU_FERTI_DONE = true;
266  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(20, 1) + 365, nl_tu_ferti_s3, false, a_farm, a_field);
267  break;
268  case nl_tu_ferti_p3:
269  if (!a_farm->FP_AmmoniumSulphate(a_field, 0.0, g_date->DayInYear(20, 2) - g_date->DayInYear())) {
270  SimpleEvent_(g_date->Date() + 1, nl_tu_ferti_p3, true, a_farm, a_field);
271  break;
272  }
273  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(15, 3), nl_tu_ferti_p4, false, a_farm, a_field);
274  break;
275  case nl_tu_ferti_s3:
276  if (!a_farm->FA_AmmoniumSulphate(a_field, 0.0, g_date->DayInYear(20, 2) - g_date->DayInYear())) {
277  SimpleEvent_(g_date->Date() + 1, nl_tu_ferti_s3, true, a_farm, a_field);
278  break;
279  }
280  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(15, 3), nl_tu_ferti_s4, false, a_farm, a_field);
281  break;
282  case nl_tu_ferti_p4:
283  if (a_ev->m_lock || a_farm->DoIt_prob(0.60))
284  {
285  if (!a_farm->FP_AmmoniumSulphate(a_field, 0.0, g_date->DayInYear(20, 5) - g_date->DayInYear())) {
286  SimpleEvent_(g_date->Date() + 1, nl_tu_ferti_p4, true, a_farm, a_field);
287  break;
288  }
289  }
290  // End of thread
291  break;
292  case nl_tu_ferti_s4:
293  if (a_ev->m_lock || a_farm->DoIt_prob(0.60))
294  {
295  if (!a_farm->FA_AmmoniumSulphate(a_field, 0.0, g_date->DayInYear(20, 5) - g_date->DayInYear())) {
296  SimpleEvent_(g_date->Date() + 1, nl_tu_ferti_s4, true, a_farm, a_field);
297  break;
298  }
299  }
300  // End of thread
301  break;
303  if (NL_TU_FERTI_DONE == 0) {
304  SimpleEvent_(g_date->Date() + 1, nl_tu_straw_covering, false, a_farm, a_field);
305  }
306  else
307  {
308  if (!a_farm->StrawCovering(a_field, 0.0, g_date->DayInYear(20, 12) - g_date->DayInYear())) {
309  SimpleEvent_(g_date->Date() + 1, nl_tu_straw_covering, true, a_farm, a_field);
310  break;
311  }
312  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(20, 1) + 365, nl_tu_straw_removal, false, a_farm, a_field);
313  break;
314  }
315  break;
316  case nl_tu_straw_removal:
317  if (!a_farm->StrawRemoval(a_field, 0.0, g_date->DayInYear(20, 2) - g_date->DayInYear())) {
318  SimpleEvent_(g_date->Date() + 1, nl_tu_straw_removal, true, a_farm, a_field);
319  break;
320  }
321  NL_TU_STRAW_REMOVED = true;
322  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(20, 4), nl_tu_flower_cutting, false, a_farm, a_field);
323  break;
325  if (!a_farm->FlowerCutting(a_field, 0.0, g_date->DayInYear(15, 5) - g_date->DayInYear())) {
326  SimpleEvent_(g_date->Date() + 1, nl_tu_flower_cutting, true, a_farm, a_field);
327  break;
328  }
329  // End of thread
330  break;
331  case nl_tu_herbicide1: // The first of the pesticide managements.
332  // Here comes the herbicide thread
333  if (NL_TU_STRAW_REMOVED == 0) {
334  SimpleEvent_(g_date->Date() + 1, nl_tu_herbicide1, false, a_farm, a_field);
335  }
336  else
337  {
338  if (!a_farm->HerbicideTreat(a_field, 0.0, g_date->DayInYear(20, 2) - g_date->DayInYear())) {
339  SimpleEvent_(g_date->Date() + 1, nl_tu_herbicide1, true, a_farm, a_field);
340  break;
341  }
342  SimpleEvent_(g_date->Date() + 7, nl_tu_herbicide2, false, a_farm, a_field);
343  break;
344  }
345  break;
346  case nl_tu_herbicide2:
347  if (!a_farm->HerbicideTreat(a_field, 0.0, g_date->DayInYear(30, 2) - g_date->DayInYear())) {
348  SimpleEvent_(g_date->Date() + 1, nl_tu_herbicide2, true, a_farm, a_field);
349  break;
350  }
351  // End of thread
352  break;
353  case nl_tu_fungicide1:
354  // Here comes the fungicide thread
355  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(30, 3) - g_date->DayInYear())) {
356  SimpleEvent_(g_date->Date() + 1, nl_tu_fungicide1, true, a_farm, a_field);
357  break;
358  }
359  NL_TU_FUNGI_SPRAY_DATE = g_date->Date();
360  SimpleEvent_(g_date->Date(), nl_tu_added_insecticide1, false, a_farm, a_field);
361  break;
363  // here we check wheter we are using ERA pesticide or not
364  if (!cfg_pest_tulips_on.value() ||
365  !g_landscape_p->SupplyShouldSpray()) // Not using pesticide spray
366  {
367  if (!a_farm->InsecticideTreat(a_field, 0.0, g_date->DayInYear(30, 3) - g_date->DayInYear())) {
368  SimpleEvent_(g_date->Date() + 1, nl_tu_added_insecticide1, true, a_farm, a_field);
369  break;
370  }
371  }
372  else {
373  a_farm->ProductApplication(a_field, 0.0, 0, cfg_pest_product_1_amount.value(), ppp_1);
374  }
375  SimpleEvent_(g_date->Date() + 3, nl_tu_fungicide2, false, a_farm, a_field);
376  break;
377  case nl_tu_fungicide2:
378  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(30, 3) - g_date->DayInYear())) {
379  SimpleEvent_(g_date->Date() + 1, nl_tu_fungicide2, true, a_farm, a_field);
380  break;
381  }
382  NL_TU_FUNGI_SPRAY_DATE = g_date->Date();
383  SimpleEvent_(g_date->Date(), nl_tu_added_insecticide2, false, a_farm, a_field);
384  break;
386  // here we check wheter we are using ERA pesticide or not
387  if (!cfg_pest_tulips_on.value() ||
388  !g_landscape_p->SupplyShouldSpray()) // Not using pesticide spray
389  {
390  if (!a_farm->InsecticideTreat(a_field, 0.0, g_date->DayInYear(30, 3) - g_date->DayInYear())) {
391  SimpleEvent_(g_date->Date() + 1, nl_tu_added_insecticide2, true, a_farm, a_field);
392  break;
393  }
394  }
395  else {
396  a_farm->ProductApplication(a_field, 0.0, 0, cfg_pest_product_1_amount.value(), ppp_1);
397  }
398  SimpleEvent_(g_date->Date() + 3, nl_tu_fungicide3, false, a_farm, a_field);
399  break;
400  case nl_tu_fungicide3:
401  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(30, 3) - g_date->DayInYear())) {
402  SimpleEvent_(g_date->Date() + 1, nl_tu_fungicide3, true, a_farm, a_field);
403  break;
404  }
405  NL_TU_FUNGI_SPRAY_DATE = g_date->Date();
406  SimpleEvent_(g_date->Date(), nl_tu_added_insecticide3, false, a_farm, a_field);
407  break;
409  // here we check wheter we are using ERA pesticide or not
410  if (!cfg_pest_tulips_on.value() ||
411  !g_landscape_p->SupplyShouldSpray()) // Not using pesticide spray
412  {
413  if (!a_farm->InsecticideTreat(a_field, 0.0, g_date->DayInYear(30, 3) - g_date->DayInYear())) {
414  SimpleEvent_(g_date->Date() + 1, nl_tu_added_insecticide3, true, a_farm, a_field);
415  break;
416  }
417  }
418  else {
419  a_farm->ProductApplication(a_field, 0.0, 0, cfg_pest_product_1_amount.value(), ppp_1);
420  }
421  d1 = g_date->Date() + 3;
422  if (d1 < g_date->OldDays() + g_date->DayInYear(15, 3)) {
423  d1 = g_date->OldDays() + g_date->DayInYear(15, 3);
424  }
425  SimpleEvent_(d1, nl_tu_fungicide4, false, a_farm, a_field);
426  break;
427  case nl_tu_fungicide4:
428  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(5, 5) - g_date->DayInYear())) {
429  SimpleEvent_(g_date->Date() + 1, nl_tu_fungicide4, true, a_farm, a_field);
430  break;
431  }
432  NL_TU_FUNGI_SPRAY_DATE = g_date->Date();
433  SimpleEvent_(g_date->Date(), nl_tu_added_insecticide4, false, a_farm, a_field);
434  break;
436  // here we check wheter we are using ERA pesticide or not
437  if (!cfg_pest_tulips_on.value() ||
438  !g_landscape_p->SupplyShouldSpray()) // Not using pesticide spray
439  {
440  if (!a_farm->InsecticideTreat(a_field, 0.0, g_date->DayInYear(5, 5) - g_date->DayInYear())) {
441  SimpleEvent_(g_date->Date() + 1, nl_tu_added_insecticide4, true, a_farm, a_field);
442  break;
443  }
444  }
445  else {
446  a_farm->ProductApplication(a_field, 0.0, 0, cfg_pest_product_1_amount.value(), ppp_1);
447  }
448  SimpleEvent_(g_date->Date() + 3, nl_tu_fungicide5, false, a_farm, a_field);
449  break;
450  case nl_tu_fungicide5:
451  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(5, 5) - g_date->DayInYear())) {
452  SimpleEvent_(g_date->Date() + 1, nl_tu_fungicide5, true, a_farm, a_field);
453  break;
454  }
455  NL_TU_FUNGI_SPRAY_DATE = g_date->Date();
456  SimpleEvent_(g_date->Date(), nl_tu_added_insecticide5, false, a_farm, a_field);
457  break;
459  // here we check wheter we are using ERA pesticide or not
460  if (!cfg_pest_tulips_on.value() ||
461  !g_landscape_p->SupplyShouldSpray()) // Not using pesticide spray
462  {
463  if (!a_farm->InsecticideTreat(a_field, 0.0, g_date->DayInYear(5, 5) - g_date->DayInYear())) {
464  SimpleEvent_(g_date->Date() + 1, nl_tu_added_insecticide5, true, a_farm, a_field);
465  break;
466  }
467  }
468  else {
469  a_farm->ProductApplication(a_field, 0.0, 0, cfg_pest_product_1_amount.value(), ppp_1);
470  }
471  SimpleEvent_(g_date->Date() + 3, nl_tu_fungicide6, false, a_farm, a_field);
472  break;
473  case nl_tu_fungicide6:
474  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(5, 5) - g_date->DayInYear())) {
475  SimpleEvent_(g_date->Date() + 1, nl_tu_fungicide6, true, a_farm, a_field);
476  break;
477  }
478  NL_TU_FUNGI_SPRAY_DATE = g_date->Date();
479  SimpleEvent_(g_date->Date(), nl_tu_added_insecticide6, false, a_farm, a_field);
480  break;
482  // here we check wheter we are using ERA pesticide or not
483  if (!cfg_pest_tulips_on.value() ||
484  !g_landscape_p->SupplyShouldSpray()) // Not using pesticide spray
485  {
486  if (!a_farm->InsecticideTreat(a_field, 0.0, g_date->DayInYear(5, 5) - g_date->DayInYear())) {
487  SimpleEvent_(g_date->Date() + 1, nl_tu_added_insecticide6, true, a_farm, a_field);
488  break;
489  }
490  }
491  else {
492  a_farm->ProductApplication(a_field, 0.0, 0, cfg_pest_product_1_amount.value(), ppp_1);
493  }
494  d1 = g_date->Date() + 3;
495  if (d1 < g_date->OldDays() + g_date->DayInYear(20, 4)) {
496  d1 = g_date->OldDays() + g_date->DayInYear(20, 4);
497  }
498  SimpleEvent_(d1, nl_tu_fungicide7, false, a_farm, a_field);
499  break;
500  case nl_tu_fungicide7:
501  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(15, 6) - g_date->DayInYear())) {
502  SimpleEvent_(g_date->Date() + 1, nl_tu_fungicide7, true, a_farm, a_field);
503  break;
504  }
505  NL_TU_FUNGI_SPRAY_DATE = g_date->Date();
506  SimpleEvent_(g_date->Date(), nl_tu_added_insecticide7, false, a_farm, a_field);
507  break;
509  // here we check wheter we are using ERA pesticide or not
510  if (!cfg_pest_tulips_on.value() ||
511  !g_landscape_p->SupplyShouldSpray()) // Not using pesticide spray
512  {
513  if (!a_farm->InsecticideTreat(a_field, 0.0, g_date->DayInYear(15, 6) - g_date->DayInYear())) {
514  SimpleEvent_(g_date->Date() + 1, nl_tu_added_insecticide7, true, a_farm, a_field);
515  break;
516  }
517  }
518  else {
519  a_farm->ProductApplication(a_field, 0.0, 0, cfg_pest_product_1_amount.value(), ppp_1);
520  }
521  SimpleEvent_(g_date->Date() + 3, nl_tu_fungicide8, false, a_farm, a_field);
522  break;
523  case nl_tu_fungicide8:
524  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(15, 6) - g_date->DayInYear())) {
525  SimpleEvent_(g_date->Date() + 1, nl_tu_fungicide8, true, a_farm, a_field);
526  break;
527  }
528  NL_TU_FUNGI_SPRAY_DATE = g_date->Date();
529  SimpleEvent_(g_date->Date(), nl_tu_added_insecticide8, false, a_farm, a_field);
530  break;
532  // here we check wheter we are using ERA pesticide or not
533  if (!cfg_pest_tulips_on.value() ||
534  !g_landscape_p->SupplyShouldSpray()) // Not using pesticide spray
535  {
536  if (!a_farm->InsecticideTreat(a_field, 0.0, g_date->DayInYear(15, 6) - g_date->DayInYear())) {
537  SimpleEvent_(g_date->Date() + 1, nl_tu_added_insecticide8, true, a_farm, a_field);
538  break;
539  }
540  }
541  else {
542  a_farm->ProductApplication(a_field, 0.0, 0, cfg_pest_product_1_amount.value(), ppp_1);
543  }
544  SimpleEvent_(g_date->Date() + 3, nl_tu_fungicide9, false, a_farm, a_field);
545  break;
546  case nl_tu_fungicide9:
547  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(15, 6) - g_date->DayInYear())) {
548  SimpleEvent_(g_date->Date() + 1, nl_tu_fungicide9, true, a_farm, a_field);
549  break;
550  }
551  NL_TU_FUNGI_SPRAY_DATE = g_date->Date();
552  SimpleEvent_(g_date->Date(), nl_tu_added_insecticide9, false, a_farm, a_field);
553  break;
555  // here we check wheter we are using ERA pesticide or not
556  if (!cfg_pest_tulips_on.value() ||
557  !g_landscape_p->SupplyShouldSpray()) // Not using pesticide spray
558  {
559  if (!a_farm->InsecticideTreat(a_field, 0.0, g_date->DayInYear(15, 6) - g_date->DayInYear())) {
560  SimpleEvent_(g_date->Date() + 1, nl_tu_added_insecticide9, true, a_farm, a_field);
561  break;
562  }
563  }
564  else {
565  a_farm->ProductApplication(a_field, 0.0, 0, cfg_pest_product_1_amount.value(), ppp_1);
566  }
567  SimpleEvent_(g_date->Date() + 3, nl_tu_fungicide10, false, a_farm, a_field);
568  break;
569  case nl_tu_fungicide10:
570  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(15, 6) - g_date->DayInYear())) {
571  SimpleEvent_(g_date->Date() + 1, nl_tu_fungicide10, true, a_farm, a_field);
572  break;
573  }
574  NL_TU_FUNGI_SPRAY_DATE = g_date->Date();
575  SimpleEvent_(g_date->Date(), nl_tu_added_insecticide10, false, a_farm, a_field);
576  break;
578  // here we check wheter we are using ERA pesticide or not
579  if (!cfg_pest_tulips_on.value() ||
580  !g_landscape_p->SupplyShouldSpray()) // Not using pesticide spray
581  {
582  if (!a_farm->InsecticideTreat(a_field, 0.0, g_date->DayInYear(15, 6) - g_date->DayInYear())) {
583  SimpleEvent_(g_date->Date() + 1, nl_tu_added_insecticide10, true, a_farm, a_field);
584  break;
585  }
586  }
587  else {
588  a_farm->ProductApplication(a_field, 0.0, 0, cfg_pest_product_1_amount.value(), ppp_1);
589  }
590  d1 = g_date->Date() + 7;
591  if (d1 < g_date->OldDays() + g_date->DayInYear(10, 6)) {
592  d1 = g_date->OldDays() + g_date->DayInYear(10, 6);
593  }
594  SimpleEvent_(d1, nl_tu_harvest, false, a_farm, a_field); break;
595 
596  case nl_tu_insecticide1:
597  if (NL_TU_FUNGI_SPRAY_DATE >= g_date->Date() - 2) { // Should by at least 3 days after fungicide + insecticide
598  SimpleEvent_(g_date->Date() + 1, nl_tu_insecticide1, false, a_farm, a_field);
599  }
600  else
601  {
602  if (a_ev->m_lock || a_farm->DoIt_prob(0.90))
603  {
604  // here we check wheter we are using ERA pesticide or not
605  if (!cfg_pest_tulips_on.value() ||
606  !g_landscape_p->SupplyShouldSpray()) // Not using pesticide spray
607  {
608  if (!a_farm->InsecticideTreat(a_field, 0.0, g_date->DayInYear(20, 4) - g_date->DayInYear())) {
609  SimpleEvent_(g_date->Date() + 1, nl_tu_insecticide1, true, a_farm, a_field);
610  break;
611  }
612  }
613  else {
614  a_farm->ProductApplication(a_field, 0.0, 0, cfg_pest_product_1_amount.value(), ppp_1);
615  }
616  }
617  d1 = g_date->Date() + 7;
618  if (d1 < g_date->OldDays() + g_date->DayInYear(20, 4)) {
619  d1 = g_date->OldDays() + g_date->DayInYear(20, 4);
620  }
621  SimpleEvent_(d1, nl_tu_insecticide2, false, a_farm, a_field);
622  break;
623  }
624  break;
625  case nl_tu_insecticide2:
626  if (NL_TU_FUNGI_SPRAY_DATE >= g_date->Date() - 2) { // Should by at least 3 days after fungicide + insecticide
627  SimpleEvent_(g_date->Date() + 1, nl_tu_insecticide2, false, a_farm, a_field);
628  }
629  else
630  {
631  // here we check wheter we are using ERA pesticide or not
632  if (!cfg_pest_tulips_on.value() ||
633  !g_landscape_p->SupplyShouldSpray()) // Not using pesticide spray
634  {
635  if (!a_farm->InsecticideTreat(a_field, 0.0, g_date->DayInYear(15, 5) - g_date->DayInYear())) {
636  SimpleEvent_(g_date->Date() + 1, nl_tu_insecticide2, true, a_farm, a_field);
637  break;
638  }
639  }
640  else {
641  a_farm->ProductApplication(a_field, 0.0, 0, cfg_pest_product_1_amount.value(), ppp_1);
642  }
643  }
644  // End of thread
645  break;
646  case nl_tu_irrigation:
647  if (a_ev->m_lock || a_farm->DoIt_prob(0.25))
648  {
649  if (!a_farm->Water(a_field, 0.0, g_date->DayInYear(25, 4) - g_date->DayInYear())) {
650  SimpleEvent_(g_date->Date() + 1, nl_tu_irrigation, true, a_farm, a_field);
651  break;
652  }
653  }
654  // End of thread
655  break;
656  case nl_tu_harvest:
657  // Here the MAIN thread continues
658  // We don't move harvest days
659  if (!a_farm->BulbHarvest(a_field, 0.0, a_field->GetMDates(0, 0) - g_date->DayInYear())) {
660  SimpleEvent_(g_date->Date() + 1, nl_tu_harvest, true, a_farm, a_field);
661  break;
662  }
663  d1 = g_date->Date();
664  if (d1 <= g_date->OldDays() + g_date->DayInYear(1, 7)) {
665  SimpleEvent_(d1, nl_tu_sleep_all_day, false, a_farm, a_field);
666  break;
667  }
668  else {
669  done = true;
670  break;
671  }
672  break;
673  case nl_tu_sleep_all_day:
674  if (!a_farm->SleepAllDay(a_field, 0.0, g_date->DayInYear(5, 7) - g_date->DayInYear())) {
675  SimpleEvent_(g_date->Date() + 1, nl_tu_sleep_all_day, true, a_farm, a_field);
676  break;
677  }
678  done = true;
679  break;
680  default:
681  g_msg->Warn(WARN_BUG, "NLTulips::Do(): "
682  "Unknown event type! ", "");
683  exit(1);
684  }
685  return done;
686 }

References Farm::AutumnPlough(), Landscape::BackTranslateVegTypes(), cfg_pest_product_1_amount, cfg_pest_tulips_on, Farm::DoIt_prob(), Farm::FA_Manure(), Farm::FP_Manure(), g_landscape_p, Farm::GetType(), Farm::IsStockFarmer(), Crop::m_first_date, FarmEvent::m_first_year, FarmEvent::m_lock, FarmEvent::m_next_tov, FarmEvent::m_startday, FarmEvent::m_todo, nl_tu_added_insecticide1, nl_tu_added_insecticide10, nl_tu_added_insecticide2, nl_tu_added_insecticide3, nl_tu_added_insecticide4, nl_tu_added_insecticide5, nl_tu_added_insecticide6, nl_tu_added_insecticide7, nl_tu_added_insecticide8, nl_tu_added_insecticide9, nl_tu_autumn_heavy_stubble_cultivator, NL_TU_AUTUMN_PLOUGH, nl_tu_autumn_plough, nl_tu_bed_forming, NL_TU_FERTI_DONE, nl_tu_ferti_p1, nl_tu_ferti_p2, nl_tu_ferti_p3, nl_tu_ferti_p4, nl_tu_ferti_s1, nl_tu_ferti_s2, nl_tu_ferti_s3, nl_tu_ferti_s4, nl_tu_flower_cutting, NL_TU_FUNGI_SPRAY_DATE, nl_tu_fungicide0, nl_tu_fungicide1, nl_tu_fungicide10, nl_tu_fungicide2, nl_tu_fungicide3, nl_tu_fungicide4, nl_tu_fungicide5, nl_tu_fungicide6, nl_tu_fungicide7, nl_tu_fungicide8, nl_tu_fungicide9, nl_tu_harvest, nl_tu_herbicide1, nl_tu_herbicide2, nl_tu_insecticide1, nl_tu_insecticide2, nl_tu_irrigation, nl_tu_planting, nl_tu_sleep_all_day, nl_tu_start, nl_tu_straw_covering, nl_tu_straw_removal, NL_TU_STRAW_REMOVED, ppp_1, Crop::SimpleEvent_(), Landscape::SupplyShouldSpray(), and tof_OptimisingFarm.


The documentation for this class was generated from the following files:
NL_TU_AUTUMN_PLOUGH
#define NL_TU_AUTUMN_PLOUGH
A flag used to indicate autumn ploughing status.
Definition: NLTulips.h:28
nl_tu_added_insecticide10
Definition: NLTulips.h:72
Farm::IsStockFarmer
bool IsStockFarmer(void)
Definition: farm.h:905
nl_tu_ferti_p2
Definition: NLTulips.h:75
FarmEvent::m_lock
bool m_lock
Definition: farm.h:465
nl_tu_ferti_s2
Definition: NLTulips.h:76
Landscape::SupplyShouldSpray
bool SupplyShouldSpray()
Definition: Landscape.h:357
nl_tu_added_insecticide8
Definition: NLTulips.h:70
NL_TU_FUNGI_SPRAY_DATE
#define NL_TU_FUNGI_SPRAY_DATE
Definition: NLTulips.h:31
FarmEvent::m_first_year
bool m_first_year
Definition: farm.h:467
tof_OptimisingFarm
Definition: farm.h:273
nl_tu_added_insecticide6
Definition: NLTulips.h:68
Farm::DoIt_prob
bool DoIt_prob(double a_probability)
Return chance out of 0 to 1.
Definition: farm.cpp:808
nl_tu_herbicide1
Definition: NLTulips.h:51
nl_tu_start
Definition: NLTulips.h:39
Landscape::BackTranslateVegTypes
int BackTranslateVegTypes(TTypesOfVegetation VegReference)
Definition: Landscape.h:1669
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
nl_tu_fungicide7
Definition: NLTulips.h:59
Farm::GetType
TTypesOfFarm GetType(void)
Definition: farm.h:901
Crop::m_first_date
int m_first_date
Definition: farm.h:540
FarmEvent::m_startday
int m_startday
Definition: farm.h:466
nl_tu_flower_cutting
Definition: NLTulips.h:81
NL_TU_FERTI_DONE
#define NL_TU_FERTI_DONE
Definition: NLTulips.h:29
nl_tu_ferti_s1
Definition: NLTulips.h:48
nl_tu_autumn_heavy_stubble_cultivator
Definition: NLTulips.h:43
Farm::FP_Manure
virtual bool FP_Manure(LE *a_field, double a_user, int a_days)
Spread manure on a_field owned by an arable farmer.
Definition: farmfuncs.cpp:773
nl_tu_fungicide0
Definition: NLTulips.h:45
nl_tu_fungicide8
Definition: NLTulips.h:60
NL_TU_STRAW_REMOVED
#define NL_TU_STRAW_REMOVED
Definition: NLTulips.h:30
nl_tu_fungicide5
Definition: NLTulips.h:57
cfg_pest_product_1_amount
CfgFloat cfg_pest_product_1_amount
nl_tu_straw_removal
Definition: NLTulips.h:50
nl_tu_insecticide2
Definition: NLTulips.h:74
nl_tu_added_insecticide7
Definition: NLTulips.h:69
nl_tu_sleep_all_day
Definition: NLTulips.h:40
nl_tu_added_insecticide2
Definition: NLTulips.h:64
nl_tu_ferti_p3
Definition: NLTulips.h:77
nl_tu_bed_forming
Definition: NLTulips.h:44
nl_tu_fungicide1
Definition: NLTulips.h:53
nl_tu_herbicide2
Definition: NLTulips.h:52
FarmEvent::m_next_tov
TTypesOfVegetation m_next_tov
Definition: farm.h:471
nl_tu_fungicide9
Definition: NLTulips.h:61
nl_tu_autumn_plough
Definition: NLTulips.h:42
FarmEvent::m_todo
int m_todo
Definition: farm.h:469
nl_tu_added_insecticide4
Definition: NLTulips.h:66
nl_tu_fungicide3
Definition: NLTulips.h:55
ppp_1
Definition: farm.h:422
nl_tu_harvest
Definition: NLTulips.h:83
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
nl_tu_added_insecticide9
Definition: NLTulips.h:71
nl_tu_irrigation
Definition: NLTulips.h:82
nl_tu_added_insecticide1
Definition: NLTulips.h:63
nl_tu_ferti_s3
Definition: NLTulips.h:78
nl_tu_fungicide2
Definition: NLTulips.h:54
nl_tu_insecticide1
Definition: NLTulips.h:73
nl_tu_straw_covering
Definition: NLTulips.h:49
nl_tu_planting
Definition: NLTulips.h:46
nl_tu_added_insecticide5
Definition: NLTulips.h:67
nl_tu_ferti_p4
Definition: NLTulips.h:79
nl_tu_ferti_p1
Definition: NLTulips.h:47
cfg_pest_tulips_on
CfgBool cfg_pest_tulips_on
nl_tu_ferti_s4
Definition: NLTulips.h:80
nl_tu_fungicide4
Definition: NLTulips.h:56
nl_tu_added_insecticide3
Definition: NLTulips.h:65
nl_tu_fungicide10
Definition: NLTulips.h:62
g_landscape_p
Landscape * g_landscape_p
Definition: Landscape.cpp:258
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
nl_tu_fungicide6
Definition: NLTulips.h:58