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

#include <DE_OAsparagusEstablishedPlantation.h>

Inheritance diagram for DE_OAsparagusEstablishedPlantation:
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_OAsparagusEstablishedPlantation (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_OAsparagusEstablishedPlantation()

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

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

Member Function Documentation

◆ Do()

bool DE_OAsparagusEstablishedPlantation::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.

82 {
83  /******************** This block can be added to the top of all Crop::Do methods ***********************************************/
84  m_farm = a_farm; // These assignments are necessary, not for this method but for related event calls
85  m_field = a_field;
86  m_ev = a_ev;
87  bool done = false; // The boolean value done indicates when we are totally finished with this plan (i.e. it is set to true).
88  bool flag = false;
89  int d1 = 0;
90  int today = g_date->Date();
92 
93  // Depending what event has occured jump to the correct bit of code
94  switch (m_ev->m_todo)
95  {
96  case de_oaep_start:
97  {
99 
100  CROP_HARVEST_DO = 50;
101 
102  m_last_date = g_date->DayInYear(10, 12); // Should match the last flexdate below
103  //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
104  std::vector<std::vector<int>> flexdates(1 + 1, std::vector<int>(2, 0));
105  // Set up the date management stuff
106  // Start and stop dates for all events after harvest
107  flexdates[0][1] = g_date->DayInYear(10, 12); // last possible day of cutting2 - this is in effect day before the earliest date that a following crop can use
108 
109  flexdates[1][0] = -1;
110  flexdates[1][1] = g_date->DayInYear(10, 12); // last possible day of grazing
111 
112  // 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
113  int isSpring = 365;
114  if (StartUpCrop(isSpring, flexdates, int(de_oaep_spring_harrow))) break;
115 
116  // End single block date checking code. Please see next line comment as well.
117  // Reinit d1 to first possible starting date.
118  d1 = g_date->OldDays() + g_date->DayInYear(1, 3) + isSpring;
119  // OK, let's go.
120  if (m_farm->IsStockFarmer()) //Stock Farmer
121  {
123  }
124  else SimpleEvent_(d1, de_oaep_ferti_p1, false, m_farm, m_field);
125  break;
126  }
127  break;
128 
129  // This is the first real farm operation
130  // This how the asparagus is managed if it is already an established plantation
131  // All events are 100% for now
132 
133  case de_oaep_ferti_s1:
134  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
135  {
136  if (!m_farm->FA_PK(m_field, 0.0, g_date->DayInYear(15, 3) - g_date->DayInYear())) {
138  break;
139  }
140  }
142  break;
143 
144  case de_oaep_ferti_p1:
145  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
146  {
147  if (!m_farm->FP_PK(m_field, 0.0, g_date->DayInYear(15, 3) - g_date->DayInYear())) {
149  break;
150  }
151  }
153  break;
154 
156  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
157  {
158  if (!m_farm->ShallowHarrow(m_field, 0.0, g_date->DayInYear(16, 3) - g_date->DayInYear())) {
160  break;
161  }
162  }
164  break;
165 
166  case de_oaep_hilling:
167  // hilling up should be before the emergence which is ~ 427 GDD, according to weather in Brandenburg in years 2011 - 2020 this GDD was earliest reached on 27.03, but in most cases ~ 10.04
168  if (!m_farm->HillingUp(m_field, 0.0, g_date->DayInYear(25, 3) - g_date->DayInYear())) {
170  break;
171  }
173  break;
174 
175  case de_oaep_harvesting:// ~55 events per year
176  // continuous harvesting till 15 June, every day
177  m_farm->HarvestShoots(m_field, 0.0, 0);
178  if (today < g_date->OldDays() + g_date->DayInYear(15, 6)) {
180  break;
181  }
182 
183  // fork of events
184  // N fertilizer treat = MAIN
185  if (m_farm->IsStockFarmer()) //Stock Farmer
186  {
188  }
189  else SimpleEvent_(g_date->Date() + 1, de_oaep_ferti_p2, false, m_farm, m_field);
190  // watering treat
192  break;
193 
194  case de_oaep_watering_start: // Start irrigation
195  if (!m_farm->IrrigationStart(m_field, 0.0, g_date->DayInYear(15, 7) - g_date->DayInYear())) {
197  break;
198  }
199  //Continue the irrigation
201  break;
202 
203  case de_oaep_watering: // Performing irrigation once a week if no raining
204  if (!m_farm->Irrigation(m_field, 0.0, g_date->DayInYear(30, 8) - g_date->DayInYear(), g_date->DayInYear(30, 8))) {
206  break;
207  }
208  // end of treat
209  break;
210 
211  case de_oaep_ferti_s2:
212  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
213  {
214  if (!m_farm->FA_N(m_field, 0.0, g_date->DayInYear(25, 6) - g_date->DayInYear())) {
216  break;
217  }
218  }
220  break;
221 
222  case de_oaep_ferti_p2:
223  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
224  {
225  if (!m_farm->FP_N(m_field, 0.0, g_date->DayInYear(25, 6) - g_date->DayInYear())) {
227  break;
228  }
229  }
231  break;
232 
233  case de_oaep_ferti_s3:
234  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
235  {
236  if (!m_farm->FA_N(m_field, 0.0, g_date->DayInYear(25, 7) - g_date->DayInYear())) {
238  break;
239  }
240  }
242  break;
243 
244  case de_oaep_ferti_p3:
245  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
246  {
247  if (!m_farm->FP_N(m_field, 0.0, g_date->DayInYear(25, 7) - g_date->DayInYear())) {
249  break;
250  }
251  }
253  break;
254 
256  if (!m_farm->HarvestShoots(m_field, 0.0, g_date->DayInYear(30, 11) - g_date->DayInYear())) {
258  break;
259  }
260  if (m_farm->IsStockFarmer()) //Stock Farmer
261  {
263  break;
264  }
265  else SimpleEvent_(g_date->Date() + 1, de_oaep_ferti_p4, false, m_farm, m_field);
266  break;
267 
268  case de_oaep_ferti_s4:
269  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
270  {
271  if (!m_farm->FA_Manure(m_field, 0.0, g_date->DayInYear(5, 12) - g_date->DayInYear())) {
273  break;
274  }
275  }
277  break;
278 
279  case de_oaep_ferti_p4:
280  if (m_ev->m_lock || m_farm->DoIt_prob(1.00))
281  {
282  if (!m_farm->FP_Manure(m_field, 0.0, g_date->DayInYear(5, 12) - g_date->DayInYear())) {
284  break;
285  }
286  }
288  break;
289 
291  if (!m_farm->RowCultivation(m_field, 0.0, m_field->GetMDates(1, 0) - g_date->DayInYear())) {
293  break;
294  }
295  done = true;
296  // So we are done, and somwhere else the farmer will queue up the start event of the next crop
297  // END of MAIN THREAD
298  break;
299 
300  default:
301  g_msg->Warn(WARN_BUG, "DE_OAsparagusEstablishedPlantation::Do(): "
302  "Unknown event type! ", "");
303  exit(1);
304  }
305  return done;
306 }

References LE::ClearManagementActionSum(), CROP_HARVEST_DO, Calendar::Date(), Calendar::DayInYear(), de_oaep_cutting_plants, de_oaep_ferti_p1, de_oaep_ferti_p2, de_oaep_ferti_p3, de_oaep_ferti_p4, de_oaep_ferti_s1, de_oaep_ferti_s2, de_oaep_ferti_s3, de_oaep_ferti_s4, de_oaep_harrowing_rows, de_oaep_harvesting, de_oaep_hilling, de_oaep_spring_harrow, de_oaep_start, de_oaep_watering, de_oaep_watering_start, Farm::DoIt_prob(), Farm::FA_Manure(), Farm::FA_N(), Farm::FA_PK(), Farm::FP_Manure(), Farm::FP_N(), Farm::FP_PK(), g_date, g_msg, LE::GetMDates(), Farm::HarvestShoots(), Farm::HillingUp(), Farm::Irrigation(), Farm::IrrigationStart(), 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(), Farm::ShallowHarrow(), Crop::SimpleEvent_(), Crop::StartUpCrop(), tov_DEOAsparagusEstablishedPlantation, MapErrorMsg::Warn(), and WARN_BUG.

◆ SetUpFarmCategoryInformation()

void DE_OAsparagusEstablishedPlantation::SetUpFarmCategoryInformation ( )
inline
102  {
103  const int elements = 2 + (de_oaep_foobar - DE_OAEP_BASE);
105 
106  FarmManagementCategory catlist[elements] =
107  {
108  fmc_Others, // zero element unused but must be here
109  fmc_Others, // de_oaep_start = 1, // Compulsory, must always be 1 (one).
110  fmc_Others, // de_oaep_sleep_all_day = DE_OAEP_BASE,
111  fmc_Fertilizer, // de_oaep_ferti_p2, // PK on spring
112  fmc_Fertilizer, // de_oaep_ferti_s2,
113  fmc_Cultivation, // de_oaep_spring_harrow,
114  fmc_Cultivation, // de_oaep_hilling,
115  fmc_Harvest, // de_oaep_harvesting,
116  fmc_Fertilizer, // de_oaep_ferti_p3, // N fertilizer I
117  fmc_Fertilizer, // de_oaep_ferti_s3,
118  fmc_Fertilizer, // de_oaep_ferti_p4, // N fertilizer II
119  fmc_Fertilizer, // de_oaep_ferti_s4,
120  fmc_Watering, // de_oaep_watering_start,
121  fmc_Watering, // de_oaep_watering,
122  fmc_Others, // de_oaep_cutting_plants,
123  fmc_Fertilizer, // de_oaep_ferti_p1, //organic fertilizer autumn
124  fmc_Fertilizer, // de_oaep_ferti_s1,
125  fmc_Cultivation, // de_oaep_harrowing_rows, //de-constructing rows before winter
126 
127  // no foobar entry
128 
129  };
130  // Iterate over the catlist elements and copy them to vector
131  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
132 
133  }

References DE_OAEP_BASE, de_oaep_foobar, fmc_Cultivation, fmc_Fertilizer, fmc_Harvest, fmc_Others, fmc_Watering, Crop::m_base_elements_no, and Crop::m_ManagementCategories.

Referenced by DE_OAsparagusEstablishedPlantation().


The documentation for this class was generated from the following files:
LE::GetMDates
int GetMDates(int a, int b)
Definition: Elements.h:405
Farm::IsStockFarmer
bool IsStockFarmer(void)
Definition: Farm.h:961
FarmEvent::m_lock
bool m_lock
Definition: Farm.h:384
Farm::Irrigation
virtual bool Irrigation(LE *a_field, double a_user, int a_days, int a_max)
Generate an 'irrigation' event with a frequency defined by a_freq in the irrigation period on a_field...
Definition: FarmFuncs.cpp:1856
LE::ClearManagementActionSum
void ClearManagementActionSum()
clears the management action counters
Definition: Elements.h:247
de_oaep_ferti_p4
Definition: DE_OAsparagusEstablishedPlantation.h:82
de_oaep_foobar
Definition: DE_OAsparagusEstablishedPlantation.h:85
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_oaep_hilling
Definition: DE_OAsparagusEstablishedPlantation.h:73
de_oaep_cutting_plants
Definition: DE_OAsparagusEstablishedPlantation.h:81
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
CROP_HARVEST_DO
#define CROP_HARVEST_DO
A flag used to indicate autumn ploughing status.
Definition: DE_AsparagusEstablishedPlantation.h:58
tov_DEOAsparagusEstablishedPlantation
Definition: LandscapeFarmingEnums.h:512
Crop::m_base_elements_no
int m_base_elements_no
Definition: Farm.h:505
de_oaep_harvesting
Definition: DE_OAsparagusEstablishedPlantation.h:74
Crop::m_first_date
int m_first_date
Definition: Farm.h:501
Farm::HillingUp
virtual bool HillingUp(LE *a_field, double a_user, int a_days)
Do hilling up on a_field, probably of potatoes.
Definition: FarmFuncs.cpp:1302
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_oaep_start
Definition: DE_OAsparagusEstablishedPlantation.h:68
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
Farm::IrrigationStart
virtual bool IrrigationStart(LE *a_field, double a_user, int a_days)
Start a irrigation event on a_field today.
Definition: FarmFuncs.cpp:1834
de_oaep_ferti_s4
Definition: DE_OAsparagusEstablishedPlantation.h:83
fmc_Fertilizer
Definition: LandscapeFarmingEnums.h:1004
de_oaep_ferti_s1
Definition: DE_OAsparagusEstablishedPlantation.h:71
de_oaep_ferti_p3
Definition: DE_OAsparagusEstablishedPlantation.h:77
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
Farm::HarvestShoots
virtual bool HarvestShoots(LE *a_field, double a_user, int a_days)
HarvestShoots applied on a_field (e.g. asparagus) - details needs to be added (e.g....
Definition: FarmFuncs.cpp:1883
fmc_Others
Definition: LandscapeFarmingEnums.h:1003
de_oaep_spring_harrow
Definition: DE_OAsparagusEstablishedPlantation.h:72
fmc_Watering
Definition: LandscapeFarmingEnums.h:1011
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_oaep_ferti_p2
Definition: DE_OAsparagusEstablishedPlantation.h:75
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_OAsparagusEstablishedPlantation::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: DE_OAsparagusEstablishedPlantation.h:102
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
Farm::ShallowHarrow
virtual bool ShallowHarrow(LE *a_field, double a_user, int a_days)
Carry out a shallow harrow event on a_field, e.g., after grass cutting event.
Definition: FarmFuncs.cpp:473
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
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_oaep_watering
Definition: DE_OAsparagusEstablishedPlantation.h:80
de_oaep_watering_start
Definition: DE_OAsparagusEstablishedPlantation.h:79
fmc_Harvest
Definition: LandscapeFarmingEnums.h:1012
Calendar::DayInYear
int DayInYear(void)
Definition: Calendar.h:58
DE_OAEP_BASE
#define DE_OAEP_BASE
Definition: DE_OAsparagusEstablishedPlantation.h:55
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_oaep_ferti_s2
Definition: DE_OAsparagusEstablishedPlantation.h:76
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
de_oaep_ferti_s3
Definition: DE_OAsparagusEstablishedPlantation.h:78
de_oaep_harrowing_rows
Definition: DE_OAsparagusEstablishedPlantation.h:84
WARN_BUG
Definition: MapErrorMsg.h:34
de_oaep_ferti_p1
Definition: DE_OAsparagusEstablishedPlantation.h:70
FarmManagementCategory
FarmManagementCategory
Definition: LandscapeFarmingEnums.h:1001
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