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

#include <WinterBarley.h>

Inheritance diagram for WinterBarley:
Crop

Public Member Functions

bool Do (Farm *a_farm, LE *a_field, FarmEvent *a_ev)
 
 WinterBarley (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

◆ WinterBarley()

WinterBarley::WinterBarley ( TTypesOfVegetation  a_tov,
TTypesOfCrops  a_toc,
Landscape a_L 
)
inline
95  : Crop(a_tov, a_toc, a_L)
96  {
99  }

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

Member Function Documentation

◆ Do()

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

Reimplemented from Crop.

38 {
39  double ins_app_prop=cfg_ins_app_prop1.value();
40  double herbi_app_prop=cfg_herbi_app_prop.value();
41  m_farm = a_farm;
42  m_field = a_field;
43  m_ev = a_ev;
44  bool done = false;
45 
46  switch ( m_ev->m_todo )
47  {
48  case wb_start:
49  {
52  a_field->ClearManagementActionSum();
53 
54  // Set up the date management stuff
56  // Start and stop dates for all events after harvest
57  int noDates= 3;
58  m_field->SetMDates(0,0,g_date->DayInYear(20,7));
59  // Determined by harvest date - used to see if at all possible
60  m_field->SetMDates(1,0,g_date->DayInYear(5,8));
61  m_field->SetMDates(0,1,g_date->DayInYear(25,7));
62  m_field->SetMDates(1,1,g_date->DayInYear(10,8));
63  m_field->SetMDates(0,2,g_date->DayInYear(20,7));
64  m_field->SetMDates(1,2,g_date->DayInYear(5,8));
65  // Check the next crop for early start, unless it is a spring crop
66  // in which case we ASSUME that no checking is necessary!!!!
67  // So DO NOT implement a crop that runs over the year boundary
68 
69  //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)
70  int d1;
72 
73  if (m_ev->m_startday>g_date->DayInYear(1,7))
74  {
75  if (m_field->GetMDates(0,0) >=m_ev->m_startday)
76  {
77  g_msg->Warn( WARN_BUG, "WinterBarley::Do(): "
78  "Harvest too late for the next crop to start!!!", "" );
79  exit( 1 );
80  }
81  // Now fix any late finishing problems
82  for (int i=0; i<noDates; i++) {
83  if(m_field->GetMDates(0,i)>=m_ev->m_startday) {
84  m_field->SetMDates(0,i,m_ev->m_startday-1); //move the starting date
85  }
86  if(m_field->GetMDates(1,i)>=m_ev->m_startday){
87  m_field->SetMConstants(i,0);
88  m_field->SetMDates(1,i,m_ev->m_startday-1); //move the finishing date
89  }
90  }
91  }
92  // Now no operations can be timed after the start of the next crop.
93 
94  if ( ! m_ev->m_first_year )
95  {
96  int today=g_date->Date();
97  // Are we before July 1st?
98  d1 = g_date->OldDays() + g_date->DayInYear( 1,7 );
99  if (today < d1){
100  // Yes, too early. We assumme this is because the last crop was late
101  g_msg->Warn( WARN_BUG, "WinterBarley::Do(): "
102  "Crop start attempt between 1st Jan & 1st July", "" );
103  exit( 1 );
104  }
105  else{
106  d1 = g_date->OldDays() + m_first_date; // Add 365 for spring crop
107  if (today > d1) {
108  // Yes too late - should not happen - raise an error
109  g_msg->Warn( WARN_BUG, "WinterBarley::Do(): "
110  "Crop start attempt after last possible start date", "" );
111  exit( 1 );
112  }
113  }
114  }
115  else
116  {
117  // Is the first year so must start in spring like nothing was unusual
118  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 20,7 )
119  ,wb_harvest, false );
120  }
121  }//if
122 
123  // End single block date checking code. Please see next line
124  // comment as well.
125  // Reinit d1 to first possible starting date.
126  d1 = g_date->OldDays() + m_first_date; // Add 365 for spring crop
127  if ( g_date->Date() > d1 ) {
128  d1 = g_date->Date();
129  }
130  // OK, let's go.
131  WB_DID_SEVEN_ONE = false;
132  WB_DID_SEVEN_TWO = false;
133  WB_DID_SEVEN_THREE = false;
134  WB_DID_SEVEN_FOUR = false;
135  WB_FUNGICIDE_DATE = 0;
136  WB_HERBICIDE_DATE = 0;
137 
138  if ( m_farm->IsStockFarmer()) {
139  SimpleEvent( d1, wb_fertmanure_stock, false );
140  d1 += 14;
141  SimpleEvent( d1, wb_fertslurry_stock_one, false );
142  } else {
143  SimpleEvent( d1, wb_fertsludge_plant_one, false );
144  }
145  }
146  break;
147 
148  case wb_fertmanure_stock:
149  if ( m_ev->m_lock || m_farm->DoIt( 10 ))
150  {
151  if (!m_farm->FA_Manure( m_field, 0.0,
152  g_date->DayInYear( 5, 9 ) -
153  g_date->DayInYear())) {
154  SimpleEvent( g_date->Date() + 1, wb_fertmanure_stock, true );
155  break;
156  }
157  }
158  break;
159 
161  if ( m_ev->m_lock || m_farm->DoIt( 95 ))
162  {
163  if (!m_farm->FA_Slurry( m_field, 0.0,
164  g_date->DayInYear( 10, 9 ) -
165  g_date->DayInYear())) {
167  break;
168  }
169  }
170  SimpleEvent( g_date->Date() + 1, wb_autumn_plough, false );
171  break;
172 
174  if ( m_ev->m_lock || m_farm->DoIt( 10 ))
175  {
176  if (!m_farm->FP_Sludge( m_field, 0.0,
177  g_date->DayInYear( 5, 9 ) -
178  g_date->DayInYear())) {
180  break;
181  }
182  }
183  SimpleEvent( g_date->Date() + 1, wb_autumn_plough, false );
184  break;
185 
186  case wb_autumn_plough:
187  if (!m_farm->AutumnPlough( m_field, 0.0,
188  g_date->DayInYear( 5, 9 ) -
189  g_date->DayInYear())) {
190  SimpleEvent( g_date->Date() + 1, wb_autumn_plough, true );
191  break;
192  }
193  SimpleEvent( g_date->Date(), wb_autumn_harrow, false );
194  break;
195 
196  case wb_autumn_harrow:
197  if (!m_farm->AutumnHarrow( m_field, 0.0,
198  g_date->DayInYear( 5, 9 ) -
199  g_date->DayInYear())) {
200  SimpleEvent( g_date->Date() + 1, wb_autumn_harrow, true );
201  break;
202  }
203  {
204  int d1 = g_date->Date();
205  if ( d1 < g_date->OldDays() + g_date->DayInYear( 1, 9 )) {
206  d1 = g_date->OldDays() + g_date->DayInYear( 1, 9 );
207  }
208  SimpleEvent( d1, wb_autumn_sow, false );
209  }
210  break;
211 
212  case wb_autumn_sow:
213  if (!m_farm->AutumnSow( m_field, 0.0,
214  g_date->DayInYear( 15,9 ) -
215  g_date->DayInYear())) {
216  SimpleEvent( g_date->Date() + 1, wb_autumn_sow, true );
217  break;
218  }
219  {
220  int d1 = g_date->Date() + 14;
221  if ( d1 < g_date->OldDays() + g_date->DayInYear( 15, 9 )) {
222  d1 = g_date->OldDays() + g_date->DayInYear( 15, 9 );
223  }
224  SimpleEvent( d1, wb_herbicide_one, false );
225  }
226  break;
227 
228  case wb_herbicide_one:
229  if ( m_ev->m_lock || m_farm->DoIt( (int) floor(100*herbi_app_prop * m_farm->Prob_multiplier()+0.5) )) //modified probability
230  {
231  if (!m_farm->HerbicideTreat( m_field, 0.0, g_date->DayInYear( 30,9 ) - g_date->DayInYear())) {
232  SimpleEvent( g_date->Date() + 1, wb_herbicide_one, true );
233  break;
234  }
235  }
236  if ( m_farm->IsStockFarmer()) {
237  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 1,4 ) + 365,
238  wb_fertslurry_stock_two, false );
239  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 5,4 ) + 365,
240  wb_fertnpk_stock_one, false );
241  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 15,4 ) + 365,
242  wb_herbicide_two, false );
243  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 1,5 ) + 365,
244  wb_fungicide_one, false );
245  } else {
246  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 16,9 ),
248  }
249  break;
250 
252  if ( m_ev->m_lock || m_farm->DoIt( 20 ))
253  {
254  if (!m_farm->FP_ManganeseSulphate( m_field, 0.0,
255  g_date->DayInYear( 30,10 ) -
256  g_date->DayInYear())) {
258  break;
259  }
260  // Did first, so do second manganese too.
261  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 1,4 ) + 365,
263  } else {
264  // Event 'wb_fertmanganese_plant_two' was not queued up, so we will
265  // signal its completion already here...
266  WB_DID_SEVEN_ONE = true;
267  }
268  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 5,4 ) + 365,
269  wb_fertnpk_plant_one, false );
270  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 15,4 ) + 365,
271  wb_herbicide_two, false );
272  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 1,5 ) + 365,
273  wb_fungicide_one, false );
274  break;
275 
277  if (!m_farm->FP_ManganeseSulphate( m_field, 0.0,
278  g_date->DayInYear( 5,5 ) -
279  g_date->DayInYear())) {
281  break;
282  }
283  WB_DID_SEVEN_ONE = true;
284  if ( WB_DID_SEVEN_TWO &&
287  // We are the last surviving thread. Enter switchboard.
288  SimpleEvent( g_date->Date(), wb_switchboard, false );
289  }
290  break;
291 
293  if (!m_farm->FP_NPK( m_field, 0.0,
294  g_date->DayInYear( 1,5 ) -
295  g_date->DayInYear())) {
296  SimpleEvent( g_date->Date() + 1, wb_fertnpk_plant_one, true );
297  break;
298  }
299  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 2,5 ),
300  wb_fertnpk_plant_two, false );
301  break;
302 
304  if ( m_ev->m_lock || m_farm->DoIt( 15 )) {
305  if (!m_farm->FP_NPK( m_field, 0.0,
306  g_date->DayInYear( 20,5 ) -
307  g_date->DayInYear())) {
308  SimpleEvent( g_date->Date() + 1, wb_fertnpk_plant_two, true );
309  break;
310  }
311  }
312  WB_DID_SEVEN_TWO = true;
313  if ( WB_DID_SEVEN_ONE &&
316  // We are the last surviving thread. Enter switchboard.
317  SimpleEvent( g_date->Date(), wb_switchboard, false );
318  }
319  break;
320 
322  if ( m_ev->m_lock || m_farm->DoIt( 20 )) {
323  if (!m_farm->FA_Slurry( m_field, 0.0,
324  g_date->DayInYear( 15,5 ) -
325  g_date->DayInYear())) {
327  break;
328  }
329  }
330  WB_DID_SEVEN_ONE = true;
331  if ( WB_DID_SEVEN_TWO &&
334  // We are the last surviving thread. Enter switchboard.
335  SimpleEvent( g_date->Date(), wb_switchboard, false );
336  }
337  break;
338 
340  if ( m_ev->m_lock || m_farm->DoIt( 90 )) {
341  if (!m_farm->FA_NPK( m_field, 0.0,
342  g_date->DayInYear( 30,4 ) -
343  g_date->DayInYear())) {
344  SimpleEvent( g_date->Date() + 1, wb_fertnpk_stock_one, true );
345  break;
346  }
347  }
348  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 1,5 ),
349  wb_fertnpk_stock_two, false );
350  break;
351 
353  if ( m_ev->m_lock || m_farm->DoIt( 14 )) {
354  if (!m_farm->FA_NPK( m_field, 0.0,
355  g_date->DayInYear( 15,5 ) -
356  g_date->DayInYear())) {
357  SimpleEvent( g_date->Date() + 1, wb_fertnpk_stock_two, true );
358  break;
359  }
360  }
361  WB_DID_SEVEN_TWO = true;
362  if ( WB_DID_SEVEN_ONE &&
365  // We are the last surviving thread. Enter switchboard.
366  SimpleEvent( g_date->Date(), wb_switchboard, false );
367  }
368  break;
369 
370  case wb_herbicide_two:
371  if ( m_ev->m_lock || m_farm->DoIt( (int) floor(35*herbi_app_prop*WB_DECIDE_TO_HERB * m_farm->Prob_multiplier()+0.5 ))) { //modified probability
372  if (!m_farm->HerbicideTreat( m_field, 0.0,
373  g_date->DayInYear( 30,5 ) -
374  g_date->DayInYear())) {
375  SimpleEvent( g_date->Date() + 1, wb_herbicide_two, true );
376  break;
377  }
379  }
380  WB_DID_SEVEN_THREE = true;
381  if ( WB_DID_SEVEN_ONE &&
384  // We are the last surviving thread. Enter switchboard.
385  SimpleEvent( g_date->Date(), wb_switchboard, false );
386  }
387  break;
388 
389  case wb_fungicide_one:
390  if ( m_ev->m_lock || m_farm->DoIt( (int) (65*cfg_fungi_app_prop1.value() * m_farm->Prob_multiplier()))) { //modified probability
391 
392  if (!m_farm->FungicideTreat( m_field, 0.0, g_date->DayInYear( 15,5 ) - g_date->DayInYear())) {
393  SimpleEvent( g_date->Date() + 1, wb_fungicide_one, true );
394  break;
395  }
396 
398  }
399  WB_DID_SEVEN_FOUR = true;
400  if ( WB_DID_SEVEN_ONE &&
403  // We are the last surviving thread. Enter switchboard.
404  SimpleEvent( g_date->Date(), wb_switchboard, false );
405  }
406  break;
407 
408  case wb_switchboard:
409  // Welcome to the Winterbarley switchboard, where all threads
410  // meet and have a jolly good time.
411 
412  // Reset all flags for the second round of parallel execution.
413  // Flags double as date indicators when each action took place
414  // (for checking proximity to watering).
415  WB_DID_EIGHT_ONE = false;
416  WB_DID_EIGHT_TWO = false;
417  WB_DID_EIGHT_THREE = false;
418  WB_DID_EIGHT_FOUR = false;
419 
420  // Start all four threads.
421  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 15,5 ),
422  wb_fungicide_two, false );
423  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 1,5 ),
424  wb_growth_reg, false );
425  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 15,5 ),
426  wb_water, false );
427  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 15,5 ),
428  wb_insecticide, false );
429  break;
430 
431  case wb_fungicide_two:
432  if ( g_date->Date() < WB_DID_EIGHT_THREE + 1 ||
433  g_date->Date() < WB_FUNGICIDE_DATE + 7 ) {
434  // Try again tomorrow.
436  break;
437  }
438  if ( m_ev->m_lock || m_farm->DoIt( (int) (15*cfg_fungi_app_prop1.value() *WB_DECIDE_TO_HERB * m_farm->Prob_multiplier()))) { //modified probability
439  if (!m_farm->FungicideTreat( m_field, 0.0,
440  g_date->DayInYear( 30,5 ) -
441  g_date->DayInYear())) {
442  SimpleEvent( g_date->Date() + 1, wb_fungicide_two, true );
443  break;
444  }
445  }
447  if ( WB_DID_EIGHT_TWO &&
450  ChooseNextCrop (3);
451  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 20,7 ),
452  wb_harvest, false );
453  }
454  break;
455 
456  case wb_growth_reg:
457  if ( g_date->Date() < WB_DID_EIGHT_THREE + 1 ) {
458  // Try again tomorrow.
460  break;
461  }
462  if ( m_ev->m_lock || m_farm->DoIt( (int) (50*cfg_greg_app_prop.value() ))) {
463  if (!m_farm->GrowthRegulator( m_field, 0.0,
464  g_date->DayInYear( 31,5 ) -
465  g_date->DayInYear())) {
466  SimpleEvent( g_date->Date() + 1, wb_growth_reg, true );
467  break;
468  }
469  }
471  if ( WB_DID_EIGHT_ONE &&
474  ChooseNextCrop (3);
475  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 20,7 ), wb_harvest, false );
476  }
477  break;
478 
479  case wb_water:
480  if ( g_date->Date() < WB_HERBICIDE_DATE + 1 ||
481  g_date->Date() < WB_DID_EIGHT_ONE + 1 ||
482  g_date->Date() < WB_DID_EIGHT_TWO + 1 ||
483  g_date->Date() < WB_DID_EIGHT_FOUR + 1 ) {
484  // Try again tomorrow.
485  SimpleEvent( g_date->Date() + 1, wb_water, m_ev->m_lock );
486  break;
487  }
488  if ( m_ev->m_lock || m_farm->DoIt( 5 )) {
489  if (!m_farm->Water( m_field, 0.0,
490  g_date->DayInYear( 15,6 ) -
491  g_date->DayInYear())) {
492  SimpleEvent( g_date->Date() + 1, wb_water, true );
493  break;
494  }
495  }
497  if ( WB_DID_EIGHT_ONE &&
500  ChooseNextCrop (3);
501  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 20,7 ),
502  wb_harvest, false );
503  }
504  break;
505 
506  case wb_insecticide:
507  if ( g_date->Date() < WB_DID_EIGHT_THREE + 1 ) {
508  // Try again tomorrow.
510  break;
511  }
512  if ( m_ev->m_lock || m_farm->DoIt( (int) floor(0.5+16*ins_app_prop * m_farm->Prob_multiplier()))) { //modified probability
513 
514  if (!m_farm->InsecticideTreat( m_field, 0.0, g_date->DayInYear( 1,6 ) - g_date->DayInYear())) {
515  SimpleEvent( g_date->Date() + 1, wb_insecticide, true );
516  break;
517 
518  }
519  }
521  if ( WB_DID_EIGHT_ONE &&
524  ChooseNextCrop (3);
525  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 20,7 ),
526  wb_harvest, false );
527  }
528  break;
529 
530  case wb_harvest:
531  if (m_field->GetMConstants(0)==0) {
532  if (!m_farm->Harvest( m_field, 0.0, -1)) { //raise an error
533  g_msg->Warn( WARN_BUG, "WinterBarley::Do(): failure in 'Harvest' execution", "" );
534  exit( 1 );
535  }
536  }
537  else{
538  if (!m_farm->Harvest( m_field, 0.0, m_field->GetMDates(1,0) - g_date->DayInYear())) {
539  SimpleEvent( g_date->Date() + 1, wb_harvest, true );
540  break;
541  }
542  }
543 
544  if ( m_farm->IsStockFarmer()) {
545  if ( m_farm->DoIt( 15 )) {
546  // Force straw chopping on the same day as harvest.
547  m_farm->StrawChopping( m_field, 0.0, 0 );
549  break;
550  }
551  // No chopping and harrowing, so try hay turning.
553  break;
554  } else {
555  // Plant farmer.
556  if ( m_farm->DoIt( 75 )) {
557  // Force straw chopping on the same day as harvest.
558  m_farm->StrawChopping( m_field, 0.0, 0 );
560  break;
561  }
563  }
564  break;
565 
566  case wb_hay_turning:
567  if ( m_ev->m_lock || m_farm->DoIt( 50 ))
568  {
569  if (m_field->GetMConstants(2)==0) {
570  if (!m_farm->HayTurning( m_field, 0.0, -1)) { //raise an error
571  g_msg->Warn( WARN_BUG, "WinterBarley::Do(): failure in 'HayTurning' execution", "" );
572  exit( 1 );
573  }
574  }
575  else {
576  if (!m_farm->HayTurning( m_field, 0.0, m_field->GetMDates(1,2) - g_date->DayInYear())) {
577  SimpleEvent( g_date->Date() + 1, wb_hay_turning, true );
578  break;
579  }
580  }
581  }
583  break;
584 
585  case wb_hay_bailing:
586  if (m_field->GetMConstants(2)==0) {
587  if (!m_farm->HayBailing( m_field, 0.0, -1)) { //raise an error
588  g_msg->Warn( WARN_BUG, "WinterBarley::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,2) - g_date->DayInYear())) {
594  SimpleEvent( g_date->Date() + 1, wb_hay_bailing, true );
595  break;
596  }
597  }
598  {
599  int d1 = g_date->Date();
600  if ( d1 < g_date->OldDays() + m_field->GetMDates(0,1)) {
601  d1 = g_date->OldDays() + m_field->GetMDates(0,1);
602  }
603  SimpleEvent( d1, wb_stubble_harrowing, false );
604  }
605  break;
606 
608  if ( m_ev->m_lock || m_farm->DoIt( 40 )) {
609  if (m_field->GetMConstants(2)==0) {
610  if (!m_farm->StubbleHarrowing( m_field, 0.0, -1)) { //raise an error
611  g_msg->Warn( WARN_BUG, "WinterBarley::Do(): failure in 'StubbleHarrowing' execution", "" );
612  exit( 1 );
613  }
614  }
615  else {
616  if (!m_farm->StubbleHarrowing( m_field, 0.0, m_field->GetMDates(1,2) - g_date->DayInYear())) {
617  SimpleEvent( g_date->Date() + 1, wb_stubble_harrowing, true );
618  break;
619  }
620  }
621  }
622  done = true;
623  break;
624 
625  default:
626  g_msg->Warn( WARN_BUG, "WinterBarley::Do(): "
627  "Unknown event type! ", "" );
628  exit( 1 );
629  }
630 
631  return done;
632 }

