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

NLGrassGrazedExtensive2 class
. More...

#include <NLGrassGrazedExtensive2.h>

Inheritance diagram for NLGrassGrazedExtensive2:
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...
 
 NLGrassGrazedExtensive2 (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...
 

Detailed Description

NLGrassGrazedExtensive2 class
.

See NLGrassGrazedExtensive2.h::NLGrassGrazedExtensive2ToDo for a complete list of all possible events triggered codes by the TemporalGrassGrazedExtensive2 management plan. When triggered these events are handled by Farm and are available as information for other objects such as animal and bird models.

Constructor & Destructor Documentation

◆ NLGrassGrazedExtensive2()

NLGrassGrazedExtensive2::NLGrassGrazedExtensive2 ( TTypesOfVegetation  a_tov,
TTypesOfCrops  a_toc,
Landscape a_L 
)
inline
74  : Crop(a_tov, a_toc, a_L)
75  {
76  // When we start it off, the first possible date for a farm operation is 5th November
77  // This information is used by other crops when they decide how much post processing of
78  // the management is allowed after harvest before the next crop starts.
79  m_first_date=g_date->DayInYear( 30,3 );
81  }

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

Member Function Documentation

◆ Do()

bool NLGrassGrazedExtensive2::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 TemporalGrassGrazedExtensive2.

Reimplemented from Crop.

55 {
56  /******************** This block can be added to the top of all Crop::Do methods ***********************************************/
57  m_farm = a_farm;
58  m_field = a_field;
59  m_ev = a_ev;
60  bool done = false; // The boolean value done indicates when we are totally finished with this plan (i.e. it is set to true, m_farm, m_field).
61  bool flag = false;
62  int d1 = 0;
63  int noDates = 1;
65  int l_nextcropstartdate;
66  /**********************************************To Here *************************************************************************/
67 
68  // Depending what event has occured jump to the correct bit of code
69  switch (m_ev->m_todo)
70  {
71  case nl_gge2_start:
72  {
74  NL_GGE2_CUT_DATE = 0;
77 
78  m_last_date = g_date->DayInYear(31, 10); // Should match the last flexdate below
79  //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
80  std::vector<std::vector<int>> flexdates(1 + 1, std::vector<int>(2, 0));
81  // Set up the date management stuff
82  // Start and stop dates for all events after harvest
83  flexdates[0][1] = g_date->DayInYear(10, 10); // first possible day of finishing harvest - this is in effect day before the earliest date that a following crop can use
84 
85  flexdates[1][0] = -1; // This date will be moved back as far as necessary and potentially to flexdates 1 (start op 1)
86  flexdates[1][1] = g_date->DayInYear(31, 10); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 1) - straw chopping
87 
88  // 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
89  int isSpring = 365;
90  if (StartUpCrop(isSpring, flexdates, int(nl_gge2_cut_to_silage1))) break;
91 
92  // End single block date checking code. Please see next line comment as well.
93  // Reinit d1 to first possible starting date.
94  d1 = g_date->OldDays() + g_date->DayInYear(1, 3) + isSpring;
95  // OK, let's go.
96  if (m_farm->IsStockFarmer()) //Stock Farmer
97  {
99  }
100  else SimpleEvent_(d1, nl_gge2_ferti_p1, false, m_farm, m_field);
101  break;
102  }
103  break;
104 
105  // This is the first real farm operation
106  case nl_gge2_ferti_p1:
107  if (m_farm->DoIt_prob(0.90)) {
108  if (!m_farm->FP_NPK(m_field, 0.0, g_date->DayInYear(30, 3) - g_date->DayInYear())) {
110  break;
111  }
112  }
113  if (m_farm->DoIt_prob(0.50)) {
115  }
117  break;
118  case nl_gge2_ferti_s1:
119  if (m_farm->DoIt_prob(0.90)) {
120  if (!m_farm->FA_NPK(m_field, 0.0, g_date->DayInYear(30, 3) - g_date->DayInYear())) {
122  break;
123  }
124  }
125  if (m_farm->DoIt_prob(0.50)) {
127  }
129  break;
131  // At least 7 days from last watering and 21 from last application of fertilizer.
132  if (g_date->Date() < NL_GGE2_WATER_DATE + 7) {
134  break;
135  }
136  else
137  {
138  if (!m_farm->CutToSilage(m_field, 0.0, g_date->DayInYear(15, 5) - g_date->DayInYear())) {
140  break;
141  }
143  if (m_farm->IsStockFarmer()) //Stock Farmer
144  {
146  }
147  else SimpleEvent_(g_date->Date() + 1, nl_gge2_ferti_p2, false, m_farm, m_field);
148  // Start water thread
150  break;
151  }
152  break;
153 
154  case nl_gge2_ferti_s2:
155  if (!m_farm->FA_Slurry(m_field, 0.0, (NL_GGE2_CUT_DATE + 4) - g_date->DayInYear())) {
157  break;
158  }
160  break;
161  case nl_gge2_ferti_p2:
162  if (!m_farm->FP_Slurry(m_field, 0.0, (NL_GGE2_CUT_DATE + 4) - g_date->DayInYear())) {
164  break;
165  }
167  break;
168  case nl_gge2_ferti_s3:
169  if (m_ev->m_lock || m_farm->DoIt_prob(0.90))
170  {
171  if (!m_farm->FA_NPK(m_field, 0.0, g_date->DayInYear(25, 5) - g_date->DayInYear())) {
173  break;
174  }
175  }
177  break;
178  case nl_gge2_ferti_p3:
179  if (m_ev->m_lock || m_farm->DoIt_prob(0.90))
180  {
181  if (!m_farm->FP_NPK(m_field, 0.0, g_date->DayInYear(25, 5) - g_date->DayInYear())) {
183  break;
184  }
185  }
187  break;
189  // At least 7 days from last watering and 21 from last application of fertilizer.
190  if (g_date->Date() < NL_GGE2_WATER_DATE + 7) {
192  break;
193  }
194  else
195  {
196  if (!m_farm->CutToSilage(m_field, 0.0, g_date->DayInYear(30, 7) - g_date->DayInYear())) {
198  break;
199  }
201  if (m_farm->IsStockFarmer()) //Stock Farmer
202  {
204  }
205  else SimpleEvent_(g_date->Date() + 1, nl_gge2_ferti_p4, false, m_farm, m_field);
206  break;
207  }
208  break;
209  case nl_gge2_ferti_s4:
210  if (!m_farm->FA_Slurry(m_field, 0.0, (NL_GGE2_CUT_DATE + 4) - g_date->DayInYear())) {
212  break;
213  }
215  break;
216  case nl_gge2_ferti_p4:
217  if (!m_farm->FP_Slurry(m_field, 0.0, (NL_GGE2_CUT_DATE + 4) - g_date->DayInYear())) {
219  break;
220  }
222  break;
223  case nl_gge2_ferti_s5:
224  if (m_ev->m_lock || m_farm->DoIt_prob(0.90))
225  {
226  if (!m_farm->FA_NPK(m_field, 0.0, g_date->DayInYear(10, 8) - g_date->DayInYear())) {
228  break;
229  }
230  }
231  done = true;
232  break;
233  case nl_gge2_ferti_p5:
234  if (m_ev->m_lock || m_farm->DoIt_prob(0.90))
235  {
236  if (!m_farm->FP_NPK(m_field, 0.0, g_date->DayInYear(10, 8) - g_date->DayInYear())) {
238  break;
239  }
240  }
241  done = true;
242  break;
243  case nl_gge2_cattle_out:
244  if (!m_farm->CattleOut(m_field, 0.0, g_date->DayInYear(30, 5) - g_date->DayInYear())) {
246  break;
247  }
248  // Keep them out there
250  break;
251  case nl_gge2_cattle_is_out: // Keep the cattle out there
252  // CattleIsOut() returns false if it is not time to stop grazing
253  if (!m_farm->CattleIsOut(m_field, 0.0, g_date->DayInYear(31, 8) - g_date->DayInYear(), g_date->DayInYear(31, 8))) {
255  break;
256  }
257  if (m_farm->IsStockFarmer()) //Stock Farmer
258  {
260  }
261  else SimpleEvent_(g_date->Date() + 1, nl_gge2_ferti_p6, false, m_farm, m_field);
262  break;
263  case nl_gge2_ferti_s6:
264  if (!m_farm->FA_Slurry(m_field, 0.0, g_date->DayInYear(5, 9) - g_date->DayInYear())) {
266  break;
267  }
268  done = true;
269  break;
270  case nl_gge2_ferti_p6:
271  if (!m_farm->FP_Slurry(m_field, 0.0, g_date->DayInYear(5, 9) - g_date->DayInYear())) {
273  break;
274  }
275  done = true;
276  break;
277  case nl_gge2_watering:
278  if (m_ev->m_lock || m_farm->DoIt_prob(0.40))
279  {
280  if (g_date->Date() < NL_GGE2_CUT_DATE + 3) {
281  // Too close to silage cutting, so try again tomorrow.
283  }
284  else
285  {
286  if (!m_farm->Water(m_field, 0.0, g_date->DayInYear(31, 8) - g_date->DayInYear())) {
288  break;
289  }
291  }
292  }
293  // End of thread
294  break;
295  default:
296  g_msg->Warn(WARN_BUG, "NLGrassGrazedExtensive2::Do(): "
297  "Unknown event type! ", "");
298  exit(1);
299  }
300  return done;
301 }

