File failed to load: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/extensions/ams.js
ALMaSS  1.2 (after EcoStack, March 2024)
The Animal, Landscape and Man Simulation System
All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DE_OMaizeSilage Class Reference

#include <DE_OMaizeSilage.h>

Inheritance diagram for DE_OMaizeSilage:
Crop

Public Member Functions

bool Do (Farm *a_farm, LE *a_field, FarmEvent *a_ev)
 
 DE_OMaizeSilage (TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape *a_L)
 
void SetUpFarmCategoryInformation ()
 
- Public Member Functions inherited from Crop
virtual ~Crop ()
 
 Crop (TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape *a_L)
 
int GetFirstDate (void)
 
void ChooseNextCrop (int a_no_dates)
 Chooses the next crop to grow in a field. More...
 
int GetCropClassification ()
 
void SetCropClassification (int a_classification)
 
void GetCropType (TTypesOfCrops a_toc)
 
TTypesOfCrops GetCropType ()
 
FarmManagementCategory LookUpManagementCategory (int a_todo)
 
bool GetForceSpringOK ()
 

Additional Inherited Members

- Public Attributes inherited from Crop
TTypesOfVegetation m_tov
 
- Protected Member Functions inherited from Crop
void SimpleEvent (long a_date, int a_todo, bool a_lock)
 Adds an event to this crop management. More...
 
void SimpleEvent_ (long a_date, int a_todo, bool a_lock, Farm *a_farm, LE *a_field)
 Adds an event to this crop management without relying on member variables. More...
 
bool StartUpCrop (int a_spring, std::vector< std::vector< int >> a_flexdates, int a_todo)
 
Holds the translation between the farm operation enum for each cropand the farm management category associated with it More...
 
bool AphidDamage (LE *a_field)
 Compares aphid numbers per m2 with a threshold to return true if threshold is exceeded. More...
 
- Protected Attributes inherited from Crop
Farmm_farm
 
LEm_field
 
FarmEventm_ev
 
int m_first_date
 
int m_count
 
int m_last_date
 
int m_ddegstoharvest
 
int m_base_elements_no
 
Landscapem_OurLandscape
 
bool m_forcespringpossible = false
 Used to signal that the crop can be forced to start in spring. More...
 
TTypesOfCrops m_toc
 The Crop type in terms of the TTypesOfCrops list (smaller list than tov, no country designation) More...
 
int m_CropClassification
 Contains information on whether this is a winter crop, spring crop, or catch crop that straddles the year boundary (0,1,2) More...
 
vector< FarmManagementCategorym_ManagementCategories
 Holds the translation between the farm operation enum for each crop and the farm management category associated with it. More...
 
- Static Protected Attributes inherited from Crop
static int m_date_modifier = 0
 Holds a value that shifts test pesticide use by this many days in crops modified to use it. More...
 

Constructor & Destructor Documentation

◆ DE_OMaizeSilage()

DE_OMaizeSilage::DE_OMaizeSilage ( TTypesOfVegetation  a_tov,
TTypesOfCrops  a_toc,
Landscape a_L 
)
inline
62  : Crop(a_tov, a_toc, a_L)
63  {
64  m_first_date = g_date->DayInYear(25, 4);
66  }

References Calendar::DayInYear(), g_date, Crop::m_first_date, and SetUpFarmCategoryInformation().

Member Function Documentation

◆ Do()

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

Reimplemented from Crop.