References Farm::AutumnHarrow(), Farm::AutumnPlough(), Farm::AutumnSow(), cfg_fungi_app_prop1, cfg_greg_app_prop, cfg_herbi_app_prop, cfg_ins_app_prop1, Crop::ChooseNextCrop(), LE::ClearManagementActionSum(), Calendar::Date(), Calendar::DayInYear(), Farm::DoIt(), Farm::FA_Manure(), Farm::FA_NPK(), Farm::FA_Slurry(), Farm::FP_ManganeseSulphate(), Farm::FP_NPK(), Farm::FP_Sludge(), Farm::FungicideTreat(), g_date, g_msg, LE::GetMConstants(), LE::GetMDates(), Farm::GetType(), Calendar::GetYearNumber(), Farm::GrowthRegulator(), Farm::Harvest(), Farm::HayBailing(), Farm::HayTurning(), 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, FarmEvent::m_startday, FarmEvent::m_todo, Calendar::OldDays(), Farm::Prob_multiplier(), LE::SetMConstants(), LE::SetMDates(), Crop::SimpleEvent(), Farm::StrawChopping(), Farm::StubbleHarrowing(), tof_OptimisingFarm, CfgFloat::value(), MapErrorMsg::Warn(), WARN_BUG, Farm::Water(), wb_autumn_harrow, wb_autumn_plough, wb_autumn_sow, WB_DECIDE_TO_FI, WB_DECIDE_TO_HERB, WB_DID_EIGHT_FOUR, WB_DID_EIGHT_ONE, WB_DID_EIGHT_THREE, WB_DID_EIGHT_TWO, WB_DID_SEVEN_FOUR, WB_DID_SEVEN_ONE, WB_DID_SEVEN_THREE, WB_DID_SEVEN_TWO, wb_fertmanganese_plant_one, wb_fertmanganese_plant_two, wb_fertmanure_stock, wb_fertnpk_plant_one, wb_fertnpk_plant_two, wb_fertnpk_stock_one, wb_fertnpk_stock_two, wb_fertsludge_plant_one, wb_fertslurry_stock_one, wb_fertslurry_stock_two, WB_FUNGICIDE_DATE, wb_fungicide_one, wb_fungicide_two, wb_growth_reg, wb_harvest, wb_hay_bailing, wb_hay_turning, WB_HERBICIDE_DATE, wb_herbicide_one, wb_herbicide_two, wb_insecticide, wb_start, wb_stubble_harrowing, wb_switchboard, and wb_water.

