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

BEWinterbarley class
. More...

#include <BEWinterBarley.h>

Inheritance diagram for BEWinterBarley:
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...
 
 BEWinterBarley (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

BEWinterbarley class
.

See BEWinterbarley.h::BEWinterbarleyToDo for a complete list of all possible events triggered codes by the winter barley 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

◆ BEWinterBarley()

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

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

Member Function Documentation

◆ Do()

bool BEWinterBarley::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 Barley.

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_BEWinterBarley ; // The current type - change to match the crop you have
75  /**********************************************To Here *************************************************************************/
76  // Depending what event has occured jump to the correct bit of code
77  switch (a_ev->m_todo)
78  {
79  case BE_wb_start:
80  {
81  // BE_wb_start just sets up all the starting conditions and reference dates that are needed to start a BE_wb
82 
83  // Set up the date management stuff
84  // The next bit of code just allows for altering dates after harvest if it is necessary
85  // to allow for a crop which starts its management early.
86 
87  // 2 start and stop dates for all 'movable' events for this crop
88  int noDates = 2;
89  a_field->SetMDates(0, 0, g_date->DayInYear(30, 7)); // last possible day of harvest
90  a_field->SetMDates(1, 0, g_date->DayInYear(5, 8)); // last possible day of straw chopping
91  a_field->SetMDates(0, 1, 0); // start day of hay bailing (not used as it depend on previous treatment)
92  a_field->SetMDates(1, 1, g_date->DayInYear(10, 8)); // end day of hay bailing
93 
94  // Can be up to 10 of these. If the shortening code is triggered
95  // then these will be reduced in value to 0
96 
97  a_field->SetMConstants(0, 1);
98 
99  // Check the next crop for early start, uBEess it is a spring crop
100  // in which case we ASSUME that no checking is necessary!!!!
101  // So DO NOT implement a crop that runs over the year boundary (i.e. from spring to spring!), at least not without fixing this.
102 
103  //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)
104  //optimising farms not used for now so most of related code is removed (but not in 'start' case)
105  if (!(a_farm->GetType() == tof_OptimisingFarm && g_date->GetYearNumber() > 0)) {
106 
107  if (a_ev->m_startday > g_date->DayInYear(1, 7)) {
108  if (a_field->GetMDates(0, 0) >= a_ev->m_startday)
109  {
110  g_msg->Warn(WARN_BUG, "BEWinterBarley::Do(): ", "Harvest too late for the next crop to start!!!");
111  int almassnum = a_field->GetLandscape()->BackTranslateVegTypes(a_ev->m_next_tov);
112  g_msg->Warn("Next Crop ", (double)almassnum); // this causes exit
113  }
114  // Now fix any late finishing problems
115  for (int i = 0; i < noDates; i++) {
116  if (a_field->GetMDates(0, i) >= a_ev->m_startday) {
117  a_field->SetMDates(0, i, a_ev->m_startday - 1); //move the starting date
118  }
119  if (a_field->GetMDates(1, i) >= a_ev->m_startday) {
120  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)
121  a_field->SetMDates(1, i, a_ev->m_startday - 1); //move the finishing date
122  }
123  }
124  }
125  // Now no operations can be timed after the start of the next crop.
126 
127  if (!a_ev->m_first_year) {
128  // Are we before July 1st?
129  d1 = g_date->OldDays() + g_date->DayInYear(1, 7);
130  if (g_date->Date() < d1) {
131  // Yes, too early. We assumme this is because the last crop was late
132  printf("Poly: %d\n", a_field->GetPoly());
133  g_msg->Warn(WARN_BUG, "BEWinterBarley::Do(): ", "Crop start attempt between 1st Jan & 1st July");
134  int prev = a_field->GetLandscape()->BackTranslateVegTypes(a_field->GetOwner()->GetPreviousTov(a_field->GetRotIndex()));
135  g_msg->Warn(WARN_BUG, "Previous Crop ", prev);
136  int almassnum = a_field->GetLandscape()->BackTranslateVegTypes(a_ev->m_next_tov);
137  g_msg->Warn("Next Crop ", (double)almassnum); // this causes exit
138  exit(1);
139  }
140  else {
141  d1 = g_date->OldDays() + m_first_date; // Add 365 for spring crop
142  if (g_date->Date() > d1) {
143  // Yes too late - should not happen - raise an error
144  g_msg->Warn(WARN_BUG, "BEWinterBarley::Do(): ", "Crop start attempt after last possible start date");
145  int prev = a_field->GetLandscape()->BackTranslateVegTypes(a_field->GetOwner()->GetPreviousTov(a_field->GetRotIndex()));
146  g_msg->Warn(WARN_BUG, "Previous Crop ", prev);
147  int almassnum = a_field->GetLandscape()->BackTranslateVegTypes(a_ev->m_next_tov);
148  g_msg->Warn("Next Crop ", (double)almassnum); // this causes exit
149  exit(1);
150  }
151  }
152  }
153  else {
154  // Is the first year
155  // Some special code to cope with that first start-up year in ALMaSS - ignore for all practical purposes
156  // Code for first spring treatment used
157  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 3), BE_wb_herbicide4, false, a_farm, a_field);
158  break;
159  }
160  }//if
161 
162  // End single block date checking code. Please see next line comment as well.
163  // Reinit d1 to first possible starting date.
164  d1 = g_date->OldDays() + g_date->DayInYear(15, 8);
165  // OK, let's go.
166  // Here we queue up the first event - cultivation of stubble after previous crop
167  SimpleEvent_(d1, BE_wb_stubble_cultivator, false, a_farm, a_field);
168  }
169  break;
170 
171  // This is the first real farm operation
173  if (a_ev->m_lock || a_farm->DoIt_prob(0.30))
174  {
175  if (!a_farm->StubbleHarrowing(a_field, 0.0, g_date->DayInYear(10, 10) - g_date->DayInYear())) {
176  SimpleEvent_(g_date->Date() + 1, BE_wb_stubble_cultivator, true, a_farm, a_field);
177  break;
178  }
179  }
180  d1 = g_date->Date() + 5;
181  if (d1 < g_date->OldDays() + g_date->DayInYear(15, 9)) {
182  d1 = g_date->OldDays() + g_date->DayInYear(15, 9);
183  }
184  SimpleEvent_(d1, BE_wb_herbicide1, false, a_farm, a_field);
185  break;
186  case BE_wb_herbicide1:
187  // Some farmers will use total herbicide on a field, and some mole (deep) ploughing
188  if (a_ev->m_lock || a_farm->DoIt_prob(0.30))
189  {
190  if (!a_farm->HerbicideTreat(a_field, 0.0, g_date->DayInYear(15, 10) - g_date->DayInYear())) {
191  SimpleEvent_(g_date->Date() + 1, BE_wb_herbicide1, true, a_farm, a_field);
192  break;
193  }
194  else
195  {
196  SimpleEvent_(g_date->Date() + 15, BE_wb_autumn_plough, false, a_farm, a_field);
197  break;
198  }
199  }
200  SimpleEvent_(g_date->Date() + 1, BE_wb_mole_plough, false, a_farm, a_field);
201  break;
202  case BE_wb_mole_plough:
203  if (a_ev->m_lock || a_farm->DoIt_prob(0.1)) // 30% from the rest 80% of farmers who don't do herbicide1
204  {
205  if (!a_farm->DeepPlough(a_field, 0.0, g_date->DayInYear(25, 10) - g_date->DayInYear())) {
206  SimpleEvent_(g_date->Date() + 1, BE_wb_mole_plough, true, a_farm, a_field);
207  break;
208  }
209  }
210  SimpleEvent_(g_date->Date() + 5, BE_wb_autumn_plough, false, a_farm, a_field);
211  break;
212  case BE_wb_autumn_plough:
213  if (a_ev->m_lock || a_farm->DoIt_prob(0.70))
214  {
215  if (!a_farm->AutumnPlough(a_field, 0.0, g_date->DayInYear(30, 10) - g_date->DayInYear())) {
216  SimpleEvent_(g_date->Date() + 1, BE_wb_autumn_plough, true, a_farm, a_field);
217  break;
218  }
219  }
220  SimpleEvent_(g_date->Date() + 10, BE_wb_preseeding_cultivator_sow, false, a_farm, a_field);
221  break;
223  // all farmers do preseeding cultivation together with sowing
224  if (!a_farm->PreseedingCultivatorSow(a_field, 0.0, g_date->DayInYear(30, 11) - g_date->DayInYear())) {
225  SimpleEvent_(g_date->Date() + 1, BE_wb_preseeding_cultivator_sow, true, a_farm, a_field);
226  break;
227  }
228  SimpleEvent_(g_date->Date() + 2, BE_wb_herbicide2, false, a_farm, a_field);
229  break;
230  case BE_wb_herbicide2: // The second of the pesticide managements.
231  // Here comes the herbicide thread
232  if (!a_farm->HerbicideTreat(a_field, 0.0, g_date->DayInYear(15, 12) - g_date->DayInYear())) {
233  SimpleEvent_(g_date->Date() + 1, BE_wb_herbicide2, true, a_farm, a_field);
234  break;
235  }
236  // Here is a fork leading to four parallel events
237  SimpleEvent_(g_date->Date() + 14, BE_wb_herbicide3, false, a_farm, a_field); // Herbidide thread = Main thread
238  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(25, 3) + 365, BE_wb_fungicide1, false, a_farm, a_field); // Fungicide thread
239  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(10, 4) + 365, BE_wb_growth_regulator1, false, a_farm, a_field); // GR thread
240  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(20, 5) + 365 + m_date_modifier, BE_wb_insecticide2, false, a_farm, a_field); // GR thread
241 
242  if (a_farm->IsStockFarmer()) //Stock Farmer // slurry thread
243  {
244  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 3) + 365, BE_wb_ferti_s1, false, a_farm, a_field);
245  }
246  else SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 3) + 365, BE_wb_ferti_p1, false, a_farm, a_field);
247  if (a_farm->IsStockFarmer()) //Stock Farmer // N thread
248  {
249  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 3) + 365, BE_wb_ferti_s3, false, a_farm, a_field);
250  }
251  else SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 3) + 365, BE_wb_ferti_p3, false, a_farm, a_field);
252  break;
253  case BE_wb_herbicide3: // The first of the pesticide managements.
254  // Here comes the herbicide thread
255  if (a_ev->m_lock || a_farm->DoIt_prob(1.0))
256  {
257  if (!a_farm->HerbicideTreat(a_field, 0.0, g_date->DayInYear(30, 12) - g_date->DayInYear())) {
258  SimpleEvent_(g_date->Date() + 1, BE_wb_herbicide3, true, a_farm, a_field);
259  break;
260  }
261  }
262  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 3) + 365, BE_wb_herbicide4, false, a_farm, a_field);
263  break;
264  case BE_wb_herbicide4:
265  if (a_ev->m_lock || a_farm->DoIt_prob(1.00))
266  {
267  if (!a_farm->HerbicideTreat(a_field, 0.0, g_date->DayInYear(30, 4) - g_date->DayInYear())) {
268  SimpleEvent_(g_date->Date() + 1, BE_wb_herbicide4, true, a_farm, a_field);
269  break;
270  }
271  }
272  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 7), BE_wb_harvest, false, a_farm, a_field);
273  break;
274  case BE_wb_fungicide1:
275  // Here comes the fungicide thread
276  if (a_ev->m_lock || a_farm->DoIt_prob(0.70))
277  {
278  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(25, 4) - g_date->DayInYear())) {
279  SimpleEvent_(g_date->Date() + 1, BE_wb_fungicide1, true, a_farm, a_field);
280  break;
281  }
282  }
283  SimpleEvent_(g_date->Date() + 21, BE_wb_fungicide2, false, a_farm, a_field);
284  break;
285  case BE_wb_fungicide2:
286  if (a_ev->m_lock || a_farm->DoIt_prob(1.00))
287  {
288  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(15, 5) - g_date->DayInYear())) {
289  SimpleEvent_(g_date->Date() + 1, BE_wb_fungicide2, true, a_farm, a_field);
290  break;
291  }
292  }
293  break;
294  case BE_wb_insecticide2:
295  if (a_ev->m_lock || a_farm->DoIt_prob(0.85))
296  {
297  // here we check whether we are using ERA pesticide or not
298  d1 = g_date->DayInYear(20, 6) - g_date->DayInYear();
299  if (!cfg_pest_winterbarley_on.value() || !m_field->GetLandscape()->SupplyShouldSpray()) // Not using pesticide spray
300  {
301  flag = m_farm->InsecticideTreat(m_field, 0.0, d1);
302  }
303  else {
305  }
306  if (!flag) {
308  break;
309  }
310  }
311  // End of thread
312  break;
314  // Here comes the GR thread
315  if (!a_farm->GrowthRegulator(a_field, 0.0, g_date->DayInYear(30, 4) - g_date->DayInYear())) {
316  SimpleEvent_(g_date->Date() + 1, BE_wb_growth_regulator1, true, a_farm, a_field);
317  break;
318  }
319  SimpleEvent_(g_date->Date() + 14, BE_wb_growth_regulator2, false, a_farm, a_field);
320  break;
322  if (a_ev->m_lock || a_farm->DoIt_prob(0.50))
323  {
324  if (!a_farm->GrowthRegulator(a_field, 0.0, g_date->DayInYear(20, 5) - g_date->DayInYear())) {
325  SimpleEvent_(g_date->Date() + 1, BE_wb_growth_regulator2, true, a_farm, a_field);
326  break;
327  }
328  }
329  // End of thread
330  break;
331  case BE_wb_ferti_p1:
332  // Here comes the slurry thread
333  if (a_ev->m_lock || a_farm->DoIt_prob(0.15))
334  {
335  if (!a_farm->FP_Slurry(a_field, 0.0, g_date->DayInYear(10, 4) - g_date->DayInYear())) {
336  SimpleEvent_(g_date->Date() + 1, BE_wb_ferti_p1, true, a_farm, a_field);
337  break;
338  }
339  }
340  // End of thread
341  break;
342  case BE_wb_ferti_s1:
343  // Here comes the slurry thread
344  if (a_ev->m_lock || a_farm->DoIt_prob(0.15))
345  {
346  if (!a_farm->FA_Slurry(a_field, 0.0, g_date->DayInYear(10, 4) - g_date->DayInYear())) {
347  SimpleEvent_(g_date->Date() + 1, BE_wb_ferti_s1, true, a_farm, a_field);
348  break;
349  }
350  }
351  // End of thread
352  break;
353  case BE_wb_ferti_p3:
354  // Here comes the N thread
355  if (!a_farm->FP_AmmoniumSulphate(a_field, 0.0, g_date->DayInYear(30, 3) - g_date->DayInYear())) {
356  SimpleEvent_(g_date->Date() + 1, BE_wb_ferti_p3, true, a_farm, a_field);
357  break;
358  }
359  d1 = g_date->Date() + 21;
360  if (d1 < g_date->OldDays() + g_date->DayInYear(20, 3)) {
361  d1 = g_date->OldDays() + g_date->DayInYear(20, 3);
362  }
363  SimpleEvent_(d1, BE_wb_ferti_p4, false, a_farm, a_field);
364  break;
365  case BE_wb_ferti_s3:
366  if (!a_farm->FA_AmmoniumSulphate(a_field, 0.0, g_date->DayInYear(30, 3) - g_date->DayInYear())) {
367  SimpleEvent_(g_date->Date() + 1, BE_wb_ferti_s3, true, a_farm, a_field);
368  break;
369  }
370  d1 = g_date->Date() + 21;
371  if (d1 < g_date->OldDays() + g_date->DayInYear(20, 3)) {
372  d1 = g_date->OldDays() + g_date->DayInYear(20, 3);
373  }
374  SimpleEvent_(d1, BE_wb_ferti_s4, false, a_farm, a_field);
375  break;
376  case BE_wb_ferti_p4:
377  if (!a_farm->FP_AmmoniumSulphate(a_field, 0.0, g_date->DayInYear(20, 4) - g_date->DayInYear())) {
378  SimpleEvent_(g_date->Date() + 1, BE_wb_ferti_p4, true, a_farm, a_field);
379  break;
380  }
381  d1 = g_date->Date() + 21;
382  if (d1 < g_date->OldDays() + g_date->DayInYear(15, 4)) {
383  d1 = g_date->OldDays() + g_date->DayInYear(15, 4);
384  }
385  SimpleEvent_(d1, BE_wb_ferti_p5, false, a_farm, a_field);
386  break;
387  case BE_wb_ferti_s4:
388  if (!a_farm->FA_AmmoniumSulphate(a_field, 0.0, g_date->DayInYear(20, 4) - g_date->DayInYear())) {
389  SimpleEvent_(g_date->Date() + 1, BE_wb_ferti_s4, true, a_farm, a_field);
390  break;
391  }
392  d1 = g_date->Date() + 21;
393  if (d1 < g_date->OldDays() + g_date->DayInYear(15, 4)) {
394  d1 = g_date->OldDays() + g_date->DayInYear(15, 4);
395  }
396  SimpleEvent_(d1, BE_wb_ferti_s5, false, a_farm, a_field);
397  break;
398  case BE_wb_ferti_p5:
399  if (a_ev->m_lock || a_farm->DoIt_prob(0.70))
400  {
401  if (!a_farm->FP_AmmoniumSulphate(a_field, 0.0, g_date->DayInYear(20, 5) - g_date->DayInYear())) {
402  SimpleEvent_(g_date->Date() + 1, BE_wb_ferti_p5, true, a_farm, a_field);
403  break;
404  }
405  }
406  // End of thread
407  break;
408  case BE_wb_ferti_s5:
409  if (a_ev->m_lock || a_farm->DoIt_prob(0.70))
410  {
411  if (!a_farm->FA_AmmoniumSulphate(a_field, 0.0, g_date->DayInYear(20, 5) - g_date->DayInYear())) {
412  SimpleEvent_(g_date->Date() + 1, BE_wb_ferti_s5, true, a_farm, a_field);
413  break;
414  }
415  }
416  // End of thread
417  break;
418  case BE_wb_harvest:
419  // Here the MAIN thread continues
420  // We don't move harvest days
421  if (!a_farm->Harvest(a_field, 0.0, a_field->GetMDates(0, 0) - g_date->DayInYear())) {
422  SimpleEvent_(g_date->Date() + 1, BE_wb_harvest, true, a_farm, a_field);
423  break;
424  }
425  // 75% of farmers will leave straw on field and rest will do hay bailing
426  if (m_farm->DoIt_prob(0.05))
427  {
428  SimpleEvent_(g_date->Date() + 1, BE_wb_straw_chopping, false, a_farm, a_field);
429  }
430  else
431  {
432  SimpleEvent_(g_date->Date() + 1, BE_wb_hay_bailing, false, a_farm, a_field);
433  }
434  break;
436  if (a_field->GetMConstants(0) == 0) {
437  if (!a_farm->StrawChopping(a_field, 0.0, -1)) { // raise an error
438  g_msg->Warn(WARN_BUG, "BEWinterBarley::Do(): failure in 'StrawChopping' execution", "");
439  exit(1);
440  }
441  }
442  else {
443  if (!a_farm->StrawChopping(a_field, 0.0, a_field->GetMDates(1, 0) - g_date->DayInYear())) {
444  SimpleEvent_(g_date->Date() + 1, BE_wb_straw_chopping, true, a_farm, a_field);
445  break;
446  }
447  }
448  done = true;
449  // So we are done, and somwhere else the farmer will queue up the start event of the next crop
450  // END of MAIN THREAD
451  break;
452  case BE_wb_hay_bailing:
453  if (a_field->GetMConstants(1) == 0) {
454  if (!a_farm->HayBailing(a_field, 0.0, -1)) { // raise an error
455  g_msg->Warn(WARN_BUG, "BEWinterBarley::Do(): failure in 'HayBailing' execution", "");
456  exit(1);
457  }
458  }
459  else {
460  if (!a_farm->HayBailing(a_field, 0.0, a_field->GetMDates(1,1) - g_date->DayInYear())) {
461  SimpleEvent_(g_date->Date() + 1, BE_wb_hay_bailing, true, a_farm, a_field);
462  break;
463  }
464  }
465  done = true;
466  // So we are done, and somwhere else the farmer will queue up the start event of the next crop
467  // END of MAIN THREAD
468  break;
469  default:
470  g_msg->Warn(WARN_BUG, "BEWinterBarley::Do(): "
471  "Unknown event type! ", "");
472  exit(1);
473  }
474  return done;
475 }

