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

#include <winterrape.h>

Public Member Functions

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

Private Member Functions

void HerbiZero (void)
 
void RowcolOne (void)
 

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

◆ WinterRape()

WinterRape::WinterRape ( )
inline
92  {
93  m_first_date=g_date->DayInYear(24,8);
94  }

References Crop::m_first_date.

Member Function Documentation

◆ Do()

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

Reimplemented from Crop.

50 {
51  double ins_app_prop1 = cfg_ins_app_prop1.value();
52  double ins_app_prop2 = cfg_ins_app_prop2.value();
53  double ins_app_prop3 = cfg_ins_app_prop3.value();
54  double herbi_app_prop = cfg_herbi_app_prop.value();
55  m_farm = a_farm;
56  m_field = a_field;
57  m_ev = a_ev;
58  int noDates=3;
59  int d1=0;
60  // DEBUG double bio=0;
61 
62  bool done = false;
63 
64  switch ( m_ev->m_todo ) {
65  case wr_start:
66  {
67  WR_DID_RC_CLEAN=false;
68  WR_DID_HERBI_ZERO=false;
70  WR_SWARTH_DATE=-1;
71  WR_HARVEST_DATE=-1;
72  // Start single block date checking code to be cut-'n-pasted...
73  // Set up the date management stuff
74  m_last_date=g_date->DayInYear(15,10);
75  // Start and stop dates for all events after harvest
76  m_field->SetMDates(0,0,g_date->DayInYear(1,8));
77  // Determined by harvest date - used to see if at all possible
78  m_field->SetMDates(1,0,g_date->DayInYear(1,8));
79  m_field->SetMDates(0,1,g_date->DayInYear(25,7));
80  m_field->SetMDates(1,1,g_date->DayInYear(15,8));
81  m_field->SetMDates(0,2,g_date->DayInYear(1,8));
82  m_field->SetMDates(1,2,g_date->DayInYear(15,10));
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  if(!(m_farm->GetType() == tof_OptimisingFarm && g_date->GetYearNumber()>0)){
89 
90  if (m_ev->m_startday>g_date->DayInYear(1,7))
91  {
92  if (m_field->GetMDates(0,0) >=m_ev->m_startday)
93  {
94  g_msg->Warn( WARN_BUG, "WinterRape::Do(): "
95  "Harvest too late for the next crop to start!!!", "" );
96  exit( 1 );
97  }
98  // Now fix any late finishing problems
99  for (int i=0; i<noDates; i++) {
100  if(m_field->GetMDates(0,i)>=m_ev->m_startday) {
101  m_field->SetMDates(0,i,m_ev->m_startday-1); //move the starting date
102  }
103  if(m_field->GetMDates(1,i)>=m_ev->m_startday){
104  m_field->SetMConstants(i,0); //change the default value of the MConst (=1) to 0 (necessary to correctly execute farm events in case the finishing date (MDate) was moved)
105  m_field->SetMDates(1,i,m_ev->m_startday-1); //move the finishing date
106  }
107  }
108  }
109  // Now no operations can be timed after the start of the next crop.
110  // Start single block date checking code to be cut-'n-pasted...
111  if ( ! m_ev->m_first_year ) {
112  // Are we before July 1st?
113  d1 = g_date->OldDays() + g_date->DayInYear( 1,7 );
114  if (g_date->Date() < d1) {
115  // Yes, too early. We assumme this is because the last crop was late
116  g_msg->Warn( WARN_BUG, "WinterRape::Do(): "
117  "Crop start attempt between 1st Jan & 1st July", "" );
118  exit( 1 );
119  }
120  else
121  {
122  d1 = g_date->OldDays() + m_first_date; // Add 365 for spring crop
123  if (g_date->Date() > d1) {
124  // Yes too late - should not happen - raise an error
125  g_msg->Warn( WARN_BUG, "WinterRape::Do(): "
126  "Crop start attempt after last possible start date", "" );
127  exit( 1 );
128  }
129  }
130  }
131  else
132  {
133  // Is the first year so must start in spring like nothing was unusual
134  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 5,7 )
135  ,wr_swarth, false );
136  break;
137  }
138  }//if
139  // End single block date checking code. Please see next line
140  // comment as well.
141  // Reinit d1 to first possible starting date.
142  d1 = g_date->OldDays() + g_date->DayInYear( 21,8 );
143  if ( g_date->Date() > d1 ) {
144  d1 = g_date->Date();
145  }
146  // OK, let's go.
147  SimpleEvent( d1, wr_ferti_zero, false );
148  }
149 
150  #ifdef __EcoSol_02
151  // THIS CODE IS ONLY NEEDED IF WE ARE TESTING A PRODUCT WITH THE PESTICIDE ENGINE & WR
152  /* */
153  if ( g_landscape_p->SupplyShouldSpray() ) {
154  d1 = g_date->OldDays() + cfg_pest_productapplic_startdate.value();
155  if (g_date->Date() >= d1) d1 += 365;
156  SimpleEvent( d1, wr_productapplic_one, false );
157  }
158  /* */
159  #endif
160 
161  break;
162 
164  if ( m_ev->m_lock || m_farm->DoIt( 100 ))
165  {
167  // We didn't do it today, try again tomorrow.
168  SimpleEvent( g_date->Date() + 1, wr_productapplic_one, true );
169  break;
170  }
171  }
172  break;
173 
174 
175  // NB this is only stock farmers
176  case wr_ferti_zero:
177  if (( m_ev->m_lock || m_farm->DoIt( 10 ))&& (m_farm->IsStockFarmer()))
178  {
179  if (!m_farm->FA_Manure( m_field, 0.0,
180  g_date->DayInYear( 24, 8 ) - g_date->DayInYear())) {
181  // We didn't do it today, try again tomorrow.
182  SimpleEvent( g_date->Date() + 1, wr_ferti_zero, true );
183  break;
184  }
185  }
186  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 1, 8 ),
187  wr_autumn_plough, false );
188  break;
189  case wr_autumn_plough:
190  if ( m_ev->m_lock || m_farm->DoIt( 95 ))
191  {
192  if (!m_farm->AutumnPlough( m_field, 0.0,
193  g_date->DayInYear( 25, 8 ) - g_date->DayInYear())) {
194  SimpleEvent( g_date->Date() + 1, wr_autumn_plough, true );
195  break;
196  }
197  }
198  SimpleEvent( g_date->Date() + 1, wr_autumn_harrow, false );
199  break;
200  case wr_autumn_harrow:
201  if (!m_farm->AutumnHarrow( m_field, 0.0,
202  g_date->DayInYear( 25, 8 ) - g_date->DayInYear()))
203  {
204  SimpleEvent( g_date->Date() + 1, wr_autumn_harrow, false );
205  break;
206  }
207  {
208  long newdate1 = g_date->OldDays() + g_date->DayInYear( 10, 8 );
209  long newdate2 = g_date->Date();
210  if ( newdate2 > newdate1 ) newdate1 = newdate2;
211  SimpleEvent( newdate1, wr_autumn_sow, false );
212  }
213  break;
214  case wr_autumn_sow:
215  if (!m_farm->AutumnSow( m_field, 0.0,
216  g_date->DayInYear( 25, 8 ) - g_date->DayInYear())) {
217  SimpleEvent( g_date->Date() + 1, wr_autumn_sow, false );
218  break;
219  }
220  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 1, 9 ),
221  wr_rowcol_clean, false );
222  break;
223  case wr_rowcol_clean:
224  if ( m_ev->m_lock || m_farm->DoIt( 25 )) {
225  if (!m_farm->RowCultivation( m_field, 0.0,
226  g_date->DayInYear( 30, 9 ) - g_date->DayInYear()))
227  {
228  SimpleEvent( g_date->Date() + 1, wr_rowcol_clean, true );
229  break;
230  }
231  WR_DID_RC_CLEAN = true;
232  }
233  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 15, 9 ),
234  wr_herbi_zero, false );
235  break;
236 
237  case wr_herbi_zero:
238  HerbiZero();
239  break;
240 
241  case wr_ferti_p1:
242  if (!m_farm->FP_NPKS( m_field, 0.0,
243  g_date->DayInYear( 15, 4 ) - g_date->DayInYear())) {
244  SimpleEvent( g_date->Date() + 1, wr_ferti_p1, false );
245  break;
246  }
247  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 20, 4 ),
248  wr_ferti_p2, false );
249  break;
250 
251  case wr_ferti_p2:
252  if ( m_ev->m_lock || m_farm->DoIt( 20 )) {
253  if ( !m_farm->FP_NPKS( m_field, 0.0,
254  g_date->DayInYear( 1, 5 ) - g_date->DayInYear())) {
255  SimpleEvent( g_date->Date() + 1, wr_ferti_p2, true );
256  }
257  }
258  // Execution in this thread stops here. No new events are queued up.
259  break;
260 case wr_ferti_s1:
261  if (!m_farm->FP_NPKS( m_field, 0.0,
262  g_date->DayInYear( 30, 4 ) - g_date->DayInYear())) {
263  SimpleEvent( g_date->Date() + 1, wr_ferti_s1, false );
264  break;
265  }
266  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 1,4 ),
267  wr_ferti_p2, false );
268  break;
269 
270  case wr_ferti_s2:
271  if ( !m_farm->FP_Slurry( m_field, 0.0,
272  g_date->DayInYear( 30,4 ) - g_date->DayInYear())) {
273  SimpleEvent( g_date->Date() + 1, wr_ferti_s2, true );
274  }
275  // Execution in this thread stops here. No new events are queued up.
276  break;
277 
278  case wr_herbi_one:
279  if ( m_ev->m_lock || (m_farm->DoIt( (int)(45*herbi_app_prop * m_farm->Prob_multiplier()) ) && !WR_DID_HERBI_ZERO) ) { //modified probability
280  if ( !m_farm->HerbicideTreat( m_field, 0.0,
281  g_date->DayInYear( 5, 4 ) - g_date->DayInYear())) {
282  SimpleEvent( g_date->Date() + 1, wr_herbi_one, true );
283  }
284  }
285  // Execution in this thread stops here. No new events are queued up.
286  break;
287  case wr_insect_one:
288  if (m_ev->m_lock || m_farm->DoIt((int)(21 * ins_app_prop1 * m_farm->Prob_multiplier()))) //modified probability
289  {
290  //new - for decision making
291  TTypesOfVegetation tov = m_field->GetVegType();
292  if (!m_ev->m_lock && !m_farm->Spraying_fungins(tov)){
293  Field * pf = dynamic_cast<Field*>(m_field);
294  pf->Add_missed_fi_app();
295  if (m_farm->DoIt(30)) pf->Add_missed_fi_app(); //the 2nd missed application
296  if (m_farm->DoIt(12)) pf->Add_missed_fi_app(); //the 3rd missed application
297  break;
298  } //end of the part for dec. making
299 
300  // Here we check wheter we are using ERA pesticde or not
302  {
303  if (!m_farm->InsecticideTreat(m_field, 0.0,
304  g_date->DayInYear(cfg_OSR_InsecticideDay.value(), cfg_OSR_InsecticideMonth.value()) - g_date->DayInYear()))
305  {
306  SimpleEvent(g_date->Date() + 1, wr_insect_one, true);
307  break;
308  }
309  else
310  {
311  WR_INSECT_DATE = g_date->Date();
312  long newdate1 = g_date->OldDays() + g_date->DayInYear(1, 5);
313  long newdate2 = g_date->Date() + 7;
314  if (newdate2 > newdate1)
315  {
316  newdate1 = newdate2;
317  }
318  SimpleEvent(newdate1, wr_insect_one_b, false);
319  break;
320  }
321  }
322  else
323  {
325  WR_INSECT_DATE = g_date->Date();
326  SimpleEvent(g_date->Date()+14, wr_insect_one_b, false);
327  break;
328  }
329 
330  }
331  break; // End of thread if gets here
332 
333  case wr_insect_one_b:
334  if ( g_date->Date() == WR_FUNGI_DATE )
335  {
336  // try again tomorrow.
337  SimpleEvent( g_date->Date() + 1, wr_insect_one_b, false );
338  break;
339  }
340  if (m_ev->m_lock || m_farm->DoIt((int)(30 * ins_app_prop2 * m_farm->Prob_multiplier()))) { //modified probability
341  // Here we check wheter we are using ERA pesticde or not
343  {
344  if (!m_farm->InsecticideTreat(m_field, 0.0,
345  g_date->DayInYear(30, 5) - g_date->DayInYear())) {
346  SimpleEvent(g_date->Date() + 1, wr_insect_one_b, true);
347  break;
348  }
349  else
350  {
351  WR_INSECT_DATE = g_date->Date();
352  long newdate1 = g_date->OldDays() + g_date->DayInYear(20, 6);
353  long newdate2 = g_date->Date() + 7;
354  if (newdate2 > newdate1) newdate1 = newdate2;
355  SimpleEvent(newdate1, wr_insect_one_c, false);
356  break;
357  }
358  }
359  else
360  {
362  WR_INSECT_DATE = g_date->Date();
363  SimpleEvent(g_date->Date() + 14, wr_insect_one_c, false);
364  break;
365  }
366  }
367  break; // End of thread if gets to here
368 
369  case wr_insect_one_c:
370  if (m_ev->m_lock || m_farm->DoIt((int)(12 * ins_app_prop3 * m_farm->Prob_multiplier()))) //modified probability
371  {
372  // Here we check wheter we are using ERA pesticde or not
374  {
375  if (g_date->Date() == WR_FUNGI_DATE)
376  {
377  // try again tomorrow.
378  SimpleEvent(g_date->Date() + 1, wr_insect_one_c, false);
379  break;
380  }
381  if (!m_farm->InsecticideTreat(m_field, 0.0,
382  g_date->DayInYear(1, 7) - g_date->DayInYear())) {
383  SimpleEvent(g_date->Date() + 1, wr_insect_one_c, true);
384  }
385  WR_INSECT_DATE = g_date->Date();
386  }
387  else
388  {
390  WR_INSECT_DATE = g_date->Date();
391  break;
392  }
393  }
394  // END_OF_ThREAD
395  break;
396 
397  case wr_fungi_one:
398  if (m_farm->DoIt((int)(34*cfg_fungi_app_prop1.value() * m_farm->Prob_multiplier()) )) //modified probability
399  {
400  if ( g_date->Date() == WR_INSECT_DATE )
401  {
402  // try again tomorrow.
403  SimpleEvent( g_date->Date() + 1, wr_fungi_one, false );
404  break;
405  }
406  if ( m_ev->m_lock || m_farm->DoIt( 10 )) {
407 
408  //new - for decision making
409  TTypesOfVegetation tov = m_field->GetVegType();
410  if(!m_ev->m_lock && !m_farm->Spraying_fungins(tov)){
411  Field * pf = dynamic_cast<Field*>(m_field);
412  pf->Add_missed_fi_app();
413  break;
414  } //end of the part for dec. making
415 
416  if ( !m_farm->FungicideTreat( m_field, 0.0,
417  g_date->DayInYear( 1, 6 ) - g_date->DayInYear())) {
418  SimpleEvent( g_date->Date() + 1, wr_insect_one_c, true );
419  }
420  WR_FUNGI_DATE = g_date->Date();
421  }
422  // END_OF_ThREAD
423  }
424  break;
425 
426  case wr_rowcol_one:
427  RowcolOne();
428  break;
429 
430  case wr_rowcol_one_b:
431  if ( m_ev->m_lock || m_farm->DoIt( 20 ))
432  {
433  if ( !m_farm->RowCultivation( m_field, 0.0,
434  g_date->DayInYear( 1, 5 ) - g_date->DayInYear())) {
435  SimpleEvent( g_date->Date() + 1, wr_rowcol_one_b, true );
436  }
437  }
438  // END_OF_ThREAD
439  break;
440 
441  case wr_swarth:
442  if (m_ev->m_lock || m_farm->DoIt( 75 ))
443  {
444  if ( !m_farm->Swathing( m_field, 0.0,
445  g_date->DayInYear( 25, 7 ) - g_date->DayInYear())) {
446  SimpleEvent( g_date->Date() + 1, wr_swarth, true );
447  break;
448  }
449  else WR_SWARTH_DATE=g_date->DayInYear();
450  }
451  ChooseNextCrop (3);
452  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 10, 7 ),
453  wr_harvest, false );
454  break;
455 
456  case wr_harvest:
457  {
458  if (m_field->GetMConstants(1)==0) {
459  if (!m_farm->Harvest( m_field, 0.0, -1)) { //raise an error
460  g_msg->Warn( WARN_BUG, "WinterRape::Do(): failure in 'Harvest' execution", "" );
461  exit( 1 );
462  }
463  }
464  else {
465  long EndDate;
466  if (WR_SWARTH_DATE!=-1)
467  {
468  EndDate=WR_SWARTH_DATE+14;
469  if (EndDate>m_field->GetMDates(0,1)) EndDate=m_field->GetMDates(0,1);
470  }
471  else EndDate=g_date->DayInYear( 1, 8 );
472  if ( !m_farm->Harvest( m_field, 0.0,
473  EndDate - g_date->DayInYear()))
474  {
475  SimpleEvent( g_date->Date() + 1, wr_harvest, false );
476  break;
477  }
478  }
479  // Must have done harvest so record the fact for Debug
480 /* DEBUG
481  WR_HARVEST_DATE=g_date->DayInYear();
482  bio=m_field->GetVegBiomass();
483  if (bio>1000) {
484  int rubbish=0;
485  }
486 */
487  if ( m_farm->DoIt( 95 )) // was 95
488  {
489  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 10, 7 ),
490  wr_cuttostraw, false );
491  }
492  else SimpleEvent( g_date->OldDays() + g_date->DayInYear( 25, 7 ),
493  wr_compress, false);
494  break;
495  }
496 
497  case wr_cuttostraw:
498  if ( !m_farm->StrawChopping( m_field, 0.0,
499  g_date->DayInYear( 1, 8 ) - g_date->DayInYear())) {
500  SimpleEvent( g_date->Date() + 1, wr_cuttostraw, false );
501  break;
502  }
503  if (g_date->DayInYear()<g_date->DayInYear(15,7))
504  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 15, 7 ),
505  wr_stub_harrow, false );
506  else SimpleEvent( g_date->Date() + 1,wr_stub_harrow, false );
507  break;
508 
509  case wr_compress:
510  if ( !m_farm->HayBailing( m_field, 0.0,
511  g_date->DayInYear( 1, 8 ) - g_date->DayInYear())) {
512  SimpleEvent( g_date->Date() + 1, wr_compress, false );
513  break;
514  }
515  if (g_date->DayInYear()<g_date->DayInYear(15,7))
516  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 15, 7 ),
517  wr_stub_harrow, false );
518  else
519  SimpleEvent( g_date->Date(), wr_stub_harrow, false );
520  break;
521 
522  case wr_stub_harrow:
523  if ( m_ev->m_lock || m_farm->DoIt( 75 )) {
524  if (m_field->GetMConstants(1)==0) {
525  if (!m_farm->StubbleHarrowing( m_field, 0.0, -1)) { //raise an error
526  g_msg->Warn( WARN_BUG, "WinterRape::Do(): failure in 'StubbleHarrowing' execution", "" );
527  exit( 1 );
528  }
529  }
530  else {
531  if ( !m_farm->StubbleHarrowing( m_field, 0.0, m_field->GetMDates(1,1) - g_date->DayInYear())) {
532  SimpleEvent( g_date->Date() + 1, wr_stub_harrow, true );
533  break;
534  }
535  }
536  }
537  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 1, 8 ), wr_grubbing, false );
538  break;
539 
540  case wr_grubbing:
541  if ( m_ev->m_lock || m_farm->DoIt( 10 )) {
542  if (m_field->GetMConstants(2)==0) {
543  if (!m_farm->DeepPlough( m_field, 0.0, -1)) { //raise an error
544  g_msg->Warn( WARN_BUG, "WinterRape::Do(): failure in 'DeepPlough' execution", "" );
545  exit( 1 );
546  }
547  }
548  else {
549  if ( !m_farm->DeepPlough( m_field, 0.0, m_field->GetMDates(1,2) - g_date->DayInYear())) {
550  SimpleEvent( g_date->Date() + 1, wr_grubbing, true );
551  }
552  }
553  }
554  //
555  // End of execution tree for this management plan.
556  //
557 /*
558 if (WR_HARVEST_DATE==-1) {
559  int rubbish=0;
560  }
561  bio=m_field->GetVegBiomass();
562  if (bio>1000) {
563  int rubbish=0;
564  }
565 */
566 done = true;
567  break;
568 
569  default:
570  g_msg->Warn( WARN_BUG, "WinterRape::Do(): "
571  "Unknown event type! ", "" );
572  exit( 1 );
573  }
574  return done;
575 }