◆ SetUpFarmCategoryInformation()

void WinterBarley::SetUpFarmCategoryInformation ( )
inline
100  {
101  const int elements = 2 + (wb_foobar - WBarley_BASE);
103 
104  FarmManagementCategory catlist[elements] =
105  {
106  fmc_Others, // zero element unused but must be here
107  fmc_Others,//wb_start = 1, // Compulsory, start event must always be 1 (one).
108  fmc_Fertilizer,//wb_fertsludge_plant_one = WBarley_BASE,
109  fmc_Fertilizer,//wb_fertmanure_stock,
110  fmc_Fertilizer,//wb_fertslurry_stock_one,
111  fmc_Cultivation,//wb_autumn_plough,
112  fmc_Cultivation,//wb_autumn_harrow,
113  fmc_Others,//wb_autumn_sow,
114  fmc_Herbicide,//wb_herbicide_one,
115  fmc_Fertilizer,//wb_fertmanganese_plant_one,
116  fmc_Fertilizer,//wb_fertmanganese_plant_two,
117  fmc_Fertilizer,//wb_fertnpk_plant_one,
118  fmc_Fertilizer,//wb_fertnpk_plant_two,
119  fmc_Fertilizer,//wb_fertslurry_stock_two,
120  fmc_Fertilizer,//wb_fertnpk_stock_one,
121  fmc_Fertilizer,//wb_fertnpk_stock_two,
122  fmc_Herbicide,//wb_herbicide_two,
123  fmc_Fungicide,//wb_fungicide_one,
124  fmc_Others,//wb_switchboard,
125  fmc_Fungicide,//wb_fungicide_two,
126  fmc_Others,//wb_growth_reg,
127  fmc_Watering,//wb_water,
128  fmc_Insecticide,//wb_insecticide,
129  fmc_Harvest,//wb_harvest,
130  fmc_Others,//wb_hay_turning,
131  fmc_Others,//wb_hay_bailing,
132  fmc_Cultivation//wb_stubble_harrowing
133 
134  // no foobar entry
135 
136  };
137  // Iterate over the catlist elements and copy them to vector
138  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
139 
140  }

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, wb_foobar, and WBarley_BASE.

