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

PTCabbage_Hort class
. More...

#include <PTCabbage_Hort.h>

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

PTCabbage_Hort class
.

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

◆ PTCabbage_Hort()

PTCabbage_Hort::PTCabbage_Hort ( 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.

83  : Crop(a_tov, a_toc, a_L)
84  {
90  m_first_date = g_date->DayInYear(31, 3); // changed from 31,3
93  }

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

Member Function Documentation

◆ Do()

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

59 {
60 /******************** This block can be added to the top of all Crop::Do methods ***********************************************/
61  m_farm = a_farm; // These assignments are necessary, not for this method but for related event calls
62  m_field = a_field;
63  m_ev = a_ev;
64  bool done = false; // The boolean value done indicates when we are totally finished with this plan (i.e. it is set to true).
65  int d1 = 0;
66  TTypesOfVegetation l_tov = tov_PTCabbage_Hort; // The current type - change to match the crop you have
67  int l_nextcropstartdate;
68 /**********************************************To Here *************************************************************************/
69 
70  // Depending what event has occured jump to the correct bit of code
71  switch (m_ev->m_todo)
72  {
73  case pt_cabb_hort_start:
74  {
76 
77  m_last_date = g_date->DayInYear(31, 8); // Should match the last flexdate below
78  //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
79  std::vector<std::vector<int>> flexdates(1 + 1, std::vector<int>(2, 0));
80  // Set up the date management stuff
81  // Start and stop dates for all events after harvest
82  flexdates[0][1] = g_date->DayInYear(31, 8); // last possible day of harvest - this is in effect day before the earliest date that a following crop can use
83 
84  flexdates[1][0] = -1; // This date will be moved back as far as necessary and potentially to flexdates 1 (start op 1)
85  flexdates[1][1] = g_date->DayInYear(31, 8); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 1)
86 
87  // 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
88  int isSpring = 365;
89  if (StartUpCrop(isSpring, flexdates, int(pt_cabb_hort_harvest))) break;
90 
91  // End single block date checking code. Please see next line comment as well.
92  // Reinit d1 to first possible starting date.
93  d1 = g_date->OldDays() + g_date->DayInYear(10, 3) + isSpring;
94  // OK, let's go.
95  // Here we queue up the first event which changes dependent on whether it is a forced spring sow or not
97  break;
98  }
99  break;
100 
101  // This is the first real farm operation
103  if (!m_farm->WinterPlough(m_field, 0.0, g_date->DayInYear(31, 3) - g_date->DayInYear())) {
105  break;
106  }
108  break;
109 
110 
112  if (!m_farm->WinterHarrow(m_field, 0.0, g_date->DayInYear(1, 4) - g_date->DayInYear())) {
114  break;
115  }
116  if (m_farm->IsStockFarmer()) //Stock Farmer
117  {
119  }
121  break;
122 
124  if (!m_farm->FA_Manure(m_field, 0.0, g_date->DayInYear(2, 4) - g_date->DayInYear())) {
126  break;
127  }
129  break;
130 
132  if (!m_farm->FP_Manure(m_field, 0.0, g_date->DayInYear(2, 4) - g_date->DayInYear())) {
134  break;
135  }
137  break;
138 
140  if (!m_farm->SpringSow(m_field, 0.0, g_date->DayInYear(3, 4) - g_date->DayInYear())) {
142  break;
143  }
144  //Fork of events: irrigation & herbicide - main thread
145  d1 = g_date->Date() + 10;
146  if (d1 < g_date->OldDays() + g_date->DayInYear(1, 4)) {
147  d1 = g_date->OldDays() + g_date->DayInYear(1, 4);
148  }
151  break;
152 
153  case pt_cabb_hort_irrigation_start1: // Start irrigation
154  if (!m_farm->IrrigationStart(m_field, 0.0, g_date->DayInYear(15, 8) - g_date->DayInYear())) {
156  break;
157  }
158  //Continue the irrigation
160  break;
161  case pt_cabb_hort_irrigation1: // Performing irrigation once a week if no raining
162  if (!m_farm->Irrigation(m_field, 0.0, g_date->DayInYear(15, 8) - g_date->DayInYear(), g_date->DayInYear(15, 8))) {
164  break;
165  }
166  // End of thread
167  break;
168 
170  if (!m_farm->HerbicideTreat(m_field, 0.0, g_date->DayInYear(15, 4) - g_date->DayInYear())) {
172  break;
173  }
174  if (m_farm->IsStockFarmer()) //Stock Farmer
175  {
177  }
179  break;
180 
182  if (!m_farm->FA_NPK(m_field, 0.0, g_date->DayInYear(10, 5) - g_date->DayInYear())) {
184  break;
185  }
187  break;
189  if (!m_farm->FP_NPK(m_field, 0.0, g_date->DayInYear(10, 5) - g_date->DayInYear())) {
191  break;
192  }
194  break;
195 
197  if (!m_farm->InsecticideTreat(m_field, 0.0, g_date->DayInYear(30, 5) - g_date->DayInYear())) {
199  break;
200  }
201  d1 = g_date->Date() + 75;
202  if (d1 < g_date->OldDays() + g_date->DayInYear(16, 8)) {
203  d1 = g_date->OldDays() + g_date->DayInYear(16, 8);
204  }
206  break;
207 
209  if (!m_farm->Harvest(m_field, 0.0, m_field->GetMDates(1, 0) - g_date->DayInYear())) {
211  break;
212  }
213  // So we are done,but this crop uses a catch crop = horticulture
215  // So we are done,but this crop uses a catch crop
216  l_nextcropstartdate = m_farm->GetNextCropStartDate(m_ev->m_field, l_tov);
217  m_field->BumpRunNum();
218  m_field->SetVegPatchy(false); // reverse the patchy before the next crop
219  m_farm->AddNewEvent(tov_PTHorticulture, g_date->Date(), m_ev->m_field, PROG_START, m_ev->m_field->GetRunNum(), false, l_nextcropstartdate, false, l_tov, fmc_Others, false, false);
220  m_field->SetVegType(tov_PTHorticulture, tov_Undefined); // Two vegetation curves are specified
221  if (m_field->GetUnsprayedMarginPolyRef() != -1)
222  {
225  }
226  // NB no "done = true" because this crop effectively continues into the catch crop.
227  break;
228  }
229  else
230  done = true;
231  break;
232 
233  default:
234  g_msg->Warn(WARN_BUG, "PTCabbage_Hort::Do(): "
235  "Unknown event type! ", "");
236  exit(1);
237  }
238  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
239  return done;
240 }

