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

PTRyegrass class
. More...

#include <PTRyegrass.h>

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

PTRyegrass class
.

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

◆ PTRyegrass()

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

95  : Crop(a_tov, a_toc, a_L)
96  {
102  m_first_date=g_date->DayInYear( 31,10 ); //EZ: This needs to be changed
104  }

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

Member Function Documentation

◆ Do()

bool PTRyegrass::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 subsequently 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 ryegrass.

Reimplemented from Crop.

63 {
64  /******************** This block can be added to the top of all Crop::Do methods ***********************************************/
65  m_farm = a_farm; // These assignments are necessary, not for this method but for related event calls
66  m_field = a_field;
67  m_ev = a_ev;
68  bool done = false; // The boolean value done indicates when we are totally finished with this plan (i.e. it is set to true).
69  int d1 = 0;
70  TTypesOfVegetation l_tov = tov_PTRyegrass; // The current type - change to match the crop you have
71 /**********************************************To Here *************************************************************************/
72 
73  // Depending what event has occured jump to the correct bit of code
74  switch (m_ev->m_todo)
75  {
76  case pt_rg_start:
77  {
79 
80  m_last_date = g_date->DayInYear(5, 7); // Should match the last flexdate below
81  //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
82  std::vector<std::vector<int>> flexdates(1 + 1, std::vector<int>(2, 0));
83  // Set up the date management stuff
84  // Start and stop dates for all events after harvest
85  flexdates[0][1] = g_date->DayInYear(5, 7); // last possible day of harvest - this is in effect day before the earliest date that a following crop can use
86 
87  flexdates[1][0] = -1; // This date will be moved back as far as necessary and potentially to flexdates 1 (start op 1)
88  flexdates[1][1] = g_date->DayInYear(5, 7); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 1)
89 
90  // 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
91  int isSpring = 0;
92  if (StartUpCrop(isSpring, flexdates, int(pt_rg_hay_turning))) break;
93 
94  // End single block date checking code. Please see next line comment as well.
95  // Reinit d1 to first possible starting date.
96  d1 = g_date->OldDays() + g_date->DayInYear(1, 9);
97  // OK, let's go.
98  // Here we queue up the first event - cultivation of stubble after previous crop
99  SimpleEvent_(d1, pt_rg_autumn_harrow, false, a_farm, a_field); //AAS: First event, in this case autumn harrow
100  break;
101  }
102  break;
103 
104  //This is the first real farm operation
105  case pt_rg_autumn_harrow:
106  if (!m_farm->AutumnHarrow(m_field, 0.0, g_date->DayInYear(31, 10) - g_date->DayInYear())) {
108  break;
109  }// Fork of two events: slurry and calcium
110  if (m_farm->IsStockFarmer()) //Stock Farmer // slurry thread // Main thread
111  {
113  }
115  if (m_farm->IsStockFarmer()) //Stock Farmer // calcium thread //End of thread
116  {
118  }
120  break;
121 
122  //------------------- calcium application
123  case pt_rg_calcium_s1:
124  if (!m_farm->FA_Calcium(m_field, 0.0, g_date->DayInYear(1, 11) - g_date->DayInYear())) {
126  break;
127  }
128  // End of thread
129  break;
130  case pt_rg_calcium_p1:
131  if (!m_farm->FP_Calcium(m_field, 0.0, g_date->DayInYear(1, 11) - g_date->DayInYear())) {
133  break;
134  }
135  // End of thread
136  break;
137  //------------------- calcium application
138 
139  case pt_rg_slurry_s1:
140  if (!m_farm->FA_Slurry(m_field, 0.0, g_date->DayInYear(1, 11) - g_date->DayInYear())) {
142  break;
143  }
145  break;
146  case pt_rg_slurry_p1:
147  if (!m_farm->FP_Slurry(m_field, 0.0, g_date->DayInYear(1, 11) - g_date->DayInYear())) {
149  break;
150  }
152  break;
153 
154  case pt_rg_autumn_sow:
155  if (!m_farm->AutumnSow(m_field, 0.0, g_date->DayInYear(2, 11) - g_date->DayInYear())) {
157  break;
158  }
160  break;
161 
163  if (!m_farm->StubbleHarrowing(m_field, 0.0, g_date->DayInYear(5, 11) - g_date->DayInYear())) {
165  break; break;
166  }
168  break;
169 
170  case pt_rg_harvest1:
171  if (!m_farm->Harvest(m_field, 0.0, g_date->DayInYear(20, 12) - g_date->DayInYear())) {
173  break;
174  }
175  if (m_farm->IsStockFarmer()) //Stock Farmer // NPK thread
176  {
178  }
179  else SimpleEvent_(g_date->Date() + 1, pt_rg_npk1_p1, false, m_farm, m_field);
180  break;
181  case pt_rg_npk1_s1:
182  if (!m_farm->FA_NPK(m_field, 0.0, g_date->DayInYear(21, 12) - g_date->DayInYear())) {
184  break;
185  }
187  break;
188  case pt_rg_npk1_p1:
189  if (!m_farm->FP_NPK(m_field, 0.0, g_date->DayInYear(21, 12) - g_date->DayInYear())) {
191  break;
192  }
194  break;
195 
196  case pt_rg_harvest2:
197  if (!m_farm->Harvest(m_field, 0.0, g_date->DayInYear(20, 1) - g_date->DayInYear())) {
199  break;
200  }
201  if (m_farm->IsStockFarmer()) //Stock Farmer // NPK thread
202  {
204  }
205  else SimpleEvent_(g_date->Date() + 1, pt_rg_npk2_p1, false, m_farm, m_field);
206  break;
207  case pt_rg_npk2_s1:
208  if (!m_farm->FA_NPK(m_field, 0.0, g_date->DayInYear(21, 1) - g_date->DayInYear())) {
210  break;
211  }
213  break;
214  case pt_rg_npk2_p1:
215  if (!m_farm->FP_NPK(m_field, 0.0, g_date->DayInYear(21, 1) - g_date->DayInYear())) {
217  break;
218  }
220  break;
221 
222  case pt_rg_harvest3:
223  if (!m_farm->Harvest(m_field, 0.0, g_date->DayInYear(25, 2) - g_date->DayInYear())) {
225  break;
226  }
227  if (m_farm->IsStockFarmer()) //Stock Farmer // NPK thread
228  {
230  }
231  else SimpleEvent_(g_date->Date() + 1, pt_rg_npk3_p1, false, m_farm, m_field);
232  break;
233  case pt_rg_npk3_s1:
234  if (!m_farm->FA_NPK(m_field, 0.0, g_date->DayInYear(26, 2) - g_date->DayInYear())) {
236  break;
237  }
239  break;
240  case pt_rg_npk3_p1:
241  if (!m_farm->FP_NPK(m_field, 0.0, g_date->DayInYear(26, 2) - g_date->DayInYear())) {
243  break;
244  }
246  break;
247 
248  case pt_rg_harvest4:
249  if (!m_farm->Harvest(m_field, 0.0, g_date->DayInYear(30, 3) - g_date->DayInYear())) {
251  break;
252  }
253  if (m_farm->IsStockFarmer()) //Stock Farmer // NPK thread
254  {
256  }
257  else SimpleEvent_(g_date->Date() + 1, pt_rg_npk4_p1, false, m_farm, m_field);
258  break;
259  case pt_rg_npk4_s1:
260  if (!m_farm->FA_NPK(m_field, 0.0, g_date->DayInYear(20, 4) - g_date->DayInYear())) {
262  break;
263  }
265  break;
266  case pt_rg_npk4_p1:
267  if (!m_farm->FP_NPK(m_field, 0.0, g_date->DayInYear(20, 4) - g_date->DayInYear())) {
269  break;
270  }
272  break;
273 
274  case pt_rg_cut_to_hay:
275  if (!m_farm->CutToHay(m_field, 0.0, g_date->DayInYear(30, 5) - g_date->DayInYear())) {
277  break;
278  }
280  break;
281 
282  case pt_rg_hay_turning:
283  if (!m_farm->HayTurning(m_field, 0.0, g_date->DayInYear(7, 6) - g_date->DayInYear())) {
285  break;
286  }
288  break;
289 
290  case pt_rg_hay_bailing:
291  if (!m_farm->HayBailing(m_field, 0.0, g_date->DayInYear(15, 6) - g_date->DayInYear())) {
293  break;
294  }
295  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 7), pt_rg_wait, false, m_farm, m_field);// Because we are ending harvest1 before 1.7 so we need to wait until the 1.7
296  break;
297 
298  case pt_rg_wait:
299  done = true;
300  break;
301  // End of Thread
302 
303 
304  default:
305  g_msg->Warn(WARN_BUG, "PTRyegrass::Do(): "
306  "Unknown event type! ", "");
307  exit(1);
308  }
309  return done;
310 }