Referenced by WinterBarley().


The documentation for this class was generated from the following files:
LE::GetMDates
int GetMDates(int a, int b)
Definition: Elements.h:405
Farm::FP_Sludge
virtual bool FP_Sludge(LE *a_field, double a_user, int a_days)
Spread sewege on a_field owned by an arable farmer.
Definition: FarmFuncs.cpp:926
wb_fertslurry_stock_one
Definition: WinterBarley.h:62
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
wb_fertnpk_plant_one
Definition: WinterBarley.h:69
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
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
cfg_greg_app_prop
CfgFloat cfg_greg_app_prop
cfg_fungi_app_prop1
CfgFloat cfg_fungi_app_prop1
Farm::FP_ManganeseSulphate
virtual bool FP_ManganeseSulphate(LE *a_field, double a_user, int a_days)
Apply Manganse Sulphate to a_field owned by an arable farmer.
Definition: FarmFuncs.cpp:840
LE::GetMConstants
int GetMConstants(int a)
Definition: Elements.h:407
wb_water
Definition: WinterBarley.h:79
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
FarmEvent::m_first_year
bool m_first_year
Definition: Farm.h:386
wb_hay_turning
Definition: WinterBarley.h:82
wb_fertmanganese_plant_one
Definition: WinterBarley.h:67
wb_autumn_harrow
Definition: WinterBarley.h:64
g_date
class Calendar * g_date
Definition: Calendar.cpp:37
WB_DECIDE_TO_FI
#define WB_DECIDE_TO_FI
Definition: WinterBarley.h:55
cfg_ins_app_prop1
CfgFloat cfg_ins_app_prop1
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
CfgFloat::value
double value() const
Definition: Configurator.h:142
Farm::GetType
TTypesOfFarm GetType(void)
Definition: Farm.h:956
WBarley_BASE
#define WBarley_BASE
Definition: WinterBarley.h:40
Crop::m_base_elements_no
int m_base_elements_no
Definition: Farm.h:505
WB_DID_EIGHT_THREE
#define WB_DID_EIGHT_THREE
Definition: WinterBarley.h:52
wb_growth_reg
Definition: WinterBarley.h:78
wb_fungicide_two
Definition: WinterBarley.h:77
WB_DID_EIGHT_ONE
#define WB_DID_EIGHT_ONE
Definition: WinterBarley.h:50
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
wb_fungicide_one
Definition: WinterBarley.h:75
Crop::SimpleEvent
void SimpleEvent(long a_date, int a_todo, bool a_lock)
Adds an event to this crop management.
Definition: Farm.cpp:747
wb_hay_bailing
Definition: WinterBarley.h:83
wb_foobar
Definition: WinterBarley.h:85
wb_start
Definition: WinterBarley.h:59
wb_switchboard
Definition: WinterBarley.h:76
wb_fertsludge_plant_one
Definition: WinterBarley.h:60
wb_herbicide_one
Definition: WinterBarley.h:66
Farm::Prob_multiplier
virtual double Prob_multiplier()
Definition: Farm.h:778
wb_autumn_plough
Definition: WinterBarley.h:63
fmc_Fertilizer
Definition: LandscapeFarmingEnums.h:1004
WB_FUNGICIDE_DATE
#define WB_FUNGICIDE_DATE
Definition: WinterBarley.h:47
WB_DID_SEVEN_FOUR
#define WB_DID_SEVEN_FOUR
Definition: WinterBarley.h:45
Calendar::Date
long Date(void)
Definition: Calendar.h:57
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
fmc_Others
Definition: LandscapeFarmingEnums.h:1003
WB_DECIDE_TO_HERB
#define WB_DECIDE_TO_HERB
Definition: WinterBarley.h:54
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
fmc_Watering
Definition: LandscapeFarmingEnums.h:1011
Calendar::OldDays
long OldDays(void)
Definition: Calendar.h:60
wb_fertmanure_stock
Definition: WinterBarley.h:61
MapErrorMsg::Warn
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: MapErrorMsg.cpp:69
wb_herbicide_two
Definition: WinterBarley.h:74
wb_harvest
Definition: WinterBarley.h:81
wb_fertnpk_plant_two
Definition: WinterBarley.h:70
Crop::m_farm
Farm * m_farm
Definition: Farm.h:498
Crop::m_field
LE * m_field
Definition: Farm.h:499
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
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
WB_HERBICIDE_DATE
#define WB_HERBICIDE_DATE
Definition: WinterBarley.h:48
WB_DID_SEVEN_TWO
#define WB_DID_SEVEN_TWO
Definition: WinterBarley.h:43
tof_OptimisingFarm
Definition: LandscapeFarmingEnums.h:696
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
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
WB_DID_EIGHT_TWO
#define WB_DID_EIGHT_TWO
Definition: WinterBarley.h:51
wb_fertslurry_stock_two
Definition: WinterBarley.h:71
cfg_herbi_app_prop
CfgFloat cfg_herbi_app_prop
Farm::AutumnHarrow
virtual bool AutumnHarrow(LE *a_field, double a_user, int a_days)
Carry out a harrow event in the autumn on a_field.
Definition: FarmFuncs.cpp:285
wb_fertmanganese_plant_two
Definition: WinterBarley.h:68
WB_DID_EIGHT_FOUR
#define WB_DID_EIGHT_FOUR
Definition: WinterBarley.h:53
Farm::AutumnSow
virtual bool AutumnSow(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 autumn on a_field.
Definition: FarmFuncs.cpp:360
fmc_Harvest
Definition: LandscapeFarmingEnums.h:1012
WB_DID_SEVEN_THREE
#define WB_DID_SEVEN_THREE
Definition: WinterBarley.h:44
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
wb_insecticide
Definition: WinterBarley.h:80
wb_stubble_harrowing
Definition: WinterBarley.h:84
Crop::Crop
Crop(TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape *a_L)
Definition: Farm.cpp:733
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
Farm::HayTurning
virtual bool HayTurning(LE *a_field, double a_user, int a_days)
Carry out hay turning on a_field.
Definition: FarmFuncs.cpp:1491
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
wb_fertnpk_stock_two
Definition: WinterBarley.h:73
WinterBarley::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: WinterBarley.h:100
WARN_BUG
Definition: MapErrorMsg.h:34
fmc_Fungicide
Definition: LandscapeFarmingEnums.h:1007
wb_autumn_sow
Definition: WinterBarley.h:65
FarmManagementCategory
FarmManagementCategory
Definition: LandscapeFarmingEnums.h:1001
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
WB_DID_SEVEN_ONE
#define WB_DID_SEVEN_ONE
Definition: WinterBarley.h:42
wb_fertnpk_stock_one
Definition: WinterBarley.h:72