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

#include <DE_OHerbsPerennial_after1year.h>

Inheritance diagram for DE_OHerbsPerennial_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_OHerbsPerennial_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_OHerbsPerennial_after1year()

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

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

Member Function Documentation

◆ Do()

bool DE_OHerbsPerennial_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_ohpa1y_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_ohpa1y_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_ohpa1y_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_ohpa1y_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_ohpa1y_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_ohpa1y_ferti_p2, false, m_farm, m_field);
170  break;
171 
172  case de_ohpa1y_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_ohpa1y_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_ohpa1y_weeding1:
195  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
196  {
197  if (!m_farm->CutWeeds(m_field, 0.0, g_date->DayInYear(30, 4) - g_date->DayInYear())) {
199  break;
200  }
201  }
202  if (m_farm->IsStockFarmer()) //Stock Farmer
203  {
205  break;
206  }
208  break;
209 
210  case de_ohpa1y_ferti_s3:
211  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
212  {
213  if (!m_farm->FA_N(m_field, 0.0, g_date->DayInYear(20, 5) - g_date->DayInYear())) {
215  break;
216  }
217  }
219  break;
220 
221  case de_ohpa1y_ferti_p3:
222  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
223  {
224  if (!m_farm->FP_N(m_field, 0.0, g_date->DayInYear(20, 5) - g_date->DayInYear())) {
226  break;
227  }
228  }
230  break;
231 
232  case de_ohpa1y_weeding2:
233  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
234  {
235  if (!m_farm->CutWeeds(m_field, 0.0, g_date->DayInYear(25, 5) - g_date->DayInYear())) {
237  break;
238  }
239  }
241  break;
242 
243  case de_ohpa1y_harvest1:
244  if (!m_farm->GreenHarvest(m_field, 0.0, g_date->DayInYear(30, 6) - g_date->DayInYear())) {
246  break;
247  }
248  if (m_farm->IsStockFarmer()) //Stock Farmer
249  {
251  break;
252  }
253  else SimpleEvent_(g_date->Date() + 5, de_ohpa1y_ferti_p4, false, m_farm, m_field);
254  break;
255 
256  case de_ohpa1y_ferti_s4:
257  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
258  {
259  if (!m_farm->FA_N(m_field, 0.0, g_date->DayInYear(30, 7) - g_date->DayInYear())) {
261  break;
262  }
263  }
265  break;
266 
267  case de_ohpa1y_ferti_p4:
268  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
269  {
270  if (!m_farm->FP_N(m_field, 0.0, g_date->DayInYear(30, 7) - g_date->DayInYear())) {
272  break;
273  }
274  }
276  break;
277 
278  case de_ohpa1y_harvest2:
279  if (!m_farm->GreenHarvest(m_field, 0.0, g_date->DayInYear(5, 9) - g_date->DayInYear())) {
281  break;
282  }
284  break;
285 
286  case de_ohpa1y_harrow:
287  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
288  {
289  if (!m_farm->RowCultivation(m_field, 0.0, m_field->GetMDates(1, 0) - g_date->DayInYear())) {
291  break;
292  }
293  }
294  done = true;
295  break;
296 
297  default:
298  g_msg->Warn(WARN_BUG, "DE_OHerbsPerennial_after1year::Do(): "
299  "Unknown event type! ", "");
300  exit(1);
301  }
302  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
303  return done;
304 }

References LE::ClearManagementActionSum(), Farm::CutWeeds(), Calendar::Date(), Calendar::DayInYear(), de_ohpa1y_ferti_p1, de_ohpa1y_ferti_p2, de_ohpa1y_ferti_p3, de_ohpa1y_ferti_p4, de_ohpa1y_ferti_s1, de_ohpa1y_ferti_s2, de_ohpa1y_ferti_s3, de_ohpa1y_ferti_s4, de_ohpa1y_harrow, de_ohpa1y_harvest1, de_ohpa1y_harvest2, de_ohpa1y_spring_harrow, de_ohpa1y_start, de_ohpa1y_weeding1, de_ohpa1y_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::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_DEOHerbsPerennial_after1year, MapErrorMsg::Warn(), and WARN_BUG.

◆ SetUpFarmCategoryInformation()