References Farm::AutumnHarrow(), Farm::AutumnSow(), LE::ClearManagementActionSum(), Farm::CutToHay(), Calendar::Date(), Calendar::DayInYear(), Farm::FA_Calcium(), Farm::FA_NPK(), Farm::FA_Slurry(), Farm::FP_Calcium(), Farm::FP_NPK(), Farm::FP_Slurry(), g_date, g_msg, Farm::Harvest(), Farm::HayBailing(), Farm::HayTurning(), Farm::IsStockFarmer(), Crop::m_ev, Crop::m_farm, Crop::m_field, Crop::m_last_date, FarmEvent::m_todo, Calendar::OldDays(), pt_rg_autumn_harrow, pt_rg_autumn_sow, pt_rg_calcium_p1, pt_rg_calcium_s1, pt_rg_cut_to_hay, pt_rg_harvest1, pt_rg_harvest2, pt_rg_harvest3, pt_rg_harvest4, pt_rg_hay_bailing, pt_rg_hay_turning, pt_rg_npk1_p1, pt_rg_npk1_s1, pt_rg_npk2_p1, pt_rg_npk2_s1, pt_rg_npk3_p1, pt_rg_npk3_s1, pt_rg_npk4_p1, pt_rg_npk4_s1, pt_rg_slurry_p1, pt_rg_slurry_s1, pt_rg_start, pt_rg_stubble_harrow, pt_rg_wait, Crop::SimpleEvent_(), Crop::StartUpCrop(), Farm::StubbleHarrowing(), tov_PTRyegrass, MapErrorMsg::Warn(), and WARN_BUG.