References Farm::CattleIsOut(), Farm::CattleOut(), LE::ClearManagementActionSum(), Farm::CutToSilage(), Calendar::Date(), Calendar::DayInYear(), Farm::DoIt_prob(), Farm::FA_NPK(), Farm::FA_Slurry(), Farm::FP_NPK(), Farm::FP_Slurry(), g_date, g_msg, Farm::IsStockFarmer(), Crop::m_ev, Crop::m_farm, Crop::m_field, Crop::m_last_date, FarmEvent::m_lock, FarmEvent::m_todo, nl_gge2_cattle_is_out, nl_gge2_cattle_out, NL_GGE2_CUT_DATE, nl_gge2_cut_to_silage1, nl_gge2_cut_to_silage2, NL_GGE2_FERTI_DATE, nl_gge2_ferti_p1, nl_gge2_ferti_p2, nl_gge2_ferti_p3, nl_gge2_ferti_p4, nl_gge2_ferti_p5, nl_gge2_ferti_p6, nl_gge2_ferti_s1, nl_gge2_ferti_s2, nl_gge2_ferti_s3, nl_gge2_ferti_s4, nl_gge2_ferti_s5, nl_gge2_ferti_s6, nl_gge2_start, NL_GGE2_WATER_DATE, nl_gge2_watering, Calendar::OldDays(), Crop::SimpleEvent_(), Crop::StartUpCrop(), tov_NLGrassGrazedExtensive2, MapErrorMsg::Warn(), WARN_BUG, and Farm::Water().

