File failed to load: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/extensions/ams.js
ALMaSS  1.2 (after EcoStack, March 2024)
The Animal, Landscape and Man Simulation System
All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BEPotatoes Class Reference

BEPotatoes class
. More...

#include <BEPotatoes.h>

Inheritance diagram for BEPotatoes:
Crop

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...
 
 BEPotatoes (TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape *a_L)
 
- Public Member Functions inherited from Crop
virtual ~Crop ()
 
 Crop (TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape *a_L)
 
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)
 
void GetCropType (TTypesOfCrops a_toc)
 
TTypesOfCrops GetCropType ()
 
FarmManagementCategory LookUpManagementCategory (int a_todo)
 
bool GetForceSpringOK ()
 

Additional Inherited Members

- Public Attributes inherited from Crop
TTypesOfVegetation m_tov
 
- 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...
 
bool StartUpCrop (int a_spring, std::vector< std::vector< int >> a_flexdates, int a_todo)
 
Holds the translation between the farm operation enum for each cropand the farm management category associated with it More...
 
bool AphidDamage (LE *a_field)
 Compares aphid numbers per m2 with a threshold to return true if threshold is exceeded. More...
 
- Protected Attributes inherited from Crop
Farmm_farm
 
LEm_field
 
FarmEventm_ev
 
int m_first_date
 
int m_count
 
int m_last_date
 
int m_ddegstoharvest
 
int m_base_elements_no
 
Landscapem_OurLandscape
 
bool m_forcespringpossible = false
 Used to signal that the crop can be forced to start in spring. More...
 
TTypesOfCrops m_toc
 The Crop type in terms of the TTypesOfCrops list (smaller list than tov, no country designation) More...
 
int m_CropClassification
 Contains information on whether this is a winter crop, spring crop, or catch crop that straddles the year boundary (0,1,2) More...
 
vector< FarmManagementCategorym_ManagementCategories
 Holds the translation between the farm operation enum for each crop and the farm management category associated with it. More...
 
- Static Protected Attributes inherited from Crop
static int m_date_modifier = 0
 Holds a value that shifts test pesticide use by this many days in crops modified to use it. More...
 

Detailed Description

BEPotatoes class
.

See BEPotatoes.h::BEPotatoesToDo 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

◆ BEPotatoes()

BEPotatoes::BEPotatoes ( TTypesOfVegetation  a_tov,
TTypesOfCrops  a_toc,
Landscape a_L 
)
inline
97  : Crop(a_tov, a_toc, a_L)
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 Calendar::DayInYear(), g_date, and Crop::m_first_date.

Member Function Documentation

◆ Do()

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

References BE_pot_bed_forming, BE_pot_dessication1, BE_pot_dessication2, BE_pot_ferti_p1_sandy, BE_pot_ferti_p2_clay, BE_pot_ferti_p2_sandy, BE_pot_ferti_p3_clay, BE_pot_ferti_p3_sandy, BE_pot_ferti_p4, BE_pot_ferti_s1_sandy, BE_pot_ferti_s2_clay, BE_pot_ferti_s2_sandy, BE_pot_ferti_s3_clay, BE_pot_ferti_s3_sandy, BE_pot_ferti_s4, BE_POT_FUNGI1, BE_POT_FUNGI2, BE_POT_FUNGI3, BE_POT_FUNGI4, BE_POT_FUNGI5, BE_pot_fungicide1, BE_pot_fungicide10, BE_pot_fungicide11, BE_pot_fungicide12, BE_pot_fungicide13, BE_pot_fungicide14, BE_pot_fungicide15, BE_pot_fungicide2, BE_pot_fungicide3, BE_pot_fungicide4, BE_pot_fungicide5, BE_pot_fungicide6, BE_pot_fungicide7, BE_pot_fungicide8, BE_pot_fungicide9, BE_pot_harvest, BE_POT_HERBI, BE_pot_herbicide1, BE_pot_hilling1, BE_pot_insecticide, BE_pot_spring_planting, BE_pot_spring_plough_sandy, BE_pot_start, BE_pot_stubble_harrow, BE_pot_winter_plough_clay, BE_pot_winter_plough_sandy, Farm::BiocideTreat(), cfg_pest_potatoes_on, cfg_pest_product_amounts, Calendar::Date(), Calendar::DayInYear(), Farm::DoIt_prob(), g_date, g_msg, LE::GetMDates(), LE::GetOwner(), LE::GetPoly(), Farm::GetPreviousTov(), LE::GetRotIndex(), LE::GetSoilType(), Farm::GetType(), Calendar::GetYearNumber(), Farm::InsecticideTreat(), Crop::m_date_modifier, Crop::m_ev, 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, Calendar::OldDays(), ppp_1, Farm::ProductApplication(), LE::SetMConstants(), LE::SetMDates(), Crop::SimpleEvent_(), Farm::StubbleHarrowing(), tof_OptimisingFarm, tov_BEPotatoes, CfgBool::value(), CfgArray_Double::value(), MapErrorMsg::Warn(), WARN_BUG, and Farm::WinterPlough().


