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

#include <SpringBarley.h>

Inheritance diagram for SpringBarley:
Crop

Public Member Functions

bool Do (Farm *a_farm, LE *a_field, FarmEvent *a_ev)
 
 SpringBarley (TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape *a_L)
 
void SetUpFarmCategoryInformation ()
 
- Public Member Functions inherited from Crop
virtual ~Crop ()
 
 Crop (TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape *a_L)
 
int GetFirstDate (void)
 
void ChooseNextCrop (int a_no_dates)
 Chooses the next crop to grow in a field. More...
 
int GetCropClassification ()
 
void SetCropClassification (int a_classification)
 
void GetCropType (TTypesOfCrops a_toc)
 
TTypesOfCrops GetCropType ()
 
FarmManagementCategory LookUpManagementCategory (int a_todo)
 
bool GetForceSpringOK ()
 

Additional Inherited Members

- Public Attributes inherited from Crop
TTypesOfVegetation m_tov
 
- Protected Member Functions inherited from Crop
void SimpleEvent (long a_date, int a_todo, bool a_lock)
 Adds an event to this crop management. More...
 
void SimpleEvent_ (long a_date, int a_todo, bool a_lock, Farm *a_farm, LE *a_field)
 Adds an event to this crop management without relying on member variables. More...
 
bool StartUpCrop (int a_spring, std::vector< std::vector< int >> a_flexdates, int a_todo)
 
Holds the translation between the farm operation enum for each cropand the farm management category associated with it More...
 
bool AphidDamage (LE *a_field)
 Compares aphid numbers per m2 with a threshold to return true if threshold is exceeded. More...
 
- Protected Attributes inherited from Crop
Farmm_farm
 
LEm_field
 
FarmEventm_ev
 
int m_first_date
 
int m_count
 
int m_last_date
 
int m_ddegstoharvest
 
int m_base_elements_no
 
Landscapem_OurLandscape
 
bool m_forcespringpossible = false
 Used to signal that the crop can be forced to start in spring. More...
 
TTypesOfCrops m_toc
 The Crop type in terms of the TTypesOfCrops list (smaller list than tov, no country designation) More...
 
int m_CropClassification
 Contains information on whether this is a winter crop, spring crop, or catch crop that straddles the year boundary (0,1,2) More...
 
vector< FarmManagementCategorym_ManagementCategories
 Holds the translation between the farm operation enum for each crop and the farm management category associated with it. More...
 
- Static Protected Attributes inherited from Crop
static int m_date_modifier = 0
 Holds a value that shifts test pesticide use by this many days in crops modified to use it. More...
 

Constructor & Destructor Documentation

◆ SpringBarley()

SpringBarley::SpringBarley ( TTypesOfVegetation  a_tov,
TTypesOfCrops  a_toc,
Landscape a_L 
)
inline
83  : Crop(a_tov, a_toc, a_L)
84  {
87  }

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

Member Function Documentation

◆ Do()

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

Reimplemented from Crop.

