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

#include <SpringBarley.h>

Public Member Functions

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

Constructor & Destructor Documentation

◆ SpringBarley()

SpringBarley::SpringBarley ( )
inline
83  {
84  m_first_date=g_date->DayInYear(2,11);
85  }

References Crop::m_first_date.

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

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_1_amount, cfg_pest_springbarley_on, cfg_SB_InsecticideDay, cfg_SB_InsecticideMonth, cfg_SpringBarley_SkScrapes(), Crop::ChooseNextCrop(), Farm::DoIt(), Farm::FA_Manure(), Farm::FA_NPK(), Farm::FA_Slurry(), Farm::FP_LiquidNH3(), Farm::FP_NPK(), Farm::FP_PK(), Farm::FungicideTreat(), g_landscape_p, Farm::GetType(), 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, FarmEvent::m_startday, FarmEvent::m_todo, 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, Crop::SimpleEvent(), Farm::Spraying_fungins(), Farm::Spraying_herbicides(), Farm::SpringHarrow(), Farm::SpringPlough(), Farm::SpringRoll(), Farm::SpringSow(), Farm::StrawChopping(), Farm::StubbleHarrowing(), Landscape::SupplyShouldSpray(), tof_OptimisingFarm, and Farm::Water().


The documentation for this class was generated from the following files:
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:525
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:965
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:444
Farm::HerbicideTreat
virtual bool HerbicideTreat(LE *a_field, double a_user, int a_days)
Apply herbicide to a_field.
Definition: farmfuncs.cpp:1156
Farm::IsStockFarmer
bool IsStockFarmer(void)
Definition: farm.h:905
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:1769
FarmEvent::m_lock
bool m_lock
Definition: farm.h:465
sb_fungicide_one
Definition: SpringBarley.h:63
sb_insecticide
Definition: SpringBarley.h:64
cfg_ins_app_prop3
CfgFloat cfg_ins_app_prop3
Landscape::SupplyShouldSpray
bool SupplyShouldSpray()
Definition: Landscape.h:357
sb_fertlnh3_plant
Definition: SpringBarley.h:54
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:629
Farm::DoIt
bool DoIt(double a_probability)
Return chance out of 0 to 100.
Definition: farm.cpp:800
sb_autumn_plough
Definition: SpringBarley.h:48
FarmEvent::m_first_year
bool m_first_year
Definition: farm.h:467
cfg_SB_InsecticideDay
CfgInt cfg_SB_InsecticideDay
tof_OptimisingFarm
Definition: farm.h:273
sb_fungicide_two
Definition: SpringBarley.h:67
sb_herbicide_one
Definition: SpringBarley.h:60
cfg_SpringBarley_SkScrapes
CfgBool cfg_SpringBarley_SkScrapes("CROP_SB_SK_SCRAPES", CFG_CUSTOM, false)
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:1036
sb_fertmanure_stock_two
Definition: SpringBarley.h:56
sb_fertpk_plant
Definition: SpringBarley.h:55
Farm::GetType
TTypesOfFarm GetType(void)
Definition: farm.h:901
Farm::ProductApplication_DateLimited
virtual bool ProductApplication_DateLimited(LE *a_field, double, int, double a_applicationrate, PlantProtectionProducts a_ppp)
Special pesticide trial functionality.
Definition: farmfuncs.cpp:2396
sb_stubble_harrow
Definition: SpringBarley.h:73
Crop::m_first_date
int m_first_date
Definition: farm.h:540
FarmEvent::m_startday
int m_startday
Definition: farm.h:466
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:917
Farm::FungicideTreat
virtual bool FungicideTreat(LE *a_field, double a_user, int a_days)
Apply fungicide to a_field.
Definition: farmfuncs.cpp:1279
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:653
Crop::SimpleEvent
void SimpleEvent(long a_date, int a_todo, bool a_lock)
Adds an event to this crop management.
Definition: farm.cpp:307
SB_MANURE_EXEC
#define SB_MANURE_EXEC
Definition: SpringBarley.h:35
SB_INSECT_DATE
#define SB_INSECT_DATE
Definition: SpringBarley.h:42
cfg_pest_product_1_amount
CfgFloat cfg_pest_product_1_amount
Farm::Prob_multiplier
virtual double Prob_multiplier()
Definition: farm.h:786
sb_water_one
Definition: SpringBarley.h:68
SB_DECIDE_TO_FI
#define SB_DECIDE_TO_FI
Definition: SpringBarley.h:44
TTypesOfVegetation
TTypesOfVegetation
Definition: tov_declaration.h:30
sb_insecticide3
Definition: SpringBarley.h:66
Farm::Spraying_herbicides
virtual bool Spraying_herbicides(TTypesOfVegetation)
Definition: farm.h:784
Farm::HayBailing
virtual bool HayBailing(LE *a_field, double a_user, int a_days)
Carry out hay bailing on a_field.
Definition: farmfuncs.cpp:2184
cfg_herbi_app_prop
CfgFloat cfg_herbi_app_prop
SB_DECIDE_TO_HERB
#define SB_DECIDE_TO_HERB
Definition: SpringBarley.h:43
Farm::StrawChopping
virtual bool StrawChopping(LE *a_field, double a_user, int a_days)
Carry out straw chopping on a_field.
Definition: farmfuncs.cpp:2132
sb_fertmanure_plant
Definition: SpringBarley.h:53
sb_spring_plough
Definition: SpringBarley.h:51
sb_water_two
Definition: SpringBarley.h:69
cfg_ins_app_prop2
CfgFloat cfg_ins_app_prop2
SB_SLURRY_DONE
#define SB_SLURRY_DONE
Definition: SpringBarley.h:32
Crop::m_farm
Farm * m_farm
Definition: farm.h:537
SB_SLURRY_EXEC
#define SB_SLURRY_EXEC
Definition: SpringBarley.h:34
Crop::m_field
LE * m_field
Definition: farm.h:538
cfg_SB_InsecticideMonth
CfgInt cfg_SB_InsecticideMonth
FarmEvent::m_todo
int m_todo
Definition: farm.h:469
Farm::InsecticideTreat
virtual bool InsecticideTreat(LE *a_field, double a_user, int a_days)
Apply insecticide to a_field.
Definition: farmfuncs.cpp:1348
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
ppp_1
Definition: farm.h:422
cfg_fungi_app_prop1
CfgFloat cfg_fungi_app_prop1
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:1717
SB_HERBI_DATE
#define SB_HERBI_DATE
Definition: SpringBarley.h:38
Crop::m_last_date
int m_last_date
Definition: farm.h:542
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:132
Farm::SpringSow
virtual bool SpringSow(LE *a_field, double a_user, int a_days)
Carry out a sowing event in the spring on a_field.
Definition: farmfuncs.cpp:546
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:677
sb_fertmanure_stock_one
Definition: SpringBarley.h:50
sb_GR
Definition: SpringBarley.h:62
SB_MANURE_DONE
#define SB_MANURE_DONE
Definition: SpringBarley.h:33
Farm::GrowthRegulator
virtual bool GrowthRegulator(LE *a_field, double a_user, int a_days)
Apply growth regulator to a_field.
Definition: farmfuncs.cpp:1250
sb_harvest
Definition: SpringBarley.h:70
sb_start
Definition: SpringBarley.h:47
sb_insecticide2
Definition: SpringBarley.h:65
Crop::ChooseNextCrop
void ChooseNextCrop(int a_no_dates)
Chooses the next crop to grow in a field.
Definition: farm.cpp:318
Crop::m_ev
FarmEvent * m_ev
Definition: farm.h:539
sb_spring_harrow
Definition: SpringBarley.h:52
Farm::Spraying_fungins
virtual bool Spraying_fungins(TTypesOfVegetation)
Definition: farm.h:785
cfg_pest_springbarley_on
CfgBool cfg_pest_springbarley_on
g_landscape_p
Landscape * g_landscape_p
Definition: Landscape.cpp:258
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:2209
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:471
SB_WATER_DATE
#define SB_WATER_DATE
Definition: SpringBarley.h:41