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

#include <DK_Carrots_Spring.h>

Inheritance diagram for DK_Carrots_Spring:
Crop

Public Member Functions

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

◆ DK_Carrots_Spring()

DK_Carrots_Spring::DK_Carrots_Spring ( TTypesOfVegetation  a_tov,
TTypesOfCrops  a_toc,
Landscape a_L 
)
inline

Member Function Documentation

◆ Do()

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

Reimplemented from Crop.

37  {
38  m_farm = a_farm;
39  m_field = a_field;
40  m_ev = a_ev;
41  bool done = false; // The boolean value done indicates when we are totally finished with this plan (i.e. it is set to true, m_farm, m_field).
42  bool flag = false;
43  int d1 = 0;
44  int noDates = 1;
45  TTypesOfVegetation l_tov = tov_DKCarrots_Spring;
46 
47  switch (m_ev->m_todo) {
48  case dk_cars_start:
49  {
50  a_field->ClearManagementActionSum();
51 
52  // Set up the date management stuff
53  // The next bit of code just allows for altering dates after harvest if it is necessary
54  // to allow for a crop which starts its management early.
55 
56  // 2 start and stop dates for all 'movable' events for this crop
57  int noDates = 1;
58  m_field->SetMDates(0, 0, g_date->DayInYear(30, 11));
59  m_field->SetMDates(1, 0, g_date->DayInYear(30, 11));// last possible day of harvest
60 
61  m_field->SetMConstants(0, 1);
62 
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 (i.e. from spring to spring!), at least not without fixing this.
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  //optimising farms not used for now so most of related code is removed (but not in 'start' case)
69  if (!(m_farm->GetType() == tof_OptimisingFarm && g_date->GetYearNumber() > 0)) {
70 
71  if (m_ev->m_startday > g_date->DayInYear(1, 7)) {
72  if (m_field->GetMDates(0, 0) >= m_ev->m_startday)
73  {
74  g_msg->Warn(WARN_BUG, "DK_Carrots_Spring::Do(): ", "Harvest too late for the next crop to start!!!");
75  int almassnum = m_field->GetLandscape()->BackTranslateVegTypes(m_ev->m_next_tov);
76  g_msg->Warn("Next Crop ", (double)almassnum); // this causes exit
77  }
78  // Now fix any late finishing problems
79  for (int i = 0; i < noDates; i++) {
80  if (m_field->GetMDates(0, i) >= m_ev->m_startday) {
81  m_field->SetMDates(0, i, m_ev->m_startday - 1); //move the starting date
82  }
83  if (m_field->GetMDates(1, i) >= m_ev->m_startday) {
84  m_field->SetMConstants(i, 0); //change the default value of the MConst (=1) to 0 (necessary to correctly execute farm events in case the finishing date (MDate) was moved)
85  m_field->SetMDates(1, i, m_ev->m_startday - 1); //move the finishing date
86  }
87  }
88  }
89  // Now no operations can be timed after the start of the next crop.
90 
91  if (!m_ev->m_first_year) {
92  // Are we before July 1st?
93  d1 = g_date->OldDays() + g_date->DayInYear(1, 7);
94  if (g_date->Date() < d1) {
95  // Yes, too early. We assumme this is because the last crop was late
96  printf("Poly: %d\n", m_field->GetPoly());
97  g_msg->Warn(WARN_BUG, "DK_Carrots_Spring::Do(): ", "Crop start attempt between 1st Jan & 1st July");
98  int prev = m_field->GetLandscape()->BackTranslateVegTypes(m_field->GetOwner()->GetPreviousTov(m_field->GetRotIndex()));
99  g_msg->Warn(WARN_BUG, "Previous Crop ", prev);
100  int almassnum = m_field->GetLandscape()->BackTranslateVegTypes(m_ev->m_next_tov);
101  g_msg->Warn("Next Crop ", (double)almassnum); // this causes exit
102  }
103  else {
104  d1 = g_date->OldDays() + 365 + m_first_date; // Add 365 for spring crop
105  if (g_date->Date() > d1) {
106  // Yes too late - should not happen - raise an error
107  g_msg->Warn(WARN_BUG, "DK_Carrots_Spring::Do(): ", "Crop start attempt after last possible start date");
108  g_msg->Warn(WARN_BUG, "Previous Crop ", "");
109  //m_field->GetOwner()->GetPreviousCrop(m_field->GetRotIndex());
110  int almassnum = m_field->GetLandscape()->BackTranslateVegTypes(m_ev->m_next_tov);
111  g_msg->Warn("Next Crop ", (double)almassnum); // this causes exit
112  }
113  }
114  }
115  else
116  {
117  // If this is the first year of running then it is possible to start
118  // on day 0, so need this to tell us what to do:
120  break;
121  }
122  }//if
123 
124  // End single block date checking code. Please see next line
125  // comment as well.
126  // Reinit d1 to first possible starting date.
127  d1 = g_date->OldDays() + m_first_date;
128  if (!m_ev->m_first_year) d1 += 365; // Add 365 for spring crop (not 1st yr)
129  if (g_date->Date() > d1) {
130  d1 = g_date->Date();
131  }
132  // This is the first real farm operation
133  SimpleEvent(d1, dk_cars_stoneburier, false);
134  }
135  break;
136  // LKM: Do stoneburier before 15th of April - if not done, try again +1 day until the the 15th of April when we succeed
137  case dk_cars_stoneburier:
138  if (!m_farm->DeepPlough(m_field, 0.0, g_date->DayInYear(15, 4) - g_date->DayInYear())) {
140  break;
141  }
142  // LKM: Queue up the next event - Deep harrow done before the 20th of April - if not done, try again +1 day until the 20th of April when we will succeed
144  break;
145  case dk_cars_deep_harrow:
146  if (!m_farm->DeepPlough(m_field, 0.0, g_date->DayInYear(20, 4) - g_date->DayInYear())) {
148  break;
149  }
150  // LKM: Queue up the next event - Bedformer done before the 20th of April - if not done, try again +1 day until the 20th of April when we will succeed
152  break;
153  case dk_cars_bedformer:
154  if (!m_farm->BedForming(m_field, 0.0, g_date->DayInYear(20, 4) - g_date->DayInYear())) {
155  SimpleEvent(g_date->Date() + 1, dk_cars_bedformer, true);
156  break;
157  }
158  // LKM: Queue up the next event - shallow harrow1 (making seedbed) done after the 5th of February and before the 5th of May - if not done, try again +1 day until the 5th of May when we will succeed
160  break;
161  case dk_cars_sharrow1:
162  if (!m_farm->ShallowHarrow(m_field, 0.0, g_date->DayInYear(5, 5) - g_date->DayInYear()))
163  {
164  SimpleEvent(g_date->Date() + 1, dk_cars_sharrow1, true);
165  break;
166  }
167  // LKM: Queue up the next event - shallow harrow2 (making seedbed) done 5 days after, and before the 10th of May - if not done, try again +1 day until the 10th of May when we will succeed
168  SimpleEvent(g_date->Date() + 5, dk_cars_sharrow2, false);
169  break;
170  case dk_cars_sharrow2:
171  if (!m_farm->ShallowHarrow(m_field, 0.0, g_date->DayInYear(10, 5) - g_date->DayInYear()))
172  {
173  SimpleEvent(g_date->Date() + 1, dk_cars_sharrow2, true);
174  break;
175  }
176  // LKM: Queue up the next event - shallow harrow3 (making seedbed) done 5 days after, and before the 15th of May - if not done, try again +1 day until the 15th of May when we will succeed
177  SimpleEvent(g_date->Date() + 5, dk_cars_sharrow3, false);
178  break;
179  case dk_cars_sharrow3:
180  if (!m_farm->ShallowHarrow(m_field, 0.0, g_date->DayInYear(15, 5) - g_date->DayInYear()))
181  {
182  SimpleEvent(g_date->Date() + 1, dk_cars_sharrow3, true);
183  break;
184  }
185  // LKM: Queue up the next event - shallow harrow4 (making seedbed) done 5 days after, and before the 20th of May - if not done, try again +1 day until the 20th of May when we will succeed
186  SimpleEvent(g_date->Date() + 5, dk_cars_sharrow4, false);
187  break;
188  case dk_cars_sharrow4:
189  if (!m_farm->ShallowHarrow(m_field, 0.0, g_date->DayInYear(20, 5) - g_date->DayInYear()))
190  {
191  SimpleEvent(g_date->Date() + 1, dk_cars_sharrow4, true);
192  break;
193  }
194  // LKM: Queue up the next event - water1 done before the 25th of May - if not done, try again +1 day until the 25th of May when we will succeed
195  SimpleEvent(g_date->Date() + 1, dk_cars_water1, false);
196  break;
197  case dk_cars_water1:
198  if (!m_farm->Water(m_field, 0.0, g_date->DayInYear(25, 5) - g_date->DayInYear()))
199  {
200  SimpleEvent(g_date->Date() + 1, dk_cars_water1, true);
201  break;
202  }
203  // LKM: Queue up the next event - fungicide1 done before the 30th of May - if not done, try again +1 day until the 30th of May when we will succeed
204  SimpleEvent(g_date->Date() + 1, dk_cars_fungicide1, false);
205  break;
206  case dk_cars_fungicide1:
207  if (!m_farm->FungicideTreat(m_field, 0.0, g_date->DayInYear(30, 5) - g_date->DayInYear()))
208  {
209  SimpleEvent(g_date->Date() + 1, dk_cars_fungicide1, true);
210  break;
211  }
212  // LKM: Queue up the next event - sow done before the 30th of May - if not done, try again +1 day until the 30th of May when we will succeed
213  SimpleEvent(g_date->Date(), dk_cars_sow, false);
214  break;
215  case dk_cars_sow:
216  if (!m_farm->SpringSow(m_field, 0.0, g_date->DayInYear(30, 5) - g_date->DayInYear()))
217  {
218  SimpleEvent(g_date->Date() + 1, dk_cars_sow, true);
219  break;
220  }
221  // LKM: Queue up the next event - herbicide2 done before the 5th of June - if not done, try again + 1 day until the 5th of June when we will succeed
222  SimpleEvent(g_date->Date() + 1, dk_cars_herbicide2, false);
223  break;
224  case dk_cars_herbicide2:
225  if (!m_farm->HerbicideTreat(m_field, 0.0, g_date->DayInYear(5, 6) - g_date->DayInYear()))
226  {
227  SimpleEvent(g_date->Date() + 1, dk_cars_herbicide2, true);
228  break;
229  }
230  // LKM: Queue up the next event - herbicide3 done before the 10th of June - if not done, try again + 1 day until the 10th of June when we will succeed
231  SimpleEvent(g_date->Date() + 1, dk_cars_herbicide3, false);
232  break;
233  case dk_cars_herbicide3:
234  if (!m_farm->HerbicideTreat(m_field, 0.0, g_date->DayInYear(10, 6) - g_date->DayInYear()))
235  {
236  SimpleEvent(g_date->Date() + 1, dk_cars_herbicide3, true);
237  break;
238  }
239  // LKM: Queue up the next event - fertilizer1 done before the 15th of June - if not done, try again + 1 day until the 15th of June when we will succeed
240  if (a_farm->IsStockFarmer()) {
241  SimpleEvent(g_date->Date() + 1, dk_cars_ferti_s1, false);
242  break;
243  }
244  else
245  {
246  SimpleEvent(g_date->Date() + 1, dk_cars_ferti_p1, false);
247  break;
248  }
249 
250  case dk_cars_ferti_s1:
251  if (!m_farm->FA_NPK(m_field, 0.0, g_date->DayInYear(15, 6) - g_date->DayInYear()))
252  {
253  SimpleEvent(g_date->Date() + 1, dk_cars_ferti_s1, true);
254  break;
255  }// LKM: Queue up the next event - herbicide4 + row cultivation1 at the same time done before the 20th of June - if not done, try again + 1 day until the 20th of June when we will succeed
256  SimpleEvent(g_date->Date() + 1, dk_cars_herbicide4, false);
257  break;
258 
259  case dk_cars_ferti_p1:
260  if (!m_farm->FP_NPK(m_field, 0.0, g_date->DayInYear(15, 6) - g_date->DayInYear()))
261  {
262  SimpleEvent(g_date->Date() + 1, dk_cars_ferti_p1, true);
263  break;
264  }// LKM: Queue up the next event - herbicide4 + row cultivation1 at the same time done before the 20th of June - if not done, try again + 1 day until the 20th of June when we will succeed
265  SimpleEvent(g_date->Date() + 1, dk_cars_herbicide4, false);
266  break;
267 
268  case dk_cars_herbicide4:
269  if (!m_farm->HerbicideTreat(m_field, 0.0, g_date->DayInYear(20, 6) - g_date->DayInYear()))
270  {
271  SimpleEvent(g_date->Date() + 1, dk_cars_herbicide4, true);
272  break;
273  }
275  break;
277  if (!m_farm->RowCultivation(m_field, 0.0, g_date->DayInYear(21, 6) - g_date->DayInYear()))
278  {
280  break;
281  }
282  // LKM: Queue up the next event - herbicide5 + row cultivation2 (+8 days after) at the same time done before the 30th of June - if not done, try again + 1 day until the 30th of June when we will succeed
283  SimpleEvent(g_date->Date() + 8, dk_cars_herbicide5, false);
284  break;
285  case dk_cars_herbicide5:
286  if (!m_farm->HerbicideTreat(m_field, 0.0, g_date->DayInYear(29, 6) - g_date->DayInYear()))
287  {
288  SimpleEvent(g_date->Date() + 1, dk_cars_herbicide5, true);
289  break;
290  }
292  break;
294  if (!m_farm->RowCultivation(m_field, 0.0, g_date->DayInYear(30, 6) - g_date->DayInYear()))
295  {
297  break;
298  }
299  // LKM: Queue up the next event - water2 done before the 30th of June - if not done, try again +1 day until the 30th of June when we will succeed
301  break;
302  case dk_cars_water2:
303  if (!m_farm->Water(m_field, 0.0, g_date->DayInYear(1, 7) - g_date->DayInYear()))
304  {
305  SimpleEvent(g_date->Date() + 1, dk_cars_water2, true);
306  break;
307  }
308  // LKM: Queue up the next event - hilling up1 done before the 5th of July - if not done, try again +1 day until the 5th of July when we will succeed
309  SimpleEvent(g_date->Date() + 1, dk_cars_hilling_up1, false);
310  break;
311  case dk_cars_hilling_up1:
312  if (!m_farm->HillingUp(m_field, 0.0, g_date->DayInYear(5, 7) - g_date->DayInYear()))
313  {
315  break;
316  }
317  // LKM: Queue up the next event - herbicide6 done before the 10th of July - if not done, try again + 1 day until the 10th of July when we will succeed
318  SimpleEvent(g_date->Date() + 1, dk_cars_herbicide6, false);
319  break;
320  case dk_cars_herbicide6:
321  if (!m_farm->HerbicideTreat(m_field, 0.0, g_date->DayInYear(10, 7) - g_date->DayInYear()))
322  {
323  SimpleEvent(g_date->Date() + 1, dk_cars_herbicide6, true);
324  break;
325  }
326  // LKM: Queue up the next event - add boron1 done before the 10th of July - if not done, try again + 1 day until the 10th of July when we will succeed
328  break;
329  case dk_cars_boron_s1:
330  if (a_farm->IsStockFarmer()) {
331  if (!m_farm->FA_Boron(m_field, 0.0, g_date->DayInYear(11, 7) - g_date->DayInYear()))
332  {
333  SimpleEvent(g_date->Date() + 1, dk_cars_boron_s1, true);
334  break;
335  }
336  // LKM: Queue up the next event - water3 done before the 20th of July - if not done, try again +1 day until the 10th of July when we will succeed
337  SimpleEvent(g_date->Date() + 1, dk_cars_water3, false);
338  break;
339  }
340  else
342  break;
343 
344  case dk_cars_boron_p1:
345  if (!m_farm->FP_Boron(m_field, 0.0, g_date->DayInYear(11, 7) - g_date->DayInYear()))
346  {
347  SimpleEvent(g_date->Date() + 1, dk_cars_boron_p1, true);
348  break;
349  }
350  // LKM: Queue up the next event - water3 done before the 20th of July - if not done, try again +1 day until the 10th of July when we will succeed
351  SimpleEvent(g_date->Date() + 1, dk_cars_water3, false);
352  break;
353 
354  case dk_cars_water3:
355  if (!m_farm->Water(m_field, 0.0, g_date->DayInYear(20, 7) - g_date->DayInYear()))
356  {
357  SimpleEvent(g_date->Date() + 1, dk_cars_water3, true);
358  break;
359  }
360  // LKM: Queue up the next event - hilling up2 done before the 30th of July - if not done, try again +1 day until the 30th of July when we will succeed
361  SimpleEvent(g_date->Date() + 1, dk_cars_hilling_up2, false);
362  break;
363  case dk_cars_hilling_up2:
364  if (!m_farm->HillingUp(m_field, 0.0, g_date->DayInYear(30, 7) - g_date->DayInYear()))
365  {
367  break;
368  }
369  // LKM: Queue up the next event - boron2 done after the 1st of May, and before the 30th of August - if not done, try again +1 day until the 30th of August when we will succeed
371  break;
372  case dk_cars_boron_s2:
373  if (a_farm->IsStockFarmer()) {
374  if (!m_farm->FA_Boron(m_field, 0.0, g_date->DayInYear(28, 8) - g_date->DayInYear()))
375  {
376  SimpleEvent(g_date->Date() + 1, dk_cars_boron_s2, true);
377  break;
378  }
379  // LKM: Queue up the next event - hilling up3 done before the 30th of August - if not done, try again +1 day until the 30th of July when we will succeed
381  break;
382  }
383  else SimpleEvent(g_date->OldDays() + g_date->DayInYear(1, 5), dk_cars_boron_p2, false);
384  break;
385 
386  case dk_cars_boron_p2:
387  if (!m_farm->FP_Boron(m_field, 0.0, g_date->DayInYear(28, 8) - g_date->DayInYear()))
388  {
389  SimpleEvent(g_date->Date() + 1, dk_cars_boron_p2, true);
390  break;
391  }
392  // LKM: Queue up the next event - hilling up3 done before the 30th of August - if not done, try again +1 day until the 30th of July when we will succeed
394  break;
395 
396  case dk_cars_hilling_up3:
397  if (!m_farm->HillingUp(m_field, 0.0, g_date->DayInYear(29, 8) - g_date->DayInYear()))
398  {
400  break;
401  }
402  // LKM: Queue up the next event - fertilizer2 done after the 10th of June and before the 30th of August - if not done, try again +1 day until the 30th of August when we will succeed
403  if (a_farm->IsStockFarmer()) {
405  break;
406  }
407  else
408  {
410  break;
411  }
412  break;
413 
414  case dk_cars_ferti_s2:
415  if (!m_farm->FA_NPK(m_field, 0.0, g_date->DayInYear(30, 8) - g_date->DayInYear()))
416  {
417  SimpleEvent(g_date->Date() + 1, dk_cars_ferti_s2, true);
418  break;
419  }
420  // LKM: Here is a fork leading to two parallel events
421  SimpleEvent(g_date->OldDays() + g_date->DayInYear(10, 6), dk_cars_insecticide1, false); // Insecticide thread
422  SimpleEvent(g_date->OldDays() + g_date->DayInYear(10, 6), dk_cars_fungicide2, false); // Fungicide thread
423  break;
424 
425  case dk_cars_ferti_p2:
426  if (!m_farm->FP_NPK(m_field, 0.0, g_date->DayInYear(30, 8) - g_date->DayInYear()))
427  {
428  SimpleEvent(g_date->Date() + 1, dk_cars_ferti_p2, true);
429  break;
430  }
431  // LKM: Here is a fork leading to two parallel events
432  SimpleEvent(g_date->OldDays() + g_date->DayInYear(10, 6), dk_cars_insecticide1, false); // Insecticide thread
433  SimpleEvent(g_date->OldDays() + g_date->DayInYear(10, 6), dk_cars_fungicide2, false); // Fungicide thread - main thread
434  break;
435 
437  // here we check whether we are using ERA pesticide or not
438  d1 = g_date->DayInYear(30, 9) - g_date->DayInYear();
439  if (!cfg_pest_carrots_on.value() || !m_field->GetLandscape()->SupplyShouldSpray()) // Not using pesticide spray
440  {
441  flag = m_farm->InsecticideTreat(m_field, 0.0, d1);
442  }
443  else {
444  flag = m_farm->ProductApplication(m_field, 0.0, d1, cfg_pest_product_amounts.value(0), ppp_1, false, 3);
445  }
446  if (!flag) {
448  break;
449  }
450  //LKM: Queue up the next event - insecticide2 (+ 7 days after) done before the 7th of October - if not done, try again +1 day until the 7th of October when we will succeed
452  break;
454  // here we check whether we are using ERA pesticide or not
455  d1 = g_date->DayInYear(8, 10) - g_date->DayInYear();
456  if (!cfg_pest_carrots_on.value() || !m_field->GetLandscape()->SupplyShouldSpray()) // Not using pesticide spray
457  {
458  flag = m_farm->InsecticideTreat(m_field, 0.0, d1);
459  }
460  else {
461  flag = m_farm->ProductApplication(m_field, 0.0, d1, cfg_pest_product_amounts.value(0), ppp_1, false, 3);
462  }
463  if (!flag) {
465  break;
466  }
467  //End of thread
468  break;
469  case dk_cars_fungicide2:
470  // Here comes the fungicide thread - done before the 30th of September - if not done, try again +1 day until the 30th of September when we will succeed
471  if (!m_farm->FungicideTreat(m_field, 0.0, g_date->DayInYear(30, 9) - g_date->DayInYear()))
472  {
473  SimpleEvent(g_date->Date() + 1, dk_cars_fungicide2, true);
474  break;
475  }
476  // LKM: Queue up the next event - fungicide3 (+ 14 days after) done before the 15th of October - if not done, try again +1 day until the 15th of October when we will succeed
477  SimpleEvent(g_date->Date() + 14, dk_cars_fungicide3, false);
478  break;
479  case dk_cars_fungicide3:
480  if (!m_farm->FungicideTreat(m_field, 0.0, g_date->DayInYear(15, 10) - g_date->DayInYear()))
481  {
482  SimpleEvent(g_date->Date() + 1, dk_cars_fungicide3, true);
483  break;
484  }
485 
486  // LKM: Queue up the next event - harvest done before the 30th of November - if not done, try again +1 day until the 30th of November when we will succeed
487  SimpleEvent(g_date->Date() + 1, dk_cars_harvest, false);
488  break;
489  case dk_cars_harvest:
490  if (m_ev->m_lock || m_farm->DoIt_prob(1.0)) {
491  if (!m_farm->Harvest(m_field, 0.0, m_field->GetMDates(1, 0) - g_date->DayInYear())) {
492  SimpleEvent(g_date->Date() + 1, dk_cars_harvest, true);
493  break;
494  }
495  d1 = g_date->Date();
496  if (d1 < g_date->OldDays() + g_date->DayInYear(1, 7)) {
497  SimpleEvent(g_date->OldDays() + g_date->DayInYear(1, 7), dk_cars_wait, false);
498  // Because we are ending harvest before 1.7 so we need to wait until the 1.7
499  break;
500  }
501  else {
502  done = true; // end of plan
503  }
504  }
505  case dk_cars_wait:
506  done = true;
507  break;
508  default:
509  g_msg->Warn(WARN_BUG, "DK_Carrots_Spring::Do(): ""Unknown event type! ", "");
510  exit(1);
511  }
512 
513  return done;
514 }