◆ SetUpFarmCategoryInformation()

void NLGrassGrazedExtensive2::SetUpFarmCategoryInformation ( )
inline
82  {
83  const int elements = 2 + (nl_gge2_foobar - NLGRASSGRAZEDEXTENSIVE2_BASE);
85 
86  FarmManagementCategory catlist[elements] =
87  {
88  fmc_Others, // zero element unused but must be here
89  fmc_Others,//nl_gge2_start = 1, // Compulsory, must always be 1 (one).
90  fmc_Others,//nl_gge2_sleep_all_day = NLGRASSGRAZEDEXTENSIVE2_BASE,
91  fmc_Fertilizer,//nl_gge2_ferti_p1,
92  fmc_Fertilizer,//nl_gge2_ferti_s1,
93  fmc_Cutting,//nl_gge2_cut_to_silage1,
94  fmc_Cutting,//nl_gge2_cut_to_silage2,
95  fmc_Fertilizer,//nl_gge2_ferti_p2,
96  fmc_Fertilizer,//nl_gge2_ferti_s2,
97  fmc_Fertilizer,//nl_gge2_ferti_p3,
98  fmc_Fertilizer,//nl_gge2_ferti_s3,
99  fmc_Fertilizer,//nl_gge2_ferti_p4,
100  fmc_Fertilizer,//nl_gge2_ferti_s4,
101  fmc_Fertilizer,//nl_gge2_ferti_p5,
102  fmc_Fertilizer,//nl_gge2_ferti_s5,
103  fmc_Fertilizer,//nl_gge2_ferti_p6,
104  fmc_Fertilizer,//nl_gge2_ferti_s6,
105  fmc_Fertilizer,//nl_gge2_watering,
106  fmc_Grazing,//nl_gge2_cattle_out,
107  fmc_Grazing//nl_gge2_cattle_is_out,
108 
109  // no foobar entry
110 
111  };
112  // Iterate over the catlist elements and copy them to vector
113  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
114 
115  }

References fmc_Cutting, fmc_Fertilizer, fmc_Grazing, fmc_Others, Crop::m_base_elements_no, Crop::m_ManagementCategories, nl_gge2_foobar, and NLGRASSGRAZEDEXTENSIVE2_BASE.

Referenced by NLGrassGrazedExtensive2().


