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_OMaize Class Reference

#include <DE_OMaize.h>

Inheritance diagram for DE_OMaize:
Crop

Public Member Functions

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

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

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

Member Function Documentation

◆ Do()

bool DE_OMaize::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_DEOMaize; // 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_om_start:
47  {
50 
51  m_last_date = g_date->DayInYear(30, 10); // 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(25, 10); // last possible day of harvest - this is in effect day before the earliest date that a following crop can use
57 
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(30, 10); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 1)
60 
61  // 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
62  int isSpring = 365;
63  if (StartUpCrop(isSpring, flexdates, int(de_om_spring_plough))) break;
64 
65  // End single block date checking code. Please see next line comment as well.
66  // Reinit d1 to first possible starting date.
67  d1 = g_date->OldDays() + g_date->DayInYear(20, 3) + isSpring;
68  // Here we queue up the first event which changes dependent on whether it is a forced spring sow or not
69  if (m_farm->IsStockFarmer()) //Stock Farmer
70  {
72  }
73  else SimpleEvent_(d1, de_om_fp_manure, false, m_farm, m_field);
74  break;
75  }
76  break;
77 
78  case de_om_fa_manure:
79  if (!m_farm->FA_Manure( m_field, 0.0, g_date->DayInYear( 25, 4 ) - g_date->DayInYear())) {
81  break;
82  }
83  d1 = g_date->OldDays() + g_date->DayInYear( 1, 4 );
84  if ( g_date->Date()+1 > d1 ) {
85  d1 = g_date->Date()+1;
86  }
88  break;
89 
91  if (m_ev->m_lock || m_farm->DoIt_prob(0.50))
92  {
93  if (!m_farm->FA_Slurry( m_field, 0.0, g_date->DayInYear( 30, 4 ) - g_date->DayInYear())) {
95  break;
96  }
97  }
99  break;
100 
101  case de_om_fp_manure:
102  if (m_ev->m_lock || m_farm->DoIt_prob(0.80))
103  {
104  if (!m_farm->FP_Manure(m_field, 0.0, g_date->DayInYear(25, 4) - g_date->DayInYear())) {
106  break;
107  }
108  }
109  d1 = g_date->OldDays() + g_date->DayInYear(1, 4);
110  if (g_date->Date() + 1 > d1) {
111  d1 = g_date->Date() + 1;
112  }
114  break;
115 
116  case de_om_fp_slurry_one:
117  if (m_ev->m_lock || m_farm->DoIt_prob(0.20))
118  {
119  if (!m_farm->FP_Slurry(m_field, 0.0, g_date->DayInYear(30, 4) - g_date->DayInYear())) {
121  break;
122  }
123  }
125  break;
126 
127  case de_om_spring_plough:
128  if (!m_farm->SpringPlough( m_field, 0.0, g_date->DayInYear( 1, 5 ) - g_date->DayInYear())) {
130  break;
131  }
133  break;
134 
135  case de_om_spring_harrow:
136  if (!m_farm->SpringHarrow( m_field, 0.0, g_date->DayInYear( 5, 5 ) - g_date->DayInYear())) {
138  break;
139  }
140  d1 = g_date->OldDays() + g_date->DayInYear( 25, 4 );
141  if ( g_date->Date() > d1 ) {
142  d1 = g_date->Date();
143  }
145  break;
146 
147  case de_om_spring_sow:
148  if (!m_farm->SpringSow( m_field, 0.0, g_date->DayInYear( 15, 5 ) - g_date->DayInYear())) {
150  break;
151  }
154  break;
155 
156  case de_om_strigling:
157  if (!m_farm->Strigling( m_field, 0.0, g_date->DayInYear( 20, 5 ) - g_date->DayInYear())) {
159  break;
160  }
161  d1 = g_date->OldDays() + g_date->DayInYear( 2, 5 );
162  if ( DE_OMAIZE_SOW_DATE + 7 > d1 ) {
163  d1 = DE_OMAIZE_SOW_DATE + 7;
164  }
165  SimpleEvent_( d1, de_om_row_one, false, m_farm, m_field);
166  break;
167 
168  case de_om_row_one:
169  if (!m_farm->RowCultivation( m_field, 0.0, g_date->DayInYear( 5, 5 ) - g_date->DayInYear())) {
171  break;
172  }
173  d1 = g_date->OldDays() + g_date->DayInYear( 1, 5 );
174  if ( DE_OMAIZE_SOW_DATE + 5 > d1 ) {
175  d1 = DE_OMAIZE_SOW_DATE + 5;
176  }
177  if (m_farm->IsStockFarmer()) //Stock Farmer
178  {
180  }
181  else SimpleEvent_(d1, de_om_fp_slurry_two, false, m_farm, m_field);
182  break;
183 
184  case de_om_fa_slurry_two:
185  if (!m_farm->FA_Slurry( m_field, 0.0, g_date->DayInYear( 25, 5 ) - g_date->DayInYear())) {
187  break;
188  }
189  d1 = g_date->OldDays() + g_date->DayInYear( 21, 5 );
190  if ( g_date->Date() + 1 > d1 ) {
191  d1 = g_date->Date() + 1;
192  }
193  SimpleEvent_( d1, de_om_row_two, false, m_farm, m_field);
194  break;
195 
196  case de_om_fp_slurry_two:
197  if (!m_farm->FP_Slurry(m_field, 0.0, g_date->DayInYear(25, 5) - g_date->DayInYear())) {
199  break;
200  }
201  d1 = g_date->OldDays() + g_date->DayInYear(21, 5);
202  if (g_date->Date() + 1 > d1) {
203  d1 = g_date->Date() + 1;
204  }
206  break;
207 
208  case de_om_row_two:
209  if (!m_farm->RowCultivation( m_field, 0.0, g_date->DayInYear( 20, 6 ) - g_date->DayInYear())) {
211  break;
212  }
213  // LKM: Queue up the next event - row cultivation3 done 15 days after
215  break;
216 
217  case de_om_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_om_water_one:
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  }
236  d1 = g_date->OldDays() + g_date->DayInYear( 31, 7 );
237  if ( g_date->Date() + 7 > d1 ) {
238  d1 = g_date->Date() + 7;
239  }
241  break;
242 
243  case de_om_water_two:
244  if (m_ev->m_lock || m_farm->DoIt(10)) {
245  if (!m_farm->Water(m_field, 0.0, g_date->DayInYear(15, 8) - g_date->DayInYear())) {
247  break;
248  }
249  }
251  break;
252 
253  case de_om_harvest:
254  if (!m_farm->Harvest( m_field, 0.0, m_field->GetMDates(1, 0) - g_date->DayInYear())) {
256  break;
257  }
258  d1 = g_date->OldDays() + m_field->GetMDates(0,1);
259  if (g_date->Date() > d1) {
260  d1 = g_date->Date();
261  }
262  SimpleEvent_( d1, de_om_stubble, false, m_farm, m_field);
263  break;
264 
265  case de_om_stubble:
266  if ( m_ev->m_lock || m_farm->DoIt( 25 )) {
267  if (!m_farm->StubbleHarrowing( m_field, 0.0, m_field->GetMDates(1, 1) - g_date->DayInYear())) {
269  break;
270  }
271  }
272  d1=g_date->DayInYear();
273  done = true;
274  break;
275 
276  default:
277  g_msg->Warn( WARN_BUG, "DE_OMaize::Do(): "
278  "Unknown event type! ", "" );
279  exit( 1 );
280  }
281  return done;
282 }

