ALMaSS Skylark ODDox  1.1
The skylark model description following ODdox protocol
NLSpringBarley Class Reference

NLSpringBarley class
. More...

#include <NLSpringBarley.h>

Public Member Functions

virtual bool Do (Farm *a_farm, LE *a_field, FarmEvent *a_ev)
 The one and only method for a crop management plan. All farm actions go through here. More...
 
 NLSpringBarley ()
 
- Public Member Functions inherited from Crop
virtual ~Crop ()
 
 Crop ()
 
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)
 

Additional Inherited Members

- 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...
 
- Protected Attributes inherited from Crop
Farmm_farm
 
LE * m_field
 
FarmEventm_ev
 
int m_first_date
 
int m_count
 
int m_last_date
 
int m_ddegstoharvest
 
int m_CropClassification
 

Detailed Description

NLSpringBarley class
.

See NLSpringBarley.h::NLSpringBarleyToDo for a complete list of all possible events triggered codes by the spring 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

◆ NLSpringBarley()

NLSpringBarley::NLSpringBarley ( )
inline
81  {
82  // When we start it off, the first possible date for a farm operation is 5th November
83  // This information is used by other crops when they decide how much post processing of
84  // the management is allowed after harvest before the next crop starts.
85  m_first_date=g_date->DayInYear( 31,10 );
86  }

References Crop::m_first_date.

Member Function Documentation

◆ Do()

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

The one and only 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 spring barley.

Reimplemented from Crop.

