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

BEWinterWheatCC class
. More...

#include <BEWinterWheatCC.h>

Inheritance diagram for BEWinterWheatCC:
Crop

Public Member Functions

virtual bool Do (Farm *a_farm, LE *a_field, FarmEvent *a_ev)
 The one and oBEy method for a crop management plan. All farm actions go through here. More...
 
 BEWinterWheatCC (TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape *a_L)
 
- 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...
 

Detailed Description

BEWinterWheatCC class
.

See BEWinterWheatCC.h::BEWinterWheatCCToDo for a complete list of all possible events triggered codes by the winter wheat management plan. When triggered these events are handled by Farm and are available as information for other objects such as animal and bird models.

Constructor & Destructor Documentation

◆ BEWinterWheatCC()

BEWinterWheatCC::BEWinterWheatCC ( TTypesOfVegetation  a_tov,
TTypesOfCrops  a_toc,
Landscape a_L 
)
inline
78  : Crop(a_tov, a_toc, a_L)
79  {
80  // When we start it off, the first possible date for a farm operation is 15th September
81  // This information is used by other crops when they decide how much post processing of
82  // the management is allowed after harvest before the next crop starts.
83  m_first_date=g_date->DayInYear( 10,10 );
84  }

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

Member Function Documentation

◆ Do()

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

The one and oBEy method for a crop management plan. All farm actions go through here.

Called every time something is done to the crop by the farmer in the first instance it is always called with a_ev->todo set to start, but susequently will be called whenever the farmer wants to carry out a new operation.
This method details all the management and relationships between operations necessary to grow and ALMaSS crop - in this case conventional winter wheat.

Reimplemented from Crop.

