Loading [MathJax]/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
Potatoes Class Reference

#include <Potatoes.h>

Inheritance diagram for Potatoes:
Crop

Public Member Functions

bool Do (Farm *a_farm, LE *a_field, FarmEvent *a_ev)
 
 Potatoes (TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape *a_L)
 
void SetUpFarmCategoryInformation ()
 
- 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...
 

Constructor & Destructor Documentation

◆ Potatoes()

Potatoes::Potatoes ( TTypesOfVegetation  a_tov,
TTypesOfCrops  a_toc,
Landscape a_L 
)
inline
77  : Crop(a_tov, a_toc, a_L)
78  {
81  }

References Calendar::DayInYear(), g_date, Crop::m_first_date, and SetUpFarmCategoryInformation().

Member Function Documentation

◆ Do()

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

Reimplemented from Crop.

39 {
40  m_farm = a_farm;
41  m_field = a_field;
42  m_ev = a_ev;
43 
44  bool done = false;
45 
46  switch ( m_ev->m_todo ) {
47  case pe_start:
48  {
49  POT_SLURRY_DATE = 0;
50  POT_HERBI_DATE = 0;
51  POT_STRIG_DATE = 0;
52  POT_HILL_DATE = 0;
53  POT_DID_TREAT = false;
54  POT_DID_HILL = false;
55  a_field->ClearManagementActionSum();
56 
57  m_field->SetVegPatchy(true); // root crop
58 
59  // Set up the date management stuff
61  // Start and stop dates for all events after harvest
62  int noDates= 1;
63  m_field->SetMDates(0,0,g_date->DayInYear(25,9));
64  // Determined by harvest date - used to see if at all possible
65  m_field->SetMDates(1,0,g_date->DayInYear(24,10));
66  // Check the next crop for early start, unless it is a spring crop
67  // in which case we ASSUME that no checking is necessary!!!!
68  // So DO NOT implement a crop that runs over the year boundary
69 
70  //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)
71  int d1;
73 
74  if (m_ev->m_startday>g_date->DayInYear(1,7))
75  {
76  if (m_field->GetMDates(0,0) >=m_ev->m_startday)
77  {
78  char veg_type[20];
79  sprintf(veg_type, "%d", m_ev->m_next_tov);
80  g_msg->Warn( WARN_BUG, "Potatoes::Do(): : Harvest too late for the next crop to start!!! The next crop is: ", veg_type);
81  exit( 1 );
82  }
83  // Now fix any late finishing problems
84  for (int i=0; i<noDates; i++) {
85  if(m_field->GetMDates(0,i)>=m_ev->m_startday) {
86  m_field->SetMDates(0,i,m_ev->m_startday-1); //move the starting date
87  }
88  if(m_field->GetMDates(1,i)>=m_ev->m_startday){
89  m_field->SetMConstants(i,0);
90  m_field->SetMDates(1,i,m_ev->m_startday-1); //move the finishing date
91  }
92  }
93  }
94  // Now no operations can be timed after the start of the next crop.
95 
96  if ( ! m_ev->m_first_year )
97  {
98  int today=g_date->Date();
99  // Are we before July 1st?
100  d1 = g_date->OldDays() + g_date->DayInYear( 1,7 );
101  if (today < d1)
102  {
103  // Yes, too early. We assumme this is because the last crop was late
104  g_msg->Warn( WARN_BUG, "Potatoes::Do(): "
105  "Crop start attempt between 1st Jan & 1st July", "" );
106  exit( 1 );
107  }
108  else
109  {
110  d1 = g_date->OldDays() + m_first_date; // Add 365 for spring crop
111  if (today > d1)
112  {
113  // Yes too late - should not happen - raise an error
114  g_msg->Warn( WARN_BUG, "Potatoes::Do(): "
115  "Crop start attempt after last possible start date", "" );
116  exit( 1 );
117  }
118  }
119  }
120  else
121  {
123  pe_spring_plough, false );
124  break;
125  }
126  }//if
127 
128  // End single block date checking code. Please see next line
129  // comment as well.
130  // Reinit d1 to first possible starting date.
131  d1 = g_date->OldDays() + m_first_date; // Add 365 for spring crop
132  if ( g_date->Date() > d1 ) {
133  d1 = g_date->Date();
134  }
135  // OK, let's go.
136 
137  if ( m_farm->DoIt( 75 )) {
138  SimpleEvent( d1,pe_autumn_plough, false );
139  } else {
140  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 1, 3 ) + 365,
141  pe_spring_plough, false );
142  }
143  }
144  break;
145 
146  case pe_autumn_plough:
147  if (!m_farm->AutumnPlough( m_field, 0.0,
148  g_date->DayInYear( 1, 12 ) -
149  g_date->DayInYear())) {
150  SimpleEvent( g_date->Date() + 1, pe_autumn_plough, false );
151  break;
152  }
153  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 20, 3 ) + 365,
154  pe_spring_harrow, false );
155  break;
156 
157  case pe_spring_plough:
158  if (!m_farm->SpringPlough( m_field, 0.0,
159  g_date->DayInYear( 15, 4 ) -
160  g_date->DayInYear())) {
161  SimpleEvent( g_date->Date() + 1, pe_spring_plough, false );
162  break;
163  }
164  {
165  int d1 = g_date->OldDays() + g_date->DayInYear( 20, 3 );
166  if ( g_date->Date() > d1 ) {
167  d1 = g_date->Date();
168  }
169  SimpleEvent( d1, pe_spring_harrow, false );
170  }
171  break;
172 
173  case pe_spring_harrow:
174  if (!m_farm->SpringHarrow( m_field, 0.0,
175  g_date->DayInYear( 24, 4 ) - g_date->DayInYear())) {
176  SimpleEvent( g_date->Date() + 1, pe_spring_harrow, false );
177  break;
178  }
179  if ( m_farm->IsStockFarmer()) {
180  // Do fa_slurry before sowing.
181  int d1 = g_date->OldDays() + g_date->DayInYear( 27, 3 );
182  if ( g_date->Date() > d1 ) {
183  d1 = g_date->Date();
184  }
185  SimpleEvent( d1, pe_fa_slurry, false );
186  } else {
187  int d1 = g_date->OldDays() + g_date->DayInYear( 1, 4 );
188  if ( g_date->Date() > d1 ) {
189  d1 = g_date->Date();
190  }
191  SimpleEvent( d1, pe_spring_sow, false );
192  }
193  break;
194 
195  case pe_fa_slurry:
196  if ( m_ev->m_lock || m_farm->DoIt( 30 )) {
197  if (!m_farm->FA_Slurry( m_field, 0.0,
198  g_date->DayInYear( 1, 5 ) -
199  g_date->DayInYear())) {
200  SimpleEvent( g_date->Date() + 1, pe_fa_slurry, true );
201  break;
202  }
204  }
205  {
206  int d1 = g_date->OldDays() + g_date->DayInYear( 1, 4 );
207  if ( g_date->Date() > d1 ) {
208  d1 = g_date->Date();
209  }
210  SimpleEvent( d1, pe_spring_sow, false );
211  }
212  break;
213 
214  case pe_spring_sow:
215  {
216  int time_to_waste;
217  if ( POT_SLURRY_DATE ) {
218  time_to_waste = POT_SLURRY_DATE + 3;
219  if ( time_to_waste > g_date->DayInYear( 1, 5 )) {
220  time_to_waste = g_date->DayInYear( 1, 5 );
221  }
222  } else {
223  time_to_waste = g_date->DayInYear( 1, 5 );
224  }
225  if (!m_farm->SpringSow( m_field, 0.0,
226  time_to_waste -
227  g_date->DayInYear())) {
228  SimpleEvent( g_date->Date() + 1, pe_spring_sow, false );
229  break;
230  }
231  // Did sowing, now add fa/fp_npk as well today.
232  if ( m_farm->IsStockFarmer()) {
233  m_farm->FA_NPK( m_field, 0.0, 0);
234  } else {
235  m_farm->FP_NPK( m_field, 0.0, 0);
236  }
237  }
238 
239  // Each of the three threads below need to set flags when they terminate
240  // so that the last one can start the insecticide thread
241  //
242  // Start hilling up sub thread.
243  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 15, 5 ), pe_hilling, false );
244 
245  if ( m_farm->DoIt( 80 )) { // was 80
246  // Start herbicide treatment thread.
247  int d1 = g_date->OldDays() + g_date->DayInYear( 10, 4 );
248  if ( g_date->Date() + 10 > d1 ) {
249  d1 = g_date->Date() + 10;}
250  SimpleEvent( d1, pe_herbi_one, false );
251  } else {
252  // Strigling thread.
253  int d1 = g_date->OldDays() + g_date->DayInYear( 14, 4 );
254  if ( g_date->Date() + 10 > d1 ) {
255  d1 = g_date->Date() + 10;
256  }
257  SimpleEvent( d1, pe_strigling_one, false );
258  }
259  break;
260 
261  case pe_strigling_one:
262  if ( POT_HILL_DATE && POT_HILL_DATE >= g_date->Date() - 1 ) {
263  // Too close to hilling, try again tomorrow.
264  SimpleEvent( g_date->Date() + 1, pe_strigling_one, false );
265  break;
266  }
267  if (!m_farm->Strigling( m_field, 0.0, g_date->DayInYear( 25, 5 ) - g_date->DayInYear())) {
268  SimpleEvent( g_date->Date() + 1, pe_strigling_one, false );
269  break;
270  }
272  {
273  int d1 = g_date->OldDays() + g_date->DayInYear( 21, 4 );
274  if ( g_date->Date() + 7 > d1 ) {
275  d1 = g_date->Date() + 7;
276  }
277  SimpleEvent( d1, pe_strigling_two, false );
278  }
279  break;
280 
281  case pe_strigling_two:
282  if ( POT_HILL_DATE && POT_HILL_DATE >= g_date->Date() - 1 ) {
283  // Too close to hilling, try again tomorrow.
284  SimpleEvent( g_date->Date() + 1, pe_strigling_two, false );
285  break;
286  }
287  if (!m_farm->Strigling( m_field, 0.0,
288  g_date->DayInYear( 3, 6 ) - g_date->DayInYear())) {
289  SimpleEvent( g_date->Date() + 1, pe_strigling_two, false );
290  break;
291  }
293  {
294  int d1 = g_date->OldDays() + g_date->DayInYear( 30, 4 );
295  if ( g_date->Date() + 7 > d1 ) {
296  d1 = g_date->Date() + 7;
297  }
298  SimpleEvent( d1, pe_strigling_three, false );
299  }
300  break;
301 
302  case pe_strigling_three:
303  if ( POT_HILL_DATE && POT_HILL_DATE >= g_date->Date() - 1 ) {
304  // Too close to hilling, try again tomorrow.
305  SimpleEvent( g_date->Date() + 1, pe_strigling_three, false );
306  break;
307  }
308  if (!m_farm->Strigling( m_field, 0.0,
309  g_date->DayInYear( 12, 6 ) -
310  g_date->DayInYear())) {
311  SimpleEvent( g_date->Date() + 1, pe_strigling_three, true );
312  break;
313  }
315  POT_DID_TREAT = true;
316  if ( POT_DID_HILL && POT_DID_TREAT) {
317  // last surviving tread, start insecticide.
318  int d1 = g_date->OldDays() + g_date->DayInYear( 10, 6 );
319  if ( g_date->Date() + 3 > d1 ) {
320  d1 = g_date->Date() + 3;
321  }
322  SimpleEvent( d1, pe_insecticide, false );
323  }
324  break;
325 
326  case pe_herbi_one:
327  if (( m_ev->m_lock || m_farm->DoIt( (int) (80*cfg_herbi_app_prop.value() * m_farm->Prob_multiplier())))) //modified probability
328  {
329  if ( POT_HILL_DATE && POT_HILL_DATE >= g_date->Date() - 1 ) {
330  // Too close to hilling, try again tomorrow.
331  SimpleEvent( g_date->Date() + 1, pe_herbi_one, false );
332  break;
333  }
334  if (!m_farm->HerbicideTreat( m_field, 0.0,
335  g_date->DayInYear( 12, 5 ) -
336  g_date->DayInYear())) {
337  SimpleEvent( g_date->Date() + 1, pe_herbi_one, false );
338  break;
339  }
341  {
342  int d1 = g_date->OldDays() + g_date->DayInYear( 20, 4 );
343  if ( g_date->Date() + 10 > d1 ) {
344  d1 = g_date->Date() + 10;
345  }
346  SimpleEvent( d1, pe_herbi_two, false );
347  }
348  }
349  else {
350  POT_DID_TREAT = true; // Need to signal the finish of this thread
351  if ( POT_DID_HILL && POT_DID_TREAT ) {
352  // last surviving tread, start insecticide.
353  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 10, 6 ),
354  pe_insecticide, false );
355  }
356  }
357  break;
358 
359  case pe_herbi_two:
360  if (( m_ev->m_lock || m_farm->DoIt( (int) (50*cfg_herbi_app_prop.value() * m_farm->Prob_multiplier() )))) //modified probability
361  {
362  if ( POT_HILL_DATE && POT_HILL_DATE >= g_date->Date() - 1 ) {
363  // Too close to hilling, try again tomorrow.
364  SimpleEvent( g_date->Date() + 1, pe_herbi_two, false );
365  break;
366  }
367  if (!m_farm->HerbicideTreat( m_field, 0.0,
368  g_date->DayInYear( 26, 5 ) -
369  g_date->DayInYear())) {
370  SimpleEvent( g_date->Date() + 1, pe_herbi_two, false );
371  break;
372  }
374  {
375  int d1 = g_date->OldDays() + g_date->DayInYear( 30, 4 );
376  if ( g_date->Date() + 10 > d1 ) {
377  d1 = g_date->Date() + 10;
378  }
379  SimpleEvent( d1, pe_herbi_three, false );
380  }
381  }
382  else {
383  POT_DID_TREAT = true; // Need to signal the finish of this thread
384  if ( POT_DID_HILL && POT_DID_TREAT ) {
385  // last surviving tread, start insecticide.
386  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 10, 6 ),
387  pe_insecticide, false );
388  }
389  }
390  break;
391 
392  case pe_herbi_three:
393  if (( m_ev->m_lock || m_farm->DoIt( (int) (53*cfg_herbi_app_prop.value() * m_farm->Prob_multiplier())))) //modified probability
394  {
395  if ( POT_HILL_DATE &&
396  POT_HILL_DATE >= g_date->Date() - 1 ) {
397  // Too close to hilling, try again tomorrow.
398  SimpleEvent( g_date->Date() + 1, pe_herbi_three, false );
399  break;
400  }
401  if (!m_farm->HerbicideTreat( m_field, 0.0,
402  g_date->DayInYear( 7, 6 ) -
403  g_date->DayInYear())) {
404  SimpleEvent( g_date->Date() + 1, pe_herbi_three, false );
405  break;
406  }
408  POT_DID_TREAT = true; // Need to signal the finish of this thread
409  if ( POT_DID_HILL && POT_DID_TREAT ) {
410  // last surviving tread, start insecticide.
411  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 10, 6 ),
412  pe_insecticide, false );
413  }
414  }
415  else {
416  POT_DID_TREAT = true; // Need to signal the finish of this thread
417  if ( POT_DID_HILL && POT_DID_TREAT ) {
418  // last surviving tread, start insecticide.
419  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 10, 6 ),
420  pe_insecticide, false );
421  }
422  }
423  break;
424 
425  case pe_hilling:
426 if ( (POT_HERBI_DATE && POT_HERBI_DATE >= g_date->Date() - 2)
427  ||
428  (POT_STRIG_DATE && POT_STRIG_DATE >= g_date->Date() - 7)) {
429  // Too close to the others, try again tomorrow.
430  SimpleEvent( g_date->Date() + 1, pe_hilling, false );
431  break;
432  }
433 if (!m_farm->HillingUp( m_field, 0.0, g_date->DayInYear( 25, 6 ) - g_date->DayInYear())) {
434  SimpleEvent( g_date->Date() + 1, pe_hilling, false );
435  break;
436  }
438  POT_DID_HILL = true;
439  if ( POT_DID_TREAT )
440  {
441  // last surviving tread, start insecticide.
442  int d1 = g_date->OldDays() + g_date->DayInYear( 10, 6 );
443  if ( g_date->Date() + 3 > d1 ) {
444  d1 = g_date->Date() + 3;
445  }
446  SimpleEvent( d1, pe_insecticide, false );
447  }
448  break;
449 
450  case pe_insecticide:
451  if ( m_ev->m_lock || m_farm->DoIt( (int) (59*cfg_ins_app_prop1.value() * m_farm->Prob_multiplier()))) { //modified probability
452  if (!m_farm->InsecticideTreat( m_field, 0.0, g_date->DayInYear( 26, 6 ) - g_date->DayInYear())) {
453  SimpleEvent( g_date->Date() + 1, pe_insecticide, true );
454  break;
455  }
456  }
457  POT_WATER_DATE = 0;
458  POT_FUNGI_DATE = 0;
459  {
460  int d1 = g_date->OldDays() + g_date->DayInYear( 15, 6 );
461  if ( g_date->Date() + 1 > d1 ) {
462  d1 = g_date->Date() + 1;
463  }
464  SimpleEvent( d1, pe_water_one, false );
465  }
466  {
467  int d1 = g_date->OldDays() + g_date->DayInYear( 25, 6 );
468  if ( g_date->Date() + 1 > d1 ) {
469  d1 = g_date->Date() + 1;
470  }
471  SimpleEvent( d1, pe_fungi_one, false );
472  }
473  break;
474 
475  case pe_water_one:
476  if ( POT_FUNGI_DATE &&
477  POT_FUNGI_DATE >= g_date->Date() + 2 ) {
478  SimpleEvent( g_date->Date() + 1, pe_water_one, true );
479  break;
480  }
481  if ( m_ev->m_lock || m_farm->DoIt( 80 )) {
482  if (!m_farm->Water( m_field, 0.0,
483  g_date->DayInYear( 30, 6 ) -
484  g_date->DayInYear())) {
485  SimpleEvent( g_date->Date() + 1, pe_water_one, true );
486  break;
487  }
489  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 1, 7 ),
490  pe_water_two, false );
491  }
492  break;
493 
494  case pe_water_two:
495  if ( POT_FUNGI_DATE &&
496  POT_FUNGI_DATE >= g_date->Date() + 2 ) {
497  SimpleEvent( g_date->Date() + 1, pe_water_two, true );
498  break;
499  }
500  if (!m_farm->Water( m_field, 0.0,
501  g_date->DayInYear( 15, 7 ) -
502  g_date->DayInYear())) {
503  SimpleEvent( g_date->Date() + 1, pe_water_two, true );
504  break;
505  }
507  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 16, 7 ),
508  pe_water_three, false );
509  break;
510 
511  case pe_water_three:
512  if ( POT_FUNGI_DATE &&
513  POT_FUNGI_DATE >= g_date->Date() + 2 ) {
514  SimpleEvent( g_date->Date() + 1, pe_water_three, true );
515  break;
516  }
517  if (!m_farm->Water( m_field, 0.0,
518  g_date->DayInYear( 30, 7 ) -
519  g_date->DayInYear())) {
520  SimpleEvent( g_date->Date() + 1, pe_water_three, true );
521  break;
522  }
524  break;
525 
526  case pe_fungi_one:
527  if ( POT_WATER_DATE && POT_WATER_DATE >= g_date->Date() + 2 ) {
528  SimpleEvent( g_date->Date() + 1, pe_fungi_one, true );
529  break;
530  }
531  if (!m_farm->FungicideTreat( m_field, 0.0, g_date->DayInYear( 10, 7 ) - g_date->DayInYear())) {
532  SimpleEvent( g_date->Date() + 1, pe_fungi_one, true );
533  break;
534  }
536  {
537  int d1 = g_date->OldDays() + g_date->DayInYear( 5, 7 );
538  if ( g_date->Date() + 10 > d1 ) {
539  d1 = g_date->Date() + 10;
540  }
541  SimpleEvent( d1, pe_fungi_two, false );
542  }
543  break;
544 
545  case pe_fungi_two:
546  if ( POT_WATER_DATE &&
547  POT_WATER_DATE >= g_date->Date() + 2 ) {
548  SimpleEvent( g_date->Date() + 1, pe_fungi_two, true );
549  break;
550  }
551  if (!m_farm->FungicideTreat( m_field, 0.0,
552  g_date->DayInYear( 20, 7 ) -
553  g_date->DayInYear())) {
554  SimpleEvent( g_date->Date() + 1, pe_fungi_two, true );
555  break;
556  }
558  {
559  int d1 = g_date->OldDays() + g_date->DayInYear( 15, 7 );
560  if ( g_date->Date() + 10 > d1 ) {
561  d1 = g_date->Date() + 10;
562  }
563  SimpleEvent( d1, pe_fungi_three, false );
564  }
565  break;
566 
567  case pe_fungi_three:
568  if ( POT_WATER_DATE &&
569  POT_WATER_DATE >= g_date->Date() + 2 ) {
570  SimpleEvent( g_date->Date() + 1, pe_fungi_three, true );
571  break;
572  }
573  if (!m_farm->FungicideTreat( m_field, 0.0,
574  g_date->DayInYear( 1, 8 ) -
575  g_date->DayInYear())) {
576  SimpleEvent( g_date->Date() + 1, pe_fungi_three, true );
577  break;
578  }
580  {
581  int d1 = g_date->OldDays() + g_date->DayInYear( 25, 7 );
582  if ( g_date->Date() + 10 > d1 ) {
583  d1 = g_date->Date() + 10;
584  }
585  SimpleEvent( d1, pe_fungi_four, false );
586  }
587  break;
588 
589  case pe_fungi_four:
590  if ( POT_WATER_DATE &&
591  POT_WATER_DATE >= g_date->Date() + 2 ) {
592  SimpleEvent( g_date->Date() + 1, pe_fungi_four, true );
593  break;
594  }
595  if (!m_farm->FungicideTreat( m_field, 0.0,
596  g_date->DayInYear( 11, 8 ) -
597  g_date->DayInYear())) {
598  SimpleEvent( g_date->Date() + 1, pe_fungi_four, true );
599  break;
600  }
602  {
603  int d1 = g_date->OldDays() + g_date->DayInYear( 5, 8 );
604  if ( g_date->Date() + 10 > d1 ) {
605  d1 = g_date->Date() + 10;
606  }
607  SimpleEvent( d1, pe_fungi_five, false );
608  }
609  break;
610 
611  case pe_fungi_five:
612  if (!m_farm->FungicideTreat( m_field, 0.0,
613  g_date->DayInYear( 21, 8 ) -
614  g_date->DayInYear())) {
615  SimpleEvent( g_date->Date() + 1, pe_fungi_five, true );
616  break;
617  }
618  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 5, 8 ),
619  pe_growth_reg, false );
620  break;
621 
622  case pe_growth_reg:
623  if ( m_ev->m_lock || m_farm->DoIt( 80 )) {
624  if (!m_farm->GrowthRegulator( m_field, 0.0,
625  g_date->DayInYear( 1, 9 ) -
626  g_date->DayInYear())) {
627  SimpleEvent( g_date->Date() + 1, pe_growth_reg, true );
628  break;
629  }
630  }
631  {
632  int d1 = g_date->OldDays() + g_date->DayInYear( 15, 9 );
633  if ( g_date->Date() + 14 > d1 ) {
634  d1 = g_date->Date() + 14;
635  }
636  ChooseNextCrop (1);
637  SimpleEvent( d1, pe_harvest, false );
638  }
639  break;
640 
641  case pe_harvest:
642  if (m_field->GetMConstants(1)==0) {
643  if (!m_farm->Harvest( m_field, 0.0, -1)) { //raise an error
644  g_msg->Warn( WARN_BUG, "Potatoes::Do(): failure in 'Harvest' execution", "" );
645  exit( 1 );
646  }
647  }
648  else {
649  if (!m_farm->Harvest( m_field, 0.0, m_field->GetMDates(0,1) - g_date->DayInYear())) {
650  SimpleEvent( g_date->Date() + 1, pe_harvest, false );
651  break;
652  }
653  }
654  m_field->SetVegPatchy(false);
655  done = true;
656  break;
657 
658  default:
659  g_msg->Warn( WARN_BUG, "PotatoesEat::Do(): "
660  "Unknown event type! ", "" );
661  exit( 1 );
662  }
663 
664  return done;
665 }