33 {
34  /******************** This block can be added to the top of all Crop::Do methods ***********************************************/
35  m_farm = a_farm; // These assignments are necessary, not for this method but for related event calls
36  m_field = a_field;
37  m_ev = a_ev;
38  bool done = false; // The boolean value done indicates when we are totally finished with this plan (i.e. it is set to true).
39  int d1 = 0;
40  TTypesOfVegetation l_tov = tov_DEMaizeSilage; // The current type - change to match the crop you have
41  /**********************************************To Here *************************************************************************/
42 
43  // Depending what event has occured jump to the correct bit of code
44  switch (m_ev->m_todo)
45  {
46  case de_oms_start:
47  {
50 
51  m_last_date = g_date->DayInYear(29, 9); // Should match the last flexdate below
52  //Create a 2d array of 1 plus the number of operations you use. Change only 4+1 to what you need in the line below
53  std::vector<std::vector<int>> flexdates(1 + 1, std::vector<int>(2, 0));
54  // Set up the date management stuff
55  // Start and stop dates for all events after harvest
56  flexdates[0][1] = g_date->DayInYear(19, 9); // last possible day of harvest - this is in effect day before the earliest date that a following crop can use
57  // Now these are done in pairs, start & end for each operation. If its not used then -1
58  flexdates[1][0] = -1; // This date will be moved back as far as necessary and potentially to flexdates 1 (start op 1)
59  flexdates[1][1] = g_date->DayInYear(29, 9); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 1)
60 
61 
62  // Below if this is a spring crop use 365, otherwise set this to 0, second parameter is fixed, and the third is the start up operation in the first year
63  int isSpring = 365;
64  if (StartUpCrop(isSpring, flexdates, int(de_oms_spring_plough))) break;
65 
66  // End single block date checking code. Please see next line comment as well.
67  // Reinit d1 to first possible starting date.
68  d1 = g_date->OldDays() + g_date->DayInYear(20, 3) + isSpring;
69  // OK, let's go.
70  if (m_farm->IsStockFarmer()) //Stock Farmer
71  {
73  }
74  else SimpleEvent_(d1, de_oms_fp_manure, false, m_farm, m_field);
75  break;
76  }
77  break;
78 
79  case de_oms_fa_manure:
80  if (!m_farm->FA_Manure(m_field, 0.0, g_date->DayInYear(25, 4) - g_date->DayInYear())) {
82  break;
83  }
84  d1 = g_date->OldDays() + g_date->DayInYear(1, 4);
85  if (g_date->Date() + 1 > d1) {
86  d1 = g_date->Date() + 1;
87  }
89  break;
90 
92  if (m_ev->m_lock || m_farm->DoIt_prob(0.50))
93  {
94  if (!m_farm->FA_Slurry(m_field, 0.0, g_date->DayInYear(30, 4) - g_date->DayInYear())) {
96  break;
97  }
98  }
100  break;
101 
102  case de_oms_fp_manure:
103  if (m_ev->m_lock || m_farm->DoIt_prob(0.80))
104  {
105  if (!m_farm->FP_Manure(m_field, 0.0, g_date->DayInYear(25, 4) - g_date->DayInYear())) {
107  break;
108  }
109  }
110  d1 = g_date->OldDays() + g_date->DayInYear(1, 4);
111  if (g_date->Date() + 1 > d1) {
112  d1 = g_date->Date() + 1;
113  }
115  break;
116 
118  if (m_ev->m_lock || m_farm->DoIt_prob(0.20))
119  {
120  if (!m_farm->FP_Slurry(m_field, 0.0, g_date->DayInYear(30, 4) - g_date->DayInYear())) {
122  break;
123  }
124  }
126  break;
127 
129  if (!m_farm->SpringPlough( m_field, 0.0, g_date->DayInYear( 1, 5 ) - g_date->DayInYear())) {
131  break;
132  }
134  break;
135 
137  if (!m_farm->SpringHarrow( m_field, 0.0, g_date->DayInYear( 5, 5 ) - g_date->DayInYear())) {
139  break;
140  }
141  d1 = g_date->OldDays() + g_date->DayInYear( 25, 4 );
142  if ( g_date->Date() > d1 ) {
143  d1 = g_date->Date();
144  }
146  break;
147 
148  case de_oms_spring_sow:
149  if (!m_farm->SpringSow( m_field, 0.0, g_date->DayInYear( 15, 5 ) - g_date->DayInYear())) {
151  break;
152  }
155  break;
156 
157  case de_oms_strigling:
158  if (!m_farm->Strigling( m_field, 0.0, g_date->DayInYear( 20, 5 ) - g_date->DayInYear())) {
160  break;
161  }
162  d1 = g_date->OldDays() + g_date->DayInYear( 2, 5 );
163  if ( DE_OMAIZESILAGE_SOW_DATE + 7 > d1 ) {
164  d1 = DE_OMAIZESILAGE_SOW_DATE + 7;
165  }
166  SimpleEvent_( d1, de_oms_row_one, false, m_farm, m_field);
167  break;
168 
169  case de_oms_row_one:
170  if (!m_farm->RowCultivation( m_field, 0.0, g_date->DayInYear( 25, 5 ) - g_date->DayInYear())) {
172  break;
173  }
174  d1 = g_date->OldDays() + g_date->DayInYear( 1, 5 );
175  if ( DE_OMAIZESILAGE_SOW_DATE + 5 > d1 ) {
176  d1 = DE_OMAIZESILAGE_SOW_DATE + 5;
177  }
178  if (m_farm->IsStockFarmer()) //Stock Farmer
179  {
181  }
182  else SimpleEvent_(d1, de_oms_fp_slurry_two, false, m_farm, m_field);
183  break;
184 
186  if (!m_farm->FA_Slurry(m_field, 0.0, g_date->DayInYear(25, 5) - g_date->DayInYear())) {
188  break;
189  }
190  d1 = g_date->OldDays() + g_date->DayInYear(21, 5);
191  if (g_date->Date() + 1 > d1) {
192  d1 = g_date->Date() + 1;
193  }
195  break;
196 
198  if (!m_farm->FP_Slurry(m_field, 0.0, g_date->DayInYear(25, 5) - g_date->DayInYear())) {
200  break;
201  }
202  d1 = g_date->OldDays() + g_date->DayInYear(21, 5);
203  if (g_date->Date() + 1 > d1) {
204  d1 = g_date->Date() + 1;
205  }
207  break;
208 
209  case de_oms_row_two:
210  if (!m_farm->RowCultivation( m_field, 0.0, g_date->DayInYear( 20, 6 ) - g_date->DayInYear())) {
212  break;
213  }
214  // LKM: Queue up the next event - row cultivation3 done 15 days after
216  break;
217  case de_oms_row_three:
218  if (m_ev->m_lock || m_farm->DoIt_prob(0.50))
219  {
220  //LKM: do row cultivaton before 15th of July - if not done, try again +1 day until the the 15th of July when we succeed
221  if (!m_farm->RowCultivation(m_field, 0.0, g_date->DayInYear(15, 7) - g_date->DayInYear())) {
223  break;
224  }
225  }
227  break;
228 
229  case de_oms_water:
230  if ( m_ev->m_lock || m_farm->DoIt( 10 )) {
231  if (!m_farm->Water( m_field, 0.0, g_date->DayInYear( 30, 7 ) - g_date->DayInYear())) {
233  break;
234  }
235  }
237  break;
238 
239  case de_oms_harvest:
240  if (!m_farm->Harvest( m_field, 0.0, m_field->GetMDates(1,0) - g_date->DayInYear())) {
242  break;
243  }
244  d1 = g_date->OldDays() + m_field->GetMDates(0,1);
245  if ( g_date->Date() > d1 ) {
246  d1 = g_date->Date();
247  }
248  SimpleEvent_( d1, de_oms_stubble, false, m_farm, m_field);
249  break;
250 
251  case de_oms_stubble:
252  if ( m_ev->m_lock || m_farm->DoIt( 25 )) {
253  if (!m_farm->StubbleHarrowing( m_field, 0.0, m_field->GetMDates(1,1) - g_date->DayInYear())) {
255  break;
256  }
257  }
258  d1=g_date->DayInYear();
259  done = true;
260  break;
261 
262  default:
263  g_msg->Warn( WARN_BUG, "DE_OMaizeSilage::Do(): "
264  "Unknown event type! ", "" );
265  exit( 1 );
266  }
267  return done;
268 }