65 {
66  /******************** This block can be added to the top of all Crop::Do methods ***********************************************/
67  m_farm = a_farm; // These assignments are necessary, not for this method but for related event calls
68  m_field = a_field;
69  m_ev = a_ev;
70  bool done = false; // The boolean value done indicates when we are totally finished with this plan (i.e. it is set to true).
71  bool flag = false;
72  int d1 = 0;
73  int noDates = 1;
74  TTypesOfVegetation l_tov = tov_DKWinterWheat_CC; // The current type - change to match the crop you have
75  /**********************************************To Here *************************************************************************/
76 
77 
78  int l_nextcropstartdate;
79  // Depending what event has occured jump to the correct bit of code
80  switch (a_ev->m_todo)
81  {
82  case BE_wwcc_start:
83  {
84  // BE_wwcc_start just sets up all the starting conditions and reference dates that are needed to start a BE_ww
85 
86  // Set up the date management stuff
87  // The next bit of code just allows for altering dates after harvest if it is necessary
88  // to allow for a crop which starts its management early.
89 
90  // 2 start and stop dates for all 'movable' events for this crop
91  int noDates = 2;
92  a_field->SetMDates(0, 0, g_date->DayInYear(30, 8)); // last possible day of harvest
93  a_field->SetMDates(1, 0, g_date->DayInYear(5, 9)); // last possible day of straw chopping
94  a_field->SetMDates(0, 1, 0); // start day of hay bailing (not used as it depend on previous treatment)
95  a_field->SetMDates(1, 1, g_date->DayInYear(10, 9)); // end day of hay bailing
96 
97  // Can be up to 10 of these. If the shortening code is triggered
98  // then these will be reduced in value to 0
99 
100  a_field->SetMConstants(0, 1);
101 
102  // Check the next crop for early start, uBEess it is a spring crop
103  // in which case we ASSUME that no checking is necessary!!!!
104  // So DO NOT implement a crop that runs over the year boundary (i.e. from spring to spring!), at least not without fixing this.
105 
106  //new if: do the check oBEy for non-optimising farms and if year>0. (030713 - m_rotation used oBEy in the hidden year, so I modified the condition from >7 to >0)
107  //optimising farms not used for now so most of related code is removed (but not in 'start' case)
108  if (!(a_farm->GetType() == tof_OptimisingFarm && g_date->GetYearNumber() > 0)) {
109 
110  if (a_ev->m_startday > g_date->DayInYear(1, 7)) {
111  if (a_field->GetMDates(0, 0) >= a_ev->m_startday)
112  {
113  g_msg->Warn(WARN_BUG, "BEWinterWheatCC::Do(): ", "Harvest too late for the next crop to start!!!");
114  int almassnum = a_field->GetLandscape()->BackTranslateVegTypes(a_ev->m_next_tov);
115  g_msg->Warn("Next Crop ", (double)almassnum); // this causes exit
116  }
117  // Now fix any late finishing problems
118  for (int i = 0; i < noDates; i++) {
119  if (a_field->GetMDates(0, i) >= a_ev->m_startday) {
120  a_field->SetMDates(0, i, a_ev->m_startday - 1); //move the starting date
121  }
122  if (a_field->GetMDates(1, i) >= a_ev->m_startday) {
123  a_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)
124  a_field->SetMDates(1, i, a_ev->m_startday - 1); //move the finishing date
125  }
126  }
127  }
128  // Now no operations can be timed after the start of the next crop.
129 
130  if (!a_ev->m_first_year) {
131  // Are we before July 1st?
132  d1 = g_date->OldDays() + g_date->DayInYear(1, 7);
133  if (g_date->Date() < d1) {
134  // Yes, too early. We assumme this is because the last crop was late
135  printf("Poly: %d\n", a_field->GetPoly());
136  g_msg->Warn(WARN_BUG, "BEWinterWheatCC::Do(): ", "Crop start attempt between 1st Jan & 1st July");
137  int prev = a_field->GetLandscape()->BackTranslateVegTypes(a_field->GetOwner()->GetPreviousTov(a_field->GetRotIndex()));
138  g_msg->Warn(WARN_BUG, "Previous Crop ", prev);
139  int almassnum = a_field->GetLandscape()->BackTranslateVegTypes(a_ev->m_next_tov);
140  g_msg->Warn("Next Crop ", (double)almassnum); // this causes exit
141  exit(1);
142  }
143  else {
144  d1 = g_date->OldDays() + m_first_date; // Add 365 for spring crop
145  if (g_date->Date() > d1) {
146  // Yes too late - should not happen - raise an error
147  g_msg->Warn(WARN_BUG, "BEWinterWheatCC::Do(): ", "Crop start attempt after last possible start date");
148  int prev = a_field->GetLandscape()->BackTranslateVegTypes(a_field->GetOwner()->GetPreviousTov(a_field->GetRotIndex()));
149  g_msg->Warn(WARN_BUG, "Previous Crop ", prev);
150  int almassnum = a_field->GetLandscape()->BackTranslateVegTypes(a_ev->m_next_tov);
151  g_msg->Warn("Next Crop ", (double)almassnum); // this causes exit
152  exit(1);
153  }
154  }
155  }
156  else {
157  // Is the first year
158  // Some special code to cope with that first start-up year in ALMaSS - ignore for all practical purposes
159  // Code for first spring treatment used
160  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 3), BE_wwcc_herbicide4, false, a_farm, a_field);
161  break;
162  }
163  }//if
164 
165  // End single block date checking code. Please see next line comment as well.
166  // Reinit d1 to first possible starting date.
167  d1 = g_date->OldDays() + g_date->DayInYear(15, 8);
168  // OK, let's go.
169  // Here we queue up the first event - cultivation of stubble after previous crop
170  SimpleEvent_(d1, BE_wwcc_stubble_cultivator, false, a_farm, a_field);
171  }
172  break;
173 
174  // This is the first real farm operation
176  if (a_ev->m_lock || a_farm->DoIt_prob(0.30))
177  {
178  if (!a_farm->StubbleHarrowing(a_field, 0.0, g_date->DayInYear(15, 9) - g_date->DayInYear())) {
179  SimpleEvent_(g_date->Date() + 1, BE_wwcc_stubble_cultivator, true, a_farm, a_field);
180  break;
181  }
182  }
183  d1 = g_date->Date() + 5;
184  if (d1 < g_date->OldDays() + g_date->DayInYear(15, 9)) {
185  d1 = g_date->OldDays() + g_date->DayInYear(15, 9);
186  }
187  SimpleEvent_(d1, BE_wwcc_herbicide1, false, a_farm, a_field);
188  break;
189  case BE_wwcc_herbicide1:
190  // Some farmers will use total herbicide on a field, and some mole (deep) ploughing
191  if (a_ev->m_lock || a_farm->DoIt_prob(0.30))
192  {
193  if (!a_farm->HerbicideTreat(a_field, 0.0, g_date->DayInYear(15, 10) - g_date->DayInYear())) {
194  SimpleEvent_(g_date->Date() + 1, BE_wwcc_herbicide1, true, a_farm, a_field);
195  break;
196  }
197  else
198  {
199  SimpleEvent_(g_date->Date() + 15, BE_wwcc_autumn_plough, false, a_farm, a_field);
200  break;
201  }
202  }
203  SimpleEvent_(g_date->Date() + 1, BE_wwcc_mole_plough, false, a_farm, a_field);
204  break;
205  case BE_wwcc_mole_plough:
206  if (a_ev->m_lock || a_farm->DoIt_prob(0.1)) // 30% from the rest 80% of farmers who don't do herbicide1
207  {
208  if (!a_farm->DeepPlough(a_field, 0.0, g_date->DayInYear(25, 10) - g_date->DayInYear())) {
209  SimpleEvent_(g_date->Date() + 1, BE_wwcc_mole_plough, true, a_farm, a_field);
210  break;
211  }
212  }
213  SimpleEvent_(g_date->Date() + 5, BE_wwcc_autumn_plough, false, a_farm, a_field);
214  break;
216  if (a_ev->m_lock || a_farm->DoIt_prob(0.70))
217  {
218  if (!a_farm->AutumnPlough(a_field, 0.0, g_date->DayInYear(15, 11) - g_date->DayInYear())) {
219  SimpleEvent_(g_date->Date() + 1, BE_wwcc_autumn_plough, true, a_farm, a_field);
220  break;
221  }
222  }
223  SimpleEvent_(g_date->Date() + 10, BE_wwcc_preseeding_cultivator_sow, false, a_farm, a_field);
224  break;
226  // all farmers do preseeding cultivation together with sowing
227  if (!a_farm->PreseedingCultivatorSow(a_field, 0.0, g_date->DayInYear(30, 11) - g_date->DayInYear())) {
228  SimpleEvent_(g_date->Date() + 1, BE_wwcc_preseeding_cultivator_sow, true, a_farm, a_field);
229  break;
230  }
231  SimpleEvent_(g_date->Date() + 2, BE_wwcc_herbicide2, false, a_farm, a_field);
232  break;
233  case BE_wwcc_herbicide2: // The second of the pesticide managements.
234  // Here comes the herbicide thread
235  if (!a_farm->HerbicideTreat(a_field, 0.0, g_date->DayInYear(15, 12) - g_date->DayInYear())) {
236  SimpleEvent_(g_date->Date() + 1, BE_wwcc_herbicide2, true, a_farm, a_field);
237  break;
238  }
239  // Here is a fork leading to four parallel events
240  SimpleEvent_(g_date->Date() + 14, BE_wwcc_herbicide3, false, a_farm, a_field); // Herbidide thread = Main thread
241  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(25, 3) + 365, BE_wwcc_fungicide1, false, a_farm, a_field); // Fungicide thread
242  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(10, 4) + 365, BE_wwcc_growth_regulator1, false, a_farm, a_field); // GR thread
243  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(20, 5) + 365 + m_date_modifier, BE_wwcc_insecticide2, false, a_farm, a_field); // GR thread
244 
245  if (a_farm->IsStockFarmer()) //Stock Farmer // slurry thread
246  {
247  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 3) + 365, BE_wwcc_ferti_s1, false, a_farm, a_field);
248  }
249  else SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 3) + 365, BE_wwcc_ferti_p1, false, a_farm, a_field);
250  if (a_farm->IsStockFarmer()) //Stock Farmer // N thread
251  {
252  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 3) + 365, BE_wwcc_ferti_s3, false, a_farm, a_field);
253  }
254  else SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 3) + 365, BE_wwcc_ferti_p3, false, a_farm, a_field);
255  break;
256  case BE_wwcc_herbicide3: // The first of the pesticide managements.
257  // Here comes the herbicide thread
258  if (a_ev->m_lock || a_farm->DoIt_prob(1.0))
259  {
260  if (!a_farm->HerbicideTreat(a_field, 0.0, g_date->DayInYear(30, 12) - g_date->DayInYear())) {
261  SimpleEvent_(g_date->Date() + 1, BE_wwcc_herbicide3, true, a_farm, a_field);
262  break;
263  }
264  }
265  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 3) + 365, BE_wwcc_herbicide4, false, a_farm, a_field);
266  break;
267  case BE_wwcc_herbicide4:
268  if (a_ev->m_lock || a_farm->DoIt_prob(1.00))
269  {
270  if (!a_farm->HerbicideTreat(a_field, 0.0, g_date->DayInYear(30, 4) - g_date->DayInYear())) {
271  SimpleEvent_(g_date->Date() + 1, BE_wwcc_herbicide4, true, a_farm, a_field);
272  break;
273  }
274  }
275  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(10, 7), BE_wwcc_harvest, false, a_farm, a_field);
276  break;
277  case BE_wwcc_fungicide1:
278  // Here comes the fungicide thread
279  if (a_ev->m_lock || a_farm->DoIt_prob(0.70))
280  {
281  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(25, 4) - g_date->DayInYear())) {
282  SimpleEvent_(g_date->Date() + 1, BE_wwcc_fungicide1, true, a_farm, a_field);
283  break;
284  }
285  }
286  SimpleEvent_(g_date->Date() + 21, BE_wwcc_fungicide2, false, a_farm, a_field);
287  break;
288  case BE_wwcc_fungicide2:
289  if (a_ev->m_lock || a_farm->DoIt_prob(0.9))
290  {
291  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(15, 5) - g_date->DayInYear())) {
292  SimpleEvent_(g_date->Date() + 1, BE_wwcc_fungicide2, true, a_farm, a_field);
293  break;
294  }
295  }
296  SimpleEvent_(g_date->Date() + 21, BE_wwcc_fungicide3, false, a_farm, a_field);
297  break;
298  case BE_wwcc_fungicide3:
299  if (a_ev->m_lock || a_farm->DoIt_prob(1.0))
300  {
301  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(10, 6) - g_date->DayInYear())) {
302  SimpleEvent_(g_date->Date() + 1, BE_wwcc_fungicide3, true, a_farm, a_field);
303  break;
304  }
305  }
306  break;
308 #ifdef ECOSTACK_BIOPESTICIDE
309  if (a_ev->m_lock || a_farm->DoIt_prob(0.85))
310 #else
311  if (a_ev->m_lock || a_farm->DoIt_prob(0.85))
312 #endif
313  {
314  // here we check whether we are using ERA pesticide or not
315  d1 = g_date->DayInYear(20, 6) - g_date->DayInYear();
316  if (!cfg_pest_winterwheat_on.value() || !m_field->GetLandscape()->SupplyShouldSpray()) // Not using pesticide spray
317  {
318 #ifdef ECOSTACK_BIOPESTICIDE
319  flag = m_farm->BiocideTreat(m_field, 0.0, d1);
320 #else
321  flag = m_farm->InsecticideTreat(m_field, 0.0, d1);
322 #endif
323  }
324  else {
326  }
327  if (!flag) {
329  break;
330  }
331 #ifdef ECOSTACK_BIOPESTICIDE
333 #else
334  break; // end of thread
335 #endif
336  }
337  // End of thread
338  break;
339 #ifdef ECOSTACK_BIOPESTICIDE
341  if (m_ev->m_lock || m_farm->DoIt_prob(1.0)) {
342  // here we check whether we are using ERA pesticide or not
343  d1 = g_date->DayInYear(27, 6) - g_date->DayInYear();
344  flag = m_farm->BiocideTreat(m_field, 0.0, d1);
345  if (!flag) {
347  break;
348  }
349  }
350  break; // end of thread
351 #endif
353  // Here comes the GR thread
354  if (!a_farm->GrowthRegulator(a_field, 0.0, g_date->DayInYear(30, 4) - g_date->DayInYear())) {
355  SimpleEvent_(g_date->Date() + 1, BE_wwcc_growth_regulator1, true, a_farm, a_field);
356  break;
357  }
358  SimpleEvent_(g_date->Date() + 14, BE_wwcc_growth_regulator2, false, a_farm, a_field);
359  break;
361  if (a_ev->m_lock || a_farm->DoIt_prob(0.80))
362  {
363  if (!a_farm->GrowthRegulator(a_field, 0.0, g_date->DayInYear(20, 5) - g_date->DayInYear())) {
364  SimpleEvent_(g_date->Date() + 1, BE_wwcc_growth_regulator2, true, a_farm, a_field);
365  break;
366  }
367  }
368  // End of thread
369  break;
370  case BE_wwcc_ferti_p1:
371  // Here comes the slurry thread
372  if (a_ev->m_lock || a_farm->DoIt_prob(0.15))
373  {
374  if (!a_farm->FP_Slurry(a_field, 0.0, g_date->DayInYear(10, 4) - g_date->DayInYear())) {
375  SimpleEvent_(g_date->Date() + 1, BE_wwcc_ferti_p1, true, a_farm, a_field);
376  break;
377  }
378  }
379  // End of thread
380  break;
381  case BE_wwcc_ferti_s1:
382  // Here comes the slurry thread
383  if (a_ev->m_lock || a_farm->DoIt_prob(0.15))
384  {
385  if (!a_farm->FA_Slurry(a_field, 0.0, g_date->DayInYear(10, 4) - g_date->DayInYear())) {
386  SimpleEvent_(g_date->Date() + 1, BE_wwcc_ferti_s1, true, a_farm, a_field);
387  break;
388  }
389  }
390  // End of thread
391  break;
392  case BE_wwcc_ferti_p3:
393  // Here comes the N thread
394  if (!a_farm->FP_AmmoniumSulphate(a_field, 0.0, g_date->DayInYear(30, 3) - g_date->DayInYear())) {
395  SimpleEvent_(g_date->Date() + 1, BE_wwcc_ferti_p3, true, a_farm, a_field);
396  break;
397  }
398  d1 = g_date->Date() + 21;
399  if (d1 < g_date->OldDays() + g_date->DayInYear(20, 3)) {
400  d1 = g_date->OldDays() + g_date->DayInYear(20, 3);
401  }
402  SimpleEvent_(d1, BE_wwcc_ferti_p4, false, a_farm, a_field);
403  break;
404  case BE_wwcc_ferti_s3:
405  if (!a_farm->FA_AmmoniumSulphate(a_field, 0.0, g_date->DayInYear(30, 3) - g_date->DayInYear())) {
406  SimpleEvent_(g_date->Date() + 1, BE_wwcc_ferti_s3, true, a_farm, a_field);
407  break;
408  }
409  d1 = g_date->Date() + 21;
410  if (d1 < g_date->OldDays() + g_date->DayInYear(20, 3)) {
411  d1 = g_date->OldDays() + g_date->DayInYear(20, 3);
412  }
413  SimpleEvent_(d1, BE_wwcc_ferti_s4, false, a_farm, a_field);
414  break;
415  case BE_wwcc_ferti_p4:
416  if (!a_farm->FP_AmmoniumSulphate(a_field, 0.0, g_date->DayInYear(20, 4) - g_date->DayInYear())) {
417  SimpleEvent_(g_date->Date() + 1, BE_wwcc_ferti_p4, true, a_farm, a_field);
418  break;
419  }
420  d1 = g_date->Date() + 21;
421  if (d1 < g_date->OldDays() + g_date->DayInYear(15, 4)) {
422  d1 = g_date->OldDays() + g_date->DayInYear(15, 4);
423  }
424  SimpleEvent_(d1, BE_wwcc_ferti_p5, false, a_farm, a_field);
425  break;
426  case BE_wwcc_ferti_s4:
427  if (!a_farm->FA_AmmoniumSulphate(a_field, 0.0, g_date->DayInYear(20, 4) - g_date->DayInYear())) {
428  SimpleEvent_(g_date->Date() + 1, BE_wwcc_ferti_s4, true, a_farm, a_field);
429  break;
430  }
431  d1 = g_date->Date() + 21;
432  if (d1 < g_date->OldDays() + g_date->DayInYear(15, 4)) {
433  d1 = g_date->OldDays() + g_date->DayInYear(15, 4);
434  }
435  SimpleEvent_(d1, BE_wwcc_ferti_s5, false, a_farm, a_field);
436  break;
437  case BE_wwcc_ferti_p5:
438  if (a_ev->m_lock || a_farm->DoIt_prob(0.70))
439  {
440  if (!a_farm->FP_AmmoniumSulphate(a_field, 0.0, g_date->DayInYear(20, 5) - g_date->DayInYear())) {
441  SimpleEvent_(g_date->Date() + 1, BE_wwcc_ferti_p5, true, a_farm, a_field);
442  break;
443  }
444  }
445  // End of thread
446  break;
447  case BE_wwcc_ferti_s5:
448  if (a_ev->m_lock || a_farm->DoIt_prob(0.70))
449  {
450  if (!a_farm->FA_AmmoniumSulphate(a_field, 0.0, g_date->DayInYear(20, 5) - g_date->DayInYear())) {
451  SimpleEvent_(g_date->Date() + 1, BE_wwcc_ferti_s5, true, a_farm, a_field);
452  break;
453  }
454  }
455  // End of thread
456  break;
457  case BE_wwcc_harvest:
458  // Here the MAIN thread continues
459  // We don't move harvest days
460  if (!a_farm->Harvest(a_field, 0.0, a_field->GetMDates(0, 0) - g_date->DayInYear())) {
461  SimpleEvent_(g_date->Date() + 1, BE_wwcc_harvest, true, a_farm, a_field);
462  break;
463  }
464  // 75% of farmers will leave straw on field and rest will do hay bailing
465  if (m_farm->DoIt_prob(0.15))
466  {
467  SimpleEvent_(g_date->Date() + 1, BE_wwcc_straw_chopping, false, a_farm, a_field);
468  }
469  else
470  {
471  SimpleEvent_(g_date->Date() + 1, BE_wwcc_hay_bailing, false, a_farm, a_field);
472  }
473  break;
475  if (a_field->GetMConstants(0) == 0) {
476  if (!a_farm->StrawChopping(a_field, 0.0, -1)) { // raise an error
477  g_msg->Warn(WARN_BUG, "BEWinterWheatCC::Do(): failure in 'StrawChopping' execution", "");
478  exit(1);
479  }
480  }
481  else {
482  if (!a_farm->StrawChopping(a_field, 0.0, a_field->GetMDates(1, 0) - g_date->DayInYear())) {
483  SimpleEvent_(g_date->Date() + 1, BE_wwcc_straw_chopping, true, a_farm, a_field);
484  break;
485  }
486  }
487  done = true;
488  // So we are done, and somwhere else the farmer will queue up the start event of the next crop
489  // END of MAIN THREAD
490  break;
491  case BE_wwcc_hay_bailing:
492  if (a_field->GetMConstants(1) == 0) {
493  if (!a_farm->HayBailing(a_field, 0.0, -1)) { // raise an error
494  g_msg->Warn(WARN_BUG, "BEWinterWheatCC::Do(): failure in 'HayBailing' execution", "");
495  exit(1);
496  }
497  }
498  else {
499  if (!a_farm->HayBailing(a_field, 0.0, a_field->GetMDates(1, 1) - g_date->DayInYear())) {
500  SimpleEvent_(g_date->Date() + 1, BE_wwcc_hay_bailing, true, a_farm, a_field);
501  break;
502  }
503  }
504  // So we are done,but this crop uses a catch crop
505  l_nextcropstartdate = m_farm->GetNextCropStartDate(m_ev->m_field, l_tov);
506  m_field->BumpRunNum();
507  m_field->SetVegPatchy(false); // reverse the patchy before the next crop
508  m_farm->AddNewEvent(tov_BECatchPeaCrop, g_date->Date(), m_ev->m_field, PROG_START, m_ev->m_field->GetRunNum(), false, l_nextcropstartdate, false, l_tov, fmc_Others, false, false);
509  m_field->SetVegType(tov_BECatchPeaCrop, tov_Undefined); // Two vegetation curves are specified
510  if (m_field->GetUnsprayedMarginPolyRef() != -1)
511  {
514  }
515  // NB no "done = true" because this crop effectively continues into the catch crop.
516  break;
517  default:
518  g_msg->Warn(WARN_BUG, "BEWinterWheatCC::Do(): "
519  "Unknown event type! ", "");
520  exit(1);
521  }
522  return done;
523 }