References Farm::AutumnPlough(), cfg_herbi_app_prop, cfg_ins_app_prop1, Crop::ChooseNextCrop(), LE::ClearManagementActionSum(), Calendar::Date(), Calendar::DayInYear(), Farm::DoIt(), Farm::FA_NPK(), Farm::FA_Slurry(), Farm::FP_NPK(), Farm::FungicideTreat(), g_date, g_msg, LE::GetMConstants(), LE::GetMDates(), Farm::GetType(), Calendar::GetYearNumber(), Farm::GrowthRegulator(), Farm::Harvest(), Farm::HerbicideTreat(), Farm::HillingUp(), Farm::InsecticideTreat(), Farm::IsStockFarmer(), Crop::m_ev, Crop::m_farm, Crop::m_field, Crop::m_first_date, FarmEvent::m_first_year, Crop::m_last_date, FarmEvent::m_lock, FarmEvent::m_next_tov, FarmEvent::m_startday, FarmEvent::m_todo, Calendar::OldDays(), pe_autumn_plough, pe_fa_slurry, pe_fungi_five, pe_fungi_four, pe_fungi_one, pe_fungi_three, pe_fungi_two, pe_growth_reg, pe_harvest, pe_herbi_one, pe_herbi_three, pe_herbi_two, pe_hilling, pe_insecticide, pe_spring_harrow, pe_spring_plough, pe_spring_sow, pe_start, pe_strigling_one, pe_strigling_three, pe_strigling_two, pe_water_one, pe_water_three, pe_water_two, POT_DID_HILL, POT_DID_TREAT, POT_FUNGI_DATE, POT_HERBI_DATE, POT_HILL_DATE, POT_SLURRY_DATE, POT_STRIG_DATE, POT_WATER_DATE, Farm::Prob_multiplier(), LE::SetMConstants(), LE::SetMDates(), LE::SetVegPatchy(), Crop::SimpleEvent(), Farm::SpringHarrow(), Farm::SpringPlough(), Farm::SpringSow(), Farm::Strigling(), tof_OptimisingFarm, CfgFloat::value(), MapErrorMsg::Warn(), WARN_BUG, and Farm::Water().

