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

#include <DE_OHerbsPerennial_1year.h>

Inheritance diagram for DE_OHerbsPerennial_1year:
Crop

Public Member Functions

virtual bool Do (Farm *a_farm, LE *a_field, FarmEvent *a_ev)
 The one and only method for a crop management plan. All farm actions go through here. More...
 
 DE_OHerbsPerennial_1year (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_OHerbsPerennial_1year()

DE_OHerbsPerennial_1year::DE_OHerbsPerennial_1year ( TTypesOfVegetation  a_tov,
TTypesOfCrops  a_toc,
Landscape a_L 
)
inline
89  : Crop(a_tov, a_toc, a_L)
90  {
91  // When we start it off, the first possible date for a farm operation is 1st October
92  // This information is used by other crops when they decide how much post processing of
93  // the management is allowed after harvest before the next crop starts.
94  m_first_date = g_date->DayInYear(5, 12);
96  }

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

Member Function Documentation

◆ Do()

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

The one and only method for a crop management plan. All farm actions go through here.

Called every time something is done to the crop by the farmer in the first instance it is always called with m_ev->todo set to start, but susequently will be called whenever the farmer wants to carry out a new operation.
This method details all the management and relationships between operations necessary to grow and ALMaSS crop - in this case conventional spring barley Fodder.

Reimplemented from Crop.

83 {
84  /******************** This block can be added to the top of all Crop::Do methods ***********************************************/
85  m_farm = a_farm; // These assignments are necessary, not for this method but for related event calls
86  m_field = a_field;
87  m_ev = a_ev;
88  bool done = false; // The boolean value done indicates when we are totally finished with this plan (i.e. it is set to true).
89  int d1 = 0;
91 
92  // Depending what event has occured jump to the correct bit of code
93  switch (m_ev->m_todo)
94  {
95  case de_ohp1y_start:
96  {
98 
99  m_last_date = g_date->DayInYear(30, 11); // Should match the last flexdate below
100  //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
101  std::vector<std::vector<int>> flexdates(1 + 1, std::vector<int>(2, 0));
102  // Set up the date management stuff
103  // Start and stop dates for all events after harvest
104  flexdates[0][1] = g_date->DayInYear(30, 11); // last possible day of cutting2 - this is in effect day before the earliest date that a following crop can use
105 
106  flexdates[1][0] = -1;
107  flexdates[1][1] = g_date->DayInYear(30, 11); // last possible day of grazing
108 
109  // 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
110  int isSpring = 0;
111  if (StartUpCrop(isSpring, flexdates, int(de_ohp1y_spring_harrow))) break;
112 
113  // End single block date checking code. Please see next line comment as well.
114  // Reinit d1 to first possible starting date.
115  d1 = g_date->OldDays() + g_date->DayInYear(1, 10) + isSpring;
116  // OK, let's go.
117  if (m_ev->m_forcespring) {
118  int day_num_shift = 365;
119  if (g_date->DayInYear() < 70) day_num_shift = 0;
120  if (m_farm->IsStockFarmer()) //Stock Farmer
121  {
122  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 3) + day_num_shift, de_ohp1y_ferti_s1, false, m_farm, m_field);
123  break;
124  }
125  else SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 3) + day_num_shift, de_ohp1y_ferti_p1, false, m_farm, m_field);
126  break;
127  }
129  break;
130  }
131  break;
132 
133  // This is the first real farm operation
134  // For now all the operations are done by 100% farmers
136  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
137  {
138  if (!m_farm->WinterPlough(m_field, 0.0, g_date->DayInYear(5, 12) - g_date->DayInYear())) {
140  break;
141  }
142  }
143  if (m_farm->IsStockFarmer()) //Stock Farmer
144  {
146  break;
147  }
148  else SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 3) + 365, de_ohp1y_ferti_p1, false, m_farm, m_field);
149  break;
150 
151  case de_ohp1y_ferti_s1:
152  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
153  {
154  if (!m_farm->FA_PK(m_field, 0.0, g_date->DayInYear(30, 3) - g_date->DayInYear())) {
156  break;
157  }
158  }
160  break;
161 
162  case de_ohp1y_ferti_p1:
163  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
164  {
165  if (!m_farm->FP_PK(m_field, 0.0, g_date->DayInYear(30, 3) - g_date->DayInYear())) {
167  break;
168  }
169  }
171  break;
172 
174  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
175  {
176  if (!m_farm->SpringHarrow(m_field, 0.0, g_date->DayInYear(31, 3) - g_date->DayInYear())) {
178  break;
179  }
180  }
181  d1 = g_date->Date() + 7;
182  if (d1 < g_date->OldDays() + g_date->DayInYear(25, 3)) {
183  d1 = g_date->OldDays() + g_date->DayInYear(25, 3);
184  }
185  if (m_farm->IsStockFarmer()) //Stock Farmer
186  {
188  break;
189  }
190  else SimpleEvent_(d1, de_ohp1y_ferti_p2, false, m_farm, m_field);
191  break;
192 
193  case de_ohp1y_ferti_s2:
194  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
195  {
196  if (!m_farm->FA_N(m_field, 0.0, g_date->DayInYear(10, 4) - g_date->DayInYear())) {
198  break;
199  }
200  }
202  break;
203 
204  case de_ohp1y_ferti_p2:
205  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
206  {
207  if (!m_farm->FP_N(m_field, 0.0, g_date->DayInYear(10, 4) - g_date->DayInYear())) {
209  break;
210  }
211  }
213  break;
214 
216  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
217  {
218  if (!m_farm->PreseedingCultivator(m_field, 0.0, g_date->DayInYear(11, 4) - g_date->DayInYear())) {
220  break;
221  }
222  }
224  break;
225 
226  case de_ohp1y_planting:
227  if (!m_farm->SpringSow(m_field, 0.0, g_date->DayInYear(15, 4) - g_date->DayInYear())) {
229  break;
230  }
232  break;
233 
234  case de_ohp1y_weeding:
235  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
236  {
237  if (!m_farm->CutWeeds(m_field, 0.0, g_date->DayInYear(30, 4) - g_date->DayInYear())) {
239  break;
240  }
241  }
242  if (m_farm->IsStockFarmer()) //Stock Farmer
243  {
245  break;
246  }
248  break;
249 
250  case de_ohp1y_ferti_s3:
251  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
252  {
253  if (!m_farm->FA_N(m_field, 0.0, g_date->DayInYear(20, 5) - g_date->DayInYear())) {
255  break;
256  }
257  }
259  break;
260 
261  case de_ohp1y_ferti_p3:
262  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
263  {
264  if (!m_farm->FP_N(m_field, 0.0, g_date->DayInYear(20, 5) - g_date->DayInYear())) {
266  break;
267  }
268  }
270  break;
271 
272  case de_ohp1y_harvest:
273  if (!m_farm->GreenHarvest(m_field, 0.0, g_date->DayInYear(30, 6) - g_date->DayInYear())) {
275  break;
276  }
277  if (m_farm->IsStockFarmer()) //Stock Farmer
278  {
280  break;
281  }
282  else SimpleEvent_(g_date->Date() + 5, de_ohp1y_ferti_p4, false, m_farm, m_field);
283  break;
284 
285  case de_ohp1y_ferti_s4:
286  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
287  {
288  if (!m_farm->FA_N(m_field, 0.0, g_date->DayInYear(30, 7) - g_date->DayInYear())) {
290  break;
291  }
292  }
294  break;
295 
296  case de_ohp1y_ferti_p4:
297  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
298  {
299  if (!m_farm->FP_N(m_field, 0.0, g_date->DayInYear(30, 7) - g_date->DayInYear())) {
301  break;
302  }
303  }
305  break;
306 
307  case de_ohp1y_harrow:
308  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
309  {
310  if (!m_farm->AutumnHarrow(m_field, 0.0, m_field->GetMDates(1, 0) - g_date->DayInYear())) {
312  break;
313  }
314  }
315  done = true;
316  break;
317 
318  default:
319  g_msg->Warn(WARN_BUG, "DE_OHerbsPerennial_1year::Do(): "
320  "Unknown event type! ", "");
321  exit(1);
322  }
323  if (done) m_ev->m_forcespring = true; // Here we need to force the next crop to spring operation, so set the ev->forcespring to true
324  return done;
325 }

