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
PotatoesIndustry Class Reference

#include <PotatoesIndustry.h>

Inheritance diagram for PotatoesIndustry:
Crop

Public Member Functions

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

◆ PotatoesIndustry()

PotatoesIndustry::PotatoesIndustry ( TTypesOfVegetation  a_tov,
TTypesOfCrops  a_toc,
Landscape a_L 
)
inline
76  : Crop(a_tov, a_toc, a_L)
77  {
80  }

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

Member Function Documentation

◆ Do()

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

Reimplemented from Crop.

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

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_startday, FarmEvent::m_todo, Calendar::OldDays(), 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(), 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 PotatoesIndustry::SetUpFarmCategoryInformation ( )
inline
81  {
82  const int elements = 2 + (pi_foobar - POTATOESIND_BASE);
84 
85  FarmManagementCategory catlist[elements] =
86  {
87  fmc_Others, // zero element unused but must be here
88  fmc_Others,//pi_start = 1, // Compulsory, start event must always be 1 (one).
89  fmc_Cultivation,//pi_autumn_plough = POTATOESIND_BASE,
90  fmc_Cultivation,//pi_spring_plough,
91  fmc_Cultivation,//pi_spring_harrow,
92  fmc_Fertilizer,//pi_fa_slurry,
93  fmc_Others,//pi_spring_sow,
94  fmc_Fertilizer,//pi_fa_npk,
95  fmc_Fertilizer,//pi_fp_npk,
96  fmc_Herbicide, //pi_herbi_one,
97  fmc_Herbicide, //pi_herbi_two,
98  fmc_Herbicide,//pi_herbi_three,
99  fmc_Cultivation,//pi_strigling_one,
100  fmc_Cultivation,//pi_strigling_two,
101  fmc_Cultivation,//pi_strigling_three,
102  fmc_Cultivation,//pi_hilling,
103  fmc_Insecticide,//pi_insecticide,
104  fmc_Watering,//pi_water_one,
105  fmc_Watering,//pi_water_two,
106  fmc_Watering,//pi_water_three,
107  fmc_Fungicide,//pi_fungi_one,
108  fmc_Fungicide, //pi_fungi_two,
109  fmc_Fungicide, //pi_fungi_three,
110  fmc_Fungicide,//pi_fungi_four,
111  fmc_Fungicide,//pi_fungi_five,
112  fmc_Others,//pi_growth_reg,
113  fmc_Harvest//pi_harvest,
114 
115  // no foobar entry
116 
117  };
118  // Iterate over the catlist elements and copy them to vector
119  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
120 
121  }

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, pi_foobar, and POTATOESIND_BASE.

Referenced by PotatoesIndustry().


The documentation for this class was generated from the following files:
LE::GetMDates
int GetMDates(int a, int b)
Definition: Elements.h:405
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:1067
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
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
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
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
pi_strigling_one
Definition: PotatoesIndustry.h:52
FarmEvent::m_first_year
bool m_first_year
Definition: Farm.h:386
g_date
class Calendar * g_date
Definition: Calendar.cpp:37
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
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:501
FarmEvent::m_startday
int m_startday
Definition: Farm.h:385
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
pi_foobar
Definition: PotatoesIndustry.h:67
Crop::SimpleEvent
void SimpleEvent(long a_date, int a_todo, bool a_lock)
Adds an event to this crop management.
Definition: Farm.cpp:747
Farm::Prob_multiplier
virtual double Prob_multiplier()
Definition: Farm.h:778
fmc_Fertilizer
Definition: LandscapeFarmingEnums.h:1004
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
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
pi_spring_harrow
Definition: PotatoesIndustry.h:44
fmc_Watering
Definition: LandscapeFarmingEnums.h:1011
Calendar::OldDays
long OldDays(void)
Definition: Calendar.h:60
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
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: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
pi_herbi_two
Definition: PotatoesIndustry.h:50
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
cfg_herbi_app_prop
CfgFloat cfg_herbi_app_prop
pi_water_two
Definition: PotatoesIndustry.h:58
pi_fungi_three
Definition: PotatoesIndustry.h:62
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
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:212
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
pi_strigling_two
Definition: PotatoesIndustry.h:53
cfg_ins_app_prop1
CfgFloat cfg_ins_app_prop1
pi_harvest
Definition: PotatoesIndustry.h:66
fmc_Harvest
Definition: LandscapeFarmingEnums.h:1012
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:2070
pi_water_three
Definition: PotatoesIndustry.h:59
Calendar::DayInYear
int DayInYear(void)
Definition: Calendar.h:58
POTATOESIND_BASE
#define POTATOESIND_BASE
Definition: PotatoesIndustry.h:30
pi_fungi_four
Definition: PotatoesIndustry.h:63
Crop::Crop
Crop(TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape *a_L)
Definition: Farm.cpp:733
PotatoesIndustry::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: PotatoesIndustry.h:81
pi_strigling_three
Definition: PotatoesIndustry.h:54
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
pi_water_one
Definition: PotatoesIndustry.h:57
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
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
WARN_BUG
Definition: MapErrorMsg.h:34
fmc_Fungicide
Definition: LandscapeFarmingEnums.h:1007
FarmManagementCategory
FarmManagementCategory
Definition: LandscapeFarmingEnums.h:1001
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
pi_autumn_plough
Definition: PotatoesIndustry.h:42