void DE_OHerbsPerennial_after1year::SetUpFarmCategoryInformation ( )
inline
96  {
97  const int elements = 2 + (de_ohpa1y_foobar - DE_OHPA1Y_BASE);
99 
100  FarmManagementCategory catlist[elements] =
101  {
102  fmc_Others, // zero element unused but must be here
103  fmc_Others, // de_ohpa1y_start = 1, // Compulsory, must always be 1 (one).
104  fmc_Others, // de_ohpa1y_sleep_all_day = DE_OHPA1Y_BASE,
105  fmc_Fertilizer, // de_ohpa1y_ferti_p1,//PK
106  fmc_Fertilizer, // de_ohpa1y_ferti_s1,//PK
107  fmc_Cultivation, // de_ohpa1y_spring_harrow,
108  fmc_Fertilizer, // de_ohpa1y_ferti_p2,//N I
109  fmc_Fertilizer, // de_ohpa1y_ferti_s2,//N I
110  fmc_Others, // de_ohpa1y_weeding1,
111  fmc_Fertilizer, // de_ohpa1y_ferti_p3,//N II
112  fmc_Fertilizer, // de_ohpa1y_ferti_s3,//N II
113  fmc_Others, // de_ohpa1y_weeding2,
114  fmc_Harvest, // de_ohpa1y_harvest1,
115  fmc_Fertilizer, // de_ohpa1y_ferti_p4,//N III
116  fmc_Fertilizer, // de_ohpa1y_ferti_s4,//N III
117  fmc_Harvest, // de_ohpa1y_harvest2,
118  fmc_Cultivation, // de_ohpa1y_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_OHPA1Y_BASE, de_ohpa1y_foobar, fmc_Cultivation, fmc_Fertilizer, fmc_Harvest, fmc_Others, Crop::m_base_elements_no, and Crop::m_ManagementCategories.

Referenced by DE_OHerbsPerennial_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_ohpa1y_harvest2
Definition: DE_OHerbsPerennial_after1year.h:77
FarmEvent::m_forcespring
bool m_forcespring
Definition: Farm.h:392
Farm::IsStockFarmer
bool IsStockFarmer(void)
Definition: Farm.h:961
FarmEvent::m_lock
bool m_lock
Definition: Farm.h:384
LE::ClearManagementActionSum
void ClearManagementActionSum()
clears the management action counters
Definition: Elements.h:247
tov_DEOHerbsPerennial_after1year
Definition: LandscapeFarmingEnums.h:516
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
Crop::m_base_elements_no
int m_base_elements_no
Definition: Farm.h:505
DE_OHPA1Y_BASE
#define DE_OHPA1Y_BASE
Definition: DE_OHerbsPerennial_after1year.h:55
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_OHerbsPerennial_after1year::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: DE_OHerbsPerennial_after1year.h:96
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
Calendar::Date
long Date(void)
Definition: Calendar.h:57
de_ohpa1y_ferti_p4
Definition: DE_OHerbsPerennial_after1year.h:75
de_ohpa1y_ferti_p2
Definition: DE_OHerbsPerennial_after1year.h:68
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
de_ohpa1y_harrow
Definition: DE_OHerbsPerennial_after1year.h:78
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_ohpa1y_ferti_s2
Definition: DE_OHerbsPerennial_after1year.h: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
de_ohpa1y_ferti_s1
Definition: DE_OHerbsPerennial_after1year.h:66
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_ohpa1y_weeding1
Definition: DE_OHerbsPerennial_after1year.h:70
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_ohpa1y_harvest1
Definition: DE_OHerbsPerennial_after1year.h:74
Crop::m_last_date
int m_last_date
Definition: Farm.h:503
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
de_ohpa1y_spring_harrow
Definition: DE_OHerbsPerennial_after1year.h:67
de_ohpa1y_weeding2
Definition: DE_OHerbsPerennial_after1year.h:73
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_ohpa1y_ferti_p1
Definition: DE_OHerbsPerennial_after1year.h:65
Calendar::DayInYear
int DayInYear(void)
Definition: Calendar.h:58
de_ohpa1y_foobar
Definition: DE_OHerbsPerennial_after1year.h:79
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
de_ohpa1y_start
Definition: DE_OHerbsPerennial_after1year.h:63
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
de_ohpa1y_ferti_s3
Definition: DE_OHerbsPerennial_after1year.h:72
de_ohpa1y_ferti_p3
Definition: DE_OHerbsPerennial_after1year.h:71
WARN_BUG
Definition: MapErrorMsg.h:34
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
de_ohpa1y_ferti_s4
Definition: DE_OHerbsPerennial_after1year.h:76