References Farm::AutumnHarrow(), LE::ClearManagementActionSum(), Farm::CutWeeds(), Calendar::Date(), Calendar::DayInYear(), de_ohp1y_ferti_p1, de_ohp1y_ferti_p2, de_ohp1y_ferti_p3, de_ohp1y_ferti_p4, de_ohp1y_ferti_s1, de_ohp1y_ferti_s2, de_ohp1y_ferti_s3, de_ohp1y_ferti_s4, de_ohp1y_harrow, de_ohp1y_harvest, de_ohp1y_planting, de_ohp1y_preseeding_cultivation, de_ohp1y_spring_harrow, de_ohp1y_start, de_ohp1y_weeding, de_ohp1y_winter_plough, Farm::DoIt_prob(), Farm::FA_N(), Farm::FA_PK(), Farm::FP_N(), Farm::FP_PK(), g_date, g_msg, LE::GetMDates(), Farm::GreenHarvest(), Farm::IsStockFarmer(), Crop::m_ev, Crop::m_farm, Crop::m_field, FarmEvent::m_forcespring, Crop::m_last_date, FarmEvent::m_lock, FarmEvent::m_todo, Calendar::OldDays(), Farm::PreseedingCultivator(), Crop::SimpleEvent_(), Farm::SpringHarrow(), Farm::SpringSow(), Crop::StartUpCrop(), tov_DEOHerbsPerennial_1year, MapErrorMsg::Warn(), WARN_BUG, and Farm::WinterPlough().