References LE::ClearManagementActionSum(), Calendar::Date(), Calendar::DayInYear(), DE_OMAIZESILAGE_SOW_DATE, de_oms_fa_manure, de_oms_fa_slurry_one, de_oms_fa_slurry_two, de_oms_fp_manure, de_oms_fp_slurry_one, de_oms_fp_slurry_two, de_oms_harvest, de_oms_row_one, de_oms_row_three, de_oms_row_two, de_oms_spring_harrow, de_oms_spring_plough, de_oms_spring_sow, de_oms_start, de_oms_strigling, de_oms_stubble, de_oms_water, Farm::DoIt(), Farm::DoIt_prob(), Farm::FA_Manure(), Farm::FA_Slurry(), Farm::FP_Manure(), Farm::FP_Slurry(), g_date, g_msg, LE::GetMDates(), Farm::Harvest(), Farm::IsStockFarmer(), Crop::m_ev, Crop::m_farm, Crop::m_field, Crop::m_last_date, FarmEvent::m_lock, FarmEvent::m_todo, Calendar::OldDays(), Farm::RowCultivation(), Crop::SimpleEvent_(), Farm::SpringHarrow(), Farm::SpringPlough(), Farm::SpringSow(), Crop::StartUpCrop(), Farm::Strigling(), Farm::StubbleHarrowing(), tov_DEMaizeSilage, MapErrorMsg::Warn(), WARN_BUG, and Farm::Water().