References BE_wb_autumn_plough, BE_wb_ferti_p1, BE_wb_ferti_p3, BE_wb_ferti_p4, BE_wb_ferti_p5, BE_wb_ferti_s1, BE_wb_ferti_s3, BE_wb_ferti_s4, BE_wb_ferti_s5, BE_wb_fungicide1, BE_wb_fungicide2, BE_wb_growth_regulator1, BE_wb_growth_regulator2, BE_wb_harvest, BE_wb_hay_bailing, BE_wb_herbicide1, BE_wb_herbicide2, BE_wb_herbicide3, BE_wb_herbicide4, BE_wb_insecticide2, BE_wb_mole_plough, BE_wb_preseeding_cultivator_sow, BE_wb_start, BE_wb_straw_chopping, BE_wb_stubble_cultivator, cfg_pest_product_amounts, cfg_pest_winterbarley_on, Calendar::Date(), Calendar::DayInYear(), Farm::DoIt_prob(), g_date, g_msg, LE::GetMConstants(), LE::GetMDates(), LE::GetOwner(), LE::GetPoly(), Farm::GetPreviousTov(), LE::GetRotIndex(), Farm::GetType(), Calendar::GetYearNumber(), Farm::HerbicideTreat(), Farm::InsecticideTreat(), Crop::m_date_modifier, 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(), LE::SetMConstants(), LE::SetMDates(), Crop::SimpleEvent_(), Farm::StubbleHarrowing(), tof_OptimisingFarm, tov_BEWinterBarley, 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_wb_ferti_p1
Definition: BEWinterBarley.h:44
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
BE_wb_fungicide1
Definition: BEWinterBarley.h:53
FarmEvent::m_lock
bool m_lock
Definition: Farm.h:384
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
Calendar::GetYearNumber
int GetYearNumber(void)
Definition: Calendar.h:72
BE_wb_straw_chopping
Definition: BEWinterBarley.h:59
FarmEvent::m_first_year
bool m_first_year
Definition: Farm.h:386
cfg_pest_winterbarley_on
CfgBool cfg_pest_winterbarley_on
Turn on pesticides for winter barley.
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.
BE_wb_ferti_s5
Definition: BEWinterBarley.h:51
LE::GetPoly
int GetPoly(void)
Returns the polyref number for this polygon.
Definition: Elements.h:238
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
BE_wb_herbicide3
Definition: BEWinterBarley.h:43
Farm::GetPreviousTov
TTypesOfVegetation GetPreviousTov(int a_index)
Definition: Farm.h:966
BE_wb_ferti_p5
Definition: BEWinterBarley.h:50
Farm::GetType
TTypesOfFarm GetType(void)
Definition: Farm.h:956
BE_wb_start
Definition: BEWinterBarley.h:35
Crop::m_first_date
int m_first_date
Definition: Farm.h:501
FarmEvent::m_startday
int m_startday
Definition: Farm.h:385
BE_wb_growth_regulator2
Definition: BEWinterBarley.h:57
tov_BEWinterBarley
Definition: LandscapeFarmingEnums.h:301
CfgBool::value
bool value() const
Definition: Configurator.h:164
BE_wb_ferti_p4
Definition: BEWinterBarley.h:48
BE_wb_insecticide2
Definition: BEWinterBarley.h:55
Calendar::Date
long Date(void)
Definition: Calendar.h:57
BE_wb_autumn_plough
Definition: BEWinterBarley.h:40
BE_wb_ferti_s4
Definition: BEWinterBarley.h:49
BE_wb_ferti_p3
Definition: BEWinterBarley.h:46
BE_wb_ferti_s1
Definition: BEWinterBarley.h:45
BE_wb_ferti_s3
Definition: BEWinterBarley.h:47
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
FarmEvent::m_next_tov
TTypesOfVegetation m_next_tov
Definition: Farm.h:390
BE_wb_hay_bailing
Definition: BEWinterBarley.h:60
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
tof_OptimisingFarm
Definition: LandscapeFarmingEnums.h:696
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_wb_growth_regulator1
Definition: BEWinterBarley.h:56
BE_wb_preseeding_cultivator_sow
Definition: BEWinterBarley.h:41
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_wb_mole_plough
Definition: BEWinterBarley.h:39
LE::GetOwner
Farm * GetOwner(void)
Definition: Elements.h:256
Calendar::DayInYear
int DayInYear(void)
Definition: Calendar.h:58
Crop::Crop
Crop(TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape *a_L)
Definition: Farm.cpp:733
BE_wb_stubble_cultivator
Definition: BEWinterBarley.h:37
LE::SetMConstants
void SetMConstants(int a, int c)
Definition: Elements.h:408
BE_wb_herbicide1
Definition: BEWinterBarley.h:38
BE_wb_herbicide2
Definition: BEWinterBarley.h:42
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
WARN_BUG
Definition: MapErrorMsg.h:34
ppp_1
Definition: LandscapeFarmingEnums.h:1079
BE_wb_fungicide2
Definition: BEWinterBarley.h:54
BE_wb_harvest
Definition: BEWinterBarley.h:58
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
BE_wb_herbicide4
Definition: BEWinterBarley.h:52