ALMaSS Hare ODDox  1.1
The hare model description following ODdox protocol
Potatoes Class Reference

#include <Potatoes.h>

Public Member Functions

bool Do (Farm *a_farm, LE *a_field, FarmEvent *a_ev)
 
 Potatoes ()
 
- Public Member Functions inherited from Crop
void ChooseNextCrop (int a_no_dates)
 Chooses the next crop to grow in a field. More...
 
 Crop ()
 
int GetCropClassification ()
 
int GetFirstDate (void)
 
void SetCropClassification (int a_classification)
 
virtual ~Crop ()
 

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
int m_count
 
int m_CropClassification
 
int m_ddegstoharvest
 
FarmEventm_ev
 
Farmm_farm
 
LE * m_field
 
int m_first_date
 
int m_last_date
 

Detailed Description

Definition at line 72 of file Potatoes.h.

Constructor & Destructor Documentation

◆ Potatoes()

Potatoes::Potatoes ( )
inline

Definition at line 76 of file Potatoes.h.

77  {
78  m_first_date=g_date->DayInYear(1,11);
79  }

References Crop::m_first_date.

Member Function Documentation

◆ Do()

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

Reimplemented from Crop.

Definition at line 38 of file Potatoes.cpp.

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

References Farm::AutumnPlough(), cfg_herbi_app_prop, cfg_ins_app_prop1, Crop::ChooseNextCrop(), Farm::DoIt(), Farm::FA_NPK(), Farm::FA_Slurry(), Farm::FP_NPK(), Farm::FungicideTreat(), Farm::GetType(), 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, 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(), Crop::SimpleEvent(), Farm::SpringHarrow(), Farm::SpringPlough(), Farm::SpringSow(), Farm::Strigling(), tof_OptimisingFarm, and Farm::Water().


The documentation for this class was generated from the following files:
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:965
pe_start
Definition: Potatoes.h:42
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:444
Farm::HerbicideTreat
virtual bool HerbicideTreat(LE *a_field, double a_user, int a_days)
Apply herbicide to a_field.
Definition: farmfuncs.cpp:1156
pe_spring_harrow
Definition: Potatoes.h:45
Farm::IsStockFarmer
bool IsStockFarmer(void)
Definition: farm.h:905
Farm::Strigling
virtual bool Strigling(LE *a_field, double a_user, int a_days)
Carry out a mechanical weeding on a_field.
Definition: farmfuncs.cpp:1545
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:1769
FarmEvent::m_lock
bool m_lock
Definition: farm.h:465
pe_fa_slurry
Definition: Potatoes.h:46
Farm::FP_NPK
virtual bool FP_NPK(LE *a_field, double a_user, int a_days)
Apply NPK fertilizer, on a_field owned by an arable farmer.
Definition: farmfuncs.cpp:629
Farm::DoIt
bool DoIt(double a_probability)
Return chance out of 0 to 100.
Definition: farm.cpp:800
FarmEvent::m_first_year
bool m_first_year
Definition: farm.h:467
tof_OptimisingFarm
Definition: farm.h:273
cfg_ins_app_prop1
CfgFloat cfg_ins_app_prop1
pe_fungi_five
Definition: Potatoes.h:65
Farm::GetType
TTypesOfFarm GetType(void)
Definition: farm.h:901
pe_spring_sow
Definition: Potatoes.h:47
Crop::m_first_date
int m_first_date
Definition: farm.h:540
pe_spring_plough
Definition: Potatoes.h:44
FarmEvent::m_startday
int m_startday
Definition: farm.h:466
Farm::FA_NPK
virtual bool FA_NPK(LE *a_field, double a_user, int a_days)
Apply NPK fertilizer to a_field owned by an stock farmer.
Definition: farmfuncs.cpp:917
Farm::FungicideTreat
virtual bool FungicideTreat(LE *a_field, double a_user, int a_days)
Apply fungicide to a_field.
Definition: farmfuncs.cpp:1279
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:1663
Crop::SimpleEvent
void SimpleEvent(long a_date, int a_todo, bool a_lock)
Adds an event to this crop management.
Definition: farm.cpp:307
pe_water_two
Definition: Potatoes.h:59
Farm::Prob_multiplier
virtual double Prob_multiplier()
Definition: farm.h:786
pe_harvest
Definition: Potatoes.h:67
pe_fungi_two
Definition: Potatoes.h:62
POT_STRIG_DATE
#define POT_STRIG_DATE
Definition: Potatoes.h:34
pe_strigling_two
Definition: Potatoes.h:54
POT_DID_TREAT
#define POT_DID_TREAT
Definition: Potatoes.h:36
cfg_herbi_app_prop
CfgFloat cfg_herbi_app_prop
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:471
pe_fungi_four
Definition: Potatoes.h:64
Crop::m_farm
Farm * m_farm
Definition: farm.h:537
Crop::m_field
LE * m_field
Definition: farm.h:538
pe_hilling
Definition: Potatoes.h:56
FarmEvent::m_todo
int m_todo
Definition: farm.h:469
Farm::InsecticideTreat
virtual bool InsecticideTreat(LE *a_field, double a_user, int a_days)
Apply insecticide to a_field.
Definition: farmfuncs.cpp:1348
pe_growth_reg
Definition: Potatoes.h:66
Farm::Water
virtual bool Water(LE *a_field, double a_user, int a_days)
Carry out a watering on a_field.
Definition: farmfuncs.cpp:1717
Crop::m_last_date
int m_last_date
Definition: farm.h:542
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
Farm::SpringSow
virtual bool SpringSow(LE *a_field, double a_user, int a_days)
Carry out a sowing event in the spring on a_field.
Definition: farmfuncs.cpp:546
pe_water_one
Definition: Potatoes.h:58
pe_autumn_plough
Definition: Potatoes.h:43
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:1250
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:318
Crop::m_ev
FarmEvent * m_ev
Definition: farm.h:539
pe_water_three
Definition: Potatoes.h:60
POT_WATER_DATE
#define POT_WATER_DATE
Definition: Potatoes.h:38
pe_fungi_one
Definition: Potatoes.h:61
pe_strigling_three
Definition: Potatoes.h:55
pe_herbi_two
Definition: Potatoes.h:51
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:471