◆ SetUpFarmCategoryInformation()

void PTRyegrass::SetUpFarmCategoryInformation ( )
inline
105  {
106  const int elements = 2 + (pt_rg_foobar - PTRYEGRASS_BASE);
108 
109  FarmManagementCategory catlist[elements] =
110  {
111  fmc_Others, // zero element unused but must be here
112  fmc_Others, //pt_ry_start = 1, // Compulsory, must always be 1 (one).
113  fmc_Others, //pt_ry_sleep_all_day = PTRYEGRASS_BASE,
114  fmc_Cultivation, //pt_rg_autumn_harrow,
115  fmc_Fertilizer, //pt_rg_calcium_p1,
116  fmc_Fertilizer, //pt_rg_calcium_s1,
117  fmc_Fertilizer, //pt_rg_slurry_p1,
118  fmc_Fertilizer, //pt_rg_slurry_s1,
119  fmc_Others, //pt_rg_autumn_sow,
120  fmc_Cultivation, //pt_rg_stubble_harrow,
121  fmc_Harvest, //pt_rg_harvest1,
122  fmc_Fertilizer, //pt_rg_npk1_p1,
123  fmc_Fertilizer, //pt_rg_npk1_s1,
124  fmc_Harvest, //pt_rg_harvest2,
125  fmc_Fertilizer, //pt_rg_npk2_p1,
126  fmc_Fertilizer, //pt_rg_npk2_s1,
127  fmc_Harvest, //pt_rg_harvest3,
128  fmc_Fertilizer, //pt_rg_npk3_p1,
129  fmc_Fertilizer, //pt_rg_npk3_s1,
130  fmc_Harvest, //pt_rg_harvest4,
131  fmc_Fertilizer, //pt_rg_npk4_p1,
132  fmc_Fertilizer, //pt_rg_npk4_s1,
133  fmc_Cutting, //pt_rg_cut_to_hay,
134  fmc_Others, //pt_rg_hay_turning,
135  fmc_Others, //pt_rg_hay_bailing,
136  fmc_Others //pt_rg_wait,
137 
138  // no foobar entry
139 
140  };
141  // Iterate over the catlist elements and copy them to vector
142  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
143 
144  }

References fmc_Cultivation, fmc_Cutting, fmc_Fertilizer, fmc_Harvest, fmc_Others, Crop::m_base_elements_no, Crop::m_ManagementCategories, pt_rg_foobar, and PTRYEGRASS_BASE.

