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

#include <NorwegianPotatoes.h>

Inheritance diagram for NorwegianPotatoes:
Crop

Public Member Functions

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

◆ NorwegianPotatoes()

NorwegianPotatoes::NorwegianPotatoes ( TTypesOfVegetation  a_tov,
TTypesOfCrops  a_toc,
Landscape a_L 
)
inline
77  : Crop(a_tov, a_toc, a_L)
78  {
79  m_first_date = g_date->DayInYear(1, 11);
80  m_ddegstoharvest = 1400; // this is hard coded for each crop that uses this
82  }

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

Member Function Documentation

◆ Do()

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

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, npe_autumn_plough, npe_fa_slurry, npe_fungi_five, npe_fungi_four, npe_fungi_one, npe_fungi_three, npe_fungi_two, npe_growth_reg, npe_harvest, npe_herbi_one, npe_herbi_three, npe_herbi_two, npe_hilling, npe_insecticide, npe_spring_harrow, npe_spring_plough, npe_spring_sow, npe_start, npe_strigling_one, npe_strigling_three, npe_strigling_two, npe_water_one, npe_water_three, npe_water_two, NPOT_DID_HILL, NPOT_DID_TREAT, NPOT_FUNGI_DATE, NPOT_HERBI_DATE, NPOT_HILL_DATE, NPOT_SLURRY_DATE, NPOT_STRIG_DATE, NPOT_WATER_DATE, Calendar::OldDays(), 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 NorwegianPotatoes::SetUpFarmCategoryInformation ( )
inline
83  {
84  const int elements = 2 + (npe_foobar - NPOTATOES_BASE);
86 
87  FarmManagementCategory catlist[elements] =
88  {
89  fmc_Others, // zero element unused but must be here
90  fmc_Others,//npe_start = 1, // Compulsory, start event must always be 1 (one).
91  fmc_Cultivation,//npe_autumn_plough = NPOTATOES_BASE,
92  fmc_Cultivation,//npe_spring_plough,
93  fmc_Cultivation,//npe_spring_harrow,
94  fmc_Fertilizer,//npe_fa_slurry,
95  fmc_Others,//npe_spring_sow,
96  fmc_Fertilizer,//npe_fa_npk,
97  fmc_Fertilizer,//npe_fp_npk,
98  fmc_Herbicide,//npe_herbi_one,
99  fmc_Herbicide,//npe_herbi_two,
100  fmc_Herbicide,//npe_herbi_three,
101  fmc_Others,//npe_strigling_one,
102  fmc_Others,//npe_strigling_two,
103  fmc_Others,//npe_strigling_three,
104  fmc_Others,//npe_hilling,
105  fmc_Insecticide,//npe_insecticide,
106  fmc_Watering,//npe_water_one,
107  fmc_Watering,//npe_water_two,
108  fmc_Watering,//npe_water_three,
109  fmc_Fungicide,//npe_fungi_one,
110  fmc_Fungicide,//npe_fungi_two,
111  fmc_Fungicide,//npe_fungi_three,
112  fmc_Fungicide,//npe_fungi_four,
113  fmc_Fungicide,//npe_fungi_five,
114  fmc_Others,//npe_growth_reg,
115  fmc_Harvest//npe_harvest
116 
117  // no foobar entry
118 
119  };
120  // Iterate over the catlist elements and copy them to vector
121  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
122 
123  }

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, npe_foobar, and NPOTATOES_BASE.

Referenced by NorwegianPotatoes().