References Farm::BedForming(), cfg_pest_carrots_on, cfg_pest_product_amounts, LE::ClearManagementActionSum(), Calendar::Date(), Calendar::DayInYear(), Farm::DeepPlough(), dk_cars_bedformer, dk_cars_boron_p1, dk_cars_boron_p2, dk_cars_boron_s1, dk_cars_boron_s2, dk_cars_deep_harrow, dk_cars_ferti_p1, dk_cars_ferti_p2, dk_cars_ferti_s1, dk_cars_ferti_s2, dk_cars_fungicide1, dk_cars_fungicide2, dk_cars_fungicide3, dk_cars_harvest, dk_cars_herbicide2, dk_cars_herbicide3, dk_cars_herbicide4, dk_cars_herbicide5, dk_cars_herbicide6, dk_cars_hilling_up1, dk_cars_hilling_up2, dk_cars_hilling_up3, dk_cars_insecticide1, dk_cars_insecticide2, dk_cars_row_cultivation1, dk_cars_row_cultivation2, dk_cars_sharrow1, dk_cars_sharrow2, dk_cars_sharrow3, dk_cars_sharrow4, dk_cars_sow, dk_cars_start, dk_cars_stoneburier, dk_cars_wait, dk_cars_water1, dk_cars_water2, dk_cars_water3, Farm::DoIt_prob(), Farm::FA_Boron(), Farm::FA_NPK(), Farm::FP_Boron(), Farm::FP_NPK(), Farm::FungicideTreat(), g_date, g_msg, LE::GetMDates(), LE::GetOwner(), LE::GetPoly(), Farm::GetPreviousTov(), LE::GetRotIndex(), Farm::GetType(), Calendar::GetYearNumber(), 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, FarmEvent::m_lock, FarmEvent::m_next_tov, FarmEvent::m_startday, FarmEvent::m_todo, Calendar::OldDays(), ppp_1, Farm::ProductApplication(), Farm::RowCultivation(), LE::SetMConstants(), LE::SetMDates(), Farm::ShallowHarrow(), Crop::SimpleEvent(), Farm::SpringSow(), tof_OptimisingFarm, CfgBool::value(), CfgArray_Double::value(), MapErrorMsg::Warn(), WARN_BUG, and Farm::Water().