References Farm::AddNewEvent(), BE_wwcc_autumn_plough, BE_wwcc_ferti_p1, BE_wwcc_ferti_p3, BE_wwcc_ferti_p4, BE_wwcc_ferti_p5, BE_wwcc_ferti_s1, BE_wwcc_ferti_s3, BE_wwcc_ferti_s4, BE_wwcc_ferti_s5, BE_wwcc_fungicide1, BE_wwcc_fungicide2, BE_wwcc_fungicide3, BE_wwcc_growth_regulator1, BE_wwcc_growth_regulator2, BE_wwcc_harvest, BE_wwcc_hay_bailing, BE_wwcc_herbicide1, BE_wwcc_herbicide2, BE_wwcc_herbicide3, BE_wwcc_herbicide4, BE_wwcc_insecticide2, BE_wwcc_insecticide2b, BE_wwcc_mole_plough, BE_wwcc_preseeding_cultivator_sow, BE_wwcc_start, BE_wwcc_straw_chopping, BE_wwcc_stubble_cultivator, Farm::BiocideTreat(), cfg_pest_product_amounts, cfg_pest_winterwheat_on, Calendar::Date(), Calendar::DayInYear(), Farm::DoIt_prob(), fmc_Others, g_date, g_msg, LE::GetMConstants(), LE::GetMDates(), Farm::GetNextCropStartDate(), LE::GetOwner(), LE::GetPoly(), Farm::GetPreviousTov(), LE::GetRotIndex(), Farm::GetType(), LE::GetUnsprayedMarginPolyRef(), Calendar::GetYearNumber(), Farm::HerbicideTreat(), Farm::InsecticideTreat(), Crop::m_date_modifier, Crop::m_ev, Crop::m_farm, FarmEvent::m_field, Crop::m_field, Crop::m_first_date, FarmEvent::m_first_year, FarmEvent::m_lock, FarmEvent::m_next_tov, Crop::m_OurLandscape, FarmEvent::m_startday, FarmEvent::m_todo, Calendar::OldDays(), ppp_1, Farm::ProductApplication(), PROG_START, LE::SetMConstants(), LE::SetMDates(), LE::SetVegPatchy(), LE::SetVegType(), Crop::SimpleEvent(), Crop::SimpleEvent_(), Farm::StubbleHarrowing(), Landscape::SupplyLEPointer(), tof_OptimisingFarm, tov_BECatchPeaCrop, tov_DKWinterWheat_CC, tov_Undefined, CfgBool::value(), CfgArray_Double::value(), MapErrorMsg::Warn(), and WARN_BUG.