◆ SetUpFarmCategoryInformation()

void DE_OHerbsPerennial_1year::SetUpFarmCategoryInformation ( )
inline
97  {
98  const int elements = 2 + (de_ohp1y_foobar - DE_OHP1Y_BASE);
100 
101  FarmManagementCategory catlist[elements] =
102  {
103  fmc_Others, // zero element unused but must be here
104  fmc_Others, // de_ohp1y_start = 1, // Compulsory, must always be 1 (one).
105  fmc_Others, // de_ohp1y_sleep_all_day = DE_HP_BASE,
106  fmc_Cultivation, // de_ohp1y_winter_plough,
107  fmc_Fertilizer, // de_ohp1y_ferti_p1,//PK
108  fmc_Fertilizer, // de_ohp1y_ferti_s1,//PK
109  fmc_Cultivation, // de_ohp1y_spring_harrow,
110  fmc_Fertilizer, // de_ohp1y_ferti_p2,//N I
111  fmc_Fertilizer, // de_ohp1y_ferti_s2,//N I
112  fmc_Cultivation, // de_ohp1y_preeseding_cultivation,
113  fmc_Others, // de_ohp1y_planting,
114  fmc_Others, // de_ohp1y_weeding,
115  fmc_Fertilizer, // de_ohp1y_ferti_p3,//N II
116  fmc_Fertilizer, // de_ohp1y_ferti_s3,//N II
117  fmc_Harvest, // de_ohp1y_harvest,
118  fmc_Fertilizer, // de_ohp1y_ferti_p4,//N III
119  fmc_Fertilizer, // de_ohp1y_ferti_s4,//N III
120  fmc_Cultivation, // de_ohp1y_harrow,
121 
122  // no foobar entry
123 
124  };
125  // Iterate over the catlist elements and copy them to vector
126  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
127 
128  }

References DE_OHP1Y_BASE, de_ohp1y_foobar, fmc_Cultivation, fmc_Fertilizer, fmc_Harvest, fmc_Others, Crop::m_base_elements_no, and Crop::m_ManagementCategories.

Referenced by DE_OHerbsPerennial_1year().