References Farm::AutumnHarrow(), Farm::AutumnPlough(), Farm::AutumnSow(), cfg_fungi_app_prop1, cfg_herbi_app_prop, cfg_ins_app_prop1, cfg_ins_app_prop2, cfg_ins_app_prop3, cfg_OSR_InsecticideDay, cfg_OSR_InsecticideMonth, cfg_pest_product_1_amount, cfg_pest_productapplic_period, cfg_pest_productapplic_startdate, cfg_pest_winterrape_on, Crop::ChooseNextCrop(), Farm::DeepPlough(), Farm::DoIt(), Farm::FA_Manure(), Farm::FP_NPKS(), Farm::FP_Slurry(), Farm::FungicideTreat(), g_landscape_p, Farm::GetType(), Farm::Harvest(), Farm::HayBailing(), Farm::HerbicideTreat(), HerbiZero(), 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(), Farm::ProductApplication_DateLimited(), RowcolOne(), Farm::RowCultivation(), Crop::SimpleEvent(), Farm::Spraying_fungins(), Farm::StrawChopping(), Farm::StubbleHarrowing(), Landscape::SupplyShouldSpray(), Farm::Swathing(), tof_OptimisingFarm, wr_autumn_harrow, wr_autumn_plough, wr_autumn_sow, wr_compress, wr_cuttostraw, WR_DID_HERBI_ZERO, WR_DID_RC_CLEAN, wr_ferti_p1, wr_ferti_p2, wr_ferti_s1, wr_ferti_s2, wr_ferti_zero, WR_FUNGI_DATE, wr_fungi_one, wr_grubbing, wr_harvest, WR_HARVEST_DATE, wr_herbi_one, wr_herbi_zero, WR_INSECT_DATE, wr_insect_one, wr_insect_one_b, wr_insect_one_c, wr_productapplic_one, wr_rowcol_clean, wr_rowcol_one, wr_rowcol_one_b, wr_start, wr_stub_harrow, wr_swarth, and WR_SWARTH_DATE.