References LE::ClearManagementActionSum(), Calendar::Date(), Calendar::DayInYear(), de_om_fa_manure, de_om_fa_slurry_one, de_om_fa_slurry_two, de_om_fp_manure, de_om_fp_slurry_one, de_om_fp_slurry_two, de_om_harvest, de_om_row_one, de_om_row_three, de_om_row_two, de_om_spring_harrow, de_om_spring_plough, de_om_spring_sow, de_om_start, de_om_strigling, de_om_stubble, de_om_water_one, de_om_water_two, DE_OMAIZE_SOW_DATE, 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_DEOMaize, MapErrorMsg::Warn(), WARN_BUG, and Farm::Water().

◆ SetUpFarmCategoryInformation()

void DE_OMaize::SetUpFarmCategoryInformation ( )
inline
68  {
69  const int elements = 2 + (de_om_foobar - DE_OMAIZE_BASE);
71 
72  FarmManagementCategory catlist[elements] =
73  {
74  fmc_Others, // zero element unused but must be here
75  fmc_Others, // de_om_start = 1, // Compulsory, start event must always be 1 (one).
76  fmc_Others, // de_om_sleep_all_day = DE_OMAIZE_BASE,
77  fmc_Fertilizer, // de_om_fa_manure_b,
78  fmc_Fertilizer, // de_om_fp_manure_b,
79  fmc_Fertilizer, // de_om_fa_slurry_one,
80  fmc_Fertilizer, // de_om_fp_slurry_one,
81  fmc_Cultivation, // de_om_spring_plough,
82  fmc_Cultivation, // de_om_spring_harrow,
83  fmc_Others, // de_om_spring_sow,
84  fmc_Cultivation, // de_om_strigling,
85  fmc_Cultivation, // de_om_row_one,
86  fmc_Fertilizer, // de_om_fa_slurry_two,
87  fmc_Fertilizer, // de_om_fp_slurry_two,
88  fmc_Cultivation, // de_om_row_two,
89  fmc_Cultivation, // de_om_row_three,
90  fmc_Others, // de_om_water_one,
91  fmc_Others, // de_om_water_two,
92  fmc_Harvest, // de_om_harvest,
93  fmc_Cultivation, // de_om_stubble,
94 
95 
96  // no foobar entry
97 
98  };
99  // Iterate over the catlist elements and copy them to vector
100  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
101 
102  }

