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

NLBeetSpring class
. More...

#include <NLBeetSpring.h>

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

NLBeetSpring class
.

See NLBeetSpring.h::NLBeetSpringToDo for a complete list of all possible events triggered codes by the beet 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

◆ NLBeetSpring()

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

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

Member Function Documentation

◆ Do()

bool NLBeetSpring::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 beet.

Reimplemented from Crop.

65 {
66  /******************** This block can be added to the top of all Crop::Do methods ***********************************************/
67  m_farm = a_farm;
68  m_field = a_field;
69  m_ev = a_ev;
70  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).
71  bool flag = false;
72  int d1 = 0;
73  int noDates = 1;
75  int l_nextcropstartdate;
76  /**********************************************To Here *************************************************************************/
77 
78  // Depending what event has occured jump to the correct bit of code
79  switch (m_ev->m_todo)
80  {
81  case nl_bes_start:
82  {
83  NL_BES_FUNGI1 = false;
84  NL_BES_HERBI1 = false;
86 
87  m_last_date = g_date->DayInYear(15, 12); // Should match the last flexdate below
88  //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
89  std::vector<std::vector<int>> flexdates(1 + 1, std::vector<int>(2, 0));
90  // Set up the date management stuff
91  // Start and stop dates for all events after harvest
92  flexdates[0][1] = g_date->DayInYear(15, 12); // last possible day of harvest - this is in effect day before the earliest date that a following crop can use
93 
94  flexdates[1][0] = -1; // This date will be moved back as far as necessary and potentially to flexdates 1 (start op 1)
95  flexdates[1][1] = g_date->DayInYear(15, 12); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 1) - straw chopping
96 
97  // 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
98  int isSpring = 365;
99  if (StartUpCrop(isSpring, flexdates, int(nl_bes_spring_sow))) break;
100 
101  // End single block date checking code. Please see next line comment as well.
102  // Reinit d1 to first possible starting date.
103  d1 = g_date->OldDays() + g_date->DayInYear(1, 3) + isSpring;
104  // OK, let's go.
105  // Here we queue up the first event - this differs depending on whether we have field on snady or clay soils
106  if (m_field->GetSoilType() == 2 || m_field->GetSoilType() == 6) { // on sandy soils (NL ZAND & LOSS)
108  }
109  else
110  {
111  if (m_farm->IsStockFarmer()) //Stock Farmer
112  {
114  }
115  else SimpleEvent_(d1, nl_bes_ferti_p1, false, m_farm, m_field);
116  }
117  break;
118  }
119  break;
120 
121  // This is the first real farm operation
123  if (!m_farm->SpringPlough(m_field, 0.0, g_date->DayInYear(30, 3) - g_date->DayInYear())) {
125  break;
126  }
127  if (m_farm->IsStockFarmer()) //Stock Farmer
128  {
130  }
131  else SimpleEvent_(g_date->Date() + 7, nl_bes_ferti_p1, false, m_farm, m_field);
132  break;
133  case nl_bes_ferti_p1:
134  if (m_ev->m_lock || m_farm->DoIt_prob(0.60))
135  {
136  if (!m_farm->FP_NPK(m_field, 0.0, g_date->DayInYear(10, 4) - g_date->DayInYear())) {
138  break;
139  }
140  }
142  break;
143  case nl_bes_ferti_s1:
144  if (m_ev->m_lock || m_farm->DoIt_prob(0.60))
145  {
146  if (!m_farm->FA_NPK(m_field, 0.0, g_date->DayInYear(10, 4) - g_date->DayInYear())) {
148  break;
149  }
150  }
152  break;
154  if (!m_farm->PreseedingCultivator(m_field, 0.0, g_date->DayInYear(14, 4) - g_date->DayInYear())) {
156  break;
157  }
159  break;
160  case nl_bes_spring_sow:
161  if (!m_farm->SpringSow(m_field, 0.0, g_date->DayInYear(15, 4) - g_date->DayInYear())) {
163  break;
164  }
165  // Here is a fork leading to four parallel events
166  SimpleEvent_(g_date->Date() + 5, nl_bes_herbicide1, false, m_farm, m_field); // Herbicide thread
167  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 7), nl_bes_fungicide1, false, m_farm, m_field); // Fungicide thread = MAIN THREAD
168  if (m_farm->IsStockFarmer()) //Stock Farmer
169  {
170  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(15, 4), nl_bes_ferti_s2, false, m_farm, m_field); // Fertilizers thread
171  }
173  break;
174  case nl_bes_ferti_p2:
175  // Here comes fertilizers thread
176  if (m_field->GetGreenBiomass() <= 0) {
178  }
179  else
180  {
181  if (!m_farm->FP_AmmoniumSulphate(m_field, 0.0, g_date->DayInYear(15, 5) - g_date->DayInYear())) {
183  break;
184  }
185  }
186  // End of thread
187  break;
188  case nl_bes_ferti_s2:
189  if (m_field->GetGreenBiomass() <= 0) {
191  break;
192  }
193  else
194  {
195  if (!m_farm->FA_AmmoniumSulphate(m_field, 0.0, g_date->DayInYear(15, 5) - g_date->DayInYear())) {
197  break;
198  }
199  }
200  // End of thread
201  break;
202  case nl_bes_herbicide1: // The first of the pesticide managements.
203  // Here comes the herbicide thread
204  // We assume that farmers do max 3 herbicide treatments
205  if (m_field->GetGreenBiomass() <= 0)
206  {
207  if (m_ev->m_lock || m_farm->DoIt_prob(0.75))
208  {
209  if (!m_farm->HerbicideTreat(m_field, 0.0, g_date->DayInYear(20, 4) - g_date->DayInYear())) {
211  break;
212  }
213  NL_BES_HERBI1 = true;
214  }
216  break;
217  }
219  break;
220  case nl_bes_herbicide2:
221  if (m_field->GetGreenBiomass() <= 0) {
223  }
224  else
225  {
226  if (!m_farm->HerbicideTreat(m_field, 0.0, g_date->DayInYear(30, 4) - g_date->DayInYear())) {
228  break;
229  }
231  break;
232  }
233  break;
234  case nl_bes_herbicide3:
235  if (!m_farm->HerbicideTreat(m_field, 0.0, g_date->DayInYear(15, 5) - g_date->DayInYear())) {
237  break;
238  }
240  break;
241  case nl_bes_herbicide4:
242  if (m_ev->m_lock || (m_farm->DoIt_prob(0.20) && (NL_BES_HERBI1 == false)))
243  {
244  if (!m_farm->HerbicideTreat(m_field, 0.0, g_date->DayInYear(30, 5) - g_date->DayInYear())) {
246  break;
247  }
248  }
249  // End of thread
250  break;
251  case nl_bes_fungicide1:
252  // Here comes the fungicide thread
253  if (!m_farm->FungicideTreat(m_field, 0.0, g_date->DayInYear(5, 8) - g_date->DayInYear())) {
255  break;
256  }
258  break;
259  case nl_bes_fungicide2:
260  if (m_ev->m_lock || m_farm->DoIt_prob(0.75))
261  {
262  if (!m_farm->FungicideTreat(m_field, 0.0, g_date->DayInYear(25, 8) - g_date->DayInYear())) {
264  break;
265  }
266  NL_BES_FUNGI1 = true;
267  }
269  break;
270  case nl_bes_fungicide3:
271  if (m_ev->m_lock || (m_farm->DoIt_prob(0.667) && NL_BES_FUNGI1 == 1)) // 50% of all farmers
272  {
273  if (!m_farm->FungicideTreat(m_field, 0.0, g_date->DayInYear(15, 9) - g_date->DayInYear())) {
275  break;
276  }
277  }
279  break;
280  case nl_bes_harvest:
281  // Here the MAIN thread continues
282  // We don't move harvest days
283  if (!m_farm->Harvest(m_field, 0.0, m_field->GetMDates(1, 0) - g_date->DayInYear())) {
285  break;
286  }
287  done = true;
288  // So we are done, and somwhere else the farmer will queue up the start event of the next crop
289  // END of MAIN THREAD
290  break;
291  default:
292  g_msg->Warn(WARN_BUG, "NLBeetSpring::Do(): "
293  "Unknown event type! ", "");
294  exit(1);
295  }
296  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
297  return done;
298 }

