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

BEWinterBarleyCC class
. More...

#include <BEWinterBarleyCC.h>

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

BEWinterBarleyCC class
.

See BEWinterBarleyCC.h::BEWinterBarleyCCToDo 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

◆ BEWinterBarleyCC()

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

References Farm::AddNewEvent(), BE_wbcc_autumn_plough, BE_wbcc_ferti_p1, BE_wbcc_ferti_p3, BE_wbcc_ferti_p4, BE_wbcc_ferti_p5, BE_wbcc_ferti_s1, BE_wbcc_ferti_s3, BE_wbcc_ferti_s4, BE_wbcc_ferti_s5, BE_wbcc_fungicide1, BE_wbcc_fungicide2, BE_wbcc_growth_regulator1, BE_wbcc_growth_regulator2, BE_wbcc_harvest, BE_wbcc_hay_bailing, BE_wbcc_herbicide1, BE_wbcc_herbicide2, BE_wbcc_herbicide3, BE_wbcc_herbicide4, BE_wbcc_insecticide2, BE_wbcc_mole_plough, BE_wbcc_preseeding_cultivator_sow, BE_wbcc_start, BE_wbcc_straw_chopping, BE_wbcc_stubble_cultivator, cfg_pest_product_amounts, cfg_pest_winterbarley_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_(), Farm::StubbleHarrowing(), Landscape::SupplyLEPointer(), tof_OptimisingFarm, tov_BECatchPeaCrop, tov_BEWinterBarleyCC, 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_wbcc_mole_plough
Definition: BEWinterBarleyCC.h:39
Landscape::SupplyLEPointer
LE * SupplyLEPointer(int a_polyref)
Returns a pointer to the object referred to by the polygon number.
Definition: Landscape.h:1722
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
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
FarmEvent::m_first_year
bool m_first_year
Definition: Farm.h:386
BE_wbcc_ferti_s3
Definition: BEWinterBarleyCC.h:47
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
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_wbcc_insecticide2
Definition: BEWinterBarleyCC.h:55
Farm::GetType
TTypesOfFarm GetType(void)
Definition: Farm.h:956
BE_wbcc_herbicide2
Definition: BEWinterBarleyCC.h:42
BE_wbcc_harvest
Definition: BEWinterBarleyCC.h:58
Crop::m_first_date
int m_first_date
Definition: Farm.h:501
FarmEvent::m_startday
int m_startday
Definition: Farm.h:385
BE_wbcc_ferti_p4
Definition: BEWinterBarleyCC.h:48
BE_wbcc_herbicide4
Definition: BEWinterBarleyCC.h:52
BE_wbcc_growth_regulator1
Definition: BEWinterBarleyCC.h:56
CfgBool::value
bool value() const
Definition: Configurator.h:164
BE_wbcc_herbicide3
Definition: BEWinterBarleyCC.h:43
BE_wbcc_hay_bailing
Definition: BEWinterBarleyCC.h:60
BE_wbcc_ferti_s5
Definition: BEWinterBarleyCC.h:51
BE_wbcc_autumn_plough
Definition: BEWinterBarleyCC.h:40
tov_BEWinterBarleyCC
Definition: LandscapeFarmingEnums.h:305
Calendar::Date
long Date(void)
Definition: Calendar.h:57
BE_wbcc_ferti_s1
Definition: BEWinterBarleyCC.h:45
BE_wbcc_start
Definition: BEWinterBarleyCC.h:35
fmc_Others
Definition: LandscapeFarmingEnums.h:1003
LE::SetVegPatchy
void SetVegPatchy(bool p)
Definition: Elements.h:229
Calendar::OldDays
long OldDays(void)
Definition: Calendar.h:60
BE_wbcc_stubble_cultivator
Definition: BEWinterBarleyCC.h:37
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_wbcc_preseeding_cultivator_sow
Definition: BEWinterBarleyCC.h:41
BE_wbcc_ferti_p3
Definition: BEWinterBarleyCC.h:46
FarmEvent::m_field
LE * m_field
Definition: Farm.h:391
FarmEvent::m_next_tov
TTypesOfVegetation m_next_tov
Definition: Farm.h:390
BE_wbcc_fungicide2
Definition: BEWinterBarleyCC.h:54
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_wbcc_ferti_p1
Definition: BEWinterBarleyCC.h:44
LE::SetVegType
virtual void SetVegType(TTypesOfVegetation)
Definition: Elements.h:175
tof_OptimisingFarm
Definition: LandscapeFarmingEnums.h:696
LE
Definition: Elements.h:86
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
BE_wbcc_straw_chopping
Definition: BEWinterBarleyCC.h:59
TTypesOfVegetation
TTypesOfVegetation
Values that represent the types of vegetation that are represented in ALMaSS.
Definition: LandscapeFarmingEnums.h:192
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_wbcc_growth_regulator2
Definition: BEWinterBarleyCC.h:57
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_wbcc_ferti_s4
Definition: BEWinterBarleyCC.h:49
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.
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
BE_wbcc_fungicide1
Definition: BEWinterBarleyCC.h:53
BE_wbcc_ferti_p5
Definition: BEWinterBarleyCC.h:50
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
Crop::m_OurLandscape
Landscape * m_OurLandscape
Definition: Farm.h:506
WARN_BUG
Definition: MapErrorMsg.h:34
ppp_1
Definition: LandscapeFarmingEnums.h:1079
BE_wbcc_herbicide1
Definition: BEWinterBarleyCC.h:38
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