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

PTPotatoes class
. More...

#include <PTPotatoes.h>

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

PTPotatoes class
.

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

◆ PTPotatoes()

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

When we start it off, the first possible date for a farm operation is 15th September This information is used by other crops when they decide how much post processing of the management is allowed after harvest before the next crop starts.

86  : Crop(a_tov, a_toc, a_L)
87  {
93  m_first_date = g_date->DayInYear(15, 4);
95  }

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

Member Function Documentation

◆ Do()

bool PTPotatoes::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 a_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 winter wheat.

Reimplemented from Crop.

56 {
57 /******************** This block can be added to the top of all Crop::Do methods ***********************************************/
58  m_farm = a_farm; // These assignments are necessary, not for this method but for related event calls
59  m_field = a_field;
60  m_ev = a_ev;
61  bool done = false; // The boolean value done indicates when we are totally finished with this plan (i.e. it is set to true).
62  int d1 = 0;
63  TTypesOfVegetation l_tov = tov_PTPotatoes; // 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 pt_pot_start:
70  {
72 
73  m_last_date = g_date->DayInYear(20, 8); // Should match the last flexdate below
74  //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
75  std::vector<std::vector<int>> flexdates(1 + 1, std::vector<int>(2, 0));
76  // Set up the date management stuff
77  // Start and stop dates for all events after harvest
78  flexdates[0][1] = g_date->DayInYear(20, 8); // last possible day of harvest - this is in effect day before the earliest date that a following crop can use
79 
80  flexdates[1][0] = -1; // This date will be moved back as far as necessary and potentially to flexdates 1 (start op 1)
81  flexdates[1][1] = g_date->DayInYear(20, 8); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 1)
82 
83  // 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
84  int isSpring = 365;
85  if (StartUpCrop(isSpring, flexdates, int(pt_pot_harvest))) break;
86 
87  // End single block date checking code. Please see next line comment as well.
88  // Reinit d1 to first possible starting date.
89  d1 = g_date->OldDays() + g_date->DayInYear(15, 3) + isSpring;
90  // OK, let's go.
91  // Here we queue up the first event which changes dependent on whether it is a forced spring sow or not
93  break;
94  }
95  break;
96 
97  // This is the first real farm operation
99  if (!m_farm->SpringPlough(m_field, 0.0, g_date->DayInYear(15, 4) - g_date->DayInYear())) {
101  break;
102  }
104  break;
105 
106 
108  if (!m_farm->SpringHarrow(m_field, 0.0, g_date->DayInYear(16, 4) - g_date->DayInYear())) {
110  break;
111  }
112  if (m_farm->IsStockFarmer()) //Stock Farmer
113  {
115  }
117  break;
118 
119  case pt_pot_ferti_s1:
120  if (!m_farm->FA_Manure(m_field, 0.0, g_date->DayInYear(17, 4) - g_date->DayInYear())) {
122  break;
123  }
125  break;
126  case pt_pot_ferti_p1:
127  if (!m_farm->FP_Manure(m_field, 0.0, g_date->DayInYear(17, 4) - g_date->DayInYear())) {
129  break;
130  }
132  break;
133 
134  case pt_pot_bed_forming:
135  if (!m_farm->BedForming(m_field, 0.0, g_date->DayInYear(20, 5) - g_date->DayInYear())) {
137  break;
138  }
140  break;
141 
142  case pt_pot_spring_sow:
143  if (!m_farm->SpringSow(m_field, 0.0, g_date->DayInYear(21, 5) - g_date->DayInYear())) {
145  break;
146  }
147  //Fork of events: irrigation & hilling - main thread
148  d1 = g_date->Date() + 10;
149  if (d1 < g_date->OldDays() + g_date->DayInYear(1, 5)) {
150  d1 = g_date->OldDays() + g_date->DayInYear(1, 5);
151  }
154  break;
155 
156  case pt_pot_irrigation_start1: // Start irrigation
157  if (!m_farm->IrrigationStart(m_field, 0.0, g_date->DayInYear(31, 7) - g_date->DayInYear())) {
159  break;
160  }
161  //Continue the irrigation
163  break;
164  case pt_pot_irrigation1: // Performing irrigation twice a week if no raining
165  if (!m_farm->Irrigation(m_field, 0.0, g_date->DayInYear(31, 7) - g_date->DayInYear(), g_date->DayInYear(31, 7))) {
167  break;
168  }
169  // End of thread
170  break;
171 
172  case pt_pot_hilling:
173  if (!m_farm->HillingUp(m_field, 0.0, g_date->DayInYear(25, 6) - g_date->DayInYear())) {
175  break;
176  }
177  if (m_farm->IsStockFarmer()) //Stock Farmer
178  {
180  }
181  else SimpleEvent_(g_date->Date() + 5, pt_pot_ferti_p2, false, m_farm, m_field);
182  break;
183 
184  case pt_pot_ferti_s2:
185  if (!m_farm->FA_NPK(m_field, 0.0, g_date->DayInYear(30, 6) - g_date->DayInYear())) {
187  break;
188  }
190  break;
191  case pt_pot_ferti_p2:
192  if (!m_farm->FP_NPK(m_field, 0.0, g_date->DayInYear(30, 6) - g_date->DayInYear())) {
194  break;
195  }
197  break;
198 
199  case pt_pot_fungicide1:
200  if (!m_farm->FungicideTreat(m_field, 0.0, g_date->DayInYear(10, 7) - g_date->DayInYear())) {
202  break;
203  }
205  break;
206 
207  case pt_pot_fungicide2:
208  if (!m_farm->FungicideTreat(m_field, 0.0, g_date->DayInYear(25, 7) - g_date->DayInYear())) {
210  break;
211  }
213  break;
214 
215  case pt_pot_desiccation:
216  if (!m_farm->HerbicideTreat(m_field, 0.0, g_date->DayInYear(10, 8) - g_date->DayInYear())) {
218  break;
219  }
220  d1 = g_date->Date() + 10;
221  if (d1 < g_date->OldDays() + g_date->DayInYear(1, 7)) {
222  d1 = g_date->OldDays() + g_date->DayInYear(1, 7);
223  }
225  break;
226 
227  case pt_pot_harvest:
228  if (!m_farm->Harvest(m_field, 0.0, m_field->GetMDates(1, 0) - g_date->DayInYear())) {
230  break;
231  }
232  done = true;
233  break;
234 
235  default:
236  g_msg->Warn(WARN_BUG, "PTPotatoes::Do(): "
237  "Unknown event type! ", "");
238  exit(1);
239  }
240  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
241  return done;
242 }

References Farm::BedForming(), LE::ClearManagementActionSum(), Calendar::Date(), Calendar::DayInYear(), Farm::FA_Manure(), Farm::FA_NPK(), Farm::FP_Manure(), Farm::FP_NPK(), Farm::FungicideTreat(), g_date, g_msg, LE::GetMDates(), Farm::Harvest(), Farm::HerbicideTreat(), Farm::HillingUp(), Farm::Irrigation(), Farm::IrrigationStart(), Farm::IsStockFarmer(), Crop::m_ev, Crop::m_farm, Crop::m_field, FarmEvent::m_forcespring, Crop::m_last_date, FarmEvent::m_todo, Calendar::OldDays(), pt_pot_bed_forming, pt_pot_desiccation, pt_pot_ferti_p1, pt_pot_ferti_p2, pt_pot_ferti_s1, pt_pot_ferti_s2, pt_pot_fungicide1, pt_pot_fungicide2, pt_pot_harvest, pt_pot_hilling, pt_pot_irrigation1, pt_pot_irrigation_start1, pt_pot_spring_harrow, pt_pot_spring_plough, pt_pot_spring_sow, pt_pot_start, Crop::SimpleEvent(), Crop::SimpleEvent_(), Farm::SpringHarrow(), Farm::SpringPlough(), Farm::SpringSow(), Crop::StartUpCrop(), tov_PTPotatoes, MapErrorMsg::Warn(), and WARN_BUG.

◆ SetUpFarmCategoryInformation()

void PTPotatoes::SetUpFarmCategoryInformation ( )
inline
96  {
97  const int elements = 2 + (pt_pot_foobar - PTPOTATOES_BASE);
99 
100  FarmManagementCategory catlist[elements] =
101  {
102  fmc_Others, // zero element unused but must be here
103  fmc_Others, //pt_pot_start = 1, // Compulsory, must always be 1 (one).
104  fmc_Others, //pt_pot_sleep_all_day = PTPOTATOES_BASE,
105  fmc_Cultivation, //pt_pot_spring_plough,
106  fmc_Cultivation, //pt_pot_spring_harrow,
107  fmc_Fertilizer, //pt_pot_ferti_p1, // Manure
108  fmc_Fertilizer, //pt_pot_ferti_s1,
109  fmc_Others, //pt_pot_bed_forming,
110  fmc_Others, //pt_pot_spring_sow,
111  fmc_Watering, //pt_pot_irrigation_start1,
112  fmc_Watering, //pt_pot_irrigation1,
113  fmc_Others, //pt_pot_hilling,
114  fmc_Fertilizer, //pt_pot_ferti_p2, //NPK
115  fmc_Fertilizer, //pt_pot_ferti_s2,
116  fmc_Fungicide, //pl_pot_fungicide1,
117  fmc_Fungicide, //pl_pot_fungicide2,
118  fmc_Others, //pl_pot_desiccation,
119  fmc_Harvest //pt_pot_harvest1,
120 
121  // no foobar entry
122 
123  };
124  // Iterate over the catlist elements and copy them to vector
125  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
126 
127  }

References fmc_Cultivation, fmc_Fertilizer, fmc_Fungicide, fmc_Harvest, fmc_Others, fmc_Watering, Crop::m_base_elements_no, Crop::m_ManagementCategories, pt_pot_foobar, and PTPOTATOES_BASE.

Referenced by PTPotatoes().


The documentation for this class was generated from the following files:
LE::GetMDates
int GetMDates(int a, int b)
Definition: Elements.h:405
pt_pot_ferti_p1
Definition: PTPotatoes.h:57
FarmEvent::m_forcespring
bool m_forcespring
Definition: Farm.h:392
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
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
pt_pot_ferti_s1
Definition: PTPotatoes.h:58
pt_pot_hilling
Definition: PTPotatoes.h:63
pt_pot_irrigation_start1
Definition: PTPotatoes.h:61
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
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
pt_pot_ferti_p2
Definition: PTPotatoes.h:64
g_date
class Calendar * g_date
Definition: Calendar.cpp:37
Farm::BedForming
virtual bool BedForming(LE *a_field, double a_user, int a_days)
Do bed forming up on a_field, probably of carrots.
Definition: FarmFuncs.cpp:1316
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
pt_pot_fungicide2
Definition: PTPotatoes.h:67
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
pt_pot_harvest
Definition: PTPotatoes.h:69
pt_pot_spring_harrow
Definition: PTPotatoes.h:56
Crop::m_base_elements_no
int m_base_elements_no
Definition: Farm.h:505
PTPotatoes::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: PTPotatoes.h:96
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
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
pt_pot_foobar
Definition: PTPotatoes.h:70
Crop::SimpleEvent
void SimpleEvent(long a_date, int a_todo, bool a_lock)
Adds an event to this crop management.
Definition: Farm.cpp:747
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
pt_pot_start
Definition: PTPotatoes.h:53
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
tov_PTPotatoes
Definition: LandscapeFarmingEnums.h:328
fmc_Fertilizer
Definition: LandscapeFarmingEnums.h:1004
Calendar::Date
long Date(void)
Definition: Calendar.h:57
fmc_Cultivation
Definition: LandscapeFarmingEnums.h:1008
pt_pot_fungicide1
Definition: PTPotatoes.h:66
pt_pot_desiccation
Definition: PTPotatoes.h:68
fmc_Others
Definition: LandscapeFarmingEnums.h:1003
fmc_Watering
Definition: LandscapeFarmingEnums.h:1011
Calendar::OldDays
long OldDays(void)
Definition: Calendar.h:60
pt_pot_ferti_s2
Definition: PTPotatoes.h:65
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
FarmEvent::m_todo
int m_todo
Definition: Farm.h:388
PTPOTATOES_BASE
#define PTPOTATOES_BASE
Definition: PTPotatoes.h:45
Crop::m_last_date
int m_last_date
Definition: Farm.h:503
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
pt_pot_bed_forming
Definition: PTPotatoes.h:59
TTypesOfVegetation
TTypesOfVegetation
Values that represent the types of vegetation that are represented in ALMaSS.
Definition: LandscapeFarmingEnums.h:192
fmc_Harvest
Definition: LandscapeFarmingEnums.h:1012
pt_pot_spring_plough
Definition: PTPotatoes.h:55
pt_pot_irrigation1
Definition: PTPotatoes.h:62
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
pt_pot_spring_sow
Definition: PTPotatoes.h:60
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
WARN_BUG
Definition: MapErrorMsg.h:34
fmc_Fungicide
Definition: LandscapeFarmingEnums.h:1007
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