◆ SetUpFarmCategoryInformation()

void DE_OMaizeSilage::SetUpFarmCategoryInformation ( )
inline
67  {
68  const int elements = 2 + (de_oms_foobar - DE_OMAIZESILAGE_BASE);
70 
71  FarmManagementCategory catlist[elements] =
72  {
73  fmc_Others, // zero element unused but must be here
74  fmc_Others, // de_oms_start = 1, // Compulsory, start event must always be 1 (one).
75  fmc_Others, // de_om_sleep_all_day = DE_OMAIZESILAGE_BASE,
76  fmc_Fertilizer, // de_oms_fa_manure_b,
77  fmc_Fertilizer, // de_oms_fp_manure_b,
78  fmc_Fertilizer, // de_oms_fa_slurry_one,
79  fmc_Fertilizer, // de_oms_fp_slurry_one,
80  fmc_Cultivation, // de_oms_spring_plough,
81  fmc_Cultivation, // de_oms_spring_harrow,
82  fmc_Others, // de_oms_spring_sow,
83  fmc_Cultivation, // de_oms_strigling,
84  fmc_Cultivation, // de_oms_row_one,
85  fmc_Fertilizer, // de_oms_fa_slurry_two,
86  fmc_Fertilizer, // de_oms_fp_slurry_two,
87  fmc_Cultivation, // de_oms_row_two,
88  fmc_Cultivation, // de_oms_row_three,
89  fmc_Others, // de_oms_water,
90  fmc_Harvest, // de_oms_harvest,
91  fmc_Cultivation, // de_oms_stubble,
92 
93 
94  // no foobar entry
95 
96  };
97  // Iterate over the catlist elements and copy them to vector
98  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
99 
100  }

References DE_OMAIZESILAGE_BASE, de_oms_foobar, fmc_Cultivation, fmc_Fertilizer, fmc_Harvest, fmc_Others, Crop::m_base_elements_no, and Crop::m_ManagementCategories.

Referenced by DE_OMaizeSilage().