49 {
50 
51  double ins_app_prop=cfg_ins_app_prop1.value();
52  double herbi_app_prop=cfg_herbi_app_prop.value();
53  m_farm = a_farm;
54  m_field = a_field;
55  m_ev = a_ev;
56 
57  bool done = false;
58 
59  switch ( m_ev->m_todo )
60  {
61  case sb_start:
62  {
64  SB_DECIDE_TO_FI =1;
65  a_field->ClearManagementActionSum();
66 
67  // Record whether skylark scrapes are present and adjust flag accordingly
69  a_field->m_skylarkscrapes=true;
70  } else {
71  a_field->m_skylarkscrapes=false;
72  }
73  // Set up the date management stuff
74  // Could save the start day in case it is needed later
75  // m_field->m_startday = m_ev->m_startday;
77  // Start and stop dates for all events after harvest
78  int noDates=2;
79  m_field->SetMDates(0,0,g_date->DayInYear(20,8));
80  // Determined by harvest date - used to see if at all possible
81  m_field->SetMDates(1,0,g_date->DayInYear(10,8));
82  m_field->SetMDates(0,1,g_date->DayInYear(10,8));
83  m_field->SetMDates(1,1,g_date->DayInYear(30,8));
84  // Check the next crop for early start, unless it is a spring crop
85  // in which case we ASSUME that no checking is necessary!!!!
86  // So DO NOT implement a crop that runs over the year boundary
87 
88  //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)
89  int d1;
91 
92  if (m_ev->m_startday>g_date->DayInYear(1,7))
93  {
94  if (m_field->GetMDates(0,0) >=m_ev->m_startday)
95  {
96  g_msg->Warn( WARN_BUG, "SpringBarley::Do(): "
97  "Harvest too late for the next crop to start!!!", "" );
98  exit( 1 );
99  }
100  // Now fix any late finishing problems
101  for (int i=0; i<noDates; i++) {
102  if(m_field->GetMDates(0,i)>=m_ev->m_startday) {
103  m_field->SetMDates(0,i,m_ev->m_startday-1); //move the starting date
104  }
105  if(m_field->GetMDates(1,i)>=m_ev->m_startday){
106  m_field->SetMConstants(i,0);
107  m_field->SetMDates(1,i,m_ev->m_startday-1); //move the finishing date
108  }
109  }
110  }
111  // Now no operations can be timed after the start of the next crop.
112 
113  if ( ! m_ev->m_first_year )
114  {
115  int today=g_date->Date();
116  // Are we before July 1st?
117  d1 = g_date->OldDays() + g_date->DayInYear( 1,7 );
118  if (today < d1)
119  {
120  // Yes, too early. We assumme this is because the last crop was late
121  g_msg->Warn( WARN_BUG, "SpringBarley::Do(): " "Crop start attempt between 1st Jan & 1st July", "" );
122  exit( 1 );
123  }
124  else
125  {
126  d1 = g_date->OldDays() + m_first_date; // Add 365 for spring crop
127  if (today > d1)
128  {
129  // Yes too late - should not happen - raise an error
130  g_msg->Warn( WARN_BUG, "SpringBarley::Do(): " "Crop start attempt after last possible start date", "" );
131  exit( 1 );
132  }
133  }
134  }
135  else
136  {
137  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 1,4 ),
138  sb_spring_plough, false );
139  break;
140  }
141  }//if
142 
143  // End single block date checking code. Please see next line
144  // comment as well.
145  // Reinit d1 to first possible starting date.
146  d1 = g_date->OldDays() + g_date->DayInYear( 2,11 );
147  if ( g_date->Date() > d1 ) {
148  d1 = g_date->Date();
149  }
150 
151 
152  // OK, let's go.
153  SimpleEvent( d1, sb_autumn_plough, false );
154  SB_SLURRY_DONE=false;
155  SB_MANURE_DONE=false;
156  SB_SLURRY_EXEC=false;
157  SB_MANURE_EXEC=false;
158  SB_DID_AUTUMN_PLOUGH = false;
159  }
160  break;
161 
162  case sb_autumn_plough:
163  if ( m_ev->m_lock || m_farm->DoIt( 70 )) // was 70
164  {
165  if (!m_farm->AutumnPlough( m_field, 0.0,
166  g_date->DayInYear( 30,11 ) - g_date->DayInYear())) {
167  SimpleEvent( g_date->Date() + 1, sb_autumn_plough, true );
168  break;
169  }
170  SB_DID_AUTUMN_PLOUGH = true;
171  }
172  // +365 for next year
173  if (m_farm->IsStockFarmer()) // StockFarmer
174  {
175  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 15,3 )+365, // was 15,3
176  sb_fertslurry_stock, false );
177  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 15,3 )+365, // was 15,3
178  sb_fertmanure_stock_one, false );
179  }
180  else { // PlantFarmer
181  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 20,3 )+365, // was 20/3
182  sb_spring_plough, false );
183  }
184  break;
185 
186  //*** The stock farmers thread
187  case sb_fertslurry_stock:
188  if ( m_ev->m_lock || m_farm->DoIt( 90 ))
189  {
190  if (!m_farm->FA_Slurry( m_field, 0.0,
191  g_date->DayInYear( 15,4 ) - g_date->DayInYear())) { // Was 15/4
192  SimpleEvent( g_date->Date() + 1, sb_fertslurry_stock, true );
193  break;
194  }
195  SB_SLURRY_EXEC=true;
196  }
197  SB_SLURRY_DONE = true;
198  if ( SB_MANURE_DONE ) {
199  // We are the last thread, so queue up spring plough.
200  SimpleEvent( g_date->Date(), sb_spring_plough, false );
201  }
202  break;
203 
205  if ( m_ev->m_lock || m_farm->DoIt( 67 ))
206  {
207  if (!m_farm->FA_Manure( m_field, 0.0,
208  g_date->DayInYear( 15,5 ) - g_date->DayInYear())) { // Was 15/5
210  break;
211  }
212  SB_MANURE_EXEC=true;
213  }
214  SB_MANURE_DONE = true;
215  if ( SB_SLURRY_DONE ) {
216  SimpleEvent( g_date->Date(), sb_spring_plough, false );
217  }
218  break;
219 
220  case sb_spring_plough:
221  if ( ! SB_DID_AUTUMN_PLOUGH )
222  {
223  if (!m_farm->SpringPlough( m_field, 0.0,
224  g_date->DayInYear( 10,4 ) - // was 10,4
225  g_date->DayInYear())) {
226  SimpleEvent( g_date->Date()+1, sb_spring_plough, true );
227  break;
228  }
229  }
230  {
231  int d1 = g_date->Date();
232  if ( d1 < g_date->OldDays() + g_date->DayInYear( 20,3 )) {
233  d1 = g_date->OldDays() + g_date->DayInYear( 20,3 );
234  }
235  SimpleEvent( d1, sb_spring_harrow, false );
236  }
237  break;
238 
239  case sb_spring_harrow:
240  if (!m_farm->SpringHarrow( m_field, 0.0,
241  g_date->DayInYear( 10,4 ) - g_date->DayInYear())) { // WAS 10,4
242  SimpleEvent( g_date->Date() + 1, sb_spring_harrow, true );
243  break;
244  }
245  if (m_farm->IsStockFarmer()) {
246  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 5,4 ), // was 5,4
247  sb_fertmanure_stock_two, false );
248  } else {
249  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 20,3 ),
250  sb_fertmanure_plant, false );
251  }
252  break;
253 
255  if ( m_ev->m_lock || m_farm->DoIt( 65 ) ||
257  {
258  if (!m_farm->FA_NPK( m_field, 0.0,
259  g_date->DayInYear( 10,4 ) - g_date->DayInYear())) { // was 10,4
261  break;
262  }
263  }
264  {
265  int d1 = g_date->Date();
266  if ( d1 < g_date->OldDays() + g_date->DayInYear( 25,3 )) {
267  d1 = g_date->OldDays() + g_date->DayInYear( 25,3 );
268  }
269  SimpleEvent( d1, sb_spring_sow, false );
270  }
271  break;
272 
273  case sb_fertmanure_plant:
274  if ( m_ev->m_lock || m_farm->DoIt( 75 ))
275  {
276  if (!m_farm->FP_NPK( m_field, 0.0,
277  g_date->DayInYear( 10, 4 ) - g_date->DayInYear())) { // WAS 10,4
278  SimpleEvent( g_date->Date() + 1, sb_fertmanure_plant, true );
279  break;
280  }
281  // Did FP_NPK so go directly to spring sow.
282  {
283  int d1 = g_date->Date();
284  if ( d1 < g_date->OldDays() + g_date->DayInYear( 25,3 )) { // was 25,3
285  d1 = g_date->OldDays() + g_date->DayInYear( 25,3 ); // was 25,3
286  }
287  SimpleEvent( d1, sb_spring_sow, false );
288  }
289  break;
290  }
292  break;
293 
294  case sb_fertlnh3_plant:
295  if (!m_farm->FP_LiquidNH3( m_field, 0.0,
296  g_date->DayInYear( 10, 4 ) - // WAS 10,4
297  g_date->DayInYear())) {
298  SimpleEvent( g_date->Date() + 1, sb_fertlnh3_plant, true );
299  break;
300  }
301  SimpleEvent( g_date->Date(), sb_fertpk_plant, false );
302  break;
303 
304  case sb_fertpk_plant:
305  if (!m_farm->FP_PK( m_field, 0.0,
306  g_date->DayInYear( 10, 4 ) - // WAS 10,4
307  g_date->DayInYear())) {
308  SimpleEvent( g_date->Date() + 1, sb_fertpk_plant, true );
309  break;
310  }
311  {
312  int d1 = g_date->Date();
313  if ( d1 < g_date->OldDays() + g_date->DayInYear( 25,3 )) { // was 25,3
314  d1 = g_date->OldDays() + g_date->DayInYear( 25,3 ); // was 25,3
315  }
316  SimpleEvent( d1, sb_spring_sow, false );
317  }
318  break;
319 
320  case sb_spring_sow:
321  if (!m_farm->SpringSow( m_field, 0.0,
322  g_date->DayInYear( 10,4 ) - g_date->DayInYear())) { // WAS 10,4
323  SimpleEvent( g_date->Date() + 1, sb_spring_sow, true );
324  break;
325  }
326  {
327  int d1 = g_date->Date();
328  if ( d1 < g_date->OldDays() + g_date->DayInYear( 5,4 )) {
329  d1 = g_date->OldDays() + g_date->DayInYear( 5,4 );
330  }
331  SimpleEvent( d1, sb_spring_roll, false );
332  }
333  break;
334 
335  case sb_spring_roll:
336  if ( m_ev->m_lock || m_farm->DoIt( 0 )) // was 30
337  {
338  if (!m_farm->SpringRoll( m_field, 0.0,
339  g_date->DayInYear( 20,4 ) - g_date->DayInYear())) {
340  SimpleEvent( g_date->Date() + 1, sb_spring_roll, true );
341  break;
342  }
343  }
344  SB_HERBI_DATE = 0;
345  SB_GR_DATE = 0;
346  SB_FUNGI_DATE = 0;
347  SB_WATER_DATE = 0;
348  SB_INSECT_DATE = 0;
349  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 5,5 ),
350  sb_herbicide_one, false );
351  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 10,5 ),
352  sb_fungicide_one, false );
353  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 10,5 ),
354  sb_GR, false );
355  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 15,5 ),
356  sb_water_one, false );
357  SimpleEvent(g_date->OldDays() + g_date->DayInYear(cfg_SB_InsecticideDay.value(), cfg_SB_InsecticideMonth.value()), // Was 15,5 - changed for skylark testing
358  sb_insecticide, false ); // MAIN THREAD
359  break;
360 
361  // Herbicide thread
362 
363  //ask for your BIherb: >0 - want to spray, otherwise - don't spray even if you should
364 
365  case sb_herbicide_one:
366  if ( g_date->Date() < SB_GR_DATE + 1 ) {
368  break;
369  }
370  if ( m_ev->m_lock || m_farm->DoIt( (int) floor(0.5+70*herbi_app_prop * m_farm->Prob_multiplier()))) //modified probability
371  {
372  if (!m_farm->HerbicideTreat( m_field, 0.0, g_date->DayInYear( 15,5 ) - g_date->DayInYear()))
373  {
374  SimpleEvent( g_date->Date() + 1, sb_herbicide_one, true );
375  break;
376  }
377 
379  // Did first spray so see if should do another, 14 days later (min)
380  {
381  int d1 = g_date->Date() + 10;
382  if ( d1 < g_date->OldDays() + g_date->DayInYear( 16,5 )) {
383  d1 = g_date->OldDays() + g_date->DayInYear( 16,5 );
384  }
385  SimpleEvent( d1, sb_herbicide_two, false );
386  }
387  }
388  break;
389 
390  case sb_herbicide_two:
391  if ( g_date->Date() < SB_GR_DATE + 1 ) {
393  break;
394  }
395  if ( m_ev->m_lock || m_farm->DoIt( (int) floor(0.5+47*herbi_app_prop*SB_DECIDE_TO_HERB * m_farm->Prob_multiplier()))) //modified probability
396  {
397  if (!m_farm->HerbicideTreat( m_field, 0.0,
398  g_date->DayInYear( 30,5 ) - g_date->DayInYear())) {
399  SimpleEvent( g_date->Date() + 1, sb_herbicide_two, true );
400  break;
401  }
403  }
404  break;
405 
406  // GReg thread
407  case sb_GR:
408  if ( g_date->Date() < SB_HERBI_DATE + 1 ||
409  g_date->Date() < SB_FUNGI_DATE + 1 ) {
410  SimpleEvent( g_date->Date() + 1, sb_GR, m_ev->m_lock );
411  break;
412  }
413  if ( m_ev->m_lock || m_farm->DoIt( (int) floor(0.5+5*cfg_greg_app_prop.value())))
414  {
415  if (!m_farm->GrowthRegulator( m_field, 0.0,
416  g_date->DayInYear( 25,5 ) - g_date->DayInYear())) {
417  SimpleEvent( g_date->Date() + 1, sb_GR, true );
418  break;
419  }
420  SB_GR_DATE = g_date->Date();
421  }
422  break;
423 
424  // Fungicide thread
425  case sb_fungicide_one:
426  if ( g_date->Date() < SB_HERBI_DATE + 1 || g_date->Date() < SB_GR_DATE + 1 ) {
428  break;
429  }
430  if ( m_ev->m_lock || m_farm->DoIt( (int) floor(0.5+30*cfg_fungi_app_prop1.value() * m_farm->Prob_multiplier()))) //modified probability
431  {
432  if (!m_farm->FungicideTreat( m_field, 0.0, g_date->DayInYear( 25,5 ) - g_date->DayInYear())) {
433  SimpleEvent( g_date->Date() + 1, sb_fungicide_one, true );
434  break;
435  }
437  {
438  int d1 = g_date->Date() + 10;
439  if ( d1 < g_date->OldDays() + g_date->DayInYear( 25,5 )) {
440  d1 = g_date->OldDays() + g_date->DayInYear( 25,5 );
441  }
442  SimpleEvent( d1, sb_fungicide_two, false );
443  }
444  }
445  break;
446 
447  case sb_fungicide_two:
448  if ( g_date->Date() < SB_HERBI_DATE + 1 ||
449  g_date->Date() < SB_GR_DATE + 1 ) {
451  break;
452  }
453  if ( m_ev->m_lock || m_farm->DoIt( (int) floor(0.5+10*cfg_fungi_app_prop1.value()*SB_DECIDE_TO_FI * m_farm->Prob_multiplier()) )) //modified probability
454  {
455  if (!m_farm->FungicideTreat( m_field, 0.0,
456  g_date->DayInYear( 10,6 ) - g_date->DayInYear())) {
457  SimpleEvent( g_date->Date() + 1, sb_fungicide_two, true );
458  break;
459  }
461  }
462  break;
463 
464  // Water thread
465  case sb_water_one:
466  if ( g_date->Date() < SB_HERBI_DATE + 1 ||
467  g_date->Date() < SB_FUNGI_DATE + 1 ) {
469  break;
470  }
471  if ( m_ev->m_lock || m_farm->DoIt( 20 ))
472  {
473  if (!m_farm->Water( m_field, 0.0,
474  g_date->DayInYear( 30,5 ) - g_date->DayInYear())) {
475  SimpleEvent( g_date->Date() + 1, sb_water_one, true );
476  break;
477  }
479  }
480  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 1,6 ),
481  sb_water_two, false );
482  break;
483 
484  case sb_water_two:
485  if ( g_date->Date() < SB_INSECT_DATE + 1 ) {
487  break;
488  }
489  if ( m_ev->m_lock || m_farm->DoIt( 10 ))
490  {
491  if (!m_farm->Water( m_field, 0.0,
492  g_date->DayInYear( 1,7 ) - g_date->DayInYear())) {
493  SimpleEvent( g_date->Date() + 1, sb_water_two, true );
494  break;
495  }
497  }
498  break;
499 
500  // Insecticide thread & MAIN THREAD
501  case sb_insecticide:
502  if (g_date->Date() < SB_WATER_DATE + 1) {
504  break;
505  }
506  if (m_ev->m_lock || m_farm->DoIt((int)floor(0.5 + 35 * ins_app_prop*m_farm->Prob_multiplier()))) //modified probability
507  {
508  // Here we check wheter we are using ERA pesticide or not
509  if (!cfg_pest_springbarley_on.value() || !a_field->GetLandscape()->SupplyShouldSpray()) {
510  if (!m_farm->InsecticideTreat(m_field, 0.0, g_date->DayInYear(10, 6) - g_date->DayInYear())) {
511  SimpleEvent(g_date->Date() + 1, sb_insecticide, true);
512  break;
513  }
514  else {
516  }
518  }
519  }
520  ChooseNextCrop(2);
521  SimpleEvent(g_date->Date() + 14, sb_insecticide2, false);
522  SimpleEvent(g_date->OldDays() + g_date->DayInYear(1, 8), sb_harvest, false);
523  break;
524 
525  case sb_insecticide2:
526  if (m_ev->m_lock || m_farm->DoIt((int)floor(0.5 + 35 * cfg_ins_app_prop2.value()*m_farm->Prob_multiplier()))) //modified probability
527  {
528  if (cfg_pest_springbarley_on.value() && a_field->GetLandscape()->SupplyShouldSpray())
529  {
531  }
532  else
533  {
535  SimpleEvent(g_date->Date() + 1, sb_insecticide2, true);
536  }
537  }
538  }
539  SimpleEvent(g_date->Date() + 14, sb_insecticide3, false);
540  break;
541 
542  case sb_insecticide3:
543  if (m_ev->m_lock || m_farm->DoIt((int)floor(0.5 + 35 * cfg_ins_app_prop3.value()*m_farm->Prob_multiplier()))) //modified probability
544  {
545  if (cfg_pest_springbarley_on.value() && a_field->GetLandscape()->SupplyShouldSpray())
546  {
548  }
549  else
550  {
552  SimpleEvent(g_date->Date() + 1, sb_insecticide3, true);
553  }
554  }
555  }
556  break; // End of thread
557 
558 
559  case sb_harvest:
560  if (!m_farm->Harvest( m_field, 0.0, g_date->DayInYear( 20,8 ) - g_date->DayInYear())) {
561  SimpleEvent( g_date->Date() + 1, sb_harvest, true );
562  break;
563  }
565  break;
566 
567  case sb_straw_chopping:
568  if ( m_ev->m_lock || m_farm->DoIt( 50 )) // was 50
569  {
570  // Force straw chopping to happen on the same day as harvest.
571  if (!m_farm->StrawChopping( m_field, 0.0, 0 )) {
572  // Shouldn't happen.
574  break;
575  }
576  // Did chop, so go directly to stubble harrowing.
578  sb_stubble_harrow, false );
579  break;
580  }
581  // Do hay baling first.
582  SimpleEvent( g_date->Date(), sb_hay_baling, false );
583  break;
584 
585  case sb_hay_baling:
586  if (m_field->GetMConstants(0)==0) {
587  if (!m_farm->HayBailing( m_field, 0.0, -1)) { //raise an error
588  g_msg->Warn( WARN_BUG, "SpringBarley::Do(): failure in 'HayBailing' execution", "" );
589  exit( 1 );
590  }
591  }
592  else {
593  if (!m_farm->HayBailing( m_field, 0.0, m_field->GetMDates(1,0) - g_date->DayInYear())) {
594  SimpleEvent( g_date->Date() + 1, sb_hay_baling, true );
595  break;
596  }
597  }
599  sb_stubble_harrow, false );
600  break;
601 
602  case sb_stubble_harrow:
603  if ( m_ev->m_lock || m_farm->DoIt( 60 )) // WAS 60
604  {
605  if (m_field->GetMConstants(1)==0) {
606  if (!m_farm->StubbleHarrowing( m_field, 0.0, -1)) { //raise an error
607  g_msg->Warn( WARN_BUG, "SpringBarley::Do(): failure in 'StubbleHarrowing' execution", "" );
608  exit( 1 );
609  }
610  }
611  else {
612  if (!m_farm->StubbleHarrowing( m_field, 0.0, m_field->GetMDates(1,1) - g_date->DayInYear())) {
613  SimpleEvent( g_date->Date() + 1, sb_stubble_harrow, true );
614  break;
615  }
616  }
617  }
618  // END MAIN THREAD
619  done=true;
620  break;
621 
622  default:
623  g_msg->Warn( WARN_BUG, "SpringBarley::Do(): "
624  "Unknown event type! ", "" );
625  exit( 1 );
626  }
627  return done;
628 }