The documentation for this class was generated from the following files:
LE::GetMDates
int GetMDates(int a, int b)
Definition: Elements.h:405
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
cfg_ins_app_prop1
CfgFloat cfg_ins_app_prop1
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
npe_harvest
Definition: NorwegianPotatoes.h:67
Crop::m_ddegstoharvest
int m_ddegstoharvest
Definition: Farm.h:504
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
FarmEvent::m_first_year
bool m_first_year
Definition: Farm.h:386
npe_fa_slurry
Definition: NorwegianPotatoes.h:46
NPOT_HERBI_DATE
#define NPOT_HERBI_DATE
Definition: NorwegianPotatoes.h:33
g_date
class Calendar * g_date
Definition: Calendar.cpp:37
NPOT_DID_HILL
#define NPOT_DID_HILL
Definition: NorwegianPotatoes.h:37
fmc_Herbicide
Definition: LandscapeFarmingEnums.h:1006
npe_fungi_one
Definition: NorwegianPotatoes.h:61
NPOT_DID_TREAT
#define NPOT_DID_TREAT
Definition: NorwegianPotatoes.h:36
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
npe_strigling_one
Definition: NorwegianPotatoes.h:53
NPOT_WATER_DATE
#define NPOT_WATER_DATE
Definition: NorwegianPotatoes.h:38
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
npe_herbi_three
Definition: NorwegianPotatoes.h:52
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
npe_spring_harrow
Definition: NorwegianPotatoes.h:45
Crop::SimpleEvent
void SimpleEvent(long a_date, int a_todo, bool a_lock)
Adds an event to this crop management.
Definition: Farm.cpp:747
npe_herbi_one
Definition: NorwegianPotatoes.h:50
NPOTATOES_BASE
#define NPOTATOES_BASE
Definition: NorwegianPotatoes.h:31
NPOT_SLURRY_DATE
#define NPOT_SLURRY_DATE
Definition: NorwegianPotatoes.h:32
npe_growth_reg
Definition: NorwegianPotatoes.h:66
Farm::Prob_multiplier
virtual double Prob_multiplier()
Definition: Farm.h:778
npe_fungi_two
Definition: NorwegianPotatoes.h:62
fmc_Fertilizer
Definition: LandscapeFarmingEnums.h:1004
npe_fungi_four
Definition: NorwegianPotatoes.h:64
npe_strigling_three
Definition: NorwegianPotatoes.h:55
Calendar::Date
long Date(void)
Definition: Calendar.h:57
npe_insecticide
Definition: NorwegianPotatoes.h:57
fmc_Cultivation
Definition: LandscapeFarmingEnums.h:1008
fmc_Others
Definition: LandscapeFarmingEnums.h:1003
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
MapErrorMsg::Warn
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: MapErrorMsg.cpp:69
npe_fungi_three
Definition: NorwegianPotatoes.h:63
npe_autumn_plough
Definition: NorwegianPotatoes.h:43
FarmEvent::m_next_tov
TTypesOfVegetation m_next_tov
Definition: Farm.h:390
npe_water_three
Definition: NorwegianPotatoes.h:60
npe_spring_sow
Definition: NorwegianPotatoes.h:47
Crop::m_farm
Farm * m_farm
Definition: Farm.h:498
Crop::m_field
LE * m_field
Definition: Farm.h:499
npe_hilling
Definition: NorwegianPotatoes.h:56
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
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
NPOT_STRIG_DATE
#define NPOT_STRIG_DATE
Definition: NorwegianPotatoes.h:34
npe_water_two
Definition: NorwegianPotatoes.h:59
npe_fungi_five
Definition: NorwegianPotatoes.h:65
npe_start
Definition: NorwegianPotatoes.h:42
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
npe_herbi_two
Definition: NorwegianPotatoes.h:51
NPOT_FUNGI_DATE
#define NPOT_FUNGI_DATE
Definition: NorwegianPotatoes.h:39
npe_spring_plough
Definition: NorwegianPotatoes.h:44
fmc_Harvest
Definition: LandscapeFarmingEnums.h:1012
Farm::GrowthRegulator
virtual bool GrowthRegulator(LE *a_field, double a_user, int a_days)
Apply growth regulator to a_field.
Definition: FarmFuncs.cpp:2070
cfg_herbi_app_prop
CfgFloat cfg_herbi_app_prop
npe_strigling_two
Definition: NorwegianPotatoes.h:54
Calendar::DayInYear
int DayInYear(void)
Definition: Calendar.h:58
npe_water_one
Definition: NorwegianPotatoes.h:58
Crop::Crop
Crop(TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape *a_L)
Definition: Farm.cpp:733
LE::SetMConstants
void SetMConstants(int a, int c)
Definition: Elements.h:408
NorwegianPotatoes::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: NorwegianPotatoes.h:83
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
NPOT_HILL_DATE
#define NPOT_HILL_DATE
Definition: NorwegianPotatoes.h:35
WARN_BUG
Definition: MapErrorMsg.h:34
fmc_Fungicide
Definition: LandscapeFarmingEnums.h:1007
FarmManagementCategory
FarmManagementCategory
Definition: LandscapeFarmingEnums.h:1001
npe_foobar
Definition: NorwegianPotatoes.h:68
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