Loading [MathJax]/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
NLCatchCropPea Class Reference

NLCatchCropPea class
. More...

#include <NLCatchCropPea.h>

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

NLCatchCropPea class
.

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

◆ NLCatchCropPea()

NLCatchCropPea::NLCatchCropPea ( TTypesOfVegetation  a_tov,
TTypesOfCrops  a_toc,
Landscape a_L 
)
inline

As a catch crop this differs a bit from the normal use of m_first_date. In this case we use the last possible date of the first action.

56  : Crop(a_tov, a_toc, a_L)
57  {
61  m_first_date=g_date->DayInYear( 15,10 );
64  }

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

Member Function Documentation

◆ Do()

bool NLCatchCropPea::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 CatchPeaCrop.

Reimplemented from Crop.

55 {
56 /******************** This block can be added to the top of all Crop::Do methods ***********************************************/
57  m_farm = a_farm; // These assignments are necessary, not for this method but for related event calls
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).
61  int d1 = 0;
62  int noDates = 1;
63  TTypesOfVegetation l_tov = tov_NLCatchCropPea; // The current type - change to match the crop you have
64 /**********************************************To Here *************************************************************************/
65 
66  // Depending what event has occured jump to the correct bit of code
67  switch (m_ev->m_todo)
68  {
69  case nl_ccp_start:
70  {
72 
73  // Reinit d1 to first possible starting date.
74  d1 = g_date->OldDays() + g_date->DayInYear(1, 8);
75  // OK, let's go.
77  }
78  break;
79 
80  // This is the first real farm operation
82  if (!m_farm->StubbleHarrowing(m_field, 0.0, g_date->DayInYear(10, 10) - g_date->DayInYear())) {
84  break;
85  }
86  // Here we queue up the nextt event - this differs depending on whether we have a
87  // stock or arable farmer
88  if (m_farm->IsStockFarmer()) //Stock Farmer
89  {
91  }
92  else SimpleEvent_(g_date->Date() + 5, nl_ccp_ferti_p1, false, m_farm, m_field);
93  break;
94 
95  case nl_ccp_ferti_p1:
96  if (!m_farm->FP_Slurry(m_field, 0.0, g_date->DayInYear(15, 10) - g_date->DayInYear())) {
98  break;
99  }
101  break;
102  case nl_ccp_ferti_s1:
103  if (!m_farm->FA_Slurry(m_field, 0.0, g_date->DayInYear(15, 10) - g_date->DayInYear())) {
105  break;
106  }
108  break;
112  break;
113  }
114  d1 = g_date->Date() + 14;
115  if (d1 < g_date->OldDays() + g_date->DayInYear(1, 9)) {
116  d1 = g_date->OldDays() + g_date->DayInYear(1, 9);
117  }
118  if (m_field->GetSoilType() == 2 || m_field->GetSoilType() == 6) { // on sandy soils (NL ZAND & LOSS)
119  if (m_farm->IsStockFarmer()) {
121  }
122  else {
124  }
125  }
126  else {
127  if (m_farm->IsStockFarmer()) {
129  }
130  else {
132  }
133  }
134  break;
136  if (!m_farm->FA_Manure(m_field, 0.0, g_date->DayInYear(5, 11) - g_date->DayInYear())) {
138  break;
139  }
140  d1 = g_date->Date() + 40;
141  if (d1 < g_date->OldDays() + g_date->DayInYear(15, 10)) {
142  d1 = g_date->OldDays() + g_date->DayInYear(15, 10);
143  }
145  break;
147  if (!m_farm->FP_Manure(m_field, 0.0, g_date->DayInYear(5, 11) - g_date->DayInYear())) {
149  break;
150  }
151  d1 = g_date->Date() + 40;
152  if (d1 < g_date->OldDays() + g_date->DayInYear(15, 10)) {
153  d1 = g_date->OldDays() + g_date->DayInYear(15, 10);
154  }
156  break;
158  if (!m_farm->WinterPlough(m_field, 0.0, g_date->DayInYear(20, 12) - g_date->DayInYear())) {
160  break;
161  }
162  // The plan is finished on clay soils (catch crop in incorporated into soil on autumn)
163  // Calling sleep_all_day to move to the next year
165  //SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 1) + 365, nl_ccp_ferti_s2_sandy, false, m_farm, m_field);
166  break;
168  if (!m_farm->SleepAllDay(m_field, 0.0, g_date->DayInYear(15, 3) - g_date->DayInYear())) {
170  break;
171  }
172  done = true;
173  break;
175  if (!m_farm->FA_Manure(m_field, 0.0, g_date->DayInYear(15, 3) - g_date->DayInYear())) {
177  break;
178  }
179  // The plan is finished on sandy soils; spring plough (to incorporate catch crop into soil) will follow but it is called from the next crop
180  done = true;
181  break;
183  if (!m_farm->FP_Manure(m_field, 0.0, g_date->DayInYear(15, 3) - g_date->DayInYear())) {
185  break;
186  }
187  // The plan is finished on sandy soils; spring plough (to incorporate catch crop into soil) will follow but it is called from the next crop
188  done = true;
189  break;
190  default:
191  g_msg->Warn(WARN_BUG, "NLCatchCropPea::Do(): "
192  "Unknown event type! ", "");
193  exit(1);
194  }
195  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
196  return done;
197 }