References Farm::AutumnPlough(), cfg_fungi_app_prop1, cfg_greg_app_prop, cfg_herbi_app_prop, cfg_ins_app_prop1, cfg_ins_app_prop2, cfg_ins_app_prop3, cfg_pest_product_amounts, cfg_pest_springbarley_on, cfg_SB_InsecticideDay, cfg_SB_InsecticideMonth, cfg_SpringBarley_SkScrapes, Crop::ChooseNextCrop(), LE::ClearManagementActionSum(), Calendar::Date(), Calendar::DayInYear(), Farm::DoIt(), Farm::FA_Manure(), Farm::FA_NPK(), Farm::FA_Slurry(), Farm::FP_LiquidNH3(), Farm::FP_NPK(), Farm::FP_PK(), Farm::FungicideTreat(), g_date, g_msg, LE::GetMConstants(), LE::GetMDates(), Farm::GetType(), Calendar::GetYearNumber(), Farm::GrowthRegulator(), Farm::Harvest(), Farm::HayBailing(), Farm::HerbicideTreat(), Farm::InsecticideTreat(), Farm::IsStockFarmer(), Crop::m_ev, Crop::m_farm, Crop::m_field, Crop::m_first_date, FarmEvent::m_first_year, Crop::m_last_date, FarmEvent::m_lock, LE::m_skylarkscrapes, FarmEvent::m_startday, FarmEvent::m_todo, Calendar::OldDays(), ppp_1, Farm::Prob_multiplier(), Farm::ProductApplication_DateLimited(), sb_autumn_plough, SB_DECIDE_TO_FI, SB_DECIDE_TO_HERB, SB_DID_AUTUMN_PLOUGH, sb_fertlnh3_plant, sb_fertmanure_plant, sb_fertmanure_stock_one, sb_fertmanure_stock_two, sb_fertpk_plant, sb_fertslurry_stock, SB_FUNGI_DATE, sb_fungicide_one, sb_fungicide_two, sb_GR, SB_GR_DATE, sb_harvest, sb_hay_baling, SB_HERBI_DATE, sb_herbicide_one, sb_herbicide_two, SB_INSECT_DATE, sb_insecticide, sb_insecticide2, sb_insecticide3, SB_MANURE_DONE, SB_MANURE_EXEC, SB_SLURRY_DONE, SB_SLURRY_EXEC, sb_spring_harrow, sb_spring_plough, sb_spring_roll, sb_spring_sow, sb_start, sb_straw_chopping, sb_stubble_harrow, SB_WATER_DATE, sb_water_one, sb_water_two, LE::SetMConstants(), LE::SetMDates(), Crop::SimpleEvent(), Farm::SpringHarrow(), Farm::SpringPlough(), Farm::SpringRoll(), Farm::SpringSow(), Farm::StrawChopping(), Farm::StubbleHarrowing(), tof_OptimisingFarm, CfgInt::value(), CfgFloat::value(), CfgBool::value(), CfgArray_Double::value(), MapErrorMsg::Warn(), WARN_BUG, and Farm::Water().

