ALMaSS Rabbit ODdox  1.00
The rabbit model description following ODdox protocol
farmfuncs.cpp
Go to the documentation of this file.
1 
14 //
15 // farmfuncs.cpp
16 //
17 /*
18 *******************************************************************************************************
19 Copyright (c) 2011, Christopher John Topping, University of Aarhus
20 All rights reserved.
21 
22 Redistribution and use in source and binary forms, with or without modification, are permitted provided
23 that the following conditions are met:
24 
25 Redistributions of source code must retain the above copyright notice, this list of conditions and the
26 following disclaimer.
27 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
28 the following disclaimer in the documentation and/or other materials provided with the distribution.
29 
30 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
31 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
32 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
33 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
34 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
35 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
37 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 ********************************************************************************************************
39 */
40 #define UNREFERENCED_PARAMETER(P) (P)
41 
42 #include "ls.h"
43 
44 
45 using namespace std;
46 
47 extern Landscape* g_landscape_p;
57 
58 #define DO_IT_PROB (l_farm_event_do_it_prob.value())
59 #define DO_IT_PROB_LONG (l_farm_event_do_it_prob_long.value())
60 
61 static CfgInt l_farm_event_do_it_prob("FARM_EVENT_DO_IT_PROB", CFG_PRIVATE, 50);
62 static CfgInt l_farm_event_do_it_prob_long("FARM_EVENT_DO_IT_PROB_LONG", CFG_PRIVATE, 5);
63 static CfgFloat l_farm_cattle_veg_reduce("FARM_CATTLE_VEG_REDUCE", CFG_CUSTOM, 1.5);
64 static CfgFloat l_farm_cattle_veg_reduce2("FARM_CATTLE_VEG_REDUCE_LOW", CFG_CUSTOM, 1.00 );
65 static CfgFloat l_farm_pig_veg_reduce("FARM_PIG_VEG_REDUCE", CFG_CUSTOM, 0.98 );
66 
67 
68 // Determine whether insecticide and herbicide actually
69 // influences the insect population. By default they *do*
70 // kill off some of the little critters.
71 static CfgBool l_farm_insecticide_kills("FARM_INSECTICIDE_KILLS",
72  CFG_CUSTOM, true );
73 static CfgBool l_farm_herbicide_kills("FARM_PESTICIDE_KILLS",
74  CFG_CUSTOM, true );
75 
77 CfgInt cfg_WW_InsecticideDay("PEST_WWINSECTONEDAY", CFG_CUSTOM, 1);
79 CfgInt cfg_WW_InsecticideMonth("PEST_WWINSECTONEMONTH", CFG_CUSTOM, 5);
81 CfgInt cfg_SB_InsecticideDay("PEST_SBINSECTONEDAY", CFG_CUSTOM, 15);
83 CfgInt cfg_SB_InsecticideMonth("PEST_SBINSECTONEMONTH", CFG_CUSTOM, 5);
85 CfgInt cfg_OSR_InsecticideDay("PEST_OSRINSECTONEDAY", CFG_CUSTOM, 30);
87 CfgInt cfg_OSR_InsecticideMonth("PEST_OSRINSECTONEMONTH", CFG_CUSTOM, 4);
88 
89 
90 //declared in elements.cpp
94 
95 
100 bool Farm::AutumnPlough( LE *a_field, double /*a_user*/, int a_days )
101 {
102 
103  // LE is a pointer to the field element
104  // a_user is a pointer to the farm
105  // a_days is the end of the operation time - today
106  // if a_days <0 then the time to do it is passed
107  // the line below reads 'plough if last day possible OR if not raining and pass a probability test
108  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
109  // this bit sets up the events to occur when ploughing occurs
110  // The trace below is for debugging checks
111  a_field->Trace( autumn_plough );
112  // Record the event for this field, so other objects can find out it has happened
113  a_field->SetLastTreatment( autumn_plough );
114  // Apply mortality to the insects present, in this case 90%. This only affects the general insect model, any ALMaSS model species need to take their specific action.
115  a_field->InsectMortality( 0.1 );
116  // Reduce the vegetation, in this case to zero
117  a_field->ZeroVeg();
118  // If the field has a field margin, then do all this to the field margin too. In events that don't occur on an unsprayed margin, e.g. insecticide, then is part is skipped.
119  int pref=a_field->GetUnsprayedMarginPolyRef();
120  if (pref!=-1){
121  // Must have an unsprayed margin so need to pass the information on to it
122  LE* um=g_landscape_p->SupplyLEPointer(pref);
124  um->InsectMortality( 0.1 );
125  um->ZeroVeg();
126  }
127  return true; // completed
128  }
129  return false; // not completed
130 }
131 
136 bool Farm::SleepAllDay( LE *a_field, double /*a_user*/, int /*a_days */)
137 {
138 
139  a_field->Trace( sleep_all_day );
140  a_field->SetLastTreatment( sleep_all_day );
141  int pref=a_field->GetUnsprayedMarginPolyRef();
142  if (pref!=-1){
143  // Must have an unsprayed margin so need to pass the information on to it
144  LE* um=g_landscape_p->SupplyLEPointer(pref);
146  }
147  return true;
148 }
149 
154 bool Farm::AutumnHarrow( LE *a_field, double /*a_user*/, int a_days )
155 {
156 
157  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
158  a_field->Trace( autumn_harrow );
159  a_field->SetLastTreatment( autumn_harrow );
160  // Apply 90% mortality to the insects
161  a_field->InsectMortality( 0.1 );
162  // Reduce the vegetation to zero
163  a_field->ZeroVeg();
164  int pref=a_field->GetUnsprayedMarginPolyRef();
165  if (pref!=-1){
166  // Must have an unsprayed margin so need to pass the information on to it
167  LE* um=g_landscape_p->SupplyLEPointer(pref);
169  um->InsectMortality( 0.1 );
170  um->ZeroVeg();
171  }
172  return true;
173  }
174  return false;
175 }
176 
181 bool Farm::AutumnRoll( LE *a_field, double /*a_user*/, int a_days )
182 {
183 
184  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
185  a_field->Trace( autumn_roll );
186  a_field->SetLastTreatment( autumn_roll );
187  a_field->ZeroVeg();
188  int pref=a_field->GetUnsprayedMarginPolyRef();
189  if (pref!=-1){
190  // Must have an unsprayed margin so need to pass the information on to it
191  LE* um=g_landscape_p->SupplyLEPointer(pref);
193  um->ZeroVeg();
194  }
195  return true;
196  }
197  return false;
198 }
199 
204 bool Farm::AutumnSow( LE *a_field, double /*a_user*/, int a_days )
205 {
206 
207  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
208  a_field->Trace( autumn_sow );
209  a_field->SetLastTreatment( autumn_sow );
210  a_field->SetGrowthPhase( sow );
211  a_field->SetLastSownVeg(a_field->GetVegType());
212  // Reduce the vegetation to zero
213  a_field->ZeroVeg();
214  int pref=a_field->GetUnsprayedMarginPolyRef();
215  if (pref!=-1){
216  // Must have an unsprayed margin so need to pass the information on to it
217  LE* um=g_landscape_p->SupplyLEPointer(pref);
219  um->SetGrowthPhase( sow );
220  um->ZeroVeg();
221  um->SetLastSownVeg(um->GetVegType());
222  }
223  return true;
224  }
225  return false;
226 }
227 
232 bool Farm::WinterPlough( LE *a_field, double /*a_user*/, int a_days )
233 {
234 
235  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
236  a_field->Trace( winter_plough );
237  a_field->SetLastTreatment( winter_plough );
238  a_field->InsectMortality( 0.1 );
239  a_field->ZeroVeg();
240  int pref=a_field->GetUnsprayedMarginPolyRef();
241  if (pref!=-1){
242  // Must have an unsprayed margin so need to pass the information on to it
243  LE* um=g_landscape_p->SupplyLEPointer(pref);
245  um->InsectMortality( 0.1 );
246  um->ZeroVeg();
247  }
248  return true;
249  }
250  return false;
251 }
252 
257 bool Farm::DeepPlough( LE *a_field, double /*a_user*/, int a_days )
258 {
259 
260  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
261  a_field->Trace( deep_ploughing );
262  a_field->SetLastTreatment( deep_ploughing );
263  // Apply 90% mortality to the insects
264  a_field->InsectMortality( 0.1 );
265  // Reduce the vegetation to zero
266  a_field->ZeroVeg();
267  int pref=a_field->GetUnsprayedMarginPolyRef();
268  if (pref!=-1){
269  // Must have an unsprayed margin so need to pass the information on to it
270  LE* um=g_landscape_p->SupplyLEPointer(pref);
272  um->InsectMortality( 0.1 );
273  um->ZeroVeg();
274  }
275  return true;
276  }
277  return false;
278 }
279 
284 bool Farm::SpringPlough( LE *a_field, double /*a_user*/, int a_days )
285 {
286 
287  if ((a_days <= 0) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
288  a_field->Trace( spring_plough );
289  a_field->SetLastTreatment( spring_plough );
290  // Apply 90% mortality to the insects
291  a_field->InsectMortality( 0.1 );
292  // Reduce the vegetation to zero
293  a_field->ZeroVeg();
294  int pref=a_field->GetUnsprayedMarginPolyRef();
295  if (pref!=-1){
296  // Must have an unsprayed margin so need to pass the information on to it
297  LE* um=g_landscape_p->SupplyLEPointer(pref);
299  um->InsectMortality( 0.1);
300  um->ZeroVeg();
301  }
302  return true;
303  }
304  return false;
305 }
306 
311 bool Farm::SpringHarrow( LE *a_field, double /*a_user*/, int a_days )
312 {
313 
314  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
315  a_field->Trace( spring_harrow );
316  a_field->SetLastTreatment( spring_harrow );
317  // 30% insect mortality
318  a_field->InsectMortality( 0.7 );
319  // remove all vegetation
320  a_field->ZeroVeg();
321  int pref=a_field->GetUnsprayedMarginPolyRef();
322  if (pref!=-1){
323  // Must have an unsprayed margin so need to pass the information on to it
324  LE* um=g_landscape_p->SupplyLEPointer(pref);
326  um->InsectMortality( 0.7 );
327  um->ZeroVeg();
328  }
329  return true;
330  }
331  return false;
332 }
333 
338 bool Farm::SpringRoll( LE *a_field, double /*a_user*/, int a_days )
339 {
340 
341  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
342  a_field->Trace( spring_roll );
343  a_field->SetLastTreatment( spring_roll );
344  int pref=a_field->GetUnsprayedMarginPolyRef();
345  if (pref!=-1){
346  // Must have an unsprayed margin so need to pass the information on to it
347  LE* um=g_landscape_p->SupplyLEPointer(pref);
349  }
350  return true;
351  }
352  return false;
353 }
354 
359 bool Farm::SpringSow( LE *a_field, double /*a_user*/, int a_days )
360 {
361 
362  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
363  a_field->Trace( spring_sow );
364  a_field->SetLastTreatment( spring_sow );
365  a_field->SetGrowthPhase( sow );
366  a_field->SetLastSownVeg(a_field->GetVegType());
367  // Reduce the vegetation to zero - should not strictly be necessary, but prevents any false starts in the crop growth.
368  a_field->ZeroVeg();
369  int pref=a_field->GetUnsprayedMarginPolyRef();
370  if (pref!=-1){
371  // Must have an unsprayed margin so need to pass the information on to it
372  LE* um=g_landscape_p->SupplyLEPointer(pref);
374  um->SetGrowthPhase( sow );
375  um->ZeroVeg();
376  um->SetLastSownVeg(um->GetVegType());
377  }
378  return true;
379  }
380  return false;
381 }
382 
387 bool Farm::FP_NPKS( LE *a_field, double /*a_user*/, int a_days )
388 {
389 
390  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
391  a_field->Trace( fp_npks );
392  a_field->SetLastTreatment( fp_npks );
394  int pref=a_field->GetUnsprayedMarginPolyRef();
395 if (pref!=-1){
396  // Must have an unsprayed margin so need to pass the information on to it
397  LE* um=g_landscape_p->SupplyLEPointer(pref);
399  um->SetGrowthPhase( harvest1 );
400  um->InsectMortality( 0.4 );
402 }
403 
404  return true;
405  }
406  return false;
407 }
408 
409 
414 bool Farm::FP_NPK( LE *a_field, double /*a_user*/, int a_days )
415 {
416 
417  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
418  a_field->Trace( fp_npk );
419  a_field->SetLastTreatment( fp_npk );
421  int pref=a_field->GetUnsprayedMarginPolyRef();
422  if (pref!=-1){
423  // Must have an unsprayed margin so need to pass the information on to it
424  LE* um=g_landscape_p->SupplyLEPointer(pref);
427  }
428  return true;
429  }
430  return false;
431 }
432 
433 
438 bool Farm::FP_PK( LE *a_field, double /*a_user*/, int a_days )
439 {
440 
441  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
442  a_field->Trace( fp_pk );
443  a_field->SetLastTreatment( fp_pk );
445  int pref=a_field->GetUnsprayedMarginPolyRef();
446  if (pref!=-1){
447  // Must have an unsprayed margin so need to pass the information on to it
448  LE* um=g_landscape_p->SupplyLEPointer(pref);
449  um->SetLastTreatment(fp_pk);
451  }
452  return true;
453  }
454  return false;
455 }
456 
457 
462 bool Farm::FP_LiquidNH3( LE *a_field, double /*a_user*/, int a_days )
463 {
464 
465  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
466  a_field->Trace( fp_liquidNH3 );
467  a_field->SetLastTreatment( fp_liquidNH3 );
469  int pref=a_field->GetUnsprayedMarginPolyRef();
470  if (pref!=-1){
471  // Must have an unsprayed margin so need to pass the information on to it
472  LE* um=g_landscape_p->SupplyLEPointer(pref);
475  }
476  return true;
477  }
478  return false;
479 }
480 
481 
486 bool Farm::FP_Slurry( LE *a_field, double /*a_user*/, int a_days )
487 {
488 
489  if ( (0 >= a_days) || ((g_weather->GetTemp()>0)&&
490  !g_weather->Raining() && DoIt(DO_IT_PROB)))
491 {
492  a_field->Trace( fp_slurry );
493  a_field->SetLastTreatment( fp_slurry );
495  int pref=a_field->GetUnsprayedMarginPolyRef();
496  if (pref!=-1){
497  // Must have an unsprayed margin so need to pass the information on to it
498  LE* um=g_landscape_p->SupplyLEPointer(pref);
501  }
502  return true;
503  }
504  return false;
505 }
506 
507 
512 bool Farm::FP_ManganeseSulphate( LE *a_field, double /*a_user*/, int a_days )
513 {
514 
515  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
516  a_field->Trace( fp_manganesesulphate );
519  int pref=a_field->GetUnsprayedMarginPolyRef();
520  if (pref!=-1){
521  // Must have an unsprayed margin so need to pass the information on to it
522  LE* um=g_landscape_p->SupplyLEPointer(pref);
525  }
526  return true;
527  }
528  return false;
529 }
530 
531 
536 bool Farm::FP_Manure( LE *a_field, double /*a_user*/, int a_days )
537 {
538 
539  if ( (0 >= a_days) || ((g_weather->GetTemp()>0)&&
540  !g_weather->Raining() && DoIt(DO_IT_PROB))) {
541  a_field->Trace( fp_manure );
542  a_field->SetLastTreatment( fp_manure );
544  int pref=a_field->GetUnsprayedMarginPolyRef();
545  if (pref!=-1){
546  // Must have an unsprayed margin so need to pass the information on to it
547  LE* um=g_landscape_p->SupplyLEPointer(pref);
550  }
551  return true;
552  }
553  return false;
554 }
555 
556 
561 bool Farm::FP_GreenManure( LE *a_field, double /*a_user*/, int a_days )
562 {
563 
564  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
565  a_field->Trace( fp_greenmanure );
566  a_field->SetLastTreatment( fp_greenmanure );
568  int pref=a_field->GetUnsprayedMarginPolyRef();
569  if (pref!=-1){
570  // Must have an unsprayed margin so need to pass the information on to it
571  LE* um=g_landscape_p->SupplyLEPointer(pref);
574  }
575  return true;
576  }
577  return false;
578 }
579 
580 
585 bool Farm::FP_Sludge( LE *a_field, double /*a_user*/, int a_days )
586 {
587  //
588  if ( (0 >= a_days) || ((g_weather->GetTemp()>0)&&
589  !g_weather->Raining() && DoIt(DO_IT_PROB)))
590 {
591  a_field->Trace( fp_sludge );
592  a_field->SetLastTreatment( fp_sludge );
594  int pref=a_field->GetUnsprayedMarginPolyRef();
595  if (pref!=-1){
596  // Must have an unsprayed margin so need to pass the information on to it
597  LE* um=g_landscape_p->SupplyLEPointer(pref);
600  }
601  return true;
602  }
603  return false;
604 }
605 
606 
611 bool Farm::FA_NPK( LE *a_field, double /*a_user*/, int a_days )
612 {
613 
614  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
615  a_field->Trace( fa_npk );
616  a_field->SetLastTreatment( fa_npk );
618  int pref=a_field->GetUnsprayedMarginPolyRef();
619  if (pref!=-1){
620  // Must have an unsprayed margin so need to pass the information on to it
621  LE* um=g_landscape_p->SupplyLEPointer(pref);
622  um->SetLastTreatment( fa_npk );
624  }
625  return true;
626  }
627  return false;
628 }
629 
630 
635 bool Farm::FA_PK( LE *a_field, double /*a_user*/, int a_days )
636 {
637 
638  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
639  a_field->Trace( fa_pk );
640  a_field->SetLastTreatment( fa_pk );
642  int pref=a_field->GetUnsprayedMarginPolyRef();
643  if (pref!=-1){
644  // Must have an unsprayed margin so need to pass the information on to it
645  LE* um=g_landscape_p->SupplyLEPointer(pref);
646  um->SetLastTreatment( fa_pk );
648  }
649  return true;
650  }
651  return false;
652 }
653 
659 bool Farm::FA_Slurry( LE *a_field, double /*a_user*/, int a_days )
660 {
661 
662  if ( (0 >= a_days) || ((g_weather->GetTemp()>0)&&
663  !g_weather->Raining() && DoIt(DO_IT_PROB)))
664 {
665  a_field->Trace( fa_slurry );
666  a_field->SetLastTreatment( fa_slurry );
668  int pref=a_field->GetUnsprayedMarginPolyRef();
669  if (pref!=-1){
670  // Must have an unsprayed margin so need to pass the information on to it
671  LE* um=g_landscape_p->SupplyLEPointer(pref);
674  }
675  return true;
676  }
677  return false;
678 }
679 
684 bool Farm::FA_AmmoniumSulphate( LE *a_field, double /*a_user*/, int a_days )
685 {
686 
687  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
688  a_field->Trace( fa_ammoniumsulphate );
691  int pref=a_field->GetUnsprayedMarginPolyRef();
692  if (pref!=-1){
693  // Must have an unsprayed margin so need to pass the information on to it
694  LE* um=g_landscape_p->SupplyLEPointer(pref);
697  }
698  return true;
699  }
700  return false;
701 }
702 
703 
708 bool Farm::FA_Manure( LE *a_field, double /*a_user*/, int a_days )
709 {
710 
711  if ( (0 >= a_days) || ((g_weather->GetTemp()>0)&&
712  !g_weather->Raining() && DoIt(DO_IT_PROB)))
713 {
714  a_field->Trace( fa_manure );
715  a_field->SetLastTreatment( fa_manure );
717  int pref=a_field->GetUnsprayedMarginPolyRef();
718  if (pref!=-1){
719  // Must have an unsprayed margin so need to pass the information on to it
720  LE* um=g_landscape_p->SupplyLEPointer(pref);
723  }
724  return true;
725  }
726  return false;
727 }
728 
729 
734 bool Farm::FA_GreenManure( LE *a_field, double /*a_user*/, int a_days )
735 {
736 
737  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
738  a_field->Trace( fa_greenmanure );
739  a_field->SetLastTreatment( fa_greenmanure );
741  int pref=a_field->GetUnsprayedMarginPolyRef();
742  if (pref!=-1){
743  // Must have an unsprayed margin so need to pass the information on to it
744  LE* um=g_landscape_p->SupplyLEPointer(pref);
747  }
748  return true;
749  }
750  return false;
751 }
752 
753 
758 bool Farm::FA_Sludge( LE *a_field, double /*a_user*/, int a_days )
759 {
760 
761  if ( (0 >= a_days) || ((g_weather->GetTemp()>0)&&
762  !g_weather->Raining() && DoIt(DO_IT_PROB)))
763 {
764  a_field->Trace( fa_sludge );
765  a_field->SetLastTreatment( fa_sludge );
767  int pref=a_field->GetUnsprayedMarginPolyRef();
768  if (pref!=-1){
769  // Must have an unsprayed margin so need to pass the information on to it
770  LE* um=g_landscape_p->SupplyLEPointer(pref);
773  }
774  return true;
775  }
776  return false;
777 }
778 
779 
784 bool Farm::HerbicideTreat( LE *a_field, double /*a_user*/, int a_days )
785 {
786 
787  if (0 >= a_days) // Must do this
788  {
789  if (((a_field->GetSignal() & LE_SIG_NO_HERBICIDE)==0 ))
790  {
791  a_field->Trace( herbicide_treat );
792  a_field->SetLastTreatment( herbicide_treat );
794  {
795  a_field->ReduceWeedBiomass( 0.05 );
796  }
799  }
800  return true;
801  }
802  else if ((g_weather->GetWind()<4.5) && (!g_weather->Raining()) && DoIt(DO_IT_PROB))
803  {
804  if ( !(a_field->GetSignal() & LE_SIG_NO_HERBICIDE) )
805  {
806  a_field->Trace( herbicide_treat );
807  a_field->SetLastTreatment( herbicide_treat );
809  {
810  a_field->ReduceWeedBiomass( 0.05 );
811  }
814  }
815  return true;
816  }
817  return false;
818 }
819 
820 
821 bool OptimisingFarm::HerbicideTreat( LE *a_field, double /*a_user*/, int a_days )
822 {
823 
824  if (0 >= a_days) // Must do this
825  {
826  if (((a_field->GetSignal() & LE_SIG_NO_HERBICIDE)==0 ))
827  {
828  a_field->Trace( herbicide_treat );
829  a_field->SetLastTreatment( herbicide_treat );
830  if ( l_farm_herbicide_kills.value()) {
831  a_field->ReduceWeedBiomass( 0.05 );
832  }
835 
836 
837  if(!cfg_OptimiseBedriftsmodelCrops.value()){
838  Field * pf = dynamic_cast<Field*>(a_field);
839  pf->Add_no_herb_app();
840  }
841 
842  }
843  return true;
844  }
845  else if ((g_weather->GetWind()<4.5) && (!g_weather->Raining()) && DoIt(DO_IT_PROB))
846  {
847  if ( !(a_field->GetSignal() & LE_SIG_NO_HERBICIDE) )
848  {
849  a_field->Trace( herbicide_treat );
850  a_field->SetLastTreatment( herbicide_treat );
851  if ( l_farm_herbicide_kills.value()) {
852  a_field->ReduceWeedBiomass( 0.05 );
853  }
856 
857  if(!cfg_OptimiseBedriftsmodelCrops.value()){
858  Field * pf = dynamic_cast<Field*>(a_field);
859  pf->Add_no_herb_app();
860  }
861  }
862  return true;
863  }
864  return false;
865 }
866 
867 
868 
873 bool Farm::GrowthRegulator( LE *a_field, double /*a_user*/, int a_days )
874 {
875 
876  if (0 >= a_days)
877  {
878  if ( (!g_weather->Raining()) && (g_weather->GetWind()<4.5) &&
879  (!(a_field->GetSignal() & LE_SIG_NO_GROWTH_REG) )) {
880  a_field->Trace( growth_regulator );
883  }
884  return true;
885  }
886  else if ( (g_weather->GetWind()<4.5) &&
887  (!g_weather->Raining()) && DoIt(DO_IT_PROB)) {
888  if ( ! (a_field->GetSignal() & LE_SIG_NO_GROWTH_REG) ) {
889  a_field->Trace( growth_regulator );
892  }
893  return true;
894  }
895  return false;
896 }
897 
902 bool Farm::FungicideTreat( LE *a_field, double /*a_user*/, int a_days )
903 {
904 
905  if (0 >= a_days)
906  {
907  if ( ( ! a_field->GetSignal() & LE_SIG_NO_FUNGICIDE ))
908  {
909  a_field->Trace( fungicide_treat );
910  a_field->SetLastTreatment( fungicide_treat );
912  }
913  return true;
914  }
915  else if ( (g_weather->GetWind()<4.5) &&
916  (!g_weather->Raining()) && DoIt(DO_IT_PROB)) {
917  if ( ! (a_field->GetSignal() & LE_SIG_NO_FUNGICIDE) ) {
918  a_field->Trace( fungicide_treat );
919  a_field->SetLastTreatment( fungicide_treat );
921  }
922  return true;
923  }
924  return false;
925 }
926 
927 
928 bool OptimisingFarm::FungicideTreat( LE *a_field, double /*a_user*/, int a_days )
929 {
930 
931  if (0 >= a_days)
932  {
933  if ( ( ! a_field->GetSignal() & LE_SIG_NO_FUNGICIDE )) {
934  a_field->Trace( fungicide_treat );
935  a_field->SetLastTreatment( fungicide_treat );
937 
938  if(!cfg_OptimiseBedriftsmodelCrops.value()){
939  Field * pf = dynamic_cast<Field*>(a_field);
940  pf->Add_no_fi_app();
941  }
942  }
943  return true;
944  }
945  else if ( (g_weather->GetWind()<4.5) && (!g_weather->Raining()) && DoIt(DO_IT_PROB)) {
946  if ( ! (a_field->GetSignal() & LE_SIG_NO_FUNGICIDE) ) {
947  a_field->Trace( fungicide_treat );
948  a_field->SetLastTreatment( fungicide_treat );
950 
951  if(!cfg_OptimiseBedriftsmodelCrops.value()){
952  Field * pf = dynamic_cast<Field*>(a_field);
953  pf->Add_no_fi_app();
954  }
955  }
956  return true;
957  }
958  return false;
959 }
960 
961 
962 
967 bool Farm::InsecticideTreat( LE *a_field, double /*a_user*/, int a_days )
968 {
969 
970  if (0 >= a_days)
971  {
972  if (( ! (a_field->GetSignal() & LE_SIG_NO_INSECTICIDE) ))
973  {
974  // **CJT** Turn this code on to use the pesticide engine with insecticides
975  // g_pest->DailyQueueAdd( a_field, l_pest_insecticide_amount.value());
976  //
977  a_field->Trace( insecticide_treat );
980  {
981  a_field->Insecticide( 0.36 );
982  }
984  }
985  return true;
986  }
987  else if ( (g_weather->GetWind()<4.5) &&
988  (!g_weather->Raining()) && DoIt(DO_IT_PROB)) {
989  if ( ! (a_field->GetSignal() & LE_SIG_NO_INSECTICIDE )) {
990 // **CJT** Turn this code on to use the pesticide engine with insecticides
991 // g_pest->DailyQueueAdd( a_field, l_pest_insecticide_amount.value());
992 //
993  a_field->Trace( insecticide_treat );
996  a_field->Insecticide( 0.36 );
997  }
999  }
1000  return true;
1001  }
1002  return false;
1003 }
1004 
1005 
1006 bool OptimisingFarm::InsecticideTreat( LE *a_field, double /*a_user*/, int a_days )
1007 {
1008 
1009  if (0 >= a_days)
1010  {
1011  if (( ! (a_field->GetSignal() & LE_SIG_NO_INSECTICIDE) ))
1012  {
1013  // **CJT** Turn this code on to use the pesticide engine with insecticides
1014  // g_pest->DailyQueueAdd( a_field, l_pest_insecticide_amount.value());
1015  //
1016  a_field->Trace( insecticide_treat );
1017  a_field->SetLastTreatment( insecticide_treat );
1019  a_field->Insecticide( 0.36 );
1020  }
1022 
1023  if(!cfg_OptimiseBedriftsmodelCrops.value()){
1024  Field * pf = dynamic_cast<Field*>(a_field);
1025  pf->Add_no_fi_app();
1026  }
1027 
1028  }
1029  return true;
1030  }
1031  else if ( (g_weather->GetWind()<4.5) && (!g_weather->Raining()) && DoIt(DO_IT_PROB))
1032  {
1033  if ( ! (a_field->GetSignal() & LE_SIG_NO_INSECTICIDE )) {
1034  // **CJT** Turn this code on to use the pesticide engine with insecticides
1035  // g_pest->DailyQueueAdd( a_field, l_pest_insecticide_amount.value());
1036  //
1037  a_field->Trace( insecticide_treat );
1038  a_field->SetLastTreatment( insecticide_treat );
1040  a_field->Insecticide( 0.36 );
1041  }
1043 
1044  if(!cfg_OptimiseBedriftsmodelCrops.value()){
1045  Field * pf = dynamic_cast<Field*>(a_field);
1046  pf->Add_no_fi_app();
1047  }
1048  }
1049 
1050  return true;
1051  }
1052  return false;
1053 }
1054 
1055 
1056 
1061 bool Farm::SynInsecticideTreat( LE *a_field, double /*a_user*/, int a_days )
1062 {
1063 
1064  // NOTE Differs from normal insecticide in that it will be done on the last
1065  // day if not managed before
1066  if (0 >= a_days) {
1067  if ( ! (a_field->GetSignal() & LE_SIG_NO_SYNG_INSECT )) {
1068  a_field->Trace( syninsecticide_treat );
1071  a_field->Insecticide( 0.2 );
1072  }
1074  }
1075 // double p=l_pest_insecticide_amount.value();
1076 // g_pest->DailyQueueAdd( a_field,p );
1077  return true;
1078  } else {
1079  if ( (!g_weather->Raining()) && (g_weather->GetWind()<4.5)) {
1080  if ( ! (a_field->GetSignal() & LE_SIG_NO_SYNG_INSECT ) ) {
1081  a_field->Trace( syninsecticide_treat );
1084  a_field->Insecticide( 0.2 );
1085  }
1087  }
1088 // g_pest->DailyQueueAdd( a_field, l_pest_insecticide_amount.value());
1089  return true;
1090  }
1091  }
1092  return false;
1093 }
1094 
1099 bool Farm::ProductApplication0( LE *a_field, double /*a_user*/, int a_days )
1100 {
1101 
1102  // NOTE Differs from normal pesticide in that it will be done on the last
1103  // day if not managed before
1104  if (0 >= a_days) {
1105  a_field->Trace( product_treat );
1106  a_field->SetLastTreatment( product_treat );
1108  a_field->Insecticide( 0.2 ); }
1110  double p=l_pest_product_0_amount.value();
1111  g_pest->DailyQueueAdd( a_field,p );
1112  return true;
1113  } else {
1114  if ( (!g_weather->Raining()) && (g_weather->GetWind()<4.5)) {
1115  a_field->Trace( product_treat );
1116  a_field->SetLastTreatment( product_treat );
1118  a_field->Insecticide( 0.2 ); }
1120  double p=l_pest_product_0_amount.value();
1121  g_pest->DailyQueueAdd( a_field,p );
1122  return true;
1123  }
1124  }
1125  return false;
1126 }
1127 
1132 bool Farm::ProductApplication1( LE *a_field, double /*a_user*/, int a_days )
1133 {
1134 
1135  // NOTE Differs from normal pesticide in that it will be done on the last
1136  // day if not managed before
1137  if (0 >= a_days) {
1138  a_field->Trace( product_treat );
1139  a_field->SetLastTreatment( product_treat );
1141  {
1142  a_field->Insecticide( 0.2 );
1143  }
1145  double p=l_pest_product_1_amount.value();
1146  g_pest->DailyQueueAdd( a_field,p );
1147  return true;
1148  } else {
1149  if ( (!g_weather->Raining()) && (g_weather->GetWind()<4.5)) {
1150  a_field->Trace( product_treat );
1151  a_field->SetLastTreatment( product_treat );
1153  a_field->Insecticide( 0.2 ); }
1155  double p=l_pest_product_1_amount.value();
1156  g_pest->DailyQueueAdd( a_field,p );
1157  return true;
1158  }
1159  }
1160  return false;
1161 }
1162 
1167 bool Farm::Molluscicide( LE *a_field, double /*a_user*/, int a_days )
1168 {
1169 
1170  if (0 >= a_days) {
1171  if ( (!g_weather->Raining()) && (g_weather->GetWind()<4.5) &&
1172  (! (a_field->GetSignal() & LE_SIG_NO_MOLLUSC ))) {
1173  a_field->Trace( molluscicide );
1174  a_field->SetLastTreatment( molluscicide );
1176  }
1177  return true;
1178  }
1179  else if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
1180  if ( ! (a_field->GetSignal() & LE_SIG_NO_MOLLUSC) ) {
1181  a_field->Trace( molluscicide );
1182  a_field->SetLastTreatment( molluscicide );
1184  }
1185  return true;
1186  }
1187  return false;
1188 }
1189 
1194 bool Farm::RowCultivation( LE *a_field, double /*a_user*/, int a_days )
1195 {
1196 
1197  if ( (0 >= a_days) && (g_weather->GetRainPeriod(g_date->Date(),3)<0.1) )
1198  {
1199  // Too much rain, just give up and claim we did it.
1200  return true;
1201  }
1202 
1203  if ( (0 >= a_days) ||
1204  ((g_weather->GetRainPeriod(g_date->Date(),3)<0.1) && DoIt(DO_IT_PROB))
1205  ) {
1206  a_field->Trace( row_cultivation );
1207  a_field->SetLastTreatment( row_cultivation );
1208  a_field->ReduceWeedBiomass( 0.5 );
1209  a_field->InsectMortality( 0.25 );
1211  int pref=a_field->GetUnsprayedMarginPolyRef();
1212  if (pref!=-1){
1213  // Must have an unsprayed margin so need to pass the information on to it
1214  LE* um=g_landscape_p->SupplyLEPointer(pref);
1216  um->InsectMortality( 0.25 );
1217  um->ReduceWeedBiomass( 0.5 );
1219  }
1220  return true;
1221  }
1222  return false;
1223 }
1224 
1229 bool Farm::Strigling( LE *a_field, double /*a_user*/, int a_days )
1230 {
1231 
1232  // Force strigling if it has not been done already!!! This happens regardless of weather as of 26/10/2005
1233  if ( (0 >= a_days) )// && (g_weather->GetRainPeriod(g_date->Date(),3)>0.1) )
1234  {
1235  a_field->Trace( strigling );
1236  a_field->SetLastTreatment( strigling );
1237  a_field->ReduceWeedBiomass( 0.05 );
1238  a_field->InsectMortality( 0.7 );
1241  int pref=a_field->GetUnsprayedMarginPolyRef();
1242  if (pref!=-1){
1243  // Must have an unsprayed margin so need to pass the information on to it
1244  LE* um=g_landscape_p->SupplyLEPointer(pref);
1245  um->SetLastTreatment( strigling );
1246  um->ReduceWeedBiomass( 0.05 );
1247  um->InsectMortality( 0.7 );
1250  return true;
1251  }
1252  }
1253  if ( (0 >= a_days) ||
1254  ((g_weather->GetRainPeriod(g_date->Date(),3)<0.1) && DoIt(DO_IT_PROB))
1255  ) {
1256  a_field->Trace( strigling );
1257  a_field->SetLastTreatment( strigling );
1258  a_field->ReduceWeedBiomass( 0.05 );
1259  a_field->InsectMortality( 0.7 );
1262  int pref=a_field->GetUnsprayedMarginPolyRef();
1263  if (pref!=-1){
1264  // Must have an unsprayed margin so need to pass the information on to it
1265  LE* um=g_landscape_p->SupplyLEPointer(pref);
1266  um->SetLastTreatment( strigling );
1267  um->ReduceWeedBiomass( 0.05 );
1268  um->InsectMortality( 0.7 );
1271  }
1272  return true;
1273  }
1274  return false;
1275 }
1276 
1281 bool Farm::StriglingSow( LE *a_field, double /*a_user*/, int a_days )
1282 {
1283 
1284  //2 days good weather afterwards
1285  if ( (0 >= a_days) && (g_weather->GetRainPeriod(g_date->Date(),3)<0.1) )
1286  {
1287  return true;
1288  }
1289 
1290  if ( (0 >= a_days) ||
1291  ((g_weather->GetRainPeriod(g_date->Date(),3)<0.1) && DoIt(DO_IT_PROB))
1292  ) {
1293  a_field->Trace( strigling_sow );
1294  a_field->SetLastTreatment( strigling_sow );
1295  a_field->ReduceWeedBiomass( 0.05 );
1296  a_field->InsectMortality( 0.7 );
1299  int pref=a_field->GetUnsprayedMarginPolyRef();
1300  if (pref!=-1){
1301  // Must have an unsprayed margin so need to pass the information on to it
1302  LE* um=g_landscape_p->SupplyLEPointer(pref);
1304  um->ReduceWeedBiomass( 0.05 );
1305  um->InsectMortality( 0.7 );
1308  }
1309  return true;
1310  }
1311  return false;
1312 }
1313 
1318 bool Farm::HillingUp( LE *a_field, double /*a_user*/, int a_days )
1319 {
1320 
1321  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
1322  a_field->Trace( hilling_up );
1323  a_field->SetLastTreatment( hilling_up );
1324  a_field->InsectMortality( 0.75 );
1325  a_field->ReduceWeedBiomass( 0.25 );
1327  int pref=a_field->GetUnsprayedMarginPolyRef();
1328  if (pref!=-1){
1329  // Must have an unsprayed margin so need to pass the information on to it
1330  LE* um=g_landscape_p->SupplyLEPointer(pref);
1332  um->ReduceWeedBiomass( 0.25 );
1333  um->InsectMortality( 0.75 );
1335  }
1336  return true;
1337  }
1338  return false;
1339 }
1340 
1345 bool Farm::Water( LE *a_field, double /*a_user*/, int a_days )
1346 {
1347 
1348 
1349  /* Turn on this code to avoid watering on heavy soils
1350  int soiltype = a_field->GetSoilType();
1351  if ( soiltype < 1 || soiltype > 4 )
1352  return true;
1353 */
1354  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
1355  a_field->Trace( water );
1356  a_field->SetLastTreatment( water );
1357  int pref=a_field->GetUnsprayedMarginPolyRef();
1358  if (pref!=-1){
1359  // Must have an unsprayed margin so need to pass the information on to it
1360  LE* um=g_landscape_p->SupplyLEPointer(pref);
1361  um->SetLastTreatment( water );
1362  }
1363  return true;
1364  }
1365  return false;
1366 }
1367 
1372 bool Farm::Swathing( LE *a_field, double /*a_user*/, int a_days )
1373 {
1374 
1375  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
1376  a_field->Trace( swathing );
1377  a_field->SetLastTreatment( swathing );
1378  a_field->InsectMortality( 0.5 );
1380  int pref=a_field->GetUnsprayedMarginPolyRef();
1381  if (pref!=-1){
1382  // Must have an unsprayed margin so need to pass the information on to it
1383  LE* um=g_landscape_p->SupplyLEPointer(pref);
1384  um->SetLastTreatment( swathing );
1385  um->InsectMortality( 0.5 );
1387  }
1388  return true;
1389  }
1390  return false;
1391 }
1392 
1397 bool Farm::Harvest(LE *a_field, double /*a_user*/, int a_days)
1398 {
1399  //5 days good weather before
1400  if ((0 >= a_days) || ((g_weather->GetRainPeriod(g_date->Date(), 5) < 0.1) && DoIt(DO_IT_PROB))) {
1401  a_field->Trace(harvest);
1402  a_field->SetLastTreatment(harvest);
1403  a_field->SetGrowthPhase(harvest1);
1404  // Here we have to do a little skip to avoid too low insect populations after harvest, but a correct veg biomass
1405  a_field->InsectMortality(0.4);
1406  double insects = a_field->GetInsectPop();
1407  a_field->ResetDigestability();
1408  a_field->RecalculateBugsNStuff();
1409  a_field->SetInsectPop(insects);
1411  int pref = a_field->GetUnsprayedMarginPolyRef();
1412  // Are we a cereal crop? If so we need to have some spilled grain
1413  double someseed = 0.0;
1414  double somemaize = 0.0;
1415  if (dynamic_cast<VegElement*>(a_field)->IsMatureCereal()) {
1416  someseed = m_OurManager->GetSpilledGrain();
1417  }
1418  else if (dynamic_cast<VegElement*>(a_field)->IsMaize()) {
1419  somemaize = m_OurManager->GetSpilledMaize();
1420  }
1421  else {
1422  someseed = 0.0;
1423  somemaize = 0.0;
1424  }
1425  a_field->SetBirdSeed( someseed );
1426  a_field->SetBirdMaize( somemaize );
1427  if (pref != -1){
1428  // Must have an unsprayed margin so need to pass the information on to it
1429  LE* um = g_landscape_p->SupplyLEPointer(pref);
1431  um->SetGrowthPhase(harvest1);
1432  um->InsectMortality(0.4);
1434  um->ResetDigestability();
1435  um->RecalculateBugsNStuff();
1436  um->SetBirdSeed( someseed );
1437  um->SetBirdMaize( somemaize );
1438  }
1439  return true;
1440  }
1441  return false;
1442 }
1443 
1444 
1449 bool Farm::HarvestLong(LE *a_field, double /*a_user*/, int a_days)
1450 {
1451 
1452  //5 days good weather before
1453  if ((0 >= a_days) ||
1454  ((g_weather->GetRainPeriod(g_date->Date(), 5)<0.1) && DoIt(DO_IT_PROB_LONG))
1455  ) {
1456  a_field->Trace(harvest);
1457  a_field->SetLastTreatment(harvest);
1458  a_field->SetGrowthPhase(harvest1);
1459  // Here we have to do a little skip to avoid too low insect populations after harvest, but a correct veg biomass
1460  a_field->InsectMortality(0.4);
1461  double insects = a_field->GetInsectPop();
1462  a_field->ResetDigestability();
1463  a_field->RecalculateBugsNStuff();
1464  a_field->SetInsectPop(insects);
1466  int pref = a_field->GetUnsprayedMarginPolyRef();
1467  double someseed = 0.0; //No bird seed or maize forage on sugar beet (which is currently (March 2015) the only crop using HarvestLong.
1468  a_field->SetBirdSeed( someseed );
1469  a_field->SetBirdMaize( someseed );
1470  if (pref != -1){
1471  // Must have an unsprayed margin so need to pass the information on to it
1472  LE* um = g_landscape_p->SupplyLEPointer(pref);
1474  um->SetGrowthPhase(harvest1);
1475  um->InsectMortality(0.4);
1477  um->ResetDigestability();
1478  um->RecalculateBugsNStuff();
1479  um->SetBirdSeed( someseed );
1480  um->SetBirdMaize( someseed );
1481  }
1482  return true;
1483  }
1484  return false;
1485 }
1486 
1487 bool OptimisingFarm::Harvest(LE *a_field, double /*a_user*/, int a_days)
1488 {
1489 
1490  //5 days good weather before
1491  if ( (0 >= a_days) ||
1492  ((g_weather->GetRainPeriod(g_date->Date(),5)<0.1) && DoIt(DO_IT_PROB)))
1493  {
1494 
1495  //05.03.13 need to get the info on biomass
1496  if(!cfg_OptimiseBedriftsmodelCrops.value()){
1497  Field * pf = dynamic_cast<Field*>(a_field); //ok????? - maybe should be VegElement instead of field!
1498  if(pf->GetVegType()!=tov_Potatoes && pf->GetVegType()!=tov_PotatoesIndustry){ //do not save biomass for potatoes!
1499  double biomass_at_harvest = a_field->GetVegBiomass();
1500  pf->Set_biomass_at_harvest(biomass_at_harvest, 0); //sets the biomass of a current crop; the current crop is at the index 0
1501  pf->Set_harvested(); //mark this crop as harvested
1502  }
1503  }
1504  //05.03.13 end
1505 
1506  a_field->Trace( harvest );
1507  a_field->SetLastTreatment( harvest );
1508  a_field->SetGrowthPhase( harvest1 );
1509  // Here we have to do a little skip to avoid too low insect populations after harvest, but a correct veg biomass
1510  a_field->InsectMortality( 0.4 );
1511  double insects=a_field->GetInsectPop();
1512  a_field->RecalculateBugsNStuff();
1513  a_field->SetInsectPop(insects);
1515  a_field->ResetDigestability();
1516  int pref=a_field->GetUnsprayedMarginPolyRef();
1517  if (pref!=-1){
1518  // Must have an unsprayed margin so need to pass the information on to it
1519  LE* um=g_landscape_p->SupplyLEPointer(pref);
1521  um->SetGrowthPhase( harvest1 );
1522  um->InsectMortality( 0.4 );
1524  um->ResetDigestability();
1525  um->RecalculateBugsNStuff();
1526  }
1527  return true;
1528  }
1529  return false;
1530 }
1531 
1532 
1533 
1538 bool Farm::CattleOut( LE *a_field, double /*a_user*/, int a_days )
1539 {
1543  if ((0 >= a_days) || DoIt( DO_IT_PROB ))
1544  {
1545  a_field->ToggleCattleGrazing();
1546  a_field->Trace( cattle_out );
1547  a_field->SetLastTreatment( cattle_out );
1548  // Reduce the vegetation because of grazing
1549  //double h=a_field->GetVegHeight();
1550  //double reduc = 1-(l_farm_cattle_veg_reduce.value()*((h-15)/15));
1551  //a_field->ReduceVeg_Extended( reduc );
1552  a_field->GrazeVegetation( l_farm_cattle_veg_reduce.value(), false );
1553  int pref = a_field->GetUnsprayedMarginPolyRef();
1554  if (pref != -1)
1555  {
1556  // Must have an unsprayed margin so need to pass the information on to it
1557  // This happens if all arable fields are given unsprayed margins - they have no effect on grass unless it is sprayed with pesticides
1558  LE* um = g_landscape_p->SupplyLEPointer( pref );
1559  um->ToggleCattleGrazing();
1562  }
1563  return true;
1564  }
1565  return false;
1566 }
1567 
1572 bool Farm::CattleOutLowGrazing( LE *a_field, double /*a_user*/, int a_days )
1573 {
1574 
1575  if ( (0 >= a_days)|| DoIt(DO_IT_PROB)) {
1576  a_field->ToggleCattleGrazing();
1577  a_field->Trace( cattle_out_low );
1578  a_field->SetLastTreatment( cattle_out_low );
1579  // Reduce the vegetation because of grazing
1580  //double h=a_field->GetVegHeight();
1581  //double reduc = 1-(l_farm_cattle_veg_reduce.value()*((h-15)/15));
1582  //a_field->ReduceVeg_Extended( reduc );
1583  a_field->GrazeVegetation( l_farm_cattle_veg_reduce2.value( ), false );
1584  int pref=a_field->GetUnsprayedMarginPolyRef();
1585  if (pref!=-1){
1586  // Must have an unsprayed margin so need to pass the information on to it
1587  // This happens if all arable fields are given unsprayed margins - they have no effect on grass unless it is sprayed with pesticides
1588  LE* um=g_landscape_p->SupplyLEPointer(pref);
1589  um->ToggleCattleGrazing();
1592  }
1593  return true;
1594  }
1595  return false;
1596 }
1597 
1602 bool Farm::CattleIsOut(LE *a_field, double /*a_user*/, int a_days, int a_max)
1603 {
1607  double biomass = a_field->GetVegBiomass();
1608  if (biomass > 100.0)
1609  {
1610  a_field->SetLastTreatment(cattle_out);
1611  a_field->Trace(cattle_out);
1612  // Reduce the vegetation because of grazing
1613  //double h=a_field->GetVegHeight();
1614  //double reduc = 1-(l_farm_cattle_veg_reduce.value()*((h-15)/15));
1615  //a_field->ReduceVeg_Extended( reduc );
1616  a_field->GrazeVegetation( l_farm_cattle_veg_reduce.value( ), false );
1617  int pref = a_field->GetUnsprayedMarginPolyRef();
1618  if (pref != -1)
1619  {
1620  // Must have an unsprayed margin so need to pass the information on to it
1621  LE* um = g_landscape_p->SupplyLEPointer(pref);
1624  }
1625  }
1626  int d1 = g_date->DayInYear(10, 9);
1627  if (d1 > a_max) d1 = a_max;
1628  if ((((g_date->DayInYear() > d1) && (10 >= a_days)) && DoIt(10)) || (0 >= a_days))
1629  {
1630  a_field->ToggleCattleGrazing();
1631  int pref = a_field->GetUnsprayedMarginPolyRef();
1632  if (pref != -1){
1633  // Must have an unsprayed margin so need to pass the information on to it
1634  LE* um = g_landscape_p->SupplyLEPointer(pref);
1635  um->ToggleCattleGrazing();
1636  }
1637  return true;
1638  }
1639  return false;
1640 }
1641 
1646 bool Farm::CattleIsOutLow(LE *a_field, double /*a_user*/, int a_days, int a_max)
1647 {
1648 
1649  // Generate a 'cattle_in_out' event for every day the cattle is on the
1650  // field.
1651  double biomass = a_field->GetVegBiomass();
1652  if (biomass > 100.0)
1653  {
1654  a_field->SetLastTreatment(cattle_out_low);
1655  a_field->Trace(cattle_out_low);
1656  // Reduce the vegetation because of grazing
1657  //double h=a_field->GetVegHeight();
1658  //double reduc = 1-(l_farm_cattle_veg_reduce2.value()*((h-15)/15));
1659  //a_field->ReduceVeg_Extended( reduc );
1660  a_field->GrazeVegetation( l_farm_cattle_veg_reduce2.value( ), false );
1661  int pref = a_field->GetUnsprayedMarginPolyRef();
1662  if (pref != -1)
1663  {
1664  // Must have an unsprayed margin so need to pass the information on to it
1665  LE* um = g_landscape_p->SupplyLEPointer(pref);
1668  }
1669  }
1670  int d1 = g_date->DayInYear(10, 9);
1671  if (d1 > a_max) d1 = a_max;
1672  if ((((g_date->DayInYear() > d1) && (10 >= a_days)) && DoIt(10)) || (0 >= a_days))
1673  {
1674  a_field->ToggleCattleGrazing();
1675  int pref = a_field->GetUnsprayedMarginPolyRef();
1676  if (pref != -1){
1677  // Must have an unsprayed margin so need to pass the information on to it
1678  LE* um = g_landscape_p->SupplyLEPointer(pref);
1679  um->ToggleCattleGrazing();
1680  }
1681  return true;
1682  }
1683  return false;
1684 }
1685 
1690 bool Farm::PigsOut( LE *a_field, double /*a_user*/, int a_days )
1691 {
1692 
1693  if ( (0 >= a_days)|| DoIt(DO_IT_PROB))
1694  {
1695  a_field->TogglePigGrazing();
1696  a_field->Trace( pigs_out );
1697  a_field->SetLastTreatment( pigs_out );
1698  // Reduce the vegetation because of grazing
1700  // make this a function of grazing pressure
1701  //and field size - perhaps in a later life
1702  int pref=a_field->GetUnsprayedMarginPolyRef();
1703  if (pref!=-1){
1704  // Must have an unsprayed margin so need to pass the information on to it
1705  LE* um=g_landscape_p->SupplyLEPointer(pref);
1706  um->SetLastTreatment( pigs_out );
1708  }
1709  return true;
1710  }
1711  return false;
1712 }
1713 
1718 bool Farm::PigsAreOutForced( LE *a_field, double /*a_user*/, int /*a_days*/)
1719 {
1720  a_field->SetLastTreatment( pigs_out );
1721  a_field->Trace( pigs_out );
1722  // Reduce the vegetation because of grazing
1724  // make this a function of grazing pressure
1725  //and field size - perhaps in a later life
1726  int pref=a_field->GetUnsprayedMarginPolyRef();
1727  if (pref!=-1){
1728  // Must have an unsprayed margin so need to pass the information on to it
1729  LE* um=g_landscape_p->SupplyLEPointer(pref);
1730  um->SetLastTreatment( pigs_out );
1732  }
1733  return false;
1734 }
1735 
1740 bool Farm::PigsAreOut( LE *a_field, double /*a_user*/, int a_days )
1741 {
1742 
1743  if ( (0 >= a_days)|| DoIt(50/a_days)) {
1744  a_field->TogglePigGrazing();
1745  int pref=a_field->GetUnsprayedMarginPolyRef();
1746  if (pref!=-1){
1747  // Must have an unsprayed margin so need to pass the information on to it
1748  LE* um=g_landscape_p->SupplyLEPointer(pref);
1749  um->TogglePigGrazing();
1750  }
1751  return true;
1752  }
1753  return false;
1754 }
1755 
1760 bool Farm::StrawChopping( LE *a_field, double /*a_user*/, int a_days )
1761 {
1762 
1763  if ( (0 >= a_days) ||
1764  ((g_weather->GetRainPeriod(g_date->Date(),5)<0.1) && DoIt(DO_IT_PROB))
1765  ) {
1766  a_field->Trace( straw_chopping );
1767  a_field->SetLastTreatment( straw_chopping );
1768  a_field->InsectMortality( 0.4 );
1770  int pref=a_field->GetUnsprayedMarginPolyRef();
1771  if (pref!=-1){
1772  // Must have an unsprayed margin so need to pass the information on to it
1773  LE* um=g_landscape_p->SupplyLEPointer(pref);
1775  um->InsectMortality( 0.4 );
1777  }
1778  return true;
1779  }
1780  return false;
1781 }
1782 
1787 bool Farm::HayTurning( LE *a_field, double /*a_user*/, int a_days )
1788 {
1789 
1790  if ( (0 >= a_days) ||
1791  ((g_weather->GetRainPeriod(g_date->Date(),5)<0.1) && DoIt(DO_IT_PROB))
1792  ) {
1793  a_field->Trace( hay_turning );
1794  a_field->SetLastTreatment( hay_turning );
1796  int pref=a_field->GetUnsprayedMarginPolyRef();
1797  if (pref!=-1){
1798  // Must have an unsprayed margin so need to pass the information on to it
1799  LE* um=g_landscape_p->SupplyLEPointer(pref);
1802  }
1803  return true;
1804  }
1805  return false;
1806 }
1807 
1812 bool Farm::HayBailing( LE *a_field, double /*a_user*/, int a_days )
1813 {
1814 
1815  if ( (0 >= a_days) ||
1816  ((g_weather->GetRainPeriod(g_date->Date(),5)<0.1) && DoIt(DO_IT_PROB))
1817  ) {
1818  a_field->Trace( hay_bailing );
1819  a_field->SetLastTreatment( hay_bailing );
1821  int pref=a_field->GetUnsprayedMarginPolyRef();
1822  if (pref!=-1){
1823  // Must have an unsprayed margin so need to pass the information on to it
1824  LE* um=g_landscape_p->SupplyLEPointer(pref);
1827  }
1828  return true;
1829  }
1830  return false;
1831 }
1832 
1837 bool Farm::StubbleHarrowing( LE *a_field, double /*a_user*/, int a_days )
1838 {
1839 
1840  if ( (0 >= a_days) ||
1841  ((g_weather->GetRainPeriod(g_date->Date(),3)<0.1) && DoIt(DO_IT_PROB))
1842  ) {
1843  a_field->Trace( stubble_harrowing );
1844  a_field->SetLastTreatment( stubble_harrowing );
1845  a_field->InsectMortality( 0.25 );
1846  a_field->ZeroVeg();
1847  int pref=a_field->GetUnsprayedMarginPolyRef();
1848  if (pref!=-1){
1849  // Must have an unsprayed margin so need to pass the information on to it
1850  LE* um=g_landscape_p->SupplyLEPointer(pref);
1852  um->ZeroVeg();
1853  um->InsectMortality( 0.25 );
1854  }
1855  return true;
1856  }
1857  return false;
1858 }
1859 
1864 bool Farm::BurnStrawStubble( LE *a_field, double /*a_user*/, int a_days )
1865 {
1866 
1867  if ( (0 >= a_days) && (g_weather->GetRainPeriod(g_date->Date(),3)>0.1))
1868  {
1869  return true;
1870  }
1871  if ( (0 >= a_days) || ((g_weather->GetRainPeriod(g_date->Date(),3)<0.1)
1872  && DoIt(DO_IT_PROB)))
1873  {
1874  a_field->Trace( burn_straw_stubble );
1876  a_field->InsectMortality( 0.4 );
1877  a_field->ReduceVeg( 0.2 );
1879  int pref=a_field->GetUnsprayedMarginPolyRef();
1880  if (pref!=-1){
1881  // Must have an unsprayed margin so need to pass the information on to it
1882  LE* um=g_landscape_p->SupplyLEPointer(pref);
1884  um->ReduceVeg( 0.2 );
1885  um->InsectMortality( 0.4 );
1887  }
1888  return true;
1889  }
1890  return false;
1891 }
1892 
1897 bool Farm::CutToHay( LE *a_field, double /*a_user*/, int a_days )
1898 {
1899 
1900  if ( (0 >= a_days) || ((g_weather->GetRainPeriod(g_date->Date(),5)<0.1)
1901  && DoIt(DO_IT_PROB)))
1902  {
1903  a_field->Trace( cut_to_hay );
1904  a_field->SetLastTreatment( cut_to_hay );
1905  a_field->SetGrowthPhase(harvest1);
1906  a_field->InsectMortality(0.4);
1907  a_field->ReduceVeg_Extended( 0.2 );
1908  a_field->SetVegHeight(10);
1909  //a_field->ResetDigestability();
1911  int pref=a_field->GetUnsprayedMarginPolyRef();
1912  if (pref!=-1){
1913  // Must have an unsprayed margin so need to pass the information on to it
1914  LE* um=g_landscape_p->SupplyLEPointer(pref);
1916  um->SetGrowthPhase(harvest1);
1917  um->InsectMortality(0.4);
1918  um->ReduceVeg_Extended( 0.2 );
1919  um->SetVegHeight( 10);
1921  }
1922  return true;
1923  }
1924  return false;
1925 }
1926 
1931 bool Farm::CutWeeds( LE *a_field, double /*a_user*/, int a_days )
1932 {
1933 
1934  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB)))
1935  {
1936  a_field->Trace( cut_weeds );
1937  a_field->SetLastTreatment( cut_weeds );
1938  a_field->ReduceVeg( 0.8 );
1940  int pref=a_field->GetUnsprayedMarginPolyRef();
1941  if (pref!=-1){
1942  // Must have an unsprayed margin so need to pass the information on to it
1943  LE* um=g_landscape_p->SupplyLEPointer(pref);
1944  um->SetLastTreatment( cut_weeds );
1945  um->ReduceVeg( 0.8 );
1947  }
1948  return true;
1949  }
1950  return false;
1951 }
1952 
1957 bool Farm::CutToSilage( LE *a_field, double /*a_user*/, int a_days )
1958 {
1959 
1960  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
1961  a_field->Trace( cut_to_silage );
1962  a_field->SetLastTreatment( cut_to_silage );
1963  a_field->ReduceVeg_Extended( 0.2 );
1964  a_field->InsectMortality( 0.4 );
1965  a_field->SetVegHeight( 10 );
1967  //a_field->ResetDigestability();
1968  int pref=a_field->GetUnsprayedMarginPolyRef();
1969  if (pref!=-1){
1970  // Must have an unsprayed margin so need to pass the information on to it
1971  LE* um=g_landscape_p->SupplyLEPointer(pref);
1973  um->ReduceVeg_Extended( 0.2 );
1974  um->InsectMortality( 0.4 );
1975  um->SetVegHeight( 10 );
1977  um->ResetDigestability();
1978  }
1979  return true;
1980  }
1981  return false;
1982 }
1983 
1988 bool Farm::CutOrch( LE *a_field, double /* a_user */, int a_days )
1989 {
1990 
1991  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
1992  a_field->Trace( mow ); //? tried to do=mow...
1993  a_field->SetLastTreatment( mow );
1994  a_field->SetMownDecay( 12 ); // 12 days of not suitable
1995  //ReduceVeg_Extended( 0.2 );
1996  //a_field->InsectMortality( 0.4 );
1997  a_field->SetGrowthPhase( harvest1 );
1998  //m_DateCut = a_today; ?? what to substitute it with?
1999 
2000  a_field->SetVegParameters( l_el_o_cut_height.value(), l_el_o_cut_total.value(), l_el_o_cut_green.value(), 0 ); //is 0 ok for weed biomass
2001 
2002  int pref=a_field->GetUnsprayedMarginPolyRef();
2003  if (pref!=-1){
2004  // Must have an unsprayed margin so need to pass the information on to it
2005  LE* um=g_landscape_p->SupplyLEPointer(pref);
2006  um->SetLastTreatment( mow );
2007  um->ReduceVeg_Extended( 0.2 ); //are these values ok?
2008  um->InsectMortality( 0.4 );
2009  um->SetVegParameters( l_el_o_cut_height.value(), l_el_o_cut_total.value(), l_el_o_cut_green.value(), 0 );
2010  }
2011  return true;
2012  }
2013  return false;
2014 }
2015 
2016 
2021 // Pesticide Trial Farm Function Code
2022 bool Farm::Trial_PesticideTreat_DateLimited(LE *a_field, double /*a_user*/, int /*a_days*/)
2023 {
2025  int year = g_landscape_p->SupplyYearNumber();
2026  if (year < cfg_productapplicstartyear.value()) return false;
2027  if (year > cfg_productapplicendyear.value()) return false;
2028  a_field->Trace(trial_insecticidetreat); // Debug function only
2030  a_field->InsectMortality(0.36); // Change this manually if it is really a herbicide
2032  a_field->SetSprayedToday(true);
2033  g_pest->DailyQueueAdd(a_field, l_pest_insecticide_amount.value());
2034  return true;
2035 }
2036 
2037 
2038 
2043 // Pesticide Trial Farm Function Code
2044 bool Farm::Trial_PesticideTreat( LE *a_field, double /*a_user*/, int /*a_days*/ )
2045 {
2047  a_field->Trace( trial_insecticidetreat );
2049  a_field->InsectMortality( 0.1 ); // Change this manually if it is really a herbicide
2051  return true;
2052 }
2053 
2058 // Pesticide Trial Farm Function Code
2059 bool Farm::Trial_PesticideTreat_GS( LE *a_field, double /*a_user*/, int /*a_days*/ )
2060 {
2061  // Can spray between two certain heights only, but we have to hope that we get called in time for the first so
2062  // right now we only care if we are above a certain height (timing is also important, so must not call this until
2063  // after a ploughing and sowing event
2064  if (a_field->GetVegHeight() < 3.0) return false;
2065  // All OK so here goes:
2066  a_field->Trace( trial_insecticidetreat );
2068  //a_field->InsectMortality( 0.1 ); // Change this manually if it is really a herbicide
2069  a_field->ReduceWeedBiomass( 0.05 );
2072  return true;
2073 }
2074 
2079 bool Farm::Trial_ToxicControl( LE *a_field, double /*a_user*/, int /*a_days*/ )
2080 {
2081  a_field->Trace( trial_toxiccontrol );
2083  a_field->InsectMortality( 0.001 );
2085  return true;
2086 }
2087 
2088 
2093 bool Farm::Trial_Control( LE *a_field, double /*a_user*/, int /*a_days*/ )
2094 {
2095  // Will always do this at the first chance
2096  a_field->Trace( trial_control );
2097  a_field->SetLastTreatment( trial_control );
2099  return true;
2100 }
2101 
2102 bool Farm::Glyphosate( LE *a_field, double /* a_user */, int /* a_days */)
2103 {
2104  // Will always do this at the first chance
2105  a_field->Trace( glyphosate );
2106  a_field->SetLastTreatment( glyphosate );
2107  a_field->InsectMortality( 0.5 );
2108  a_field->ReduceVeg_Extended( 0.05 );
2109  return true;
2110 }
#define LE_SIG_NO_FUNGICIDE
Definition: elements.h:40
CfgFloat l_pest_product_0_amount
static CfgInt l_farm_event_do_it_prob_long("FARM_EVENT_DO_IT_PROB_LONG", CFG_PRIVATE, 5)
#define EL_STRIGLING_DELAYTIME
Definition: elements.h:59
The landscape class containing all environmental and topographical data.
Definition: landscape.h:109
virtual bool StubbleHarrowing(LE *a_field, double a_user, int a_days)
Carry out stubble harrowing on a_field.
Definition: farmfuncs.cpp:1837
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:387
long Date(void)
Definition: calendar.h:57
class Pesticide * g_pest
Definition: pesticide.cpp:70
virtual bool BurnStrawStubble(LE *a_field, double a_user, int a_days)
Burn stubble on a_field.
Definition: farmfuncs.cpp:1864
CfgInt cfg_SB_InsecticideMonth("PEST_SBINSECTONEMONTH", CFG_CUSTOM, 5)
Provided to allow configuration control of the first insecticide spray in spring barley crops - this ...
virtual bool CutToSilage(LE *a_field, double a_user, int a_days)
Cut vegetation for silage on a_field.
Definition: farmfuncs.cpp:1957
virtual bool CattleIsOut(LE *a_field, double a_user, int a_days, int a_max)
Generate a &#39;cattle_out&#39; event for every day the cattle are on a_field.
Definition: farmfuncs.cpp:1602
#define LE_SIG_NO_MOLLUSC
Definition: elements.h:44
CfgFloat l_el_o_cut_height
static CfgBool l_farm_insecticide_kills("FARM_INSECTICIDE_KILLS", CFG_CUSTOM, true)
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
virtual bool Strigling(LE *a_field, double a_user, int a_days)
Carry out a mechanical weeding on a_field.
Definition: farmfuncs.cpp:1229
virtual void SetInsectPop(double)
Definition: elements.h:157
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
CfgInt cfg_SB_InsecticideDay("PEST_SBINSECTONEDAY", CFG_CUSTOM, 15)
Provided to allow configuration control of the first insecticide spray in spring barley crops - this ...
virtual bool HillingUp(LE *a_field, double a_user, int a_days)
Do hilling up on a_field, probably of potatoes.
Definition: farmfuncs.cpp:1318
virtual bool CutWeeds(LE *a_field, double a_user, int a_days)
Carry out weed topping on a_field.
Definition: farmfuncs.cpp:1931
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:512
virtual bool PigsAreOut(LE *a_field, double a_user, int a_days)
Start a pig grazing event on a_field today or soon.
Definition: farmfuncs.cpp:1740
virtual void SetVegParameters(double, double, double, double)
Definition: elements.h:166
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:708
virtual void TogglePigGrazing(void)
Definition: elements.h:162
virtual bool FA_Sludge(LE *a_field, double a_user, int a_days)
Spread sewege sludge on a_field owned by an stock farmer.
Definition: farmfuncs.cpp:758
void Add_no_fi_app()
Definition: elements.h:579
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:438
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:338
virtual bool InsecticideTreat(LE *a_field, double, int a_days)
Carries out insecticide application. Saves information on each application for a given crop...
Definition: farmfuncs.cpp:1006
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:659
#define LE_SIG_NO_HERBICIDE
Definition: elements.h:45
virtual bool Molluscicide(LE *a_field, double a_user, int a_days)
Apply molluscidie to a_field.
Definition: farmfuncs.cpp:1167
double GetWind(long a_date)
Definition: weather.h:425
#define LE_SIG_NO_GROWTH_REG
Definition: elements.h:43
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:284
Integer configurator entry class.
Definition: configurator.h:85
virtual bool FA_GreenManure(LE *a_field, double a_user, int a_days)
Spread green manure on a_field owned by an stock farmer.
Definition: farmfuncs.cpp:734
virtual bool FP_Manure(LE *a_field, double a_user, int a_days)
Spread manure on a_field owned by an arable farmer.
Definition: farmfuncs.cpp:536
void DailyQueueAdd(LE *a_element_sprayed, double a_amount)
Definition: pesticide.cpp:105
virtual bool FungicideTreat(LE *a_field, double a_user, int a_days)
Apply fungicide to a_field.
Definition: farmfuncs.cpp:902
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:611
virtual double GetVegHeight(void)
Definition: elements.h:135
virtual bool PigsAreOutForced(LE *a_field, double a_user, int a_days)
Start a pig grazing event on a_field today - no exceptions.
Definition: farmfuncs.cpp:1718
CfgInt cfg_OSR_InsecticideDay("PEST_OSRINSECTONEDAY", CFG_CUSTOM, 30)
Provided to allow configuration control of the first insecticide spray in OSR - this changes the day ...
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:414
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
static CfgFloat l_farm_cattle_veg_reduce("FARM_CATTLE_VEG_REDUCE", CFG_CUSTOM, 1.5)
virtual bool Trial_Control(LE *a_field, double a_user, int a_days)
Special pesticide trial functionality.
Definition: farmfuncs.cpp:2093
#define DO_IT_PROB_LONG
Definition: farmfuncs.cpp:59
virtual bool CattleIsOutLow(LE *a_field, double a_user, int a_days, int a_max)
Generate a &#39;cattle_out_low&#39; event for every day the cattle are on a_field.
Definition: farmfuncs.cpp:1646
double value(void)
Definition: configurator.h:107
Definition: elements.h:81
virtual bool CattleOutLowGrazing(LE *a_field, double a_user, int a_days)
Start a extensive grazing event on a_field today.
Definition: farmfuncs.cpp:1572
virtual bool HerbicideTreat(LE *a_field, double, int a_days)
Carries out herbicide application. Saves information on each application for a given crop...
Definition: farmfuncs.cpp:821
CfgFloat l_pest_product_1_amount
virtual bool CutToHay(LE *a_field, double a_user, int a_days)
Carry out hay cutting on a_field.
Definition: farmfuncs.cpp:1897
void SetSprayedToday(bool a_didit)
Definition: elements.h:297
void SetMownDecay(int a_decaytime_days)
Definition: elements.h:308
void SetLastSownVeg(TTypesOfVegetation a_tov)
Records the last vegetation type to be sown.
Definition: elements.h:287
virtual void SetVegHeight(double)
Definition: elements.h:165
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:204
class Weather * g_weather
Definition: weather.cpp:41
CfgInt l_pest_productapplic_startdate
void Add_no_herb_app()
Definition: elements.h:576
virtual bool Trial_PesticideTreat_GS(LE *a_field, double a_user, int a_days)
Special pesticide trial functionality.
Definition: farmfuncs.cpp:2059
virtual TTypesOfVegetation GetVegType(void)
Definition: elements.h:509
double GetTemp(long a_date)
Get the temperature on a particular date.
Definition: weather.h:417
virtual TTypesOfVegetation GetVegType(void)
Definition: elements.h:125
virtual void ReduceVeg(double)
Definition: elements.h:175
static CfgInt l_farm_event_do_it_prob("FARM_EVENT_DO_IT_PROB", CFG_PRIVATE, 50)
virtual bool StrawChopping(LE *a_field, double a_user, int a_days)
Carry out straw chopping on a_field.
Definition: farmfuncs.cpp:1760
int SupplyYearNumber(void)
Definition: landscape.h:1542
bool value(void)
Definition: configurator.h:123
virtual double GetVegBiomass(void)
Definition: elements.h:154
CfgInt cfg_productapplicendyear
virtual void ResetDigestability()
sets growth record to zero in descendent classes
Definition: elements.h:370
virtual void ReduceVeg_Extended(double)
Definition: elements.h:176
int DayInYear(void)
Definition: calendar.h:58
CfgFloat l_pest_insecticide_amount
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:486
bool Raining(void)
Definition: weather.h:432
virtual bool Water(LE *a_field, double a_user, int a_days)
Carry out a watering on a_field.
Definition: farmfuncs.cpp:1345
#define EL_HERBICIDE_DELAYTIME
Definition: elements.h:58
Definition: plants.h:51
virtual bool FA_AmmoniumSulphate(LE *a_field, double a_user, int a_days)
Apply ammonium supahte to a_field owned by an stock farmer.
Definition: farmfuncs.cpp:684
CfgInt l_pest_productapplic_enddate
virtual void ToggleCattleGrazing(void)
Definition: elements.h:161
CfgFloat l_el_o_cut_green
void Set_biomass_at_harvest(double a_biomass, int index)
Definition: elements.h:571
CfgBool cfg_OptimiseBedriftsmodelCrops
If set to true, the original farm optimisation model&#39;s crop set is used in the farmer decision making...
virtual bool InsecticideTreat(LE *a_field, double a_user, int a_days)
Apply insecticide to a_field.
Definition: farmfuncs.cpp:967
virtual void InsectMortality(double)
Definition: elements.h:159
Definition: treatment.h:82
virtual bool CutOrch(LE *a_field, double a_user, int a_days)
Cut vegetation on orchard crop. //based on cut to silage - values from cutting function of orchard...
Definition: farmfuncs.cpp:1988
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:181
virtual bool HarvestLong(LE *a_field, double a_user, int a_days)
Carry out a harvest on a_field.
Definition: farmfuncs.cpp:1449
Bool configurator entry class.
Definition: configurator.h:116
virtual bool HayBailing(LE *a_field, double a_user, int a_days)
Carry out hay bailing on a_field.
Definition: farmfuncs.cpp:1812
class Calendar * g_date
Definition: calendar.cpp:38
CfgFloat l_el_o_cut_total
static CfgBool l_farm_herbicide_kills("FARM_PESTICIDE_KILLS", CFG_CUSTOM, true)
virtual bool Glyphosate(LE *a_field, double a_user, int a_days)
Definition: farmfuncs.cpp:2102
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
virtual bool FP_GreenManure(LE *a_field, double a_user, int a_days)
Spread green manure on a_field owned by an arable farmer.
Definition: farmfuncs.cpp:561
static CfgFloat l_farm_cattle_veg_reduce2("FARM_CATTLE_VEG_REDUCE_LOW", CFG_CUSTOM, 1.00)
CfgInt cfg_productapplicstartyear
Landscape * g_landscape_p
Definition: Landscape.cpp:238
void SetBirdMaize(double a_forage)
Definition: elements.h:207
#define LE_SIG_NO_SYNG_INSECT
Definition: elements.h:42
CfgInt cfg_WW_InsecticideMonth("PEST_WWINSECTONEMONTH", CFG_CUSTOM, 5)
Provided to allow configuration control of the first insecticide spray in winter wheat - this changes...
CfgInt cfg_OSR_InsecticideMonth("PEST_OSRINSECTONEMONTH", CFG_CUSTOM, 4)
Provided to allow configuration control of the first insecticide spray in OSR - this changes the mont...
virtual bool DeepPlough(LE *a_field, double a_user, int a_days)
Carry out a deep ploughing event on a_field.
Definition: farmfuncs.cpp:257
LE_Signal GetSignal(void)
Definition: elements.h:107
static CfgFloat l_farm_pig_veg_reduce("FARM_PIG_VEG_REDUCE", CFG_CUSTOM, 0.98)
virtual void Insecticide(double)
Definition: elements.h:158
virtual void SetGrowthPhase(int)
Definition: elements.h:170
int value(void)
Definition: configurator.h:92
virtual void RecalculateBugsNStuff(void)
Definition: elements.h:132
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:100
virtual bool Trial_PesticideTreat(LE *a_field, double a_user, int a_days)
Special pesticide trial functionality.
Definition: farmfuncs.cpp:2044
CfgInt cfg_WW_InsecticideDay("PEST_WWINSECTONEDAY", CFG_CUSTOM, 1)
Provided to allow configuration control of the first insecticide spray in winter wheat - this changes...
virtual bool PigsOut(LE *a_field, double a_user, int a_days)
Generate a &#39;pigs_out&#39; event for every day the cattle are on a_field.
Definition: farmfuncs.cpp:1690
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:154
virtual bool ProductApplication1(LE *a_field, double a_user, int a_days)
Apply test pesticide to a_field.
Definition: farmfuncs.cpp:1132
virtual bool Trial_PesticideTreat_DateLimited(LE *a_field, double, int)
Special pesticide trial functionality.
Definition: farmfuncs.cpp:2022
void SetBirdSeed(double a_forage)
Definition: elements.h:201
double GetRainPeriod(long a_date, unsigned int a_period)
Definition: weather.cpp:278
virtual bool ProductApplication0(LE *a_field, double a_user, int a_days)
Apply test pesticide to a_field.
Definition: farmfuncs.cpp:1099
CfgInt l_pest_productapplic_period
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:311
virtual bool SleepAllDay(LE *a_field, double a_user, int a_days)
Nothing to to today on a_field.
Definition: farmfuncs.cpp:136
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:1194
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
bool Harvest(LE *a_field, double a_user, int a_days)
OptimisingFarm&#39;s virtual version of Farm::Harvest(). Saves information on biomass of a crop at harves...
Definition: farmfuncs.cpp:1487
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:1372
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:359
void SetHerbicideDelay(int a_decaytime_days)
Definition: elements.h:306
virtual bool FungicideTreat(LE *a_field, double, int a_days)
Carries out fungicide application. Saves information on each application for a given crop...
Definition: farmfuncs.cpp:928
virtual bool GrowthRegulator(LE *a_field, double a_user, int a_days)
Apply growth regulator to a_field.
Definition: farmfuncs.cpp:873
Double configurator entry class.
Definition: configurator.h:100
virtual bool HerbicideTreat(LE *a_field, double a_user, int a_days)
Apply herbicide to a_field.
Definition: farmfuncs.cpp:784
void Set_harvested()
Definition: elements.h:573
virtual void GrazeVegetation(double, bool)
Definition: elements.h:225
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:462
virtual bool StriglingSow(LE *a_field, double a_user, int a_days)
Carry out a mechanical weeding followed by sowing on a_field.
Definition: farmfuncs.cpp:1281
virtual void ZeroVeg(void)
Definition: elements.h:174
virtual bool Harvest(LE *a_field, double a_user, int a_days)
Carry out a harvest on a_field.
Definition: farmfuncs.cpp:1397
virtual void ReduceWeedBiomass(double)
Definition: elements.h:160
virtual double GetInsectPop(void)
Definition: elements.h:156
virtual bool FA_PK(LE *a_field, double a_user, int a_days)
Apply PK fertilizer to a_field owned by an stock farmer.
Definition: farmfuncs.cpp:635
virtual bool FP_Sludge(LE *a_field, double a_user, int a_days)
Spread sewege on a_field owned by an arable farmer.
Definition: farmfuncs.cpp:585
void Trace(int a_value)
Definition: elements.cpp:459
virtual bool Trial_ToxicControl(LE *a_field, double a_user, int a_days)
Special pesticide trial functionality.
Definition: farmfuncs.cpp:2079
virtual bool WinterPlough(LE *a_field, double a_user, int a_days)
Carry out a ploughing event in the winter on a_field.
Definition: farmfuncs.cpp:232
virtual bool SynInsecticideTreat(LE *a_field, double a_user, int a_days)
Apply special insecticide to a_field.
Definition: farmfuncs.cpp:1061
virtual bool HayTurning(LE *a_field, double a_user, int a_days)
Carry out hay turning on a_field.
Definition: farmfuncs.cpp:1787
#define LE_SIG_NO_INSECTICIDE
Definition: elements.h:41
virtual bool CattleOut(LE *a_field, double a_user, int a_days)
Start a grazing event on a_field today.
Definition: farmfuncs.cpp:1538