References Farm::AddNewEvent(), cfg_PTHorticulturePct, LE::ClearManagementActionSum(), Calendar::Date(), Calendar::DayInYear(), Farm::DoIt_prob(), Farm::FA_Manure(), Farm::FA_NPK(), fmc_Others, Farm::FP_Manure(), Farm::FP_NPK(), g_date, g_msg, LE::GetMDates(), Farm::GetNextCropStartDate(), LE::GetUnsprayedMarginPolyRef(), Farm::Harvest(), Farm::HerbicideTreat(), Farm::InsecticideTreat(), Farm::Irrigation(), Farm::IrrigationStart(), Farm::IsStockFarmer(), Crop::m_ev, Crop::m_farm, FarmEvent::m_field, Crop::m_field, FarmEvent::m_forcespring, Crop::m_last_date, FarmEvent::m_lock, Crop::m_OurLandscape, FarmEvent::m_todo, Calendar::OldDays(), PROG_START, pt_cabb_hort_ferti_p1, pt_cabb_hort_ferti_p2, pt_cabb_hort_ferti_s1, pt_cabb_hort_ferti_s2, pt_cabb_hort_harvest, pt_cabb_hort_herbicide, pt_cabb_hort_insecticide, pt_cabb_hort_irrigation1, pt_cabb_hort_irrigation_start1, pt_cabb_hort_start, pt_cabb_hort_winter_harrow, pt_cabb_hort_winter_plough, pt_cabb_hort_winter_sow, LE::SetVegPatchy(), LE::SetVegType(), Crop::SimpleEvent_(), Farm::SpringSow(), Crop::StartUpCrop(), Landscape::SupplyLEPointer(), tov_PTCabbage_Hort, tov_PTHorticulture, tov_Undefined, CfgFloat::value(), MapErrorMsg::Warn(), WARN_BUG, Farm::WinterHarrow(), and Farm::WinterPlough().