◆ SetUpFarmCategoryInformation()

void SpringBarley::SetUpFarmCategoryInformation ( )
inline
88  {
89  const int elements = 2 + (sb_foobar - SBARLEY_BASE);
91 
92  FarmManagementCategory catlist[elements] =
93  {
94  fmc_Others, // zero element unused but must be here
95  fmc_Others,//sb_start = 1, // Compulsory, start event must always be 1 (one).
96  fmc_Cultivation,//sb_autumn_plough = SBARLEY_BASE,
97  fmc_Fertilizer,//sb_fertslurry_stock,
98  fmc_Fertilizer,//sb_fertmanure_stock_one,
99  fmc_Cultivation,//sb_spring_plough,
100  fmc_Cultivation,//sb_spring_harrow,
101  fmc_Fertilizer,//sb_fertmanure_plant,
102  fmc_Fertilizer,//sb_fertlnh3_plant,
103  fmc_Fertilizer,//sb_fertpk_plant,
104  fmc_Fertilizer,//sb_fertmanure_stock_two,
105  fmc_Fertilizer,//sb_fertnpk_stock,
106  fmc_Others,//sb_spring_sow,
107  fmc_Others,//sb_spring_roll,
108  fmc_Herbicide,//sb_herbicide_one,
109  fmc_Herbicide,//sb_herbicide_two,
110  fmc_Others,//sb_GR,
111  fmc_Fungicide,//sb_fungicide_one,
112  fmc_Insecticide,//sb_insecticide,
113  fmc_Insecticide,//sb_insecticide2,
114  fmc_Insecticide,//sb_insecticide3,
115  fmc_Fungicide,//sb_fungicide_two,
116  fmc_Watering,//sb_water_one,
117  fmc_Watering,//sb_water_two,
118  fmc_Harvest,//sb_harvest,
119  fmc_Others,//sb_straw_chopping,
120  fmc_Others,//sb_hay_baling,
121  fmc_Cultivation//sb_stubble_harrow
122 
123  // no foobar entry
124 
125  };
126  // Iterate over the catlist elements and copy them to vector
127  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
128 
129  }

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