References LE::ClearManagementActionSum(), Calendar::Date(), Calendar::DayInYear(), Farm::DoIt_prob(), Farm::FA_AmmoniumSulphate(), Farm::FA_NPK(), Farm::FP_AmmoniumSulphate(), Farm::FP_NPK(), Farm::FungicideTreat(), g_date, g_msg, LE::GetGreenBiomass(), LE::GetMDates(), LE::GetSoilType(), Farm::Harvest(), 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, nl_bes_ferti_p1, nl_bes_ferti_p2, nl_bes_ferti_s1, nl_bes_ferti_s2, NL_BES_FUNGI1, nl_bes_fungicide1, nl_bes_fungicide2, nl_bes_fungicide3, nl_bes_harvest, NL_BES_HERBI1, nl_bes_herbicide1, nl_bes_herbicide2, nl_bes_herbicide3, nl_bes_herbicide4, nl_bes_preseeding_cultivator, nl_bes_spring_plough_sandy, nl_bes_spring_sow, nl_bes_start, Calendar::OldDays(), Farm::PreseedingCultivator(), Crop::SimpleEvent_(), Farm::SpringPlough(), Farm::SpringSow(), Crop::StartUpCrop(), tov_NLBeetSpring, MapErrorMsg::Warn(), and WARN_BUG.