The documentation for this class was generated from the following files:
LE::GetMDates
int GetMDates(int a, int b)
Definition: Elements.h:405
de_oms_fa_slurry_two
Definition: DE_OMaizeSilage.h:46
de_oms_fa_manure
Definition: DE_OMaizeSilage.h:37
de_oms_start
Definition: DE_OMaizeSilage.h:35
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:1067
de_oms_spring_plough
Definition: DE_OMaizeSilage.h:41
Farm::SpringPlough
virtual bool SpringPlough(LE *a_field, double a_user, int a_days)
Carry out a ploughing event in the spring on a_field.
Definition: FarmFuncs.cpp:421
Farm::IsStockFarmer
bool IsStockFarmer(void)
Definition: Farm.h:961
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:1206
Farm::Harvest
virtual bool Harvest(LE *a_field, double a_user, int a_days)
Carry out a harvest on a_field.
Definition: FarmFuncs.cpp:1364
FarmEvent::m_lock
bool m_lock
Definition: Farm.h:384
LE::ClearManagementActionSum
void ClearManagementActionSum()
clears the management action counters
Definition: Elements.h:247
Farm::DoIt
bool DoIt(double a_probability)
Return chance out of 0 to 100.
Definition: Farm.cpp:856
Farm::DoIt_prob
bool DoIt_prob(double a_probability)
Return chance out of 0 to 1.
Definition: Farm.cpp:864
g_date
class Calendar * g_date
Definition: Calendar.cpp:37
de_oms_strigling
Definition: DE_OMaizeSilage.h:44
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:1110
de_oms_row_two
Definition: DE_OMaizeSilage.h:48
de_oms_spring_sow
Definition: DE_OMaizeSilage.h:43
Farm::SpringSow
virtual bool SpringSow(LE *a_field, double a_user, int a_days, double a_seed_coating_amount=-1, PlantProtectionProducts a_ppp=ppp_foobar)
Carry out a sowing event in the spring on a_field.
Definition: FarmFuncs.cpp:501
Crop::m_base_elements_no
int m_base_elements_no
Definition: Farm.h:505
Crop::m_first_date
int m_first_date
Definition: Farm.h:501
Farm::FP_Manure
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:896
DE_OMAIZESILAGE_SOW_DATE
#define DE_OMAIZESILAGE_SOW_DATE
Definition: DE_OMaizeSilage.h:32
de_oms_water
Definition: DE_OMaizeSilage.h:50
fmc_Fertilizer
Definition: LandscapeFarmingEnums.h:1004
DE_OMaizeSilage::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: DE_OMaizeSilage.h:67
Calendar::Date
long Date(void)
Definition: Calendar.h:57
de_oms_fp_manure
Definition: DE_OMaizeSilage.h:38
fmc_Cultivation
Definition: LandscapeFarmingEnums.h:1008
fmc_Others
Definition: LandscapeFarmingEnums.h:1003
Calendar::OldDays
long OldDays(void)
Definition: Calendar.h:60
MapErrorMsg::Warn
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: MapErrorMsg.cpp:69
de_oms_fp_slurry_two
Definition: DE_OMaizeSilage.h:47
Crop::StartUpCrop
bool StartUpCrop(int a_spring, std::vector< std::vector< int >> a_flexdates, int a_todo)
Holds the translation between the farm operation enum for each cropand the farm management category a...
Definition: Farm.cpp:652
DE_OMAIZESILAGE_BASE
#define DE_OMAIZESILAGE_BASE
Definition: DE_OMaizeSilage.h:31
de_oms_row_three
Definition: DE_OMaizeSilage.h:49
Crop::m_farm
Farm * m_farm
Definition: Farm.h:498
Crop::m_field
LE * m_field
Definition: Farm.h:499
Crop::m_ManagementCategories
vector< FarmManagementCategory > m_ManagementCategories
Holds the translation between the farm operation enum for each crop and the farm management category ...
Definition: Farm.h:530
FarmEvent::m_todo
int m_todo
Definition: Farm.h:388
de_oms_harvest
Definition: DE_OMaizeSilage.h:51
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:823
Farm::RowCultivation
virtual bool RowCultivation(LE *a_field, double a_user, int a_days)
Carry out a harrowing between crop rows on a_field.
Definition: FarmFuncs.cpp:1183
Farm::Water
virtual bool Water(LE *a_field, double a_user, int a_days)
Carry out a watering on a_field.
Definition: FarmFuncs.cpp:1330
Crop::m_last_date
int m_last_date
Definition: Farm.h:503
de_oms_stubble
Definition: DE_OMaizeSilage.h:52
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
de_oms_fp_slurry_one
Definition: DE_OMaizeSilage.h:40
TTypesOfVegetation
TTypesOfVegetation
Values that represent the types of vegetation that are represented in ALMaSS.
Definition: LandscapeFarmingEnums.h:192
fmc_Harvest
Definition: LandscapeFarmingEnums.h:1012
de_oms_row_one
Definition: DE_OMaizeSilage.h:45
Calendar::DayInYear
int DayInYear(void)
Definition: Calendar.h:58
Crop::Crop
Crop(TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape *a_L)
Definition: Farm.cpp:733
de_oms_fa_slurry_one
Definition: DE_OMaizeSilage.h:39
tov_DEMaizeSilage
Definition: LandscapeFarmingEnums.h:478
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
WARN_BUG
Definition: MapErrorMsg.h:34
de_oms_spring_harrow
Definition: DE_OMaizeSilage.h:42
FarmManagementCategory
FarmManagementCategory
Definition: LandscapeFarmingEnums.h:1001
Farm::StubbleHarrowing
virtual bool StubbleHarrowing(LE *a_field, double a_user, int a_days)
Carry out stubble harrowing on a_field.
Definition: FarmFuncs.cpp:1523
Farm::SpringHarrow
virtual bool SpringHarrow(LE *a_field, double a_user, int a_days)
Carry out a harrow event in the spring on a_field.
Definition: FarmFuncs.cpp:459
de_oms_foobar
Definition: DE_OMaizeSilage.h:53
Crop::SimpleEvent_
void SimpleEvent_(long a_date, int a_todo, bool a_lock, Farm *a_farm, LE *a_field)
Adds an event to this crop management without relying on member variables.
Definition: Farm.cpp:751