The documentation for this class was generated from the following files:
LE::GetMDates
int GetMDates(int a, int b)
Definition: Elements.h:405
FarmEvent::m_forcespring
bool m_forcespring
Definition: Farm.h:392
de_ohp1y_ferti_s2
Definition: DE_OHerbsPerennial_1year.h:70
Farm::PreseedingCultivator
virtual bool PreseedingCultivator(LE *a_field, double a_user, int a_days)
Carry out preseeding cultivation on a_field (tilling set including cultivator and string roller to co...
Definition: FarmFuncs.cpp:312
Farm::IsStockFarmer
bool IsStockFarmer(void)
Definition: Farm.h:961
FarmEvent::m_lock
bool m_lock
Definition: Farm.h:384
de_ohp1y_harrow
Definition: DE_OHerbsPerennial_1year.h:79
LE::ClearManagementActionSum
void ClearManagementActionSum()
clears the management action counters
Definition: Elements.h:247
de_ohp1y_planting
Definition: DE_OHerbsPerennial_1year.h:72
de_ohp1y_ferti_s1
Definition: DE_OHerbsPerennial_1year.h:67
de_ohp1y_preseeding_cultivation
Definition: DE_OHerbsPerennial_1year.h:71
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_ohp1y_winter_plough
Definition: DE_OHerbsPerennial_1year.h:65
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
de_ohp1y_ferti_s4
Definition: DE_OHerbsPerennial_1year.h:78
Crop::m_first_date
int m_first_date
Definition: Farm.h:501
Farm::FP_PK
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:673
de_ohp1y_weeding
Definition: DE_OHerbsPerennial_1year.h:73
de_ohp1y_start
Definition: DE_OHerbsPerennial_1year.h:63
de_ohp1y_ferti_s3
Definition: DE_OHerbsPerennial_1year.h:75
DE_OHP1Y_BASE
#define DE_OHP1Y_BASE
Definition: DE_OHerbsPerennial_1year.h:55
Farm::GreenHarvest
virtual bool GreenHarvest(LE *a_field, double a_user, int a_days)
GreenHarvest (remove of excess production that may affect the desired quality of the fruits,...
Definition: FarmFuncs.cpp:1942
fmc_Fertilizer
Definition: LandscapeFarmingEnums.h:1004
de_ohp1y_ferti_p3
Definition: DE_OHerbsPerennial_1year.h:74
Calendar::Date
long Date(void)
Definition: Calendar.h:57
fmc_Cultivation
Definition: LandscapeFarmingEnums.h:1008
Farm::FP_N
virtual bool FP_N(LE *a_field, double a_user, int a_days)
Apply N fertilizer, on a_field owned by an arable farmer.
Definition: FarmFuncs.cpp:700
fmc_Others
Definition: LandscapeFarmingEnums.h:1003
de_ohp1y_ferti_p1
Definition: DE_OHerbsPerennial_1year.h:66
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
Farm::FA_N
virtual bool FA_N(LE *a_field, double a_user, int a_days)
Apply N fertilizer, on a_field owned by a stock farmer.
Definition: FarmFuncs.cpp:713
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_OHerbsPerennial_1year::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: DE_OHerbsPerennial_1year.h:97
Crop::m_last_date
int m_last_date
Definition: Farm.h:503
de_ohp1y_ferti_p2
Definition: DE_OHerbsPerennial_1year.h:69
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
Farm::AutumnHarrow
virtual bool AutumnHarrow(LE *a_field, double a_user, int a_days)
Carry out a harrow event in the autumn on a_field.
Definition: FarmFuncs.cpp:285
TTypesOfVegetation
TTypesOfVegetation
Values that represent the types of vegetation that are represented in ALMaSS.
Definition: LandscapeFarmingEnums.h:192
tov_DEOHerbsPerennial_1year
Definition: LandscapeFarmingEnums.h:515
fmc_Harvest
Definition: LandscapeFarmingEnums.h:1012
Farm::WinterPlough
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:395
de_ohp1y_harvest
Definition: DE_OHerbsPerennial_1year.h:76
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
Farm::FA_PK
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:1010
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
de_ohp1y_ferti_p4
Definition: DE_OHerbsPerennial_1year.h:77
de_ohp1y_foobar
Definition: DE_OHerbsPerennial_1year.h:80
WARN_BUG
Definition: MapErrorMsg.h:34
FarmManagementCategory
FarmManagementCategory
Definition: LandscapeFarmingEnums.h:1001
de_ohp1y_spring_harrow
Definition: DE_OHerbsPerennial_1year.h:68
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
Farm::CutWeeds
virtual bool CutWeeds(LE *a_field, double a_user, int a_days)
Carry out weed topping on a_field.
Definition: FarmFuncs.cpp:1629