Referenced by PTRyegrass().


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
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_rg_slurry_p1
Definition: PTRyegrass.h:58
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_rg_npk4_s1
Definition: PTRyegrass.h:73
g_date
class Calendar * g_date
Definition: Calendar.cpp:37
pt_rg_start
Definition: PTRyegrass.h:53
Crop::m_base_elements_no
int m_base_elements_no
Definition: Farm.h:505
Farm::CutToHay
virtual bool CutToHay(LE *a_field, double a_user, int a_days)
Carry out hay cutting on a_field.
Definition: FarmFuncs.cpp:1607
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_rg_hay_bailing
Definition: PTRyegrass.h:76
pt_rg_calcium_s1
Definition: PTRyegrass.h:57
pt_rg_npk2_s1
Definition: PTRyegrass.h:67
pt_rg_slurry_s1
Definition: PTRyegrass.h:59
pt_rg_npk1_p1
Definition: PTRyegrass.h:63
fmc_Cutting
Definition: LandscapeFarmingEnums.h:1009
pt_rg_wait
Definition: PTRyegrass.h:77
fmc_Fertilizer
Definition: LandscapeFarmingEnums.h:1004
PTRYEGRASS_BASE
#define PTRYEGRASS_BASE
Definition: PTRyegrass.h:45
Calendar::Date
long Date(void)
Definition: Calendar.h:57
fmc_Cultivation
Definition: LandscapeFarmingEnums.h:1008
Farm::HayBailing
virtual bool HayBailing(LE *a_field, double a_user, int a_days)
Carry out hay bailing on a_field.
Definition: FarmFuncs.cpp:1507
pt_rg_harvest4
Definition: PTRyegrass.h:71
pt_rg_harvest2
Definition: PTRyegrass.h:65
fmc_Others
Definition: LandscapeFarmingEnums.h:1003
Farm::FA_Calcium
virtual bool FA_Calcium(LE *a_field, double a_user, int a_days)
Calcium applied on a_field owned by a stock farmer.
Definition: FarmFuncs.cpp:1168
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
Farm::FP_Calcium
virtual bool FP_Calcium(LE *a_field, double a_user, int a_days)
Calcium applied on a_field owned by an arable farmer.
Definition: FarmFuncs.cpp:954
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
pt_rg_calcium_p1
Definition: PTRyegrass.h:56
pt_rg_npk3_p1
Definition: PTRyegrass.h:69
Crop::m_farm
Farm * m_farm
Definition: Farm.h:498
Crop::m_field
LE * m_field
Definition: Farm.h:499
pt_rg_stubble_harrow
Definition: PTRyegrass.h:61
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
pt_rg_npk2_p1
Definition: PTRyegrass.h:66
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
pt_rg_npk1_s1
Definition: PTRyegrass.h:64
Crop::m_last_date
int m_last_date
Definition: Farm.h:503
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
tov_PTRyegrass
Definition: LandscapeFarmingEnums.h:324
Farm::AutumnHarrow
virtual bool AutumnHarrow(LE *a_field, double a_user, int a_days)
Carry out a harrow event in the autumn on a_field.
Definition: FarmFuncs.cpp:285
pt_rg_harvest1
Definition: PTRyegrass.h:62
pt_rg_harvest3
Definition: PTRyegrass.h:68
TTypesOfVegetation
TTypesOfVegetation
Values that represent the types of vegetation that are represented in ALMaSS.
Definition: LandscapeFarmingEnums.h:192
pt_rg_npk3_s1
Definition: PTRyegrass.h:70
Farm::AutumnSow
virtual bool AutumnSow(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 autumn on a_field.
Definition: FarmFuncs.cpp:360
fmc_Harvest
Definition: LandscapeFarmingEnums.h:1012
PTRyegrass::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: PTRyegrass.h:105
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_rg_foobar
Definition: PTRyegrass.h:78
pt_rg_autumn_harrow
Definition: PTRyegrass.h:55
pt_rg_autumn_sow
Definition: PTRyegrass.h:60
Farm::HayTurning
virtual bool HayTurning(LE *a_field, double a_user, int a_days)
Carry out hay turning on a_field.
Definition: FarmFuncs.cpp:1491
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
WARN_BUG
Definition: MapErrorMsg.h:34
pt_rg_hay_turning
Definition: PTRyegrass.h:75
pt_rg_npk4_p1
Definition: PTRyegrass.h:72
pt_rg_cut_to_hay
Definition: PTRyegrass.h:74
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