◆ HerbiZero()

void WinterRape::HerbiZero ( void  )
private
606 {
607  double herbi_app_prop=cfg_herbi_app_prop.value();
608  if ( m_ev->m_lock || (m_farm->DoIt((int) (65*herbi_app_prop * m_farm->Prob_multiplier()) && !WR_DID_RC_CLEAN ))) //modified probability
609  {
610 
611  //new - for decision making
612  TTypesOfVegetation tov = m_field->GetVegType();
613  if(!m_ev->m_lock && !m_farm->Spraying_herbicides(tov)){
614  Field * pf = dynamic_cast<Field*>(m_field);
615  pf->Add_missed_herb_app();
616  if(m_farm->DoIt(45)) pf->Add_missed_herb_app(); //the 2nd missed application (herbi_one !)
617  //break; cant be break!
618  } //end of the part for dec. making
619  else{
620  WR_DID_HERBI_ZERO = true;
621  if (!m_farm->HerbicideTreat( m_field, 0.0,
622  g_date->DayInYear( 5, 10 ) - g_date->DayInYear())) {
623  // We didn't do it today, try again tomorrow.
624  SimpleEvent( g_date->Date() + 1, wr_herbi_zero, true );
625  return;
626  }
627  }
628  }
629  //
630  // Fork off 6 (six!) threads of execution for *next* year...
631  //
632  if (m_farm->IsStockFarmer())
633  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 1,3 )+365,
634  wr_ferti_s1, false );
635  else SimpleEvent( g_date->OldDays() + g_date->DayInYear( 1,4 )+365,
636  wr_ferti_p1, false );
637 
638  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 15,3 )+365,
639  wr_herbi_one, false );
640  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 15,4 )+365,
641  wr_insect_one, false );
642  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 20,5 )+365,
643  wr_fungi_one, false );
644  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 15,4 )+365,
645  wr_rowcol_one, false );
646 
647  // This is the main thread, that will lead to the end (eventually)...
648 SimpleEvent( g_date->OldDays() + g_date->DayInYear( 5,7 )+365,
649  wr_swarth, false );
650 }