◆ SetUpFarmCategoryInformation()

void NLBeetSpring::SetUpFarmCategoryInformation ( )
inline
79  {
80  const int elements = 2 + (nl_bes_foobar - NLBEETSPRING_BASE);
82 
83  FarmManagementCategory catlist[elements] =
84  {
85  fmc_Others, // zero element unused but must be here
86  fmc_Others,//nl_bes_start = 1, // Compulsory, must always be 1 (one).
87  fmc_Others,//nl_bes_sleep_all_day = NLBEETSPRING_BASE,
88  fmc_Cultivation,//nl_bes_spring_plough_sandy,
89  fmc_Fertilizer,//nl_bes_ferti_p1,
90  fmc_Fertilizer,//nl_bes_ferti_s1,
91  fmc_Cultivation,//nl_bes_preseeding_cultivator,
92  fmc_Others,//nl_bes_spring_sow,
93  fmc_Fertilizer,//nl_bes_ferti_p2,
94  fmc_Fertilizer,//nl_bes_ferti_s2,
95  fmc_Herbicide,//nl_bes_herbicide1,
96  fmc_Herbicide,//nl_bes_herbicide2,
97  fmc_Herbicide,//nl_bes_herbicide3,
98  fmc_Herbicide,//nl_bes_herbicide4,
99  fmc_Fungicide,//nl_bes_fungicide1,
100  fmc_Fungicide,//nl_bes_fungicide2,
101  fmc_Fungicide,//nl_bes_fungicide3,
102  fmc_Harvest//nl_bes_harvest,
103  };
104  // Iterate over the catlist elements and copy them to vector
105  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
106 
107  }

References fmc_Cultivation, fmc_Fertilizer, fmc_Fungicide, fmc_Harvest, fmc_Herbicide, fmc_Others, Crop::m_base_elements_no, Crop::m_ManagementCategories, nl_bes_foobar, and NLBEETSPRING_BASE.