References LE::ClearManagementActionSum(), Calendar::Date(), Calendar::DayInYear(), Farm::FA_Manure(), Farm::FA_Slurry(), Farm::FP_Manure(), Farm::FP_Slurry(), g_date, g_msg, LE::GetSoilType(), Farm::IsStockFarmer(), Crop::m_ev, Crop::m_farm, Crop::m_field, FarmEvent::m_forcespring, FarmEvent::m_todo, nl_ccp_ferti_p1, nl_ccp_ferti_p2_clay, nl_ccp_ferti_p2_sandy, nl_ccp_ferti_s1, nl_ccp_ferti_s2_clay, nl_ccp_ferti_s2_sandy, nl_ccp_preseeding_cultivator_with_sow, nl_ccp_sleep_all_day, nl_ccp_start, nl_ccp_stubble_cultivator, nl_ccp_winter_plough_clay, Calendar::OldDays(), Farm::PreseedingCultivatorSow(), Crop::SimpleEvent_(), Farm::SleepAllDay(), Farm::StubbleHarrowing(), tov_NLCatchCropPea, MapErrorMsg::Warn(), WARN_BUG, and Farm::WinterPlough().

◆ SetUpFarmCategoryInformation()

void NLCatchCropPea::SetUpFarmCategoryInformation ( )
inline
65  {
66  const int elements = 2 + (nl_ccp_foobar - NLCatchCropPea_BASE);
68 
69  FarmManagementCategory catlist[elements] =
70  {
71  fmc_Others, // zero element unused but must be here
72  fmc_Others,//nl_ccp_start = 1, // Compulsory, must always be 1 (one).
73  fmc_Others,//nl_ccp_sleep_all_day = NLCatchCropPea_BASE,
74  fmc_Cultivation,//nl_ccp_stubble_cultivator,
75  fmc_Fertilizer,//nl_ccp_ferti_p1,
76  fmc_Fertilizer,//nl_ccp_ferti_s1,
77  fmc_Cultivation,//nl_ccp_preseeding_cultivator_with_sow,
78  fmc_Fertilizer,//nl_ccp_ferti_p2_clay,
79  fmc_Fertilizer,//nl_ccp_ferti_s2_clay,
80  fmc_Cultivation,//nl_ccp_winter_plough_clay,
81  fmc_Fertilizer,//nl_ccp_ferti_p2_sandy,
82  fmc_Fertilizer//nl_ccp_ferti_s2_sandy,
83 
84  };
85  // Iterate over the catlist elements and copy them to vector
86  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
87 
88  }