References cfg_herbi_app_prop, Farm::DoIt(), Farm::HerbicideTreat(), Farm::IsStockFarmer(), Crop::m_ev, Crop::m_farm, Crop::m_field, FarmEvent::m_lock, Farm::Prob_multiplier(), Crop::SimpleEvent(), Farm::Spraying_herbicides(), WR_DID_HERBI_ZERO, WR_DID_RC_CLEAN, wr_ferti_p1, wr_ferti_s1, wr_fungi_one, wr_herbi_one, wr_herbi_zero, wr_insect_one, wr_rowcol_one, and wr_swarth.

Referenced by Do().

◆ RowcolOne()

void WinterRape::RowcolOne ( void  )
private
579 {
580  if ( g_date->Date() == WR_INSECT_DATE )
581  {
582  SimpleEvent( g_date->Date() + 1, wr_rowcol_one, m_ev->m_lock );
583  return;
584  }
585  if ( m_ev->m_lock || m_farm->DoIt( 25 )) {
586  if ( !m_farm->RowCultivation( m_field, 0.0,
587  g_date->DayInYear( 25, 4 ) - g_date->DayInYear())) {
588  SimpleEvent( g_date->Date() + 1, wr_rowcol_one, true );
589  return;
590  }
591  else
592  {
593  long newdate1 = g_date->OldDays() + g_date->DayInYear( 25, 4 );
594  long newdate2 = g_date->Date() + 5;
595  if ( newdate2 > newdate1 )
596  newdate1 = newdate2;
597  SimpleEvent( newdate1, wr_rowcol_one_b, false );
598  return;
599  }
600  }
601  return; // End of thread
602 }