Referenced by NLBeetSpring().


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
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::SpringPlough
virtual bool SpringPlough(LE *a_field, double a_user, int a_days)
Carry out a ploughing event in the spring on a_field.
Definition: FarmFuncs.cpp:421
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
nl_bes_harvest
Definition: NLBeetSpring.h:54
Farm::Harvest
virtual bool Harvest(LE *a_field, double a_user, int a_days)
Carry out a harvest on a_field.
Definition: FarmFuncs.cpp:1364
FarmEvent::m_lock
bool m_lock
Definition: Farm.h:384
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
nl_bes_herbicide4
Definition: NLBeetSpring.h:50
nl_bes_ferti_s2
Definition: NLBeetSpring.h:46
nl_bes_herbicide3
Definition: NLBeetSpring.h:49
Farm::DoIt_prob
bool DoIt_prob(double a_probability)
Return chance out of 0 to 1.
Definition: Farm.cpp:864
nl_bes_ferti_p1
Definition: NLBeetSpring.h:41
g_date
class Calendar * g_date
Definition: Calendar.cpp:37
fmc_Herbicide
Definition: LandscapeFarmingEnums.h:1006
nl_bes_ferti_s1
Definition: NLBeetSpring.h:42
NLBEETSPRING_BASE
#define NLBEETSPRING_BASE
Definition: NLBeetSpring.h:24
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
nl_bes_preseeding_cultivator
Definition: NLBeetSpring.h:43
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
Farm::FungicideTreat
virtual bool FungicideTreat(LE *a_field, double a_user, int a_days)
Apply fungicide to a_field.
Definition: FarmFuncs.cpp:2101
nl_bes_start
Definition: NLBeetSpring.h:38
NLBeetSpring::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: NLBeetSpring.h:79
NL_BES_HERBI1
#define NL_BES_HERBI1
A flag used to indicate autumn ploughing status.
Definition: NLBeetSpring.h:28
nl_bes_spring_sow
Definition: NLBeetSpring.h:44
fmc_Fertilizer
Definition: LandscapeFarmingEnums.h:1004
nl_bes_spring_plough_sandy
Definition: NLBeetSpring.h:40
Calendar::Date
long Date(void)
Definition: Calendar.h:57
Farm::FP_AmmoniumSulphate
virtual bool FP_AmmoniumSulphate(LE *a_field, double a_user, int a_days)
Apply Ammonium Sulphate to a_field owned by an arable farmer.
Definition: FarmFuncs.cpp:882
fmc_Cultivation
Definition: LandscapeFarmingEnums.h:1008
LE::GetSoilType
int GetSoilType()
Definition: Elements.h:302
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
tov_NLBeetSpring
Definition: LandscapeFarmingEnums.h:262
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
NL_BES_FUNGI1
#define NL_BES_FUNGI1
Definition: NLBeetSpring.h:29
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
LE::GetGreenBiomass
virtual double GetGreenBiomass(void)
Definition: Elements.h:160
Crop::m_last_date
int m_last_date
Definition: Farm.h:503
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
nl_bes_herbicide2
Definition: NLBeetSpring.h:48
Farm::FA_AmmoniumSulphate
virtual bool FA_AmmoniumSulphate(LE *a_field, double a_user, int a_days)
Apply ammonium sulphate to a_field owned by an stock farmer.
Definition: FarmFuncs.cpp:1081
TTypesOfVegetation
TTypesOfVegetation
Values that represent the types of vegetation that are represented in ALMaSS.
Definition: LandscapeFarmingEnums.h:192
fmc_Harvest
Definition: LandscapeFarmingEnums.h:1012
nl_bes_herbicide1
Definition: NLBeetSpring.h:47
nl_bes_ferti_p2
Definition: NLBeetSpring.h:45
nl_bes_fungicide2
Definition: NLBeetSpring.h:52
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_bes_foobar
Definition: NLBeetSpring.h:55
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
WARN_BUG
Definition: MapErrorMsg.h:34
fmc_Fungicide
Definition: LandscapeFarmingEnums.h:1007
nl_bes_fungicide1
Definition: NLBeetSpring.h:51
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
nl_bes_fungicide3
Definition: NLBeetSpring.h:53