ALMaSS Hare ODDox  1.1
The hare model description following ODdox protocol
WinterWheatStrigling.cpp
Go to the documentation of this file.
1 //
2 // winterwheatStrigling.cpp
3 //
4 /*
5 *******************************************************************************************************
6 Copyright (c) 2011, Christopher John Topping, Aarhus University
7 All rights reserved.
8 
9 Redistribution and use in source and binary forms, with or without modification, are permitted provided
10 that the following conditions are met:
11 
12 Redistributions of source code must retain the above copyright notice, this list of conditions and the
13 following disclaimer.
14 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
15 the following disclaimer in the documentation and/or other materials provided with the distribution.
16 
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
18 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
19 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
20 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
22 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 ********************************************************************************************************
26 */
27 
28 #include "../../Landscape/ls.h"
29 #include "../../Landscape/cropprogs/WinterWheatStrigling.h"
30 
31 
32 extern CfgFloat cfg_ins_app_prop1;
33 extern CfgFloat cfg_herbi_app_prop;
34 extern CfgFloat cfg_fungi_app_prop1;
35 extern CfgFloat cfg_greg_app_prop;
36 extern CfgFloat cfg_strigling_prop;
37 
38 bool WinterWheatStrigling::Do( Farm *a_farm, LE *a_field, FarmEvent *a_ev )
39 {
40  m_farm = a_farm;
41  m_field = a_field;
42  m_ev = a_ev;
43 
44  bool done = false;
45 
46  switch ( m_ev->m_todo )
47  {
48  case wws_start:
49  {
52 
53  // Set up the date management stuff
54 
55  // Could save the start day in case it is needed later
56  // m_field->m_startday = m_ev->m_startday;
57 
58  // Start and stop dates for all events after harvest
59  int noDates=5;
60  m_field->SetMDates(0,0,g_date->DayInYear(20,8));
61 
62  // Determined by harvest date - used to see if at all possible
63  m_field->SetMDates(1,0,g_date->DayInYear(20,8));
64  m_field->SetMDates(0,1,0); // Subbleharrow start
65  m_field->SetMDates(1,1,g_date->DayInYear(20,8));
66  m_field->SetMDates(0,2,g_date->DayInYear(5,8));
67  m_field->SetMDates(1,2,g_date->DayInYear(25,8));
68  m_field->SetMDates(0,3,g_date->DayInYear(10,8));
69  m_field->SetMDates(1,3,g_date->DayInYear(15,9));
70  m_field->SetMDates(0,4,g_date->DayInYear(15,8));
71  m_field->SetMDates(1,4,g_date->DayInYear(15,10));
72  // Can be up to 10 of these. If the shortening code is triggered
73  // then these will be reduced in value to 0
74  m_field->SetMConstants(0,1);
75 
76  // Check the next crop for early start, unless it is a spring crop
77  // in which case we ASSUME that no checking is necessary!!!!
78  // So DO NOT implement a crop that runs over the year boundary
79  if (m_ev->m_startday>g_date->DayInYear(1,7))
80  {
81  if (m_field->GetMDates(0,0) >=m_ev->m_startday)
82  {
83  g_msg->Warn( WARN_BUG, "WinterWheat::Do(): "
84  "Harvest too late for the next crop to start!!!", "" );
85  exit( 1 );
86  }
87  // Now fix any late finishing problems
88  bool toggle=false;
89  for (int i=0; i<noDates; i++) {
90  if (m_field->GetMDates(0,i)>=m_ev->m_startday) {
91  toggle=true;
92  m_field->SetMDates(0,i,m_ev->m_startday-1);
93  }
94  if (m_field->GetMDates(1,i)>=m_ev->m_startday){
95  toggle=true;
96  m_field->SetMDates(1,i,m_ev->m_startday-1);
97  }
98  }
99  if (toggle) for (int i=0; i<10; i++) m_field->SetMConstants(i,0);
100  }
101  // Now no operations can be timed after the start of the next crop.
102 
103  // CJT note:
104  // Start single block date checking code to be cut-'n-pasted...
105  int d1;
106  if ( ! m_ev->m_first_year ) {
107 
108  // Are we before July 1st?
109  d1 = g_date->OldDays() + g_date->DayInYear( 1,7 );
110  if (g_date->Date() < d1 ) {
111  // Yes, too early. We assumme this is because the last crop was late
112  printf ("Poly: %d\n", m_field->GetPoly());
113  g_msg->Warn( WARN_BUG, "WinterWheatStrigling::Do(): "
114  "Crop start attempt between 1st Jan & 1st July", "" );
115  exit( 1 );
116  }
117  else
118  {
119  d1 = g_date->OldDays() + m_first_date; // Add 365 for spring crop
120  if (g_date->Date() > d1)
121  {
122  // Yes too late - should not happen - raise an error
123  g_msg->Warn( WARN_BUG, "WinterWheatStrigling::Do(): "
124  "Crop start attempt after last possible start date", "" );
125  exit( 1 );
126  }
127  }
128  }
129  else
130  {
131  // Is the first year
132  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 1,4 ),
133  wws_spring_roll, false );
134  break;
135  }
136  // End single block date checking code. Please see next line
137  // comment as well.
138  // Reinit d1 to first possible starting date.
139  d1 = g_date->OldDays() + g_date->DayInYear( 21,8 );
140  // OK, let's go.
141  if (m_farm->IsStockFarmer()) // StockFarmer
142  {
143  SimpleEvent( d1, wws_ferti_s1, false );
144  }
145  else SimpleEvent( d1, wws_ferti_p1, false );
146  }
147  break;
148 
149  case wws_ferti_p1:
150  if ( m_ev->m_lock || m_farm->DoIt( 10 ))
151  {
152  if (!m_farm->FP_Slurry( m_field, 0.0,
153  g_date->DayInYear( 1,10 ) - g_date->DayInYear())) {
154  SimpleEvent( g_date->Date() + 1, wws_ferti_p1, true );
155  break;
156  }
157  }
158  SimpleEvent( g_date->Date(),wws_autumn_plough, false );
159  break;
160 
161  case wws_ferti_s1:
162  if (!m_farm->FA_Slurry( m_field, 0.0,
163  g_date->DayInYear( 1,10 ) - g_date->DayInYear())) {
164  SimpleEvent( g_date->Date() + 1, wws_ferti_s1, true );
165  break;
166  }
167  // This may cause two applications of fertilizer in one day...
168  // --FN--
169  SimpleEvent( g_date->Date(),wws_ferti_s2, false );
170  // --FN--
171  break;
172 
173  case wws_ferti_s2:
174  if ( m_ev->m_lock || m_farm->DoIt( 10 ))
175  {
176  if (!m_farm->FA_Manure( m_field, 0.0,
177  g_date->DayInYear( 1,10 ) - g_date->DayInYear())) {
178  SimpleEvent( g_date->Date() + 1, wws_ferti_s2, true );
179  break;
180  }
181  }
182  SimpleEvent( g_date->Date(),wws_autumn_plough, false );
183  break;
184 
185  case wws_autumn_plough:
186  if ( m_ev->m_lock || m_farm->DoIt( 95 ))
187  {
188  if (!m_farm->AutumnPlough( m_field, 0.0,
189  g_date->DayInYear( 1,10 ) - g_date->DayInYear())) {
190  SimpleEvent( g_date->Date() + 1, wws_autumn_plough, true );
191  break;
192  }
193  else
194  {
196  SimpleEvent( g_date->Date()+1,wws_autumn_harrow, false );
197  break;
198  }
199  }
200  SimpleEvent( g_date->Date()+1,wws_stubble_harrow1, false );
201  break;
202 
203  case wws_autumn_harrow:
204  if (!m_farm->AutumnHarrow( m_field, 0.0,
205  g_date->DayInYear( 10,10 ) - g_date->DayInYear())) {
206  SimpleEvent( g_date->Date() + 1, wws_autumn_harrow, true );
207  break;
208  }
209  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 10,9 ),
210  wws_autumn_sow, false );
211  break;
212 
213  case wws_stubble_harrow1:
214  if (!m_farm->StubbleHarrowing( m_field, 0.0,
215  g_date->DayInYear( 10,10 ) - g_date->DayInYear())) {
216  SimpleEvent( g_date->Date() + 1, wws_stubble_harrow1, true );
217  break;
218  }
219  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 10,9 ),
220  wws_autumn_sow, false );
221  break;
222 
223  case wws_autumn_sow:
224  if (!m_farm->AutumnSow( m_field, 0.0,
225  g_date->DayInYear( 20,10 ) - g_date->DayInYear())) {
226  SimpleEvent( g_date->Date() + 1, wws_autumn_sow, true );
227  break;
228  }
229  // --FN-- Oooo!
230  //SimpleEvent( g_date->OldDays() + g_date->Date( ),
231  // wws_autumn_roll, false );
232  SimpleEvent( g_date->Date() + 1, wws_autumn_roll, false );
233  break;
234 
235  case wws_autumn_roll:
236  if (( m_ev->m_lock || m_farm->DoIt( 5 ))&& (WWStrigling_AUTUMN_PLOUGH))
237  {
238  if (!m_farm->AutumnRoll( m_field, 0.0,
239  g_date->DayInYear( 27,10 ) - g_date->DayInYear())) {
240  SimpleEvent( g_date->Date() + 1, wws_autumn_roll, true );
241  break;
242  }
243  }
244  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 15,9 ),
245  wws_ferti_p2, false );
246  break;
247 
248  case wws_ferti_p2:
249  if (( m_ev->m_lock || m_farm->DoIt( 20 )) && (!m_farm->IsStockFarmer()))
250  {
251  if ( m_field->GetVegBiomass()>0)
252  //only when there has been a bit of growth
253  {
254  if (!m_farm->FP_ManganeseSulphate( m_field, 0.0,
255  g_date->DayInYear( 30,10 ) - g_date->DayInYear()))
256  {
257  SimpleEvent( g_date->Date() + 1, wws_ferti_p2, true );
258  break;
259  }
260  }
261  }
262  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 20,9 ),
263  wws_strigling0a, false );
264  break;
265 
266  case wws_strigling0a:
267  if ( m_ev->m_lock || m_farm->DoIt( (int) ( 100*cfg_strigling_prop.value() )))
268  {
269  if (!m_farm->Strigling( m_field, 0.0,
270  g_date->DayInYear( 5,10 ) - g_date->DayInYear())) {
271  SimpleEvent( g_date->Date() + 1, wws_strigling0a, true );
272  break;
273  }
274  }
275  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 1,4 )+365,
276  wws_spring_roll, false );
277  break;
278 
279  case wws_spring_roll:
280  if ( m_ev->m_lock || m_farm->DoIt( 5 ))
281  {
282  if (!m_farm->SpringRoll( m_field, 0.0,
283  g_date->DayInYear( 30,4 ) - g_date->DayInYear())) {
284  SimpleEvent( g_date->Date() + 1, wws_spring_roll, true );
285  break;
286  }
287  }
288  if (m_farm->IsStockFarmer()) // StockFarmer
289  {
290  SimpleEvent( g_date->Date() + 1, wws_ferti_s3, false );
291  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 10,4 ),
292  wws_ferti_s4, false );
293  }
294  else
295  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 25,3 ),
296  wws_ferti_p3, false );
297  // All need the next threads
298  SimpleEvent( g_date->OldDays() + g_date->DayInYear( )+10,
299  wws_strigling0b, false );
300  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 25,4 ),
301  wws_GR, false );
302  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 20,4 ),
303  wws_fungicide, false );
304  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 1,5 ),
305  wws_insecticide1, false );
306  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 10,4 ),
307  wws_strigling1, false );
308  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 1,5 ),
309  wws_water1, false );
310  break;
311 
312  case wws_strigling0b:
313  if ( m_ev->m_lock || m_farm->DoIt( (int) ( (int) ( 100*cfg_strigling_prop.value() ))))
314  {
315  if (!m_farm->Strigling( m_field, 0.0,
316  g_date->DayInYear( 30,4 ) - g_date->DayInYear())) {
317  SimpleEvent( g_date->Date() + 1, wws_strigling0a, true );
318  break;
319  }
320  }
321  // End of thread
322  break;
323 
324  case wws_GR:
325  if ( m_ev->m_lock || m_farm->DoIt( (int) ( 15*cfg_greg_app_prop.value() )))
326  {
327  // --FN--
328  if (!m_farm->GrowthRegulator( m_field, 0.0,
329  g_date->DayInYear( 10,5 ) - g_date->DayInYear())) {
330  SimpleEvent( g_date->Date() + 1, wws_GR, true );
331  break;
332  }
333  }
334  // End of thread
335  break;
336 
337  case wws_fungicide:
338  if ( m_ev->m_lock || m_farm->DoIt( (int) ( 70*cfg_fungi_app_prop1.value() )))
339  {
340  if (!m_farm->FungicideTreat( m_field, 0.0,
341  g_date->DayInYear( 10,5 ) - g_date->DayInYear())) {
342  SimpleEvent( g_date->Date() + 1, wws_fungicide, true );
343  break;
344  }
345  }
346  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 20,5 ),
347  wws_fungicide2, false );
348  break;
349 
350  case wws_fungicide2:
351  if ( m_ev->m_lock || m_farm->DoIt( (int) ( 50*cfg_fungi_app_prop1.value() )))
352  {
353  if (!m_farm->FungicideTreat( m_field, 0.0,
354  g_date->DayInYear( 15,5 ) - g_date->DayInYear())) {
355  SimpleEvent( g_date->Date() + 1, wws_fungicide2, true );
356  break;
357  }
358  }
359  // End of thread
360  break;
361 
362  case wws_insecticide1:
363  if ( m_ev->m_lock || m_farm->DoIt( (int) ( 16*cfg_ins_app_prop1.value() )))
364  {
365  if (!m_farm->InsecticideTreat( m_field, 0.0,
366  g_date->DayInYear( 15,5 ) - g_date->DayInYear()))
367  {
368  SimpleEvent( g_date->Date() + 1, wws_insecticide1, true );
369  break;
370  }
371  else
372  {
373  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 1,6 ),
374  wws_insecticide2, false );
375  break;
376  }
377  }
378  break;
379 
380  case wws_insecticide2:
381  if ( m_ev->m_lock || m_farm->DoIt( (int) ( 33*cfg_ins_app_prop1.value() )))
382  {
383  if (!m_farm->InsecticideTreat( m_field, 0.0,
384  g_date->DayInYear( 10,6 ) - g_date->DayInYear())) {
385  SimpleEvent( g_date->Date() + 1, wws_insecticide2, true );
386  break;
387  }
388  else
389  {
390  if ((g_date->Date()+7)<( g_date->OldDays() + g_date->DayInYear( 15,6 )))
391  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 15,6 ),
392  wws_insecticide3, false );
393  else
394  SimpleEvent( g_date->Date()+7, wws_insecticide3, false );
395  break;
396  }
397  }
398  break;
399 
400  case wws_insecticide3:
401  if ( m_ev->m_lock || m_farm->DoIt( (int) ( 67*cfg_ins_app_prop1.value() )))
402  {
403  if (!m_farm->InsecticideTreat( m_field, 0.0,
404  g_date->DayInYear( 30,6 ) - g_date->DayInYear())) {
405  SimpleEvent( g_date->Date() + 1, wws_insecticide3, true );
406  break;
407  }
408  }
409  // End of thread
410  break;
411 
412  case wws_strigling1:
413  if ( m_ev->m_lock || m_farm->DoIt( 5 ))
414  {
415  if (!m_farm->Strigling( m_field, 0.0,
416  g_date->DayInYear( 25,4 ) - g_date->DayInYear())) {
417  SimpleEvent( g_date->Date() + 1, wws_strigling1, true );
418  break;
419  }
420  else
421  {
422  if ((g_date->Date()+7)<( g_date->OldDays() + g_date->DayInYear( 15,6 )))
423  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 25,4),
424  wws_strigling2, false );
425  else
426  SimpleEvent( g_date->Date()+7,wws_strigling2, false );
427  }
428  }
429  break;
430 
431  case wws_strigling2:
432  if (!m_farm->Strigling( m_field, 0.0,
433  g_date->DayInYear( 5,5 ) - g_date->DayInYear())) {
434  SimpleEvent( g_date->Date() + 1, wws_strigling2, true );
435  break;
436  }
437  // End of thread
438  break;
439 
440  case wws_water1:
441  if ( m_ev->m_lock || m_farm->DoIt( 10 )) // **CJT** Soil type 1-4 only
442  {
443  if (!m_farm->Water( m_field, 0.0,
444  g_date->DayInYear( 15,5 ) - g_date->DayInYear())) {
445  SimpleEvent( g_date->Date() + 1, wws_water1, true );
446  break;
447  }
448  else
449  if ((g_date->Date()+5)<( g_date->OldDays() + g_date->DayInYear( 2,5 )))
450  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 2,5 ),
451  wws_water2, false );
452  else
453  SimpleEvent( g_date->Date()+5, wws_water2, false );
454  }
455  break;
456 
457  case wws_water2:
458  if (!m_farm->Water( m_field, 0.0,
459  g_date->DayInYear( 1,6 ) - g_date->DayInYear())) {
460  SimpleEvent( g_date->Date() + 1, wws_water2, true );
461  break;
462  }
463  // End of thread
464  break;
465 
466  case wws_ferti_p3:
467  if (!m_farm->FP_NPK( m_field, 0.0,
468  g_date->DayInYear( 15,4 ) - g_date->DayInYear())) {
469  SimpleEvent( g_date->Date() + 1, wws_ferti_p3, true );
470  break;
471  }
472 
473  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 25,4 ),
474  wws_ferti_p4, false );
475  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 1,4 ),
476  wws_ferti_p5, false );
477  break;
478 
479  case wws_ferti_p4:
480  if ( m_ev->m_lock || m_farm->DoIt( 50 ))
481  {
482  if (!m_farm->FP_NPK( m_field, 0.0,
483  g_date->DayInYear( 15,5 ) - g_date->DayInYear())) {
484  SimpleEvent( g_date->Date() + 1, wws_ferti_p4, true );
485  break;
486  }
487  }
488 
489  // The Main thread
490  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 5,8 ),
491  wws_harvest, false );
492  break;
493 
494  case wws_ferti_p5:
495  if ( m_ev->m_lock || m_farm->DoIt( 20 ))
496  {
497  if (!m_farm->FP_ManganeseSulphate( m_field, 0.0,
498  g_date->DayInYear( 5,5 ) - g_date->DayInYear())) {
499  SimpleEvent( g_date->Date() + 1, wws_ferti_p5, true );
500  break;
501  }
502  }
503  break;
504 
505  case wws_ferti_s3:
506  if (!m_farm->FA_Slurry(m_field, 0.0,
507  g_date->DayInYear( 30,4 ) - g_date->DayInYear())) {
508  SimpleEvent( g_date->Date() + 1, wws_ferti_s3, true );
509  break;
510  }
511  // The Main thread
512  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 5,8 ),
513  wws_harvest, false );
514  break;
515 
516  case wws_ferti_s4:
517  if ( m_ev->m_lock || m_farm->DoIt( 75 ))
518  {
519  if (!m_farm->FA_NPK( m_field, 0.0,
520  g_date->DayInYear( 20,4 ) - g_date->DayInYear())) {
521  SimpleEvent( g_date->Date() + 1, wws_ferti_s4, true );
522  break;
523  }
524  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 21,4 ),
525  wws_ferti_s5, false );
526  }
527  break;
528 
529  case wws_ferti_s5:
530  if ( m_ev->m_lock || m_farm->DoIt( 40 ))
531  {
532  if (!m_farm->FA_NPK( m_field, 0.0,
533  g_date->DayInYear( 1,5 ) - g_date->DayInYear())) {
534  SimpleEvent( g_date->Date() + 1, wws_ferti_s5, true );
535  break;
536  }
537  }
538  break;
539 
540  case wws_harvest:
541  if (!m_farm->Harvest( m_field, 0.0,
542  g_date->DayInYear( 20,8 ) - g_date->DayInYear()))
543  {
544  SimpleEvent( g_date->Date() + 1, wws_harvest, true );
545  break;
546  }
547  SimpleEvent( g_date->Date(), wws_straw_chopping, false );
548  break;
549 
550  case wws_straw_chopping:
551  if ( m_ev->m_lock || m_farm->DoIt( 75 ))
552  {
553  if (!m_farm->StrawChopping( m_field, 0.0,
554  m_field->GetMDates(1,0) - g_date->DayInYear())) {
555  SimpleEvent( g_date->Date() + 1, wws_straw_chopping, true );
556  break;
557  }
558  else
559  {
560  SimpleEvent( g_date->Date()+m_field->GetMConstants(0), wws_stubble_harrow2, false );
561  }
562  }
563  else
564  {
565  SimpleEvent( g_date->Date()+m_field->GetMConstants(0), wws_hay_turning, false );
566  }
567  break;
568 
569  case wws_hay_turning:
570  if ( m_ev->m_lock || m_farm->DoIt( 5 ))
571  {
572  if (!m_farm->HayTurning( m_field, 0.0,
573  m_field->GetMDates(1,1) - g_date->DayInYear())) {
574  SimpleEvent( g_date->Date() + 1, wws_hay_turning, true );
575  break;
576  }
577  }
578  SimpleEvent( g_date->OldDays() + m_field->GetMDates(0,2),
579  wws_hay_baling, false );
580  break;
581 
582  case wws_hay_baling:
583  if (!m_farm->HayBailing( m_field, 0.0,
584  m_field->GetMDates(1,2) - g_date->DayInYear())) {
585  SimpleEvent( g_date->Date() + 1, wws_hay_baling, true );
586  break;
587  }
588  SimpleEvent( g_date->OldDays() + m_field->GetMDates(0,3),
589  wws_stubble_harrow2, false );
590  break;
591 
592  case wws_stubble_harrow2:
593  if ( m_ev->m_lock || m_farm->DoIt( 65 ))
594  {
595  if (!m_farm->StubbleHarrowing( m_field, 0.0,
596  m_field->GetMDates(1,3) - g_date->DayInYear())) {
597  SimpleEvent( g_date->Date() + 1, wws_stubble_harrow2, true );
598  break;
599  }
600  }
601  SimpleEvent( g_date->OldDays() + m_field->GetMDates(0,4),
602  wws_grubning, false );
603  break;
604 
605  case wws_grubning:
606  if ( m_ev->m_lock || m_farm->DoIt( 10 ))
607  {
608  if (!m_farm->DeepPlough( m_field, 0.0,
609  m_field->GetMDates(1,4) - g_date->DayInYear())) {
610  SimpleEvent( g_date->Date() + 1, wws_grubning, true );
611  break;
612  }
613  }
614  done=true;
615  // END OF MAIN THREAD
616  break;
617 
618  default:
619  g_msg->Warn( WARN_BUG, "WinterWheat::Do(): "
620  "Unknown event type! ", "" );
621  exit( 1 );
622  }
623  return done;
624 }
625 
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
wws_straw_chopping
Definition: WinterWheatStrigling.h:76
wws_strigling0a
Definition: WinterWheatStrigling.h:56
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
wws_ferti_p1
Definition: WinterWheatStrigling.h:47
wws_strigling1
Definition: WinterWheatStrigling.h:65
Farm::IsStockFarmer
bool IsStockFarmer(void)
Definition: farm.h:905
Farm::Strigling
virtual bool Strigling(LE *a_field, double a_user, int a_days)
Carry out a mechanical weeding on a_field.
Definition: farmfuncs.cpp:1545
wws_stubble_harrow1
Definition: WinterWheatStrigling.h:52
wws_grubning
Definition: WinterWheatStrigling.h:80
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
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:727
FarmEvent
A struct to hold the information required to trigger a farm event.
Definition: farm.h:463
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
wws_strigling2
Definition: WinterWheatStrigling.h:66
wws_start
Definition: WinterWheatStrigling.h:45
FarmEvent::m_first_year
bool m_first_year
Definition: farm.h:467
WWStrigling_AUTUMN_PLOUGH
#define WWStrigling_AUTUMN_PLOUGH
Definition: WinterWheatStrigling.h:42
wws_ferti_s5
Definition: WinterWheatStrigling.h:74
wws_ferti_p4
Definition: WinterWheatStrigling.h:70
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
wws_autumn_roll
Definition: WinterWheatStrigling.h:54
WinterWheatStrigling::Do
virtual bool Do(Farm *a_farm, LE *a_field, FarmEvent *a_ev)
Definition: WinterWheatStrigling.cpp:38
wws_ferti_p5
Definition: WinterWheatStrigling.h:71
wws_harvest
Definition: WinterWheatStrigling.h:75
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
wws_strigling0b
Definition: WinterWheatStrigling.h:58
Farm::FungicideTreat
virtual bool FungicideTreat(LE *a_field, double a_user, int a_days)
Apply fungicide to a_field.
Definition: farmfuncs.cpp:1279
wws_GR
Definition: WinterWheatStrigling.h:59
wws_autumn_plough
Definition: WinterWheatStrigling.h:50
Crop::SimpleEvent
void SimpleEvent(long a_date, int a_todo, bool a_lock)
Adds an event to this crop management.
Definition: farm.cpp:307
wws_water2
Definition: WinterWheatStrigling.h:68
cfg_fungi_app_prop1
CfgFloat cfg_fungi_app_prop1
wws_insecticide3
Definition: WinterWheatStrigling.h:64
wws_insecticide2
Definition: WinterWheatStrigling.h:63
wws_fungicide2
Definition: WinterWheatStrigling.h:61
cfg_ins_app_prop1
CfgFloat cfg_ins_app_prop1
wws_ferti_s1
Definition: WinterWheatStrigling.h:48
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
wws_autumn_harrow
Definition: WinterWheatStrigling.h:51
cfg_greg_app_prop
CfgFloat cfg_greg_app_prop
wws_hay_baling
Definition: WinterWheatStrigling.h:78
wws_ferti_s4
Definition: WinterWheatStrigling.h:73
wws_hay_turning
Definition: WinterWheatStrigling.h:77
wws_fungicide
Definition: WinterWheatStrigling.h:60
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
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
wws_stubble_harrow2
Definition: WinterWheatStrigling.h:79
wws_ferti_s3
Definition: WinterWheatStrigling.h:72
wws_spring_roll
Definition: WinterWheatStrigling.h:57
Crop::m_farm
Farm * m_farm
Definition: farm.h:537
Crop::m_field
LE * m_field
Definition: farm.h:538
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
Farm::AutumnRoll
virtual bool AutumnRoll(LE *a_field, double a_user, int a_days)
Carry out a roll event in the autumn on a_field.
Definition: farmfuncs.cpp:288
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
wws_ferti_p2
Definition: WinterWheatStrigling.h:55
WWStrigling_WAIT_FOR_PLOUGH
#define WWStrigling_WAIT_FOR_PLOUGH
Definition: WinterWheatStrigling.h:41
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
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::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
wws_insecticide1
Definition: WinterWheatStrigling.h:62
Farm
The base class for all farm types.
Definition: farm.h:767
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
wws_ferti_s2
Definition: WinterWheatStrigling.h:49
cfg_herbi_app_prop
CfgFloat cfg_herbi_app_prop
wws_water1
Definition: WinterWheatStrigling.h:67
Farm::GrowthRegulator
virtual bool GrowthRegulator(LE *a_field, double a_user, int a_days)
Apply growth regulator to a_field.
Definition: farmfuncs.cpp:1250
wws_ferti_p3
Definition: WinterWheatStrigling.h:69
wws_autumn_sow
Definition: WinterWheatStrigling.h:53
Farm::HayTurning
virtual bool HayTurning(LE *a_field, double a_user, int a_days)
Carry out hay turning on a_field.
Definition: farmfuncs.cpp:2159
Crop::m_ev
FarmEvent * m_ev
Definition: farm.h:539
cfg_strigling_prop
CfgFloat cfg_strigling_prop
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