References fmc_Cultivation, fmc_Fertilizer, fmc_Others, Crop::m_base_elements_no, Crop::m_ManagementCategories, nl_ccp_foobar, and NLCatchCropPea_BASE.

Referenced by NLCatchCropPea().


The documentation for this class was generated from the following files:
FarmEvent::m_forcespring
bool m_forcespring
Definition: Farm.h:392
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
nl_ccp_preseeding_cultivator_with_sow
Definition: NLCatchCropPea.h:34
LE::ClearManagementActionSum
void ClearManagementActionSum()
clears the management action counters
Definition: Elements.h:247
nl_ccp_foobar
Definition: NLCatchCropPea.h:40
g_date
class Calendar * g_date
Definition: Calendar.cpp:37
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
nl_ccp_ferti_s2_clay
Definition: NLCatchCropPea.h:36
Crop::m_base_elements_no
int m_base_elements_no
Definition: Farm.h:505
nl_ccp_ferti_s1
Definition: NLCatchCropPea.h:33
nl_ccp_start
Definition: NLCatchCropPea.h:29
Crop::m_first_date
int m_first_date
Definition: Farm.h:501
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
nl_ccp_sleep_all_day
Definition: NLCatchCropPea.h:30
fmc_Fertilizer
Definition: LandscapeFarmingEnums.h:1004
nl_ccp_ferti_p2_clay
Definition: NLCatchCropPea.h:35
Calendar::Date
long Date(void)
Definition: Calendar.h:57
nl_ccp_ferti_s2_sandy
Definition: NLCatchCropPea.h:39
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
tocc_Catch
Definition: LandscapeFarmingEnums.h:627
MapErrorMsg::Warn
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: MapErrorMsg.cpp:69
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
Farm::PreseedingCultivatorSow
virtual bool PreseedingCultivatorSow(LE *a_field, double a_user, int a_days, double a_seed_coating_amount=-1, PlantProtectionProducts a_ppp=ppp_foobar)
Carry out preseeding cultivation together with sow on a_field (tilling and sowing set including culti...
Definition: FarmFuncs.cpp:325
FarmEvent::m_todo
int m_todo
Definition: Farm.h:388
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
Farm::SleepAllDay
virtual bool SleepAllDay(LE *a_field, double a_user, int a_days)
Nothing to to today on a_field.
Definition: FarmFuncs.cpp:272
NLCatchCropPea_BASE
#define NLCatchCropPea_BASE
Definition: NLCatchCropPea.h:21
NLCatchCropPea::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: NLCatchCropPea.h:65
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
nl_ccp_ferti_p2_sandy
Definition: NLCatchCropPea.h:38
TTypesOfVegetation
TTypesOfVegetation
Values that represent the types of vegetation that are represented in ALMaSS.
Definition: LandscapeFarmingEnums.h:192
nl_ccp_stubble_cultivator
Definition: NLCatchCropPea.h:31
nl_ccp_ferti_p1
Definition: NLCatchCropPea.h:32
nl_ccp_winter_plough_clay
Definition: NLCatchCropPea.h:37
Farm::WinterPlough
virtual bool WinterPlough(LE *a_field, double a_user, int a_days)
Carry out a ploughing event in the winter on a_field.
Definition: FarmFuncs.cpp:395
Calendar::DayInYear
int DayInYear(void)
Definition: Calendar.h:58
Crop::SetCropClassification
void SetCropClassification(int a_classification)
Definition: Farm.h:549
Crop::Crop
Crop(TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape *a_L)
Definition: Farm.cpp:733
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
tov_NLCatchCropPea
Definition: LandscapeFarmingEnums.h:268
WARN_BUG
Definition: MapErrorMsg.h:34
FarmManagementCategory
FarmManagementCategory
Definition: LandscapeFarmingEnums.h:1001
Farm::StubbleHarrowing
virtual bool StubbleHarrowing(LE *a_field, double a_user, int a_days)
Carry out stubble harrowing on a_field.
Definition: FarmFuncs.cpp:1523
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