The documentation for this class was generated from the following files:
LE::GetMDates
int GetMDates(int a, int b)
Definition: Elements.h:405
BE_wwcc_fungicide3
Definition: BEWinterWheatCC.h:55
Landscape::SupplyLEPointer
LE * SupplyLEPointer(int a_polyref)
Returns a pointer to the object referred to by the polygon number.
Definition: Landscape.h:1722
BE_wwcc_fungicide2
Definition: BEWinterWheatCC.h:54
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
FarmEvent::m_lock
bool m_lock
Definition: Farm.h:384
BE_wwcc_autumn_plough
Definition: BEWinterWheatCC.h:40
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
LE::GetMConstants
int GetMConstants(int a)
Definition: Elements.h:407
BE_wwcc_ferti_p4
Definition: BEWinterWheatCC.h:48
Calendar::GetYearNumber
int GetYearNumber(void)
Definition: Calendar.h:72
FarmEvent::m_first_year
bool m_first_year
Definition: Farm.h:386
BE_wwcc_insecticide2b
Definition: BEWinterWheatCC.h:57
LE::GetPoly
int GetPoly(void)
Returns the polyref number for this polygon.
Definition: Elements.h:238
tov_BECatchPeaCrop
Definition: LandscapeFarmingEnums.h:291
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::GetPreviousTov
TTypesOfVegetation GetPreviousTov(int a_index)
Definition: Farm.h:966
BE_wwcc_ferti_s3
Definition: BEWinterWheatCC.h:47
Farm::GetNextCropStartDate
int GetNextCropStartDate(LE *a_field, TTypesOfVegetation &a_curr_veg)
Returns the start date of the next crop in the rotation.
Definition: Farm.cpp:920
Farm::AddNewEvent
void AddNewEvent(TTypesOfVegetation a_event, long a_date, LE *a_field, int a_todo, long a_num, bool a_lock, int a_start, bool a_first_year, TTypesOfVegetation a_crop, FarmManagementCategory a_fmc, bool a_forcespring, bool a_forcespringOK)
Adds an event to the event queue for a farm.
Definition: Farm.cpp:845
BE_wwcc_straw_chopping
Definition: BEWinterWheatCC.h:61
Farm::GetType
TTypesOfFarm GetType(void)
Definition: Farm.h:956
BE_wwcc_herbicide1
Definition: BEWinterWheatCC.h:38
Crop::m_first_date
int m_first_date
Definition: Farm.h:501
FarmEvent::m_startday
int m_startday
Definition: Farm.h:385
BE_wwcc_ferti_p5
Definition: BEWinterWheatCC.h:50
BE_wwcc_growth_regulator1
Definition: BEWinterWheatCC.h:58
Crop::SimpleEvent
void SimpleEvent(long a_date, int a_todo, bool a_lock)
Adds an event to this crop management.
Definition: Farm.cpp:747
BE_wwcc_preseeding_cultivator_sow
Definition: BEWinterWheatCC.h:41
CfgBool::value
bool value() const
Definition: Configurator.h:164
BE_wwcc_ferti_s4
Definition: BEWinterWheatCC.h:49
BE_wwcc_start
Definition: BEWinterWheatCC.h:35
Calendar::Date
long Date(void)
Definition: Calendar.h:57
fmc_Others
Definition: LandscapeFarmingEnums.h:1003
BE_wwcc_stubble_cultivator
Definition: BEWinterWheatCC.h:37
LE::SetVegPatchy
void SetVegPatchy(bool p)
Definition: Elements.h:229
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
LE::GetRotIndex
int GetRotIndex(void)
Definition: Elements.h:373
BE_wwcc_fungicide1
Definition: BEWinterWheatCC.h:53
BE_wwcc_ferti_p3
Definition: BEWinterWheatCC.h:46
FarmEvent::m_field
LE * m_field
Definition: Farm.h:391
BE_wwcc_hay_bailing
Definition: BEWinterWheatCC.h:62
FarmEvent::m_next_tov
TTypesOfVegetation m_next_tov
Definition: Farm.h:390
BE_wwcc_herbicide3
Definition: BEWinterWheatCC.h:43
Crop::m_farm
Farm * m_farm
Definition: Farm.h:498
Crop::m_field
LE * m_field
Definition: Farm.h:499
CfgArray_Double::value
std::vector< double > value() const
Definition: Configurator.h:219
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
tov_Undefined
Definition: LandscapeFarmingEnums.h:610
BE_wwcc_herbicide2
Definition: BEWinterWheatCC.h:42
LE::SetVegType
virtual void SetVegType(TTypesOfVegetation)
Definition: Elements.h:175
BE_wwcc_herbicide4
Definition: BEWinterWheatCC.h:52
Farm::BiocideTreat
virtual bool BiocideTreat(LE *a_field, double a_user, int a_days)
Apply Biocide to a_field.
Definition: FarmFuncs.cpp:2175
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.
tof_OptimisingFarm
Definition: LandscapeFarmingEnums.h:696
BE_wwcc_harvest
Definition: BEWinterWheatCC.h:60
LE
Definition: Elements.h:86
BE_wwcc_ferti_s1
Definition: BEWinterWheatCC.h:45
tov_DKWinterWheat_CC
Definition: LandscapeFarmingEnums.h:422
cfg_pest_winterwheat_on
CfgBool cfg_pest_winterwheat_on
Turn on pesticides for winter wheat.
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
TTypesOfVegetation
TTypesOfVegetation
Values that represent the types of vegetation that are represented in ALMaSS.
Definition: LandscapeFarmingEnums.h:192
BE_wwcc_ferti_s5
Definition: BEWinterWheatCC.h:51
Crop::m_date_modifier
static int m_date_modifier
Holds a value that shifts test pesticide use by this many days in crops modified to use it.
Definition: Farm.h:514
BE_wwcc_mole_plough
Definition: BEWinterWheatCC.h:39
BE_wwcc_ferti_p1
Definition: BEWinterWheatCC.h:44
LE::GetUnsprayedMarginPolyRef
int GetUnsprayedMarginPolyRef(void)
Definition: Elements.h:383
LE::GetOwner
Farm * GetOwner(void)
Definition: Elements.h:256
Calendar::DayInYear
int DayInYear(void)
Definition: Calendar.h:58
BE_wwcc_insecticide2
Definition: BEWinterWheatCC.h:56
Crop::Crop
Crop(TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape *a_L)
Definition: Farm.cpp:733
PROG_START
#define PROG_START
Definition: Farm.h:69
LE::SetMConstants
void SetMConstants(int a, int c)
Definition: Elements.h:408
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
Crop::m_OurLandscape
Landscape * m_OurLandscape
Definition: Farm.h:506
BE_wwcc_growth_regulator2
Definition: BEWinterWheatCC.h:59
WARN_BUG
Definition: MapErrorMsg.h:34
ppp_1
Definition: LandscapeFarmingEnums.h:1079
Farm::StubbleHarrowing
virtual bool StubbleHarrowing(LE *a_field, double a_user, int a_days)
Carry out stubble harrowing on a_field.
Definition: FarmFuncs.cpp:1523
Crop::SimpleEvent_
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.
Definition: Farm.cpp:751