65 {
66  bool done = false; // The boolean value done indicates when we are totally finished with this plan (i.e. it is set to true).
67  int d1 = 0;
68  // Depending what event has occured jump to the correct bit of code
69  switch (a_ev->m_todo)
70  {
71  case nl_sb_start:
72  {
73  // nl_sb_start just sets up all the starting conditions and reference dates that are needed to start a nl_sb
74  NL_SB_FUNGII = false;
75 
76  // Set up the date management stuff
77  // The next bit of code just allows for altering dates after harvest if it is necessary
78  // to allow for a crop which starts its management early.
79 
80  // 5 start and stop dates for all 'movable' events for this crop
81  int noDates = 2;
82  a_field->SetMDates(0, 0, g_date->DayInYear(15, 8)); // last possible day of harvest
83  a_field->SetMDates(1, 0, g_date->DayInYear(20, 8)); // last possible day of straw chopping
84  a_field->SetMDates(0, 1, 0); // start day of hay bailing (not used as it depend on previous treatment)
85  a_field->SetMDates(1, 1, g_date->DayInYear(25, 8)); // end day of hay bailing
86  // Can be up to 10 of these. If the shortening code is triggered
87  // then these will be reduced in value to 0
88 
89  a_field->SetMConstants(0, 1);
90 
91  // Check the next crop for early start, unless it is a spring crop
92  // in which case we ASSUME that no checking is necessary!!!!
93  // So DO NOT implement a crop that runs over the year boundary (i.e. from spring to spring!), at least not without fixing this.
94 
95  //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)
96  //optimising farms not used for now so most of related code is removed (but not in 'start' case)
97  if (!(a_farm->GetType() == tof_OptimisingFarm && g_date->GetYearNumber() > 0)) {
98 
99  if (a_ev->m_startday > g_date->DayInYear(1, 7)) {
100  if (a_field->GetMDates(0, 0) >= a_ev->m_startday)
101  {
102  g_msg->Warn(WARN_BUG, "NLSpringBarley::Do(): ", "Harvest too late for the next crop to start!!!");
103  int almassnum = g_landscape_p->BackTranslateVegTypes(a_ev->m_next_tov);
104  g_msg->Warn("Next Crop ", (double)almassnum); // this causes exit
105  }
106  // Now fix any late finishing problems
107  for (int i = 0; i < noDates; i++) {
108  if (a_field->GetMDates(0, i) >= a_ev->m_startday) {
109  a_field->SetMDates(0, i, a_ev->m_startday - 1); //move the starting date
110  }
111  if (a_field->GetMDates(1, i) >= a_ev->m_startday) {
112  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)
113  a_field->SetMDates(1, i, a_ev->m_startday - 1); //move the finishing date
114  }
115  }
116  }
117  // Now no operations can be timed after the start of the next crop.
118 
119  if (!a_ev->m_first_year) {
120  // Are we before July 1st?
121  d1 = g_date->OldDays() + g_date->DayInYear(1, 7);
122  if (g_date->Date() < d1) {
123  // Yes, too early. We assumme this is because the last crop was late
124  printf("Poly: %d\n", a_field->GetPoly());
125  g_msg->Warn(WARN_BUG, "NLSpringBarley::Do(): ", "Crop start attempt between 1st Jan & 1st July");
126  int prev = g_landscape_p->BackTranslateVegTypes(a_field->GetOwner()->GetPreviousCrop(a_field->GetRotIndex()));
127  g_msg->Warn(WARN_BUG, "Previous Crop ", prev);
128  int almassnum = g_landscape_p->BackTranslateVegTypes(a_ev->m_next_tov);
129  g_msg->Warn("Next Crop ", (double)almassnum); // this causes exit
130  exit(1);
131  }
132  else {
133  d1 = g_date->OldDays() + m_first_date; // Add 365 for spring crop
134  if (g_date->Date() > d1) {
135  // Yes too late - should not happen - raise an error
136  g_msg->Warn(WARN_BUG, "NLSpringBarley::Do(): ", "Crop start attempt after last possible start date");
137  int prev = g_landscape_p->BackTranslateVegTypes(a_field->GetOwner()->GetPreviousCrop(a_field->GetRotIndex()));
138  g_msg->Warn(WARN_BUG, "Previous Crop ", prev);
139  int almassnum = g_landscape_p->BackTranslateVegTypes(a_ev->m_next_tov);
140  g_msg->Warn("Next Crop ", (double)almassnum); // this causes exit
141  exit(1);
142  }
143  }
144  }
145  else {
146  // Is the first year
147  // Some special code to cope with that first start-up year in ALMaSS - ignore for all practical purposes
148  // Code for first spring treatment used
149  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 3), nl_sb_spring_sow, false, a_farm, a_field);
150  break;
151  }
152  }//if
153  // End single block date checking code. Please see next line comment as well.
154  // Reinit d1 to first possible starting date.
155  d1 = g_date->OldDays() + g_date->DayInYear(1, 9);
156  // OK, let's go.
157  // Here we queue up the first event - this differs depending on whether we have field on snady or clay soils
158  if (a_field->GetSoilType() == 2 || a_field->GetSoilType() == 6) { // on sandy soils (NL ZAND & LOSS)
159  SimpleEvent_(d1, nl_sb_stubble_harrow_sandy, false, a_farm, a_field);
160  }
161  else SimpleEvent_(d1, nl_sb_stubble_harrow_clay, false, a_farm, a_field);
162  }
163  break;
164 
165  // This is the first real farm operation
167  if (!a_farm->StubbleHarrowing(a_field, 0.0, g_date->DayInYear(31,10) - g_date->DayInYear())) {
168  SimpleEvent_(g_date->Date() + 1, nl_sb_stubble_harrow_sandy, true, a_farm, a_field);
169  break;
170  }
171  if (a_farm->IsStockFarmer()) //Stock Farmer
172  {
173  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 3) + 365, nl_sb_ferti_s1_sandy, false, a_farm, a_field);
174  }
175  else SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 3) + 365, nl_sb_ferti_p1_sandy, false, a_farm, a_field);
176  break;
178  if (a_ev->m_lock || a_farm->DoIt_prob(0.40))
179  {
180  if (!a_farm->FP_Slurry(a_field, 0.0, g_date->DayInYear(25, 3) - g_date->DayInYear())) {
181  SimpleEvent_(g_date->Date() + 1, nl_sb_ferti_p1_sandy, true, a_farm, a_field);
182  break;
183  }
184  }
185  SimpleEvent_(g_date->Date() + 1, nl_sb_spring_plough_sandy, false, a_farm, a_field);
186  break;
188  if (a_ev->m_lock || a_farm->DoIt_prob(0.40))
189  {
190  if (!a_farm->FA_Slurry(a_field, 0.0, g_date->DayInYear(25, 3) - g_date->DayInYear())) {
191  SimpleEvent_(g_date->Date() + 1, nl_sb_ferti_s1_sandy, true, a_farm, a_field);
192  break;
193  }
194  }
195  SimpleEvent_(g_date->Date() + 1, nl_sb_spring_plough_sandy, false, a_farm, a_field);
196  break;
198  if (a_ev->m_lock || a_farm->DoIt_prob(0.20))
199  {
200  if (!a_farm->SpringPlough(a_field, 0.0, g_date->DayInYear(25, 3) - g_date->DayInYear())) {
201  SimpleEvent_(g_date->Date() + 1, nl_sb_spring_plough_sandy, true, a_farm, a_field);
202  break;
203  }
204  }
205  if (a_farm->IsStockFarmer()) //Stock Farmer
206  {
207  SimpleEvent_(g_date->Date() + 7, nl_sb_ferti_s2_sandy, false, a_farm, a_field);
208  }
209  else SimpleEvent_(g_date->Date() + 7, nl_sb_ferti_p2_sandy, false, a_farm, a_field);
210  break;
212  if (a_ev->m_lock || a_farm->DoIt_prob(0.70))
213  {
214  if (!a_farm->FP_AmmoniumSulphate(a_field, 0.0, g_date->DayInYear(30, 3) - g_date->DayInYear())) {
215  SimpleEvent_(g_date->Date() + 1, nl_sb_ferti_p2_sandy, true, a_farm, a_field);
216  break;
217  }
218  }
219  d1 = g_date->Date() + 1;
220  if (d1 < g_date->OldDays() + g_date->DayInYear(15, 3)) {
221  d1 = g_date->OldDays() + g_date->DayInYear(15, 3);
222  }
223  if (a_farm->IsStockFarmer()) //Stock Farmer
224  {
225  SimpleEvent_(d1, nl_sb_ferti_s3, false, a_farm, a_field);
226  }
227  else SimpleEvent_(d1, nl_sb_ferti_p3, false, a_farm, a_field);
228  break;
230  if (a_ev->m_lock || a_farm->DoIt_prob(0.70))
231  {
232  if (!a_farm->FA_AmmoniumSulphate(a_field, 0.0, g_date->DayInYear(30, 3) - g_date->DayInYear())) {
233  SimpleEvent_(g_date->Date() + 1, nl_sb_ferti_s2_sandy, true, a_farm, a_field);
234  break;
235  }
236  }
237  d1 = g_date->Date() + 1;
238  if (d1 < g_date->OldDays() + g_date->DayInYear(15, 3)) {
239  d1 = g_date->OldDays() + g_date->DayInYear(15, 3);
240  }
241  if (a_farm->IsStockFarmer()) //Stock Farmer
242  {
243  SimpleEvent_(d1, nl_sb_ferti_s3, false, a_farm, a_field);
244  }
245  else SimpleEvent_(d1, nl_sb_ferti_p3, false, a_farm, a_field);
246  break;
248  if (a_ev->m_lock || a_farm->DoIt_prob(0.20))
249  {
250  if (!a_farm->StubbleHarrowing(a_field, 0.0, g_date->DayInYear(31, 10) - g_date->DayInYear())) {
251  SimpleEvent_(g_date->Date() + 1, nl_sb_stubble_harrow_clay, true, a_farm, a_field);
252  break;
253  }
254  }
255  d1 = g_date->Date() + 10;
256  if (d1 < g_date->OldDays() + g_date->DayInYear(15, 10)) {
257  d1 = g_date->OldDays() + g_date->DayInYear(15, 10);
258  }
259  SimpleEvent_(d1, nl_sb_winter_plough_clay, false, a_farm, a_field);
260  break;
262  if (!a_farm->WinterPlough(a_field, 0.0, g_date->DayInYear(1, 12) - g_date->DayInYear())) {
263  SimpleEvent_(g_date->Date() + 1, nl_sb_winter_plough_clay, true, a_farm, a_field);
264  break;
265  }
266  if (a_farm->IsStockFarmer()) //Stock Farmer
267  {
268  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(5, 3) + 365, nl_sb_ferti_s2_clay, false, a_farm, a_field);
269  }
270  else SimpleEvent_(g_date->OldDays() + g_date->DayInYear(5, 3) + 365, nl_sb_ferti_p2_clay, false, a_farm, a_field);
271  break;
272  case nl_sb_ferti_p2_clay:
273  if (!a_farm->FP_AmmoniumSulphate(a_field, 0.0, g_date->DayInYear(25, 4) - g_date->DayInYear())) {
274  SimpleEvent_(g_date->Date() + 1, nl_sb_ferti_p2_clay, true, a_farm, a_field);
275  break;
276  }
277  d1 = g_date->Date() + 1;
278  if (d1 < g_date->OldDays() + g_date->DayInYear(15, 3)) {
279  d1 = g_date->OldDays() + g_date->DayInYear(15, 3);
280  }
281  if (a_farm->IsStockFarmer()) //Stock Farmer
282  {
283  SimpleEvent_(d1, nl_sb_ferti_s3, false, a_farm, a_field);
284  }
285  else SimpleEvent_(d1, nl_sb_ferti_p3, false, a_farm, a_field);
286  break;
287  case nl_sb_ferti_s2_clay:
288  if (!a_farm->FA_AmmoniumSulphate(a_field, 0.0, g_date->DayInYear(25, 4) - g_date->DayInYear())) {
289  SimpleEvent_(g_date->Date() + 1, nl_sb_ferti_s2_clay, true, a_farm, a_field);
290  break;
291  }
292  d1 = g_date->Date() + 1;
293  if (d1 < g_date->OldDays() + g_date->DayInYear(15, 3)) {
294  d1 = g_date->OldDays() + g_date->DayInYear(15, 3);
295  }
296  if (a_farm->IsStockFarmer()) //Stock Farmer
297  {
298  SimpleEvent_(d1, nl_sb_ferti_s3, false, a_farm, a_field);
299  }
300  else SimpleEvent_(d1, nl_sb_ferti_p3, false, a_farm, a_field);
301  break;
302  case nl_sb_ferti_p3:
303  if (a_ev->m_lock || a_farm->DoIt_prob(0.50))
304  {
305  if (!a_farm->FP_NPK(a_field, 0.0, g_date->DayInYear(9, 4) - g_date->DayInYear())) {
306  SimpleEvent_(g_date->Date() + 1, nl_sb_ferti_p3, true, a_farm, a_field);
307  break;
308  }
309  }
310  SimpleEvent_(g_date->Date() + 3, nl_sb_preseeding_cultivator, false, a_farm, a_field);
311  break;
312  case nl_sb_ferti_s3:
313  if (a_ev->m_lock || a_farm->DoIt_prob(0.50))
314  {
315  if (!a_farm->FA_NPK(a_field, 0.0, g_date->DayInYear(9, 4) - g_date->DayInYear())) {
316  SimpleEvent_(g_date->Date() + 1, nl_sb_ferti_s3, true, a_farm, a_field);
317  break;
318  }
319  }
320  SimpleEvent_(g_date->Date() + 3, nl_sb_preseeding_cultivator, false, a_farm, a_field);
321  break;
323  if (a_ev->m_lock || a_farm->DoIt_prob(0.80))
324  {
325  if (!a_farm->PreseedingCultivator(a_field, 0.0, g_date->DayInYear(9, 4) - g_date->DayInYear())) {
326  SimpleEvent_(g_date->Date() + 1, nl_sb_preseeding_cultivator, true, a_farm, a_field);
327  break;
328  }
329  else
330  {
331  SimpleEvent_(g_date->Date() + 1, nl_sb_spring_sow, false, a_farm, a_field);
332  break;
333  }
334  }
335  SimpleEvent_(g_date->Date() + 1, nl_sb_preseeding_cultivator_sow, false, a_farm, a_field);
336  break;
337  case nl_sb_spring_sow:
338  if (!a_farm->SpringSow(a_field, 0.0, g_date->DayInYear(10, 4) - g_date->DayInYear())) {
339  SimpleEvent_(g_date->Date() + 1, nl_sb_spring_sow, true, a_farm, a_field);
340  break;
341  }
342  // Here is a fork leading to four parallel events
343  SimpleEvent_(g_date->Date() + 3, nl_sb_harrow, false, a_farm, a_field); // Harrowing
344  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(15, 4), nl_sb_herbicide1, false, a_farm, a_field); // Herbidide thread
345  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 5), nl_sb_fungicide1, false, a_farm, a_field); // Fungicide thread
346  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(15, 5), nl_sb_insecticide1, false, a_farm, a_field); // Insecticide thread = MAIN THREAD
347  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 5), nl_sb_growth_regulator1, false, a_farm, a_field); // GR thread
348  if (a_farm->IsStockFarmer()) //Stock Farmer // N thread
349  {
350  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 5), nl_sb_ferti_s4_clay, false, a_farm, a_field);
351  }
352  else SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 5), nl_sb_ferti_p4_clay, false, a_farm, a_field);
353  break;
355  if (!a_farm->PreseedingCultivatorSow(a_field, 0.0, g_date->DayInYear(10, 4) - g_date->DayInYear())) {
356  SimpleEvent_(g_date->Date() + 1, nl_sb_preseeding_cultivator_sow, true, a_farm, a_field);
357  break;
358  }
359  // Here is a fork leading to four parallel events
360  SimpleEvent_(g_date->Date() + 3, nl_sb_harrow, false, a_farm, a_field); // Harrowing
361  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(15, 4), nl_sb_herbicide1, false, a_farm, a_field); // Herbidide thread
362  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 5), nl_sb_fungicide1, false, a_farm, a_field); // Fungicide thread
363  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(15, 5), nl_sb_insecticide1, false, a_farm, a_field); // Insecticide thread = MAIN THREAD
364  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 5), nl_sb_growth_regulator1, false, a_farm, a_field); // GR thread
365  if (a_farm->IsStockFarmer()) //Stock Farmer // N thread
366  {
367  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 5), nl_sb_ferti_s4_clay, false, a_farm, a_field);
368  }
369  else SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 5), nl_sb_ferti_p4_clay, false, a_farm, a_field);
370  break;
371  case nl_sb_harrow:
372  if (a_field->GetGreenBiomass() <= 0)
373  {
374  if (a_ev->m_lock || a_farm->DoIt_prob(0.20))
375  {
376  if (!a_farm->ShallowHarrow(a_field, 0.0, g_date->DayInYear(20, 4) - g_date->DayInYear())) {
377  SimpleEvent_(g_date->Date() + 1, nl_sb_harrow, true, a_farm, a_field);
378  break;
379  }
380  }
381  }
382  // end of thread
383  break;
384  case nl_sb_ferti_p4_clay:
385  if (a_ev->m_lock || (a_farm->DoIt_prob(0.50) && (a_field->GetSoilType() != 2 && a_field->GetSoilType() != 6)))
386  {
387  if (!a_farm->FP_AmmoniumSulphate(a_field, 0.0, g_date->DayInYear(10, 5) - g_date->DayInYear())) {
388  SimpleEvent_(g_date->Date() + 1, nl_sb_ferti_p4_clay, true, a_farm, a_field);
389  break;
390  }
391  }
392  // End of thread
393  break;
394  case nl_sb_ferti_s4_clay:
395  if (a_ev->m_lock || (a_farm->DoIt_prob(0.50) && (a_field->GetSoilType() != 2 && a_field->GetSoilType() != 6)))
396  {
397  if (!a_farm->FA_AmmoniumSulphate(a_field, 0.0, g_date->DayInYear(10, 5) - g_date->DayInYear())) {
398  SimpleEvent_(g_date->Date() + 1, nl_sb_ferti_s4_clay, true, a_farm, a_field);
399  break;
400  }
401  }
402  // End of thread
403  break;
404  case nl_sb_herbicide1: // The first of the pesticide managements.
405  // Here comes the herbicide thread
406  if (a_ev->m_lock || a_farm->DoIt_prob(0.90))
407  {
408  if (a_field->GetGreenBiomass() <= 0) {
409  SimpleEvent_(g_date->Date() + 5, nl_sb_herbicide1, true, a_farm, a_field);
410  }
411  else
412  {
413  if (!a_farm->HerbicideTreat(a_field, 0.0, g_date->DayInYear(30, 4) - g_date->DayInYear())) {
414  SimpleEvent_(g_date->Date() + 1, nl_sb_herbicide1, true, a_farm, a_field);
415  break;
416  }
417  }
418  }
419  // End of thread
420  break;
421  case nl_sb_fungicide1:
422  // Here comes the fungicide thread
423  if (a_ev->m_lock || a_farm->DoIt_prob(0.80))
424  {
425  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(15, 6) - g_date->DayInYear())) {
426  SimpleEvent_(g_date->Date() + 1, nl_sb_fungicide1, true, a_farm, a_field);
427  break;
428  }
429  NL_SB_FUNGII = true;
430  }
431  SimpleEvent_(g_date->Date() + 14, nl_sb_fungicide2, false, a_farm, a_field);
432  break;
433  case nl_sb_fungicide2:
434  if (a_ev->m_lock || (a_farm->DoIt_prob(0.50) && NL_SB_FUNGII == 1)) // 40% of all farmers
435  {
436  if (!a_farm->FungicideTreat(a_field, 0.0, g_date->DayInYear(15, 6) - g_date->DayInYear())) {
437  SimpleEvent_(g_date->Date() + 1, nl_sb_fungicide2, true, a_farm, a_field);
438  break;
439  }
440  }
441  // End of thread
442  break;
443  case nl_sb_insecticide1:
444  // Here comes the insecticide thread = MAIN THREAD
445  if (a_ev->m_lock || a_farm->DoIt_prob(0.30))
446  {
447  // here we check wheter we are using ERA pesticide or not
448  if (!cfg_pest_springbarley_on.value() ||
449  !g_landscape_p->SupplyShouldSpray()) // Not using pesticide spray
450  {
451  if (!a_farm->InsecticideTreat(a_field, 0.0, g_date->DayInYear(30, 6) - g_date->DayInYear())) {
452  SimpleEvent_(g_date->Date() + 1, nl_sb_insecticide1, true, a_farm, a_field);
453  break;
454  }
455  }
456  else {
457  a_farm->ProductApplication(a_field, 0.0, 0, cfg_pest_product_1_amount.value(), ppp_1);
458  }
459  }
460  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(20, 7), nl_sb_harvest, false, a_farm, a_field);
461  break;
463  // Here comes the GR thread
464  if (a_ev->m_lock || a_farm->DoIt_prob(0.80))
465  {
466  if (!a_farm->GrowthRegulator(a_field, 0.0, g_date->DayInYear(15, 5) - g_date->DayInYear())) {
467  SimpleEvent_(g_date->Date() + 1, nl_sb_growth_regulator1, true, a_farm, a_field);
468  break;
469  }
470  }
471  // End of thread
472  break;
473  case nl_sb_harvest:
474  // Here the MAIN thread continues
475  // We don't move harvest days
476  if (!a_farm->Harvest(a_field, 0.0, a_field->GetMDates(0, 0) - g_date->DayInYear())) {
477  SimpleEvent_(g_date->Date() + 1, nl_sb_harvest, true, a_farm, a_field);
478  break;
479  }
480  SimpleEvent_(g_date->Date() + 1, nl_sb_straw_chopping, false, a_farm, a_field);
481  break;
483  if (a_ev->m_lock || a_farm->DoIt_prob(0.50))
484  {
485  if (a_field->GetMConstants(0) == 0) {
486  if (!a_farm->StrawChopping(a_field, 0.0, -1)) { // raise an error
487  g_msg->Warn(WARN_BUG, "NLSpringBarley::Do(): failure in 'StrawChopping' execution", "");
488  exit(1);
489  }
490  }
491  else {
492  if (!a_farm->StrawChopping(a_field, 0.0, a_field->GetMDates(1, 0) - g_date->DayInYear())) {
493  SimpleEvent_(g_date->Date() + 1, nl_sb_straw_chopping, true, a_farm, a_field);
494  break;
495  }
496  }
497  done = true;
498  break;
499  }
500  SimpleEvent_(g_date->Date() + 1, nl_sb_hay_bailing, false, a_farm, a_field);
501  break;
502  case nl_sb_hay_bailing:
503  if (a_field->GetMConstants(1) == 0) {
504  if (!a_farm->HayBailing(a_field, 0.0, -1)) { // raise an error
505  g_msg->Warn(WARN_BUG, "NLWinterWheat::Do(): failure in 'HayBailing' execution", "");
506  exit(1);
507  }
508  }
509  else {
510  if (!a_farm->HayBailing(a_field, 0.0, a_field->GetMDates(1, 1) - g_date->DayInYear())) {
511  SimpleEvent_(g_date->Date() + 1, nl_sb_hay_bailing, true, a_farm, a_field);
512  break;
513  }
514  }
515  done = true;
516  break;
517  default:
518  g_msg->Warn(WARN_BUG, "PLSpringBarley::Do(): "
519  "Unknown event type! ", "");
520  exit(1);
521  }
522  return done;
523 }