References Farm::DoIt(), Crop::m_ev, Crop::m_farm, Crop::m_field, FarmEvent::m_lock, Farm::RowCultivation(), Crop::SimpleEvent(), WR_INSECT_DATE, wr_rowcol_one, and wr_rowcol_one_b.

Referenced by Do().


The documentation for this class was generated from the following files:
wr_swarth
Definition: winterrape.h:71
wr_ferti_p1
Definition: winterrape.h:60
wr_productapplic_one
Definition: winterrape.h:77
cfg_OSR_InsecticideDay
CfgInt cfg_OSR_InsecticideDay
cfg_ins_app_prop1
CfgFloat cfg_ins_app_prop1
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
wr_ferti_s2
Definition: winterrape.h:63
g_landscape_p
Landscape * g_landscape_p
Definition: Landscape.cpp:258
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
WR_DID_HERBI_ZERO
#define WR_DID_HERBI_ZERO
Definition: winterrape.h:46
Farm::ProductApplication
virtual bool ProductApplication(LE *a_field, double a_user, int a_days, double a_applicationrate, PlantProtectionProducts a_ppp)
Apply test pesticide to a_field.
Definition: farmfuncs.cpp:1445
Landscape::SupplyShouldSpray
bool SupplyShouldSpray()
Definition: Landscape.h:357
wr_ferti_s1
Definition: winterrape.h:62
Farm::DoIt
bool DoIt(double a_probability)
Return chance out of 0 to 100.
Definition: farm.cpp:800
cfg_pest_winterrape_on
CfgBool cfg_pest_winterrape_on
wr_insect_one_c
Definition: winterrape.h:70
FarmEvent::m_first_year
bool m_first_year
Definition: farm.h:467
WinterRape::RowcolOne
void RowcolOne(void)
Definition: winterrape.cpp:578
tof_OptimisingFarm
Definition: farm.h:273
wr_start
Definition: winterrape.h:53
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
cfg_fungi_app_prop1
CfgFloat cfg_fungi_app_prop1
cfg_pest_productapplic_startdate
CfgInt cfg_pest_productapplic_startdate
wr_herbi_zero
Definition: winterrape.h:59
cfg_pest_product_1_amount
CfgFloat cfg_pest_product_1_amount
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
Crop::m_first_date
int m_first_date
Definition: farm.h:540
FarmEvent::m_startday
int m_startday
Definition: farm.h:466
Farm::FungicideTreat
virtual bool FungicideTreat(LE *a_field, double a_user, int a_days)
Apply fungicide to a_field.
Definition: farmfuncs.cpp:1279
wr_rowcol_clean
Definition: winterrape.h:58
Crop::SimpleEvent
void SimpleEvent(long a_date, int a_todo, bool a_lock)
Adds an event to this crop management.
Definition: farm.cpp:307
wr_cuttostraw
Definition: winterrape.h:73
WinterRape::HerbiZero
void HerbiZero(void)
Definition: winterrape.cpp:605
wr_grubbing
Definition: winterrape.h:76
Farm::Prob_multiplier
virtual double Prob_multiplier()
Definition: farm.h:786
Farm::AutumnSow
virtual bool AutumnSow(LE *a_field, double a_user, int a_days)
Carry out a sowing event in the autumn on a_field.
Definition: farmfuncs.cpp:364
TTypesOfVegetation
TTypesOfVegetation
Definition: tov_declaration.h:30
wr_insect_one
Definition: winterrape.h:68
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
wr_autumn_plough
Definition: winterrape.h:55
cfg_herbi_app_prop
CfgFloat cfg_herbi_app_prop
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
cfg_ins_app_prop3
CfgFloat cfg_ins_app_prop3
WR_FUNGI_DATE
#define WR_FUNGI_DATE
Definition: winterrape.h:48
cfg_OSR_InsecticideMonth
CfgInt cfg_OSR_InsecticideMonth
wr_rowcol_one_b
Definition: winterrape.h:67
wr_ferti_p2
Definition: winterrape.h:61
wr_fungi_one
Definition: winterrape.h:65
Crop::m_farm
Farm * m_farm
Definition: farm.h:537
Crop::m_field
LE * m_field
Definition: farm.h:538
cfg_pest_productapplic_period
CfgInt cfg_pest_productapplic_period
FarmEvent::m_todo
int m_todo
Definition: farm.h:469
wr_rowcol_one
Definition: winterrape.h:66
Farm::InsecticideTreat
virtual bool InsecticideTreat(LE *a_field, double a_user, int a_days)
Apply insecticide to a_field.
Definition: farmfuncs.cpp:1348
Farm::FP_Slurry
virtual bool FP_Slurry(LE *a_field, double a_user, int a_days)
Apply slurry to a_field owned by an arable farmer.
Definition: farmfuncs.cpp:701
WR_DID_RC_CLEAN
#define WR_DID_RC_CLEAN
Definition: winterrape.h:45
ppp_1
Definition: farm.h:422
Farm::RowCultivation
virtual bool RowCultivation(LE *a_field, double a_user, int a_days)
Carry out a harrowing between crop rows on a_field.
Definition: farmfuncs.cpp:1510
cfg_ins_app_prop2
CfgFloat cfg_ins_app_prop2
Crop::m_last_date
int m_last_date
Definition: farm.h:542
wr_harvest
Definition: winterrape.h:72
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
wr_autumn_harrow
Definition: winterrape.h:56
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:261
WR_SWARTH_DATE
#define WR_SWARTH_DATE
Definition: winterrape.h:49
wr_compress
Definition: winterrape.h:74
wr_herbi_one
Definition: winterrape.h:64
Farm::DeepPlough
virtual bool DeepPlough(LE *a_field, double a_user, int a_days)
Carry out a deep ploughing event on a_field.
Definition: farmfuncs.cpp:417
WR_INSECT_DATE
#define WR_INSECT_DATE
Definition: winterrape.h:47
wr_stub_harrow
Definition: winterrape.h:75
wr_autumn_sow
Definition: winterrape.h:57
Farm::Swathing
virtual bool Swathing(LE *a_field, double a_user, int a_days)
Cut the crop on a_field and leave it lying (probably rape)
Definition: farmfuncs.cpp:1744
wr_insect_one_b
Definition: winterrape.h:69
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
wr_ferti_zero
Definition: winterrape.h:54
WR_HARVEST_DATE
#define WR_HARVEST_DATE
Definition: winterrape.h:50
Farm::Spraying_fungins
virtual bool Spraying_fungins(TTypesOfVegetation)
Definition: farm.h:785
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::FP_NPKS
virtual bool FP_NPKS(LE *a_field, double a_user, int a_days)
Apply NPKS fertilizer, on a_field owned by an arable farmer.
Definition: farmfuncs.cpp:602