◆ SetUpFarmCategoryInformation()

void Potatoes::SetUpFarmCategoryInformation ( )
inline
82  {
83  const int elements = 2 + (pe_foobar - POTATOESEAT_BASE);
85 
86  FarmManagementCategory catlist[elements] =
87  {
88  fmc_Others, // zero element unused but must be here
89  fmc_Others,//pe_start = 1, // Compulsory, start event must always be 1 (one).
90  fmc_Cultivation,//pe_autumn_plough = POTATOESEAT_BASE,
91  fmc_Cultivation,//pe_spring_plough,
92  fmc_Cultivation,//pe_spring_harrow,
93  fmc_Fertilizer,//pe_fa_slurry,
94  fmc_Others,//pe_spring_sow,
95  fmc_Fertilizer,//pe_fa_npk,
96  fmc_Fertilizer,//pe_fp_npk,
97  fmc_Herbicide,//pe_herbi_one,
98  fmc_Herbicide,//pe_herbi_two,
99  fmc_Herbicide,//pe_herbi_three,
100  fmc_Cultivation,//pe_strigling_one,
101  fmc_Cultivation,//pe_strigling_two,
102  fmc_Cultivation,//pe_strigling_three,
103  fmc_Cultivation,//pe_hilling,
104  fmc_Insecticide,//pe_insecticide,
105  fmc_Watering,//pe_water_one,
106  fmc_Watering,//pe_water_two,
107  fmc_Watering,//pe_water_three,
108  fmc_Fungicide,//pe_fungi_one,
109  fmc_Fungicide,//pe_fungi_two,
110  fmc_Fungicide,//pe_fungi_three,
111  fmc_Fungicide,//pe_fungi_four,
112  fmc_Fungicide,//pe_fungi_five,
113  fmc_Others,//pe_growth_reg,
114  fmc_Harvest//pe_harvest
115 
116  // no foobar entry
117 
118  };
119  // Iterate over the catlist elements and copy them to vector
120  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
121 
122  }