The documentation for this class was generated from the following files:
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::IsStockFarmer
bool IsStockFarmer(void)
Definition: Farm.h:961
FarmEvent::m_lock
bool m_lock
Definition: Farm.h:384
Farm::CattleIsOut
virtual bool CattleIsOut(LE *a_field, double a_user, int a_days, int a_max)
Generate a 'cattle_out' event for every day the cattle are on a_field.
Definition: FarmFuncs.cpp:2470
LE::ClearManagementActionSum
void ClearManagementActionSum()
clears the management action counters
Definition: Elements.h:247
Farm::FP_NPK
virtual bool FP_NPK(LE *a_field, double a_user, int a_days)
Apply NPK fertilizer, on a_field owned by an arable farmer.
Definition: FarmFuncs.cpp:645
Farm::CutToSilage
virtual bool CutToSilage(LE *a_field, double a_user, int a_days)
Cut vegetation for silage on a_field.
Definition: FarmFuncs.cpp:1644
nl_gge2_ferti_s2
Definition: NLGrassGrazedExtensive2.h:46
nl_gge2_cut_to_silage1
Definition: NLGrassGrazedExtensive2.h:43
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
nl_gge2_ferti_s1
Definition: NLGrassGrazedExtensive2.h:42
NL_GGE2_WATER_DATE
#define NL_GGE2_WATER_DATE
Definition: NLGrassGrazedExtensive2.h:30
Crop::m_base_elements_no
int m_base_elements_no
Definition: Farm.h:505
nl_gge2_ferti_p6
Definition: NLGrassGrazedExtensive2.h:53
Crop::m_first_date
int m_first_date
Definition: Farm.h:501
Farm::FA_NPK
virtual bool FA_NPK(LE *a_field, double a_user, int a_days)
Apply NPK fertilizer to a_field owned by an stock farmer.
Definition: FarmFuncs.cpp:982
NL_GGE2_CUT_DATE
#define NL_GGE2_CUT_DATE
Definition: NLGrassGrazedExtensive2.h:29
nl_gge2_ferti_p4
Definition: NLGrassGrazedExtensive2.h:49
nl_gge2_ferti_p3
Definition: NLGrassGrazedExtensive2.h:47
nl_gge2_cut_to_silage2
Definition: NLGrassGrazedExtensive2.h:44
nl_gge2_foobar
Definition: NLGrassGrazedExtensive2.h:58
NLGrassGrazedExtensive2::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: NLGrassGrazedExtensive2.h:82
fmc_Cutting
Definition: LandscapeFarmingEnums.h:1009
fmc_Fertilizer
Definition: LandscapeFarmingEnums.h:1004
nl_gge2_watering
Definition: NLGrassGrazedExtensive2.h:55
nl_gge2_ferti_p2
Definition: NLGrassGrazedExtensive2.h:45
NL_GGE2_FERTI_DATE
#define NL_GGE2_FERTI_DATE
A flag used to indicate autumn ploughing status.
Definition: NLGrassGrazedExtensive2.h:28
nl_gge2_cattle_is_out
Definition: NLGrassGrazedExtensive2.h:57
nl_gge2_ferti_s3
Definition: NLGrassGrazedExtensive2.h:48
Calendar::Date
long Date(void)
Definition: Calendar.h:57
nl_gge2_ferti_p1
Definition: NLGrassGrazedExtensive2.h:41
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
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
tov_NLGrassGrazedExtensive2
Definition: LandscapeFarmingEnums.h:274
FarmEvent::m_todo
int m_todo
Definition: Farm.h:388
NLGRASSGRAZEDEXTENSIVE2_BASE
#define NLGRASSGRAZEDEXTENSIVE2_BASE
Definition: NLGrassGrazedExtensive2.h:24
nl_gge2_cattle_out
Definition: NLGrassGrazedExtensive2.h:56
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
nl_gge2_ferti_s6
Definition: NLGrassGrazedExtensive2.h:54
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
fmc_Grazing
Definition: LandscapeFarmingEnums.h:1010
TTypesOfVegetation
TTypesOfVegetation
Values that represent the types of vegetation that are represented in ALMaSS.
Definition: LandscapeFarmingEnums.h:192
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
nl_gge2_ferti_s4
Definition: NLGrassGrazedExtensive2.h:50
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
Farm::CattleOut
virtual bool CattleOut(LE *a_field, double a_user, int a_days)
Start a grazing event on a_field today.
Definition: FarmFuncs.cpp:2368
WARN_BUG
Definition: MapErrorMsg.h:34
nl_gge2_start
Definition: NLGrassGrazedExtensive2.h:39
nl_gge2_ferti_p5
Definition: NLGrassGrazedExtensive2.h:51
FarmManagementCategory
FarmManagementCategory
Definition: LandscapeFarmingEnums.h:1001
nl_gge2_ferti_s5
Definition: NLGrassGrazedExtensive2.h:52
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