◆ SetUpFarmCategoryInformation()

void DK_Carrots_Spring::SetUpFarmCategoryInformation ( )
inline
83  {
84  const int elements = 2 + (dk_cars_foobar - DK_CARS_BASE);
86 
87  FarmManagementCategory catlist[elements] =
88  {
89  fmc_Others, // zero element unused but must be here
90  fmc_Others, // dk_car_start = 1, // Compulsory, start event must always be 1 (one).
91  fmc_Cultivation, // dk_car_stoneburier = DK_CAR_BASE,
92  fmc_Herbicide, // dk_car_herbicide1,
93  fmc_Cultivation, // dk_car_deep_harrow,
94  fmc_Cultivation, // dk_car_bedformer,
95  fmc_Cultivation, // dk_car_sharrow1,
96  fmc_Cultivation, // dk_car_sharrow2,
97  fmc_Cultivation, // dk_car_sharrow3,
98  fmc_Cultivation, // dk_car_sharrow4,
99  fmc_Watering, // dk_car_water1,
100  fmc_Fungicide, // dk_car_fungicide1,
101  fmc_Others, // dk_car_sow,
102  fmc_Herbicide, // dk_car_herbicide2,
103  fmc_Herbicide, // dk_car_herbicide3,
104  fmc_Fertilizer, // dk_car_ferti_s1,
105  fmc_Fertilizer, // dk_car_ferti_p1,
106  fmc_Herbicide, // dk_car_herbicide4,
107  fmc_Cultivation, // dk_car_row_cultivation1,
108  fmc_Herbicide, // dk_car_herbicide5,
109  fmc_Cultivation, // dk_car_row_cultivation2,
110  fmc_Watering, // dk_car_water2,
111  fmc_Cultivation, // dk_car_hilling_up1,
112  fmc_Herbicide, // dk_car_herbicide6,
113  fmc_Fertilizer, // dk_car_boron_s1,
114  fmc_Fertilizer, // dk_car_boron_p1,
115  fmc_Watering, // dk_car_water3,
116  fmc_Cultivation, // dk_car_hilling_up2,
117  fmc_Fertilizer, // dk_car_boron_s2,
118  fmc_Fertilizer, // dk_car_boron_p2,
119  fmc_Cultivation, // dk_car_hilling_up3,
120  fmc_Fertilizer, // dk_car_ferti_s2,
121  fmc_Fertilizer, // dk_car_ferti_p2,
122  fmc_Insecticide, // dk_car_insecticide1,
123  fmc_Insecticide, // dk_car_insecticide2,
124  fmc_Fungicide, // dk_car_fungicide2,
125  fmc_Fungicide, // dk_car_fungicide3,
126  fmc_Harvest, // dk_car_harvest,
127  fmc_Others, // dk_car_wait,
128 
129  // no foobar entry
130 
131  };
132  // Iterate over the catlist elements and copy them to vector
133  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
134  }

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

