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