Referenced by SpringBarley().


The documentation for this class was generated from the following files:
LE::GetMDates
int GetMDates(int a, int b)
Definition: Elements.h:405
SB_FUNGI_DATE
#define SB_FUNGI_DATE
Definition: SpringBarley.h:40
sb_herbicide_two
Definition: SpringBarley.h:61
cfg_ins_app_prop1
CfgFloat cfg_ins_app_prop1
Farm::SpringRoll
virtual bool SpringRoll(LE *a_field, double a_user, int a_days)
Carry out a roll event in the spring on a_field.
Definition: FarmFuncs.cpp:487
Farm::FA_Slurry
virtual bool FA_Slurry(LE *a_field, double a_user, int a_days)
Spready slurry on a_field owned by an stock farmer.
Definition: FarmFuncs.cpp:1067
fmc_Insecticide
Definition: LandscapeFarmingEnums.h:1005
LE::SetMDates
void SetMDates(int a, int b, int c)
Definition: Elements.h:406
Farm::SpringPlough
virtual bool SpringPlough(LE *a_field, double a_user, int a_days)
Carry out a ploughing event in the spring on a_field.
Definition: FarmFuncs.cpp:421
Farm::HerbicideTreat
virtual bool HerbicideTreat(LE *a_field, double a_user, int a_days)
Apply herbicide to a_field.
Definition: FarmFuncs.cpp:2025
Farm::IsStockFarmer
bool IsStockFarmer(void)
Definition: Farm.h:961
SB_GR_DATE
#define SB_GR_DATE
Definition: SpringBarley.h:39
Farm::Harvest
virtual bool Harvest(LE *a_field, double a_user, int a_days)
Carry out a harvest on a_field.
Definition: FarmFuncs.cpp:1364
FarmEvent::m_lock
bool m_lock
Definition: Farm.h:384
sb_fungicide_one
Definition: SpringBarley.h:63
sb_insecticide
Definition: SpringBarley.h:64
cfg_ins_app_prop3
CfgFloat cfg_ins_app_prop3
sb_fertlnh3_plant
Definition: SpringBarley.h:54
LE::GetMConstants
int GetMConstants(int a)
Definition: Elements.h:407
LE::ClearManagementActionSum
void ClearManagementActionSum()
clears the management action counters
Definition: Elements.h:247
Farm::FP_NPK
virtual bool FP_NPK(LE *a_field, double a_user, int a_days)
Apply NPK fertilizer, on a_field owned by an arable farmer.
Definition: FarmFuncs.cpp:645
Farm::DoIt
bool DoIt(double a_probability)
Return chance out of 0 to 100.
Definition: Farm.cpp:856
Calendar::GetYearNumber
int GetYearNumber(void)
Definition: Calendar.h:72
sb_autumn_plough
Definition: SpringBarley.h:48
FarmEvent::m_first_year
bool m_first_year
Definition: Farm.h:386
cfg_SB_InsecticideDay
CfgInt cfg_SB_InsecticideDay
Provided to allow configuration control of the first insecticide spray in spring barley crops - this ...
Definition: SpringBarleySilage.cpp:42
sb_fungicide_two
Definition: SpringBarley.h:67
g_date
class Calendar * g_date
Definition: Calendar.cpp:37
sb_herbicide_one
Definition: SpringBarley.h:60
fmc_Herbicide
Definition: LandscapeFarmingEnums.h:1006
Farm::FA_Manure
virtual bool FA_Manure(LE *a_field, double a_user, int a_days)
Spread manure on a_field owned by an stock farmer.
Definition: FarmFuncs.cpp:1110
sb_fertmanure_stock_two
Definition: SpringBarley.h:56
sb_fertpk_plant
Definition: SpringBarley.h:55
Farm::SpringSow
virtual bool SpringSow(LE *a_field, double a_user, int a_days, double a_seed_coating_amount=-1, PlantProtectionProducts a_ppp=ppp_foobar)
Carry out a sowing event in the spring on a_field.
Definition: FarmFuncs.cpp:501
CfgFloat::value
double value() const
Definition: Configurator.h:142
Farm::GetType
TTypesOfFarm GetType(void)
Definition: Farm.h:956
Crop::m_base_elements_no
int m_base_elements_no
Definition: Farm.h:505
sb_stubble_harrow
Definition: SpringBarley.h:73
Crop::m_first_date
int m_first_date
Definition: Farm.h:501
FarmEvent::m_startday
int m_startday
Definition: Farm.h:385
Farm::FA_NPK
virtual bool FA_NPK(LE *a_field, double a_user, int a_days)
Apply NPK fertilizer to a_field owned by an stock farmer.
Definition: FarmFuncs.cpp:982
Farm::FungicideTreat
virtual bool FungicideTreat(LE *a_field, double a_user, int a_days)
Apply fungicide to a_field.
Definition: FarmFuncs.cpp:2101
Farm::FP_PK
virtual bool FP_PK(LE *a_field, double a_user, int a_days)
Apply PK fertilizer, on a_field owned by an arable farmer.
Definition: FarmFuncs.cpp:673
Crop::SimpleEvent
void SimpleEvent(long a_date, int a_todo, bool a_lock)
Adds an event to this crop management.
Definition: Farm.cpp:747
CfgBool::value
bool value() const
Definition: Configurator.h:164
SB_MANURE_EXEC
#define SB_MANURE_EXEC
Definition: SpringBarley.h:35
SB_INSECT_DATE
#define SB_INSECT_DATE
Definition: SpringBarley.h:42
Farm::Prob_multiplier
virtual double Prob_multiplier()
Definition: Farm.h:778
fmc_Fertilizer
Definition: LandscapeFarmingEnums.h:1004
sb_water_one
Definition: SpringBarley.h:68
SB_DECIDE_TO_FI
#define SB_DECIDE_TO_FI
Definition: SpringBarley.h:44
Farm::ProductApplication_DateLimited
virtual bool ProductApplication_DateLimited(LE *a_field, double, int, double a_applicationrate, PlantProtectionProducts a_ppp, bool a_isgranularpesticide=false)
Special pesticide trial functionality.
Definition: FarmFuncs.cpp:2342
LE::m_skylarkscrapes
bool m_skylarkscrapes
For management testing of skylark scrapes.
Definition: Elements.h:95
Calendar::Date
long Date(void)
Definition: Calendar.h:57
sb_insecticide3
Definition: SpringBarley.h:66
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.
fmc_Cultivation
Definition: LandscapeFarmingEnums.h:1008
Farm::HayBailing
virtual bool HayBailing(LE *a_field, double a_user, int a_days)
Carry out hay bailing on a_field.
Definition: FarmFuncs.cpp:1507
cfg_herbi_app_prop
CfgFloat cfg_herbi_app_prop
SB_DECIDE_TO_HERB
#define SB_DECIDE_TO_HERB
Definition: SpringBarley.h:43
fmc_Others
Definition: LandscapeFarmingEnums.h:1003
Farm::StrawChopping
virtual bool StrawChopping(LE *a_field, double a_user, int a_days)
Carry out straw chopping on a_field.
Definition: FarmFuncs.cpp:1475
sb_fertmanure_plant
Definition: SpringBarley.h:53
sb_spring_plough
Definition: SpringBarley.h:51
sb_water_two
Definition: SpringBarley.h:69
fmc_Watering
Definition: LandscapeFarmingEnums.h:1011
cfg_ins_app_prop2
CfgFloat cfg_ins_app_prop2
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
SB_SLURRY_DONE
#define SB_SLURRY_DONE
Definition: SpringBarley.h:32
Crop::m_farm
Farm * m_farm
Definition: Farm.h:498
SB_SLURRY_EXEC
#define SB_SLURRY_EXEC
Definition: SpringBarley.h:34
Crop::m_field
LE * m_field
Definition: Farm.h:499
CfgInt::value
int value() const
Definition: Configurator.h:116
Crop::m_ManagementCategories
vector< FarmManagementCategory > m_ManagementCategories
Holds the translation between the farm operation enum for each crop and the farm management category ...
Definition: Farm.h:530
CfgArray_Double::value
std::vector< double > value() const
Definition: Configurator.h:219
cfg_SB_InsecticideMonth
CfgInt cfg_SB_InsecticideMonth
Provided to allow configuration control of the first insecticide spray in spring barley crops - this ...
Definition: SpringBarleySilage.cpp:43
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
sb_fertslurry_stock
Definition: SpringBarley.h:49
SB_DID_AUTUMN_PLOUGH
#define SB_DID_AUTUMN_PLOUGH
Definition: SpringBarley.h:36
cfg_greg_app_prop
CfgFloat cfg_greg_app_prop
cfg_fungi_app_prop1
CfgFloat cfg_fungi_app_prop1
tof_OptimisingFarm
Definition: LandscapeFarmingEnums.h:696
sb_hay_baling
Definition: SpringBarley.h:72
sb_straw_chopping
Definition: SpringBarley.h:71
Farm::Water
virtual bool Water(LE *a_field, double a_user, int a_days)
Carry out a watering on a_field.
Definition: FarmFuncs.cpp:1330
SB_HERBI_DATE
#define SB_HERBI_DATE
Definition: SpringBarley.h:38
Crop::m_last_date
int m_last_date
Definition: Farm.h:503
Farm::AutumnPlough
virtual bool AutumnPlough(LE *a_field, double a_user, int a_days)
Carry out a ploughing event in the autumn on a_field.
Definition: FarmFuncs.cpp:212
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
sb_spring_sow
Definition: SpringBarley.h:58
Farm::FP_LiquidNH3
virtual bool FP_LiquidNH3(LE *a_field, double a_user, int a_days)
Apply liquid ammonia fertilizer to a_field owned by an arable farmer.
Definition: FarmFuncs.cpp:808
SBARLEY_BASE
#define SBARLEY_BASE
Definition: SpringBarley.h:31
sb_fertmanure_stock_one
Definition: SpringBarley.h:50
fmc_Harvest
Definition: LandscapeFarmingEnums.h:1012
SpringBarley::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: SpringBarley.h:88
sb_GR
Definition: SpringBarley.h:62
cfg_SpringBarley_SkScrapes
CfgBool cfg_SpringBarley_SkScrapes("CROP_SB_SK_SCRAPES", CFG_CUSTOM, false)
SB_MANURE_DONE
#define SB_MANURE_DONE
Definition: SpringBarley.h:33
sb_foobar
Definition: SpringBarley.h:74
Farm::GrowthRegulator
virtual bool GrowthRegulator(LE *a_field, double a_user, int a_days)
Apply growth regulator to a_field.
Definition: FarmFuncs.cpp:2070
Calendar::DayInYear
int DayInYear(void)
Definition: Calendar.h:58
sb_harvest
Definition: SpringBarley.h:70
Crop::Crop
Crop(TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape *a_L)
Definition: Farm.cpp:733
sb_start
Definition: SpringBarley.h:47
sb_insecticide2
Definition: SpringBarley.h:65
LE::SetMConstants
void SetMConstants(int a, int c)
Definition: Elements.h:408
Crop::ChooseNextCrop
void ChooseNextCrop(int a_no_dates)
Chooses the next crop to grow in a field.
Definition: Farm.cpp:756
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
WARN_BUG
Definition: MapErrorMsg.h:34
ppp_1
Definition: LandscapeFarmingEnums.h:1079
sb_spring_harrow
Definition: SpringBarley.h:52
fmc_Fungicide
Definition: LandscapeFarmingEnums.h:1007
FarmManagementCategory
FarmManagementCategory
Definition: LandscapeFarmingEnums.h:1001
cfg_pest_springbarley_on
CfgBool cfg_pest_springbarley_on
Turn on pesticides for spring barley.
sb_spring_roll
Definition: SpringBarley.h:59
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
Farm::SpringHarrow
virtual bool SpringHarrow(LE *a_field, double a_user, int a_days)
Carry out a harrow event in the spring on a_field.
Definition: FarmFuncs.cpp:459
SB_WATER_DATE
#define SB_WATER_DATE
Definition: SpringBarley.h:41