The documentation for this class was generated from the following files:
LE::GetMDates
int GetMDates(int a, int b)
Definition: Elements.h:405
BE_pot_dessication2
Definition: BEPotatoes.h:80
LE::SetMDates
void SetMDates(int a, int b, int c)
Definition: Elements.h:406
BE_pot_fungicide6
Definition: BEPotatoes.h:68
FarmEvent::m_lock
bool m_lock
Definition: Farm.h:384
BE_pot_fungicide13
Definition: BEPotatoes.h:75
Farm::ProductApplication
virtual bool ProductApplication(LE *a_field, double a_user, int a_days, double a_applicationrate, PlantProtectionProducts a_ppp, bool a_isgranularpesticide=false, int a_orcharddrifttype=0)
Apply test pesticide to a_field.
Definition: FarmFuncs.cpp:2267
cfg_pest_potatoes_on
CfgBool cfg_pest_potatoes_on
Turn on pesticides for potatoes.
BE_pot_spring_plough_sandy
Definition: BEPotatoes.h:50
Calendar::GetYearNumber
int GetYearNumber(void)
Definition: Calendar.h:72
FarmEvent::m_first_year
bool m_first_year
Definition: Farm.h:386
BE_pot_fungicide11
Definition: BEPotatoes.h:73
LE::GetPoly
int GetPoly(void)
Returns the polyref number for this polygon.
Definition: Elements.h:238
BE_pot_fungicide14
Definition: BEPotatoes.h:76
Farm::DoIt_prob
bool DoIt_prob(double a_probability)
Return chance out of 0 to 1.
Definition: Farm.cpp:864
g_date
class Calendar * g_date
Definition: Calendar.cpp:37
BE_pot_ferti_p3_clay
Definition: BEPotatoes.h:56
Farm::GetPreviousTov
TTypesOfVegetation GetPreviousTov(int a_index)
Definition: Farm.h:966
Farm::GetType
TTypesOfFarm GetType(void)
Definition: Farm.h:956
cfg_pest_product_amounts
CfgArray_Double cfg_pest_product_amounts
Amount of pesticide applied in grams of active substance per hectare for each of the 10 pesticides.
BE_POT_FUNGI1
#define BE_POT_FUNGI1
Definition: BEPotatoes.h:29
BE_pot_insecticide
Definition: BEPotatoes.h:78
BE_pot_fungicide1
Definition: BEPotatoes.h:63
Crop::m_first_date
int m_first_date
Definition: Farm.h:501
FarmEvent::m_startday
int m_startday
Definition: Farm.h:385
BE_POT_FUNGI3
#define BE_POT_FUNGI3
Definition: BEPotatoes.h:31
BE_POT_FUNGI2
#define BE_POT_FUNGI2
Definition: BEPotatoes.h:30
BE_pot_ferti_p1_sandy
Definition: BEPotatoes.h:48
CfgBool::value
bool value() const
Definition: Configurator.h:164
tov_BEPotatoes
Definition: LandscapeFarmingEnums.h:299
BE_POT_FUNGI5
#define BE_POT_FUNGI5
Definition: BEPotatoes.h:33
BE_pot_herbicide1
Definition: BEPotatoes.h:62
BE_pot_fungicide8
Definition: BEPotatoes.h:70
BE_pot_fungicide7
Definition: BEPotatoes.h:69
BE_pot_spring_planting
Definition: BEPotatoes.h:54
Calendar::Date
long Date(void)
Definition: Calendar.h:57
LE::GetSoilType
int GetSoilType()
Definition: Elements.h:302
BE_pot_harvest
Definition: BEPotatoes.h:81
Calendar::OldDays
long OldDays(void)
Definition: Calendar.h:60
BE_pot_winter_plough_clay
Definition: BEPotatoes.h:45
BE_pot_ferti_s2_sandy
Definition: BEPotatoes.h:52
MapErrorMsg::Warn
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: MapErrorMsg.cpp:69
LE::GetRotIndex
int GetRotIndex(void)
Definition: Elements.h:373
BE_POT_FUNGI4
#define BE_POT_FUNGI4
Definition: BEPotatoes.h:32
BE_POT_HERBI
#define BE_POT_HERBI
A flag used to indicate autumn ploughing status.
Definition: BEPotatoes.h:28
BE_pot_fungicide4
Definition: BEPotatoes.h:66
BE_pot_ferti_s3_sandy
Definition: BEPotatoes.h:59
FarmEvent::m_next_tov
TTypesOfVegetation m_next_tov
Definition: Farm.h:390
Crop::m_farm
Farm * m_farm
Definition: Farm.h:498
Crop::m_field
LE * m_field
Definition: Farm.h:499
CfgArray_Double::value
std::vector< double > value() const
Definition: Configurator.h:219
FarmEvent::m_todo
int m_todo
Definition: Farm.h:388
Farm::InsecticideTreat
virtual bool InsecticideTreat(LE *a_field, double a_user, int a_days)
Apply insecticide to a_field.
Definition: FarmFuncs.cpp:2135
BE_pot_start
Definition: BEPotatoes.h:41
BE_pot_fungicide12
Definition: BEPotatoes.h:74
BE_pot_fungicide10
Definition: BEPotatoes.h:72
Farm::BiocideTreat
virtual bool BiocideTreat(LE *a_field, double a_user, int a_days)
Apply Biocide to a_field.
Definition: FarmFuncs.cpp:2175
BE_pot_fungicide2
Definition: BEPotatoes.h:64
tof_OptimisingFarm
Definition: LandscapeFarmingEnums.h:696
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
BE_pot_ferti_s3_clay
Definition: BEPotatoes.h:57
BE_pot_hilling1
Definition: BEPotatoes.h:55
BE_pot_fungicide15
Definition: BEPotatoes.h:77
TTypesOfVegetation
TTypesOfVegetation
Values that represent the types of vegetation that are represented in ALMaSS.
Definition: LandscapeFarmingEnums.h:192
BE_pot_ferti_p3_sandy
Definition: BEPotatoes.h:58
BE_pot_fungicide9
Definition: BEPotatoes.h:71
BE_pot_ferti_s2_clay
Definition: BEPotatoes.h:47
Crop::m_date_modifier
static int m_date_modifier
Holds a value that shifts test pesticide use by this many days in crops modified to use it.
Definition: Farm.h:514
BE_pot_fungicide5
Definition: BEPotatoes.h:67
Farm::WinterPlough
virtual bool WinterPlough(LE *a_field, double a_user, int a_days)
Carry out a ploughing event in the winter on a_field.
Definition: FarmFuncs.cpp:395
BE_pot_fungicide3
Definition: BEPotatoes.h:65
BE_pot_ferti_p2_sandy
Definition: BEPotatoes.h:51
BE_pot_ferti_s1_sandy
Definition: BEPotatoes.h:49
LE::GetOwner
Farm * GetOwner(void)
Definition: Elements.h:256
Calendar::DayInYear
int DayInYear(void)
Definition: Calendar.h:58
BE_pot_ferti_p4
Definition: BEPotatoes.h:60
BE_pot_ferti_p2_clay
Definition: BEPotatoes.h:46
BE_pot_stubble_harrow
Definition: BEPotatoes.h:43
Crop::Crop
Crop(TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape *a_L)
Definition: Farm.cpp:733
BE_pot_dessication1
Definition: BEPotatoes.h:79
BE_pot_bed_forming
Definition: BEPotatoes.h:53
LE::SetMConstants
void SetMConstants(int a, int c)
Definition: Elements.h:408
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
BE_pot_winter_plough_sandy
Definition: BEPotatoes.h:44
WARN_BUG
Definition: MapErrorMsg.h:34
ppp_1
Definition: LandscapeFarmingEnums.h:1079
BE_pot_ferti_s4
Definition: BEPotatoes.h:61
Farm::StubbleHarrowing
virtual bool StubbleHarrowing(LE *a_field, double a_user, int a_days)
Carry out stubble harrowing on a_field.
Definition: FarmFuncs.cpp:1523
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:751