Referenced by DK_Carrots_Spring().


The documentation for this class was generated from the following files:
LE::GetMDates
int GetMDates(int a, int b)
Definition: Elements.h:405
dk_cars_harvest
Definition: DK_Carrots_Spring.h:70
fmc_Insecticide
Definition: LandscapeFarmingEnums.h:1005
dk_cars_herbicide2
Definition: DK_Carrots_Spring.h:46
LE::SetMDates
void SetMDates(int a, int b, int c)
Definition: Elements.h:406
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::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
dk_cars_ferti_p2
Definition: DK_Carrots_Spring.h:65
Farm::ProductApplication
virtual bool ProductApplication(LE *a_field, double a_user, int a_days, double a_applicationrate, PlantProtectionProducts a_ppp, bool a_isgranularpesticide=false, int a_orcharddrifttype=0)
Apply test pesticide to a_field.
Definition: FarmFuncs.cpp:2267
dk_cars_ferti_s1
Definition: DK_Carrots_Spring.h:48
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
dk_cars_fungicide3
Definition: DK_Carrots_Spring.h:69
Calendar::GetYearNumber
int GetYearNumber(void)
Definition: Calendar.h:72
FarmEvent::m_first_year
bool m_first_year
Definition: Farm.h:386
LE::GetPoly
int GetPoly(void)
Returns the polyref number for this polygon.
Definition: Elements.h:238
dk_cars_ferti_p1
Definition: DK_Carrots_Spring.h:49
dk_cars_water3
Definition: DK_Carrots_Spring.h:59
DK_CARS_BASE
#define DK_CARS_BASE
Definition: DK_Carrots_Spring.h:31
Farm::DoIt_prob
bool DoIt_prob(double a_probability)
Return chance out of 0 to 1.
Definition: Farm.cpp:864
g_date
class Calendar * g_date
Definition: Calendar.cpp:37
Farm::BedForming
virtual bool BedForming(LE *a_field, double a_user, int a_days)
Do bed forming up on a_field, probably of carrots.
Definition: FarmFuncs.cpp:1316
fmc_Herbicide
Definition: LandscapeFarmingEnums.h:1006
Farm::GetPreviousTov
TTypesOfVegetation GetPreviousTov(int a_index)
Definition: Farm.h:966
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
Farm::GetType
TTypesOfFarm GetType(void)
Definition: Farm.h:956
Crop::m_base_elements_no
int m_base_elements_no
Definition: Farm.h:505
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
DK_Carrots_Spring::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: DK_Carrots_Spring.h:83
Farm::FungicideTreat
virtual bool FungicideTreat(LE *a_field, double a_user, int a_days)
Apply fungicide to a_field.
Definition: FarmFuncs.cpp:2101
Farm::HillingUp
virtual bool HillingUp(LE *a_field, double a_user, int a_days)
Do hilling up on a_field, probably of potatoes.
Definition: FarmFuncs.cpp:1302
Crop::SimpleEvent
void SimpleEvent(long a_date, int a_todo, bool a_lock)
Adds an event to this crop management.
Definition: Farm.cpp:747
cfg_pest_carrots_on
CfgBool cfg_pest_carrots_on
Turn on pesticides for carrots.
CfgBool::value
bool value() const
Definition: Configurator.h:164
dk_cars_insecticide1
Definition: DK_Carrots_Spring.h:66
dk_cars_fungicide1
Definition: DK_Carrots_Spring.h:44
fmc_Fertilizer
Definition: LandscapeFarmingEnums.h:1004
dk_cars_sharrow1
Definition: DK_Carrots_Spring.h:39
dk_cars_ferti_s2
Definition: DK_Carrots_Spring.h:64
dk_cars_herbicide3
Definition: DK_Carrots_Spring.h:47
dk_cars_row_cultivation2
Definition: DK_Carrots_Spring.h:53
Calendar::Date
long Date(void)
Definition: Calendar.h:57
dk_cars_sharrow2
Definition: DK_Carrots_Spring.h:40
dk_cars_hilling_up3
Definition: DK_Carrots_Spring.h:63
fmc_Cultivation
Definition: LandscapeFarmingEnums.h:1008
fmc_Others
Definition: LandscapeFarmingEnums.h:1003
fmc_Watering
Definition: LandscapeFarmingEnums.h:1011
Calendar::OldDays
long OldDays(void)
Definition: Calendar.h:60
dk_cars_insecticide2
Definition: DK_Carrots_Spring.h:67
MapErrorMsg::Warn
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: MapErrorMsg.cpp:69
Farm::FA_Boron
virtual bool FA_Boron(LE *a_field, double a_user, int a_days)
Apply soluble Boron to a_field owned by a stock farmer.
Definition: FarmFuncs.cpp:868
LE::GetRotIndex
int GetRotIndex(void)
Definition: Elements.h:373
dk_cars_boron_p2
Definition: DK_Carrots_Spring.h:62
Farm::FP_Boron
virtual bool FP_Boron(LE *a_field, double a_user, int a_days)
Apply soluble Boron to a_field owned by an arable farmer.
Definition: FarmFuncs.cpp:854
FarmEvent::m_next_tov
TTypesOfVegetation m_next_tov
Definition: Farm.h:390
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
CfgArray_Double::value
std::vector< double > value() const
Definition: Configurator.h:219
dk_cars_boron_p1
Definition: DK_Carrots_Spring.h:58
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
dk_cars_start
Definition: DK_Carrots_Spring.h:34
dk_cars_sow
Definition: DK_Carrots_Spring.h:45
Farm::ShallowHarrow
virtual bool ShallowHarrow(LE *a_field, double a_user, int a_days)
Carry out a shallow harrow event on a_field, e.g., after grass cutting event.
Definition: FarmFuncs.cpp:473
dk_cars_herbicide5
Definition: DK_Carrots_Spring.h:52
Farm::RowCultivation
virtual bool RowCultivation(LE *a_field, double a_user, int a_days)
Carry out a harrowing between crop rows on a_field.
Definition: FarmFuncs.cpp:1183
tof_OptimisingFarm
Definition: LandscapeFarmingEnums.h:696
dk_cars_herbicide4
Definition: DK_Carrots_Spring.h:50
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
dk_cars_hilling_up1
Definition: DK_Carrots_Spring.h:55
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
dk_cars_boron_s2
Definition: DK_Carrots_Spring.h:61
dk_cars_water2
Definition: DK_Carrots_Spring.h:54
TTypesOfVegetation
TTypesOfVegetation
Values that represent the types of vegetation that are represented in ALMaSS.
Definition: LandscapeFarmingEnums.h:192
dk_cars_sharrow4
Definition: DK_Carrots_Spring.h:42
Farm::DeepPlough
virtual bool DeepPlough(LE *a_field, double a_user, int a_days)
Carry out a deep ploughing event on a_field.
Definition: FarmFuncs.cpp:408
dk_cars_wait
Definition: DK_Carrots_Spring.h:71
fmc_Harvest
Definition: LandscapeFarmingEnums.h:1012
dk_cars_sharrow3
Definition: DK_Carrots_Spring.h:41
dk_cars_bedformer
Definition: DK_Carrots_Spring.h:38
dk_cars_row_cultivation1
Definition: DK_Carrots_Spring.h:51
dk_cars_herbicide6
Definition: DK_Carrots_Spring.h:56
dk_cars_foobar
Definition: DK_Carrots_Spring.h:72
LE::GetOwner
Farm * GetOwner(void)
Definition: Elements.h:256
Calendar::DayInYear
int DayInYear(void)
Definition: Calendar.h:58
dk_cars_hilling_up2
Definition: DK_Carrots_Spring.h:60
dk_cars_deep_harrow
Definition: DK_Carrots_Spring.h:37
Crop::Crop
Crop(TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape *a_L)
Definition: Farm.cpp:733
cfg_pest_product_amounts
CfgArray_Double cfg_pest_product_amounts
Amount of pesticide applied in grams of active substance per hectare for each of the 10 pesticides.
dk_cars_boron_s1
Definition: DK_Carrots_Spring.h:57
dk_cars_stoneburier
Definition: DK_Carrots_Spring.h:35
LE::SetMConstants
void SetMConstants(int a, int c)
Definition: Elements.h:408
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
WARN_BUG
Definition: MapErrorMsg.h:34
ppp_1
Definition: LandscapeFarmingEnums.h:1079
fmc_Fungicide
Definition: LandscapeFarmingEnums.h:1007
FarmManagementCategory
FarmManagementCategory
Definition: LandscapeFarmingEnums.h:1001
dk_cars_fungicide2
Definition: DK_Carrots_Spring.h:68
dk_cars_water1
Definition: DK_Carrots_Spring.h:43