References de_om_foobar, DE_OMAIZE_BASE, fmc_Cultivation, fmc_Fertilizer, fmc_Harvest, fmc_Others, Crop::m_base_elements_no, and Crop::m_ManagementCategories.

Referenced by DE_OMaize().


The documentation for this class was generated from the following files:
LE::GetMDates
int GetMDates(int a, int b)
Definition: Elements.h:405
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
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
de_om_harvest
Definition: DE_OMaize.h:52
g_date
class Calendar * g_date
Definition: Calendar.cpp:37
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_om_fa_slurry_two
Definition: DE_OMaize.h:46
de_om_fp_manure
Definition: DE_OMaize.h:38
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
de_om_fp_slurry_two
Definition: DE_OMaize.h:47
DE_OMAIZE_SOW_DATE
#define DE_OMAIZE_SOW_DATE
Definition: DE_OMaize.h:32
DE_OMAIZE_BASE
#define DE_OMAIZE_BASE
Definition: DE_OMaize.h:31
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
fmc_Fertilizer
Definition: LandscapeFarmingEnums.h:1004
de_om_fa_manure
Definition: DE_OMaize.h:37
de_om_spring_plough
Definition: DE_OMaize.h:41
de_om_spring_harrow
Definition: DE_OMaize.h:42
Calendar::Date
long Date(void)
Definition: Calendar.h:57
fmc_Cultivation
Definition: LandscapeFarmingEnums.h:1008
de_om_fa_slurry_one
Definition: DE_OMaize.h:39
fmc_Others
Definition: LandscapeFarmingEnums.h:1003
tov_DEOMaize
Definition: LandscapeFarmingEnums.h:485
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_OMaize::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: DE_OMaize.h:68
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
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_om_row_two
Definition: DE_OMaize.h:48
de_om_stubble
Definition: DE_OMaize.h:53
de_om_foobar
Definition: DE_OMaize.h:54
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
de_om_fp_slurry_one
Definition: DE_OMaize.h:40
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
de_om_start
Definition: DE_OMaize.h:35
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
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
TTypesOfVegetation
TTypesOfVegetation
Values that represent the types of vegetation that are represented in ALMaSS.
Definition: LandscapeFarmingEnums.h:192
de_om_row_one
Definition: DE_OMaize.h:45
fmc_Harvest
Definition: LandscapeFarmingEnums.h:1012
de_om_spring_sow
Definition: DE_OMaize.h:43
Calendar::DayInYear
int DayInYear(void)
Definition: Calendar.h:58
de_om_water_two
Definition: DE_OMaize.h:51
Crop::Crop
Crop(TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape *a_L)
Definition: Farm.cpp:733
de_om_strigling
Definition: DE_OMaize.h:44
de_om_row_three
Definition: DE_OMaize.h:49
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
WARN_BUG
Definition: MapErrorMsg.h:34
de_om_water_one
Definition: DE_OMaize.h:50
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
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