References fmc_Cultivation, fmc_Fertilizer, fmc_Fungicide, fmc_Harvest, fmc_Herbicide, fmc_Insecticide, fmc_Others, fmc_Watering, Crop::m_base_elements_no, Crop::m_ManagementCategories, pe_foobar, and POTATOESEAT_BASE.

Referenced by Potatoes().


The documentation for this class was generated from the following files:
LE::GetMDates
int GetMDates(int a, int b)
Definition: Elements.h:405
POT_HILL_DATE
#define POT_HILL_DATE
Definition: Potatoes.h:35
Farm::FA_Slurry
virtual bool FA_Slurry(LE *a_field, double a_user, int a_days)
Spready slurry on a_field owned by an stock farmer.
Definition: FarmFuncs.cpp:1067
pe_start
Definition: Potatoes.h:42
fmc_Insecticide
Definition: LandscapeFarmingEnums.h:1005
LE::SetMDates
void SetMDates(int a, int b, int c)
Definition: Elements.h:406
Farm::SpringPlough
virtual bool SpringPlough(LE *a_field, double a_user, int a_days)
Carry out a ploughing event in the spring on a_field.
Definition: FarmFuncs.cpp:421
Farm::HerbicideTreat
virtual bool HerbicideTreat(LE *a_field, double a_user, int a_days)
Apply herbicide to a_field.
Definition: FarmFuncs.cpp:2025
pe_spring_harrow
Definition: Potatoes.h:45
Farm::IsStockFarmer
bool IsStockFarmer(void)
Definition: Farm.h:961
Farm::Strigling
virtual bool Strigling(LE *a_field, double a_user, int a_days)
Carry out a mechanical weeding on a_field.
Definition: FarmFuncs.cpp:1206
pe_strigling_one
Definition: Potatoes.h:53
pe_herbi_three
Definition: Potatoes.h:52
Farm::Harvest
virtual bool Harvest(LE *a_field, double a_user, int a_days)
Carry out a harvest on a_field.
Definition: FarmFuncs.cpp:1364
FarmEvent::m_lock
bool m_lock
Definition: Farm.h:384
LE::GetMConstants
int GetMConstants(int a)
Definition: Elements.h:407
pe_fa_slurry
Definition: Potatoes.h:46
LE::ClearManagementActionSum
void ClearManagementActionSum()
clears the management action counters
Definition: Elements.h:247
Farm::FP_NPK
virtual bool FP_NPK(LE *a_field, double a_user, int a_days)
Apply NPK fertilizer, on a_field owned by an arable farmer.
Definition: FarmFuncs.cpp:645
Farm::DoIt
bool DoIt(double a_probability)
Return chance out of 0 to 100.
Definition: Farm.cpp:856
Calendar::GetYearNumber
int GetYearNumber(void)
Definition: Calendar.h:72
FarmEvent::m_first_year
bool m_first_year
Definition: Farm.h:386
cfg_ins_app_prop1
CfgFloat cfg_ins_app_prop1
g_date
class Calendar * g_date
Definition: Calendar.cpp:37
pe_fungi_five
Definition: Potatoes.h:65
fmc_Herbicide
Definition: LandscapeFarmingEnums.h:1006
Farm::SpringSow
virtual bool SpringSow(LE *a_field, double a_user, int a_days, double a_seed_coating_amount=-1, PlantProtectionProducts a_ppp=ppp_foobar)
Carry out a sowing event in the spring on a_field.
Definition: FarmFuncs.cpp:501
CfgFloat::value
double value() const
Definition: Configurator.h:142
Farm::GetType
TTypesOfFarm GetType(void)
Definition: Farm.h:956
Crop::m_base_elements_no
int m_base_elements_no
Definition: Farm.h:505
pe_spring_sow
Definition: Potatoes.h:47
Crop::m_first_date
int m_first_date
Definition: Farm.h:501
pe_spring_plough
Definition: Potatoes.h:44
FarmEvent::m_startday
int m_startday
Definition: Farm.h:385
pe_foobar
Definition: Potatoes.h:68
Farm::FA_NPK
virtual bool FA_NPK(LE *a_field, double a_user, int a_days)
Apply NPK fertilizer to a_field owned by an stock farmer.
Definition: FarmFuncs.cpp:982
Farm::FungicideTreat
virtual bool FungicideTreat(LE *a_field, double a_user, int a_days)
Apply fungicide to a_field.
Definition: FarmFuncs.cpp:2101
Farm::HillingUp
virtual bool HillingUp(LE *a_field, double a_user, int a_days)
Do hilling up on a_field, probably of potatoes.
Definition: FarmFuncs.cpp:1302
Crop::SimpleEvent
void SimpleEvent(long a_date, int a_todo, bool a_lock)
Adds an event to this crop management.
Definition: Farm.cpp:747
pe_water_two
Definition: Potatoes.h:59
Farm::Prob_multiplier
virtual double Prob_multiplier()
Definition: Farm.h:778
fmc_Fertilizer
Definition: LandscapeFarmingEnums.h:1004
pe_harvest
Definition: Potatoes.h:67
pe_fungi_two
Definition: Potatoes.h:62
POT_STRIG_DATE
#define POT_STRIG_DATE
Definition: Potatoes.h:34
Calendar::Date
long Date(void)
Definition: Calendar.h:57
fmc_Cultivation
Definition: LandscapeFarmingEnums.h:1008
pe_strigling_two
Definition: Potatoes.h:54
fmc_Others
Definition: LandscapeFarmingEnums.h:1003
POT_DID_TREAT
#define POT_DID_TREAT
Definition: Potatoes.h:36
LE::SetVegPatchy
void SetVegPatchy(bool p)
Definition: Elements.h:229
fmc_Watering
Definition: LandscapeFarmingEnums.h:1011
Calendar::OldDays
long OldDays(void)
Definition: Calendar.h:60
cfg_herbi_app_prop
CfgFloat cfg_herbi_app_prop
MapErrorMsg::Warn
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: MapErrorMsg.cpp:69
POT_SLURRY_DATE
#define POT_SLURRY_DATE
Definition: Potatoes.h:32
POT_HERBI_DATE
#define POT_HERBI_DATE
Definition: Potatoes.h:33
FarmEvent::m_next_tov
TTypesOfVegetation m_next_tov
Definition: Farm.h:390
pe_fungi_four
Definition: Potatoes.h:64
Crop::m_farm
Farm * m_farm
Definition: Farm.h:498
Crop::m_field
LE * m_field
Definition: Farm.h:499
Crop::m_ManagementCategories
vector< FarmManagementCategory > m_ManagementCategories
Holds the translation between the farm operation enum for each crop and the farm management category ...
Definition: Farm.h:530
pe_hilling
Definition: Potatoes.h:56
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
pe_growth_reg
Definition: Potatoes.h:66
tof_OptimisingFarm
Definition: LandscapeFarmingEnums.h:696
Farm::Water
virtual bool Water(LE *a_field, double a_user, int a_days)
Carry out a watering on a_field.
Definition: FarmFuncs.cpp:1330
Crop::m_last_date
int m_last_date
Definition: Farm.h:503
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:212
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
pe_water_one
Definition: Potatoes.h:58
pe_autumn_plough
Definition: Potatoes.h:43
fmc_Harvest
Definition: LandscapeFarmingEnums.h:1012
POT_FUNGI_DATE
#define POT_FUNGI_DATE
Definition: Potatoes.h:39
pe_fungi_three
Definition: Potatoes.h:63
pe_insecticide
Definition: Potatoes.h:57
Farm::GrowthRegulator
virtual bool GrowthRegulator(LE *a_field, double a_user, int a_days)
Apply growth regulator to a_field.
Definition: FarmFuncs.cpp:2070
Calendar::DayInYear
int DayInYear(void)
Definition: Calendar.h:58
Crop::Crop
Crop(TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape *a_L)
Definition: Farm.cpp:733
Potatoes::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: Potatoes.h:82
POTATOESEAT_BASE
#define POTATOESEAT_BASE
Definition: Potatoes.h:31
LE::SetMConstants
void SetMConstants(int a, int c)
Definition: Elements.h:408
POT_DID_HILL
#define POT_DID_HILL
Definition: Potatoes.h:37
Crop::ChooseNextCrop
void ChooseNextCrop(int a_no_dates)
Chooses the next crop to grow in a field.
Definition: Farm.cpp:756
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
pe_water_three
Definition: Potatoes.h:60
POT_WATER_DATE
#define POT_WATER_DATE
Definition: Potatoes.h:38
WARN_BUG
Definition: MapErrorMsg.h:34
pe_fungi_one
Definition: Potatoes.h:61
fmc_Fungicide
Definition: LandscapeFarmingEnums.h:1007
pe_strigling_three
Definition: Potatoes.h:55
pe_herbi_two
Definition: Potatoes.h:51
FarmManagementCategory
FarmManagementCategory
Definition: LandscapeFarmingEnums.h:1001
pe_herbi_one
Definition: Potatoes.h:50
Farm::SpringHarrow
virtual bool SpringHarrow(LE *a_field, double a_user, int a_days)
Carry out a harrow event in the spring on a_field.
Definition: FarmFuncs.cpp:459