References Landscape::BackTranslateVegTypes(), cfg_pest_product_1_amount, cfg_pest_springbarley_on, g_landscape_p, Farm::GetType(), Farm::IsStockFarmer(), Crop::m_first_date, FarmEvent::m_first_year, FarmEvent::m_lock, FarmEvent::m_next_tov, FarmEvent::m_startday, FarmEvent::m_todo, nl_sb_ferti_p1_sandy, nl_sb_ferti_p2_clay, nl_sb_ferti_p2_sandy, nl_sb_ferti_p3, nl_sb_ferti_p4_clay, nl_sb_ferti_s1_sandy, nl_sb_ferti_s2_clay, nl_sb_ferti_s2_sandy, nl_sb_ferti_s3, nl_sb_ferti_s4_clay, nl_sb_fungicide1, nl_sb_fungicide2, NL_SB_FUNGII, nl_sb_growth_regulator1, nl_sb_harrow, nl_sb_harvest, nl_sb_hay_bailing, nl_sb_herbicide1, nl_sb_insecticide1, nl_sb_preseeding_cultivator, nl_sb_preseeding_cultivator_sow, nl_sb_spring_plough_sandy, nl_sb_spring_sow, nl_sb_start, nl_sb_straw_chopping, nl_sb_stubble_harrow_clay, nl_sb_stubble_harrow_sandy, nl_sb_winter_plough_clay, ppp_1, Crop::SimpleEvent_(), Farm::StubbleHarrowing(), Landscape::SupplyShouldSpray(), and tof_OptimisingFarm.


