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

#include <DE_HerbsPerennial_after1year.h>

Inheritance diagram for DE_HerbsPerennial_after1year:
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_HerbsPerennial_after1year (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_HerbsPerennial_after1year()

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

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

Member Function Documentation

◆ Do()

bool DE_HerbsPerennial_after1year::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_hpa1y_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 = 365;
111  if (StartUpCrop(isSpring, flexdates, int(de_hpa1y_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, 3) + isSpring;
116  // OK, let's go.
117  if (m_farm->IsStockFarmer()) //Stock Farmer
118  {
120  break;
121  }
122  else SimpleEvent_(d1, de_hpa1y_ferti_p1, false, m_farm, m_field);
123  break;
124  }
125  break;
126 
127  // This is the first real farm operation
128  // For now all the operations are done by 100% farmers
129 
130  case de_hpa1y_ferti_s1:
131  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
132  {
133  if (!m_farm->FA_PK(m_field, 0.0, g_date->DayInYear(30, 3) - g_date->DayInYear())) {
135  break;
136  }
137  }
139  break;
140 
141  case de_hpa1y_ferti_p1:
142  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
143  {
144  if (!m_farm->FP_PK(m_field, 0.0, g_date->DayInYear(30, 3) - g_date->DayInYear())) {
146  break;
147  }
148  }
150  break;
151 
153  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
154  {
155  if (!m_farm->SpringHarrow(m_field, 0.0, g_date->DayInYear(31, 3) - g_date->DayInYear())) {
157  break;
158  }
159  }
160  d1 = g_date->Date() + 7;
161  if (d1 < g_date->OldDays() + g_date->DayInYear(25, 3)) {
162  d1 = g_date->OldDays() + g_date->DayInYear(25, 3);
163  }
164  if (m_farm->IsStockFarmer()) //Stock Farmer
165  {
167  break;
168  }
169  else SimpleEvent_(d1, de_hpa1y_ferti_p2, false, m_farm, m_field);
170  break;
171 
172  case de_hpa1y_ferti_s2:
173  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
174  {
175  if (!m_farm->FA_N(m_field, 0.0, g_date->DayInYear(10, 4) - g_date->DayInYear())) {
177  break;
178  }
179  }
181  break;
182 
183  case de_hpa1y_ferti_p2:
184  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
185  {
186  if (!m_farm->FP_N(m_field, 0.0, g_date->DayInYear(10, 4) - g_date->DayInYear())) {
188  break;
189  }
190  }
192  break;
193 
194  case de_hpa1y_weeding1:
195  if (m_ev->m_lock || m_farm->DoIt_prob(0.50))
196  {
197  if (!m_farm->CutWeeds(m_field, 0.0, g_date->DayInYear(30, 4) - g_date->DayInYear())) {
199  break;
200  }
201  if (m_farm->IsStockFarmer()) //Stock Farmer
202  {
204  break;
205  }
207  break;
208  }
210  break;
211 
212  case de_hpa1y_herbicide:
213  if (!m_farm->HerbicideTreat(m_field, 0.0, g_date->DayInYear(30, 4) - g_date->DayInYear())) {
215  break;
216  }
217  if (m_farm->IsStockFarmer()) //Stock Farmer
218  {
220  break;
221  }
223  break;
224 
225  case de_hpa1y_ferti_s3:
226  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
227  {
228  if (!m_farm->FA_N(m_field, 0.0, g_date->DayInYear(20, 5) - g_date->DayInYear())) {
230  break;
231  }
232  }
234  break;
235 
236  case de_hpa1y_ferti_p3:
237  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
238  {
239  if (!m_farm->FP_N(m_field, 0.0, g_date->DayInYear(20, 5) - g_date->DayInYear())) {
241  break;
242  }
243  }
245  break;
246 
247  case de_hpa1y_weeding2:
248  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
249  {
250  if (!m_farm->CutWeeds(m_field, 0.0, g_date->DayInYear(25, 5) - g_date->DayInYear())) {
252  break;
253  }
254  }
256  break;
257 
258  case de_hpa1y_harvest1:
259  if (!m_farm->GreenHarvest(m_field, 0.0, g_date->DayInYear(30, 6) - g_date->DayInYear())) {
261  break;
262  }
263  if (m_farm->IsStockFarmer()) //Stock Farmer
264  {
266  break;
267  }
268  else SimpleEvent_(g_date->Date() + 5, de_hpa1y_ferti_p4, false, m_farm, m_field);
269  break;
270 
271  case de_hpa1y_ferti_s4:
272  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
273  {
274  if (!m_farm->FA_N(m_field, 0.0, g_date->DayInYear(30, 7) - g_date->DayInYear())) {
276  break;
277  }
278  }
280  break;
281 
282  case de_hpa1y_ferti_p4:
283  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
284  {
285  if (!m_farm->FP_N(m_field, 0.0, g_date->DayInYear(30, 7) - g_date->DayInYear())) {
287  break;
288  }
289  }
291  break;
292 
293  case de_hpa1y_harvest2:
294  if (!m_farm->GreenHarvest(m_field, 0.0, g_date->DayInYear(5, 9) - g_date->DayInYear())) {
296  break;
297  }
299  break;
300 
301  case de_hpa1y_harrow:
302  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
303  {
304  if (!m_farm->RowCultivation(m_field, 0.0, m_field->GetMDates(1, 0) - g_date->DayInYear())) {
306  break;
307  }
308  }
309  done = true;
310  break;
311 
312  default:
313  g_msg->Warn(WARN_BUG, "DE_HerbsPerennial_after1year::Do(): "
314  "Unknown event type! ", "");
315  exit(1);
316  }
317  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
318  return done;
319 }

