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

#include <PotatoesIndustry.h>

Public Member Functions

bool Do (Farm *a_farm, LE *a_field, FarmEvent *a_ev)
 
 PotatoesIndustry ()
 
- 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 71 of file PotatoesIndustry.h.

Constructor & Destructor Documentation

◆ PotatoesIndustry()

PotatoesIndustry::PotatoesIndustry ( )
inline

Definition at line 75 of file PotatoesIndustry.h.

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

References Crop::m_first_date.

Member Function Documentation

◆ Do()

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

Reimplemented from Crop.

Definition at line 37 of file PotatoesIndustry.cpp.

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

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_startday, FarmEvent::m_todo, pi_autumn_plough, pi_fa_slurry, pi_fungi_five, pi_fungi_four, pi_fungi_one, pi_fungi_three, pi_fungi_two, pi_growth_reg, pi_harvest, pi_herbi_one, pi_herbi_three, pi_herbi_two, pi_hilling, pi_insecticide, pi_spring_harrow, pi_spring_plough, pi_spring_sow, pi_start, pi_strigling_one, pi_strigling_three, pi_strigling_two, pi_water_one, pi_water_three, pi_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:
pi_start
Definition: PotatoesIndustry.h:41
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
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
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
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
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
pi_strigling_one
Definition: PotatoesIndustry.h:52
FarmEvent::m_first_year
bool m_first_year
Definition: farm.h:467
tof_OptimisingFarm
Definition: farm.h:273
Farm::GetType
TTypesOfFarm GetType(void)
Definition: farm.h:901
pi_hilling
Definition: PotatoesIndustry.h:55
pi_spring_sow
Definition: PotatoesIndustry.h:46
pi_herbi_three
Definition: PotatoesIndustry.h:51
Crop::m_first_date
int m_first_date
Definition: farm.h:540
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
Farm::Prob_multiplier
virtual double Prob_multiplier()
Definition: farm.h:786
POT_STRIG_DATE
#define POT_STRIG_DATE
Definition: Potatoes.h:34
POT_DID_TREAT
#define POT_DID_TREAT
Definition: Potatoes.h:36
pi_spring_harrow
Definition: PotatoesIndustry.h:44
POT_SLURRY_DATE
#define POT_SLURRY_DATE
Definition: Potatoes.h:32
pi_fungi_one
Definition: PotatoesIndustry.h:60
POT_HERBI_DATE
#define POT_HERBI_DATE
Definition: Potatoes.h:33
pi_insecticide
Definition: PotatoesIndustry.h:56
Crop::m_farm
Farm * m_farm
Definition: farm.h:537
Crop::m_field
LE * m_field
Definition: farm.h:538
pi_herbi_two
Definition: PotatoesIndustry.h:50
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
cfg_herbi_app_prop
CfgFloat cfg_herbi_app_prop
pi_water_two
Definition: PotatoesIndustry.h:58
pi_fungi_three
Definition: PotatoesIndustry.h:62
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
pi_fungi_five
Definition: PotatoesIndustry.h:64
pi_spring_plough
Definition: PotatoesIndustry.h:43
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
pi_strigling_two
Definition: PotatoesIndustry.h:53
cfg_ins_app_prop1
CfgFloat cfg_ins_app_prop1
pi_harvest
Definition: PotatoesIndustry.h:66
POT_FUNGI_DATE
#define POT_FUNGI_DATE
Definition: Potatoes.h:39
pi_fungi_two
Definition: PotatoesIndustry.h:61
pi_fa_slurry
Definition: PotatoesIndustry.h:45
Farm::GrowthRegulator
virtual bool GrowthRegulator(LE *a_field, double a_user, int a_days)
Apply growth regulator to a_field.
Definition: farmfuncs.cpp:1250
pi_water_three
Definition: PotatoesIndustry.h:59
pi_fungi_four
Definition: PotatoesIndustry.h:63
pi_strigling_three
Definition: PotatoesIndustry.h:54
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
pi_water_one
Definition: PotatoesIndustry.h:57
Crop::m_ev
FarmEvent * m_ev
Definition: farm.h:539
pi_growth_reg
Definition: PotatoesIndustry.h:65
POT_WATER_DATE
#define POT_WATER_DATE
Definition: Potatoes.h:38
pi_herbi_one
Definition: PotatoesIndustry.h:49
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
pi_autumn_plough
Definition: PotatoesIndustry.h:42