The documentation for this class was generated from the following files:
nl_sb_ferti_s2_sandy
Definition: NLSpringBarley.h:43
nl_sb_winter_plough_clay
Definition: NLSpringBarley.h:46
nl_sb_ferti_p4_clay
Definition: NLSpringBarley.h:55
Farm::IsStockFarmer
bool IsStockFarmer(void)
Definition: farm.h:905
FarmEvent::m_lock
bool m_lock
Definition: farm.h:465
Landscape::SupplyShouldSpray
bool SupplyShouldSpray()
Definition: Landscape.h:357
nl_sb_preseeding_cultivator_sow
Definition: NLSpringBarley.h:52
nl_sb_preseeding_cultivator
Definition: NLSpringBarley.h:51
FarmEvent::m_first_year
bool m_first_year
Definition: farm.h:467
tof_OptimisingFarm
Definition: farm.h:273
Landscape::BackTranslateVegTypes
int BackTranslateVegTypes(TTypesOfVegetation VegReference)
Definition: Landscape.h:1669
nl_sb_ferti_s1_sandy
Definition: NLSpringBarley.h:41
nl_sb_spring_plough_sandy
Definition: NLSpringBarley.h:44
Farm::GetType
TTypesOfFarm GetType(void)
Definition: farm.h:901
Crop::m_first_date
int m_first_date
Definition: farm.h:540
FarmEvent::m_startday
int m_startday
Definition: farm.h:466
nl_sb_harvest
Definition: NLSpringBarley.h:62
nl_sb_stubble_harrow_sandy
Definition: NLSpringBarley.h:39
nl_sb_start
Definition: NLSpringBarley.h:37
nl_sb_fungicide1
Definition: NLSpringBarley.h:58
nl_sb_harrow
Definition: NLSpringBarley.h:54
nl_sb_ferti_s2_clay
Definition: NLSpringBarley.h:48
nl_sb_ferti_p2_clay
Definition: NLSpringBarley.h:47
cfg_pest_springbarley_on
CfgBool cfg_pest_springbarley_on
FarmEvent::m_next_tov
TTypesOfVegetation m_next_tov
Definition: farm.h:471
nl_sb_spring_sow
Definition: NLSpringBarley.h:53
FarmEvent::m_todo
int m_todo
Definition: farm.h:469
nl_sb_insecticide1
Definition: NLSpringBarley.h:60
nl_sb_stubble_harrow_clay
Definition: NLSpringBarley.h:45
nl_sb_hay_bailing
Definition: NLSpringBarley.h:64
ppp_1
Definition: farm.h:422
nl_sb_straw_chopping
Definition: NLSpringBarley.h:63
nl_sb_ferti_p3
Definition: NLSpringBarley.h:49
nl_sb_ferti_p1_sandy
Definition: NLSpringBarley.h:40
nl_sb_herbicide1
Definition: NLSpringBarley.h:57
nl_sb_fungicide2
Definition: NLSpringBarley.h:59
nl_sb_ferti_s3
Definition: NLSpringBarley.h:50
NL_SB_FUNGII
#define NL_SB_FUNGII
A flag used to indicate autumn ploughing status.
Definition: NLSpringBarley.h:28
nl_sb_ferti_p2_sandy
Definition: NLSpringBarley.h:42
nl_sb_growth_regulator1
Definition: NLSpringBarley.h:61
g_landscape_p
Landscape * g_landscape_p
Definition: Landscape.cpp:258
nl_sb_ferti_s4_clay
Definition: NLSpringBarley.h:56
Farm::StubbleHarrowing
virtual bool StubbleHarrowing(LE *a_field, double a_user, int a_days)
Carry out stubble harrowing on a_field.
Definition: farmfuncs.cpp:2209
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:312
cfg_pest_product_1_amount
CfgFloat cfg_pest_product_1_amount