References LE::ClearManagementActionSum(), Farm::CutWeeds(), Calendar::Date(), Calendar::DayInYear(), de_hpa1y_ferti_p1, de_hpa1y_ferti_p2, de_hpa1y_ferti_p3, de_hpa1y_ferti_p4, de_hpa1y_ferti_s1, de_hpa1y_ferti_s2, de_hpa1y_ferti_s3, de_hpa1y_ferti_s4, de_hpa1y_harrow, de_hpa1y_harvest1, de_hpa1y_harvest2, de_hpa1y_herbicide, de_hpa1y_spring_harrow, de_hpa1y_start, de_hpa1y_weeding1, de_hpa1y_weeding2, Farm::DoIt_prob(), Farm::FA_N(), Farm::FA_PK(), Farm::FP_N(), Farm::FP_PK(), g_date, g_msg, LE::GetMDates(), Farm::GreenHarvest(), Farm::HerbicideTreat(), 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::RowCultivation(), Crop::SimpleEvent_(), Farm::SpringHarrow(), Crop::StartUpCrop(), tov_DEHerbsPerennial_after1year, MapErrorMsg::Warn(), and WARN_BUG.

◆ SetUpFarmCategoryInformation()

void DE_HerbsPerennial_after1year::SetUpFarmCategoryInformation ( )
inline
95  {
96  const int elements = 2 + (de_hpa1y_foobar - DE_HPA1Y_BASE);
98 
99  FarmManagementCategory catlist[elements] =
100  {
101  fmc_Others, // zero element unused but must be here
102  fmc_Others, // de_hpa1y_start = 1, // Compulsory, must always be 1 (one).
103  fmc_Others, // de_hpa1y_sleep_all_day = DE_HPA1Y_BASE,
104  fmc_Fertilizer, // de_hpa1y_ferti_p1,//PK
105  fmc_Fertilizer, // de_hpa1y_ferti_s1,//PK
106  fmc_Cultivation, // de_hpa1y_spring_harrow,
107  fmc_Fertilizer, // de_hpa1y_ferti_p2,//N I
108  fmc_Fertilizer, // de_hpa1y_ferti_s2,//N I
109  fmc_Others, // de_hpa1y_weeding1,
110  fmc_Herbicide, // de_hpa1y_herbicide,
111  fmc_Fertilizer, // de_hpa1y_ferti_p3,//N II
112  fmc_Fertilizer, // de_hpa1y_ferti_s3,//N II
113  fmc_Others, // de_hpa1y_weeding2,
114  fmc_Harvest, // de_hpa1y_harvest1,
115  fmc_Fertilizer, // de_hpa1y_ferti_p4,//N III
116  fmc_Fertilizer, // de_hpa1y_ferti_s4,//N III
117  fmc_Harvest, // de_hpa1y_harvest2,
118  fmc_Cultivation, // de_hpa1y_harrow,
119 
120  // no foobar entry
121 
122  };
123  // Iterate over the catlist elements and copy them to vector
124  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
125 
126  }

References DE_HPA1Y_BASE, de_hpa1y_foobar, fmc_Cultivation, fmc_Fertilizer, fmc_Harvest, fmc_Herbicide, fmc_Others, Crop::m_base_elements_no, and Crop::m_ManagementCategories.

Referenced by DE_HerbsPerennial_after1year().


The documentation for this class was generated from the following files:
LE::GetMDates
int GetMDates(int a, int b)
Definition: Elements.h:405
de_hpa1y_ferti_s2
Definition: DE_HerbsPerennial_after1year.h:67
FarmEvent::m_forcespring
bool m_forcespring
Definition: Farm.h:392
DE_HPA1Y_BASE
#define DE_HPA1Y_BASE
Definition: DE_HerbsPerennial_after1year.h:53
Farm::HerbicideTreat
virtual bool HerbicideTreat(LE *a_field, double a_user, int a_days)
Apply herbicide to a_field.
Definition: FarmFuncs.cpp:2025
Farm::IsStockFarmer
bool IsStockFarmer(void)
Definition: Farm.h:961
de_hpa1y_harrow
Definition: DE_HerbsPerennial_after1year.h:77
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_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_hpa1y_weeding1
Definition: DE_HerbsPerennial_after1year.h:68
fmc_Herbicide
Definition: LandscapeFarmingEnums.h:1006
de_hpa1y_ferti_s4
Definition: DE_HerbsPerennial_after1year.h:75
Crop::m_base_elements_no
int m_base_elements_no
Definition: Farm.h:505
de_hpa1y_harvest1
Definition: DE_HerbsPerennial_after1year.h:73
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
tov_DEHerbsPerennial_after1year
Definition: LandscapeFarmingEnums.h:514
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_hpa1y_ferti_p4
Definition: DE_HerbsPerennial_after1year.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_hpa1y_weeding2
Definition: DE_HerbsPerennial_after1year.h:72
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_hpa1y_harvest2
Definition: DE_HerbsPerennial_after1year.h:76
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_hpa1y_ferti_s3
Definition: DE_HerbsPerennial_after1year.h:71
Crop::m_last_date
int m_last_date
Definition: Farm.h:503
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
de_hpa1y_start
Definition: DE_HerbsPerennial_after1year.h:61
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_hpa1y_herbicide
Definition: DE_HerbsPerennial_after1year.h:69
de_hpa1y_ferti_p3
Definition: DE_HerbsPerennial_after1year.h:70
Calendar::DayInYear
int DayInYear(void)
Definition: Calendar.h:58
de_hpa1y_ferti_s1
Definition: DE_HerbsPerennial_after1year.h:64
de_hpa1y_ferti_p2
Definition: DE_HerbsPerennial_after1year.h:66
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_HerbsPerennial_after1year::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: DE_HerbsPerennial_after1year.h:95
WARN_BUG
Definition: MapErrorMsg.h:34
de_hpa1y_ferti_p1
Definition: DE_HerbsPerennial_after1year.h:63
de_hpa1y_foobar
Definition: DE_HerbsPerennial_after1year.h:78
de_hpa1y_spring_harrow
Definition: DE_HerbsPerennial_after1year.h:65
FarmManagementCategory
FarmManagementCategory
Definition: LandscapeFarmingEnums.h:1001
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