◆ SetUpFarmCategoryInformation()

void PTCabbage_Hort::SetUpFarmCategoryInformation ( )
inline
94  {
95  const int elements = 2 + (pt_cabb_hort_foobar - PTCABBAGE_HORT_BASE);
97 
98  FarmManagementCategory catlist[elements] =
99  {
100  fmc_Others, // zero element unused but must be here
101  fmc_Others, //pt_cabb_hort_start = 1, // Compulsory, must always be 1 (one).
102  fmc_Others, //pt_cabb_hort_sleep_all_day = PTCABBAGE_HORT_BASE,
103  fmc_Cultivation, //pt_cabb_hort_winter_plough,
104  fmc_Cultivation, //pt_cabb_hort_winter_harrow,
105  fmc_Fertilizer, //pt_cabb_hort_ferti_p1, // Manure
106  fmc_Fertilizer, //pt_cabb_hort_ferti_s1,
107  fmc_Others, //pt_cabb_hort_winter_sow,
108  fmc_Watering, //pt_cabb_hort_irrigation_start1,
109  fmc_Watering, //pt_cabb_hort_irrigation1,
110  fmc_Herbicide, //pt_cabb_hort_herbicide,
111  fmc_Fertilizer, //pt_cabb_hort_ferti_p2, //NPK
112  fmc_Fertilizer, //pt_cabb_hort_ferti_s2,
113  fmc_Insecticide, //pt_cabb_hort_insecticide,
114  fmc_Harvest //pt_cabb_hort_harvest,
115 
116  // no foobar entry
117 
118  };
119  // Iterate over the catlist elements and copy them to vector
120  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
121 
122  }

References fmc_Cultivation, fmc_Fertilizer, fmc_Harvest, fmc_Herbicide, fmc_Insecticide, fmc_Others, fmc_Watering, Crop::m_base_elements_no, Crop::m_ManagementCategories, pt_cabb_hort_foobar, and PTCABBAGE_HORT_BASE.

Referenced by PTCabbage_Hort().


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
Landscape::SupplyLEPointer
LE * SupplyLEPointer(int a_polyref)
Returns a pointer to the object referred to by the polygon number.
Definition: Landscape.h:1722
pt_cabb_hort_irrigation1
Definition: PTCabbage_Hort.h:61
fmc_Insecticide
Definition: LandscapeFarmingEnums.h:1005
Farm::HerbicideTreat
virtual bool HerbicideTreat(LE *a_field, double a_user, int a_days)
Apply herbicide to a_field.
Definition: FarmFuncs.cpp:2025
tov_PTCabbage_Hort
Definition: LandscapeFarmingEnums.h:331
Farm::IsStockFarmer
bool IsStockFarmer(void)
Definition: Farm.h:961
pt_cabb_hort_ferti_p2
Definition: PTCabbage_Hort.h:63
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
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_cabb_hort_ferti_p1
Definition: PTCabbage_Hort.h:57
pt_cabb_hort_irrigation_start1
Definition: PTCabbage_Hort.h:60
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
fmc_Herbicide
Definition: LandscapeFarmingEnums.h:1006
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
Farm::GetNextCropStartDate
int GetNextCropStartDate(LE *a_field, TTypesOfVegetation &a_curr_veg)
Returns the start date of the next crop in the rotation.
Definition: Farm.cpp:920
PTCABBAGE_HORT_BASE
#define PTCABBAGE_HORT_BASE
Definition: PTCabbage_Hort.h:45
Farm::AddNewEvent
void AddNewEvent(TTypesOfVegetation a_event, long a_date, LE *a_field, int a_todo, long a_num, bool a_lock, int a_start, bool a_first_year, TTypesOfVegetation a_crop, FarmManagementCategory a_fmc, bool a_forcespring, bool a_forcespringOK)
Adds an event to the event queue for a farm.
Definition: Farm.cpp:845
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
CfgFloat::value
double value() const
Definition: Configurator.h:142
Crop::m_base_elements_no
int m_base_elements_no
Definition: Farm.h:505
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
pt_cabb_hort_herbicide
Definition: PTCabbage_Hort.h:62
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
fmc_Fertilizer
Definition: LandscapeFarmingEnums.h:1004
Calendar::Date
long Date(void)
Definition: Calendar.h:57
fmc_Cultivation
Definition: LandscapeFarmingEnums.h:1008
fmc_Others
Definition: LandscapeFarmingEnums.h:1003
LE::SetVegPatchy
void SetVegPatchy(bool p)
Definition: Elements.h:229
fmc_Watering
Definition: LandscapeFarmingEnums.h:1011
Calendar::OldDays
long OldDays(void)
Definition: Calendar.h:60
tocc_Catch
Definition: LandscapeFarmingEnums.h:627
pt_cabb_hort_foobar
Definition: PTCabbage_Hort.h:67
MapErrorMsg::Warn
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: MapErrorMsg.cpp:69
pt_cabb_hort_winter_plough
Definition: PTCabbage_Hort.h:55
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
PTCabbage_Hort::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: PTCabbage_Hort.h:94
pt_cabb_hort_winter_harrow
Definition: PTCabbage_Hort.h:56
FarmEvent::m_field
LE * m_field
Definition: Farm.h:391
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::InsecticideTreat
virtual bool InsecticideTreat(LE *a_field, double a_user, int a_days)
Apply insecticide to a_field.
Definition: FarmFuncs.cpp:2135
tov_Undefined
Definition: LandscapeFarmingEnums.h:610
LE::SetVegType
virtual void SetVegType(TTypesOfVegetation)
Definition: Elements.h:175
LE
Definition: Elements.h:86
Crop::m_last_date
int m_last_date
Definition: Farm.h:503
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
pt_cabb_hort_start
Definition: PTCabbage_Hort.h:53
TTypesOfVegetation
TTypesOfVegetation
Values that represent the types of vegetation that are represented in ALMaSS.
Definition: LandscapeFarmingEnums.h:192
pt_cabb_hort_harvest
Definition: PTCabbage_Hort.h:66
fmc_Harvest
Definition: LandscapeFarmingEnums.h:1012
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
LE::GetUnsprayedMarginPolyRef
int GetUnsprayedMarginPolyRef(void)
Definition: Elements.h:383
pt_cabb_hort_ferti_s1
Definition: PTCabbage_Hort.h:58
Calendar::DayInYear
int DayInYear(void)
Definition: Calendar.h:58
Crop::SetCropClassification
void SetCropClassification(int a_classification)
Definition: Farm.h:549
tov_PTHorticulture
Definition: LandscapeFarmingEnums.h:329
Farm::WinterHarrow
virtual bool WinterHarrow(LE *a_field, double a_user, int a_days)
Carry out a harrow event in the winter on a_field.
Definition: FarmFuncs.cpp:1539
Crop::Crop
Crop(TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape *a_L)
Definition: Farm.cpp:733
pt_cabb_hort_winter_sow
Definition: PTCabbage_Hort.h:59
pt_cabb_hort_insecticide
Definition: PTCabbage_Hort.h:65
PROG_START
#define PROG_START
Definition: Farm.h:69
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
Crop::m_OurLandscape
Landscape * m_OurLandscape
Definition: Farm.h:506
WARN_BUG
Definition: MapErrorMsg.h:34
pt_cabb_hort_ferti_s2
Definition: PTCabbage_Hort.h:64
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
cfg_PTHorticulturePct
CfgFloat cfg_PTHorticulturePct