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

#include <DE_OPermanentGrassLowYield.h>

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

Constructor & Destructor Documentation

◆ DE_OPermanentGrassLowYield()

DE_OPermanentGrassLowYield::DE_OPermanentGrassLowYield ( TTypesOfVegetation  a_tov,
TTypesOfCrops  a_toc,
Landscape a_L 
)
inline
81  : Crop(a_tov, a_toc, a_L)
82  {
83  // When we start it off, the first possible date for a farm operation is 1st October
84  // This information is used by other crops when they decide how much post processing of
85  // the management is allowed after harvest before the next crop starts.
86  m_first_date = g_date->DayInYear(28, 2);
88  }

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

Member Function Documentation

◆ Do()

bool DE_OPermanentGrassLowYield::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 spring barley Fodder.

Reimplemented from Crop.

83 {
84  /******************** This block can be added to the top of all Crop::Do methods ***********************************************/
85  m_farm = a_farm; // These assignments are necessary, not for this method but for related event calls
86  m_field = a_field;
87  m_ev = a_ev;
88  bool done = false; // The boolean value done indicates when we are totally finished with this plan (i.e. it is set to true).
89  int d1 = 0;
91 
92  // Depending what event has occured jump to the correct bit of code
93  switch (m_ev->m_todo)
94  {
95  case de_opgly_start:
96  {
98 
99  m_last_date = g_date->DayInYear(30, 9); // Should match the last flexdate below
100  //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
101  std::vector<std::vector<int>> flexdates(1 + 1, std::vector<int>(2, 0));
102  // Set up the date management stuff
103  // Start and stop dates for all events after harvest
104  flexdates[0][1] = g_date->DayInYear(30, 8); // last possible day of cutting2 - this is in effect day before the earliest date that a following crop can use
105 
106  flexdates[1][0] = -1;
107  flexdates[1][1] = g_date->DayInYear(30, 9); // last possible day of grazing
108 
109  // 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
110  int isSpring = 365;
111  if (StartUpCrop(isSpring, flexdates, int(de_opgly_strigling))) break;
112 
113  // End single block date checking code. Please see next line comment as well.
114  // Reinit d1 to first possible starting date.
115  d1 = g_date->OldDays() + g_date->DayInYear(1, 2) + isSpring;
116  // OK, let's go.
118  break;
119  }
120  break;
121 
122  // This is the first real farm operation
123  // This happens in a non-sowing year
124  case de_opgly_strigling:
125  if (!m_farm->Strigling(m_field, 0.0, g_date->DayInYear(28, 2) - g_date->DayInYear())) {
127  break;
128  }
130  break;
132  if (!m_farm->CattleOut(m_field, 0.0, g_date->DayInYear(10, 3) - g_date->DayInYear())) {
134  break;
135  }
136  // Keep them out there
138  break;
139  case de_opgly_cattle_is_out1: // Keep the cattle out there
140  // CattleIsOut() returns false if it is not time to stop grazing
141  if (!m_farm->CattleIsOut(m_field, 0.0, g_date->DayInYear(1, 4) - g_date->DayInYear(), g_date->DayInYear(1, 4))) {
143  break;
144  }
146  break;
148  if (a_ev->m_lock || a_farm->DoIt(20)) {
149  if (!m_farm->CattleOut(m_field, 0.0, g_date->DayInYear(10, 5) - g_date->DayInYear())) {
151  break;
152  }
154  break;
155  }
157  break;
158  case de_opgly_cutting1:
159  if (!m_farm->CutToSilage(m_field, 0.0, g_date->DayInYear(30, 6) - g_date->DayInYear())) {
160  SimpleEvent(g_date->Date() + 1, de_opgly_cutting1, true);
161  break;
162  }
163  d1 = g_date->Date() + 28;
164  if (d1 < g_date->OldDays() + g_date->DayInYear(1, 7)) {
165  d1 = g_date->OldDays() + g_date->DayInYear(1, 7);
166  }
168  break;
169  case de_opgly_wait:
170  // end of management
171  done = true;
172  break;
173  case de_opgly_cattle_is_out2: // Keep the cattle out there
174  // CattleIsOutLow() returns false if it is not time to stop grazing
175  if (!m_farm->CattleIsOut(m_field, 0.0, m_field->GetMDates(1, 1) - g_date->DayInYear(), m_field->GetMDates(1, 0))) {
177  break;
178  }
179  done = true;
180  break;
181 
182  default:
183  g_msg->Warn(WARN_BUG, "DE_OPermanentGrassLowYield::Do(): "
184  "Unknown event type! ", "");
185  exit(1);
186  }
187  return done;
188 }

References Farm::CattleIsOut(), Farm::CattleOut(), LE::ClearManagementActionSum(), Farm::CutToSilage(), Calendar::Date(), Calendar::DayInYear(), de_opgly_cattle_is_out1, de_opgly_cattle_is_out2, de_opgly_cattle_out1, de_opgly_cattle_out2, de_opgly_cutting1, de_opgly_start, de_opgly_strigling, de_opgly_wait, Farm::DoIt(), g_date, g_msg, LE::GetMDates(), Crop::m_ev, Crop::m_farm, Crop::m_field, Crop::m_last_date, FarmEvent::m_lock, FarmEvent::m_todo, Calendar::OldDays(), Crop::SimpleEvent(), Crop::SimpleEvent_(), Crop::StartUpCrop(), Farm::Strigling(), tov_DEOPermanentGrassLowYield, MapErrorMsg::Warn(), and WARN_BUG.

◆ SetUpFarmCategoryInformation()

void DE_OPermanentGrassLowYield::SetUpFarmCategoryInformation ( )
inline
89  {
90  const int elements = 2 + (de_opgly_foobar - DE_OPGLY_BASE);
92 
93  FarmManagementCategory catlist[elements] =
94  {
95  fmc_Others, // zero element unused but must be here
96  fmc_Others, // de_opgly_start = 1, // Compulsory, must always be 1 (one).
97  fmc_Others, // de_opgly_sleep_all_day = DE_OPGLY_BASE,
98  fmc_Cultivation, // de_opgly_strigling
99  fmc_Grazing, // de_opgly_cattle_out1,//Out means outside the barns. Out in the field to eat grass.
100  fmc_Grazing, // de_opgly_cattle_is_out1,//Time that the catle is in the field.
101  fmc_Grazing, // de_opgly_cattle_out2,
102  fmc_Grazing, // de_opgly_cattle_is_out2,
103  fmc_Others, // de_opgly_cutting1,
104  fmc_Others, // de_opgly_wait,
105 
106  // no foobar entry
107 
108  };
109  // Iterate over the catlist elements and copy them to vector
110  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
111 
112  }

References DE_OPGLY_BASE, de_opgly_foobar, fmc_Cultivation, fmc_Grazing, fmc_Others, Crop::m_base_elements_no, and Crop::m_ManagementCategories.

Referenced by DE_OPermanentGrassLowYield().


The documentation for this class was generated from the following files:
LE::GetMDates
int GetMDates(int a, int b)
Definition: Elements.h:405
de_opgly_cattle_is_out1
Definition: DE_OPermanentGrassLowYield.h:67
de_opgly_cattle_out1
Definition: DE_OPermanentGrassLowYield.h:66
Farm::Strigling
virtual bool Strigling(LE *a_field, double a_user, int a_days)
Carry out a mechanical weeding on a_field.
Definition: FarmFuncs.cpp:1206
de_opgly_start
Definition: DE_OPermanentGrassLowYield.h:63
FarmEvent::m_lock
bool m_lock
Definition: Farm.h:384
Farm::CattleIsOut
virtual bool CattleIsOut(LE *a_field, double a_user, int a_days, int a_max)
Generate a 'cattle_out' event for every day the cattle are on a_field.
Definition: FarmFuncs.cpp:2470
LE::ClearManagementActionSum
void ClearManagementActionSum()
clears the management action counters
Definition: Elements.h:247
Farm::CutToSilage
virtual bool CutToSilage(LE *a_field, double a_user, int a_days)
Cut vegetation for silage on a_field.
Definition: FarmFuncs.cpp:1644
Farm::DoIt
bool DoIt(double a_probability)
Return chance out of 0 to 100.
Definition: Farm.cpp:856
g_date
class Calendar * g_date
Definition: Calendar.cpp:37
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
Crop::SimpleEvent
void SimpleEvent(long a_date, int a_todo, bool a_lock)
Adds an event to this crop management.
Definition: Farm.cpp:747
de_opgly_foobar
Definition: DE_OPermanentGrassLowYield.h:72
Calendar::Date
long Date(void)
Definition: Calendar.h:57
fmc_Cultivation
Definition: LandscapeFarmingEnums.h:1008
fmc_Others
Definition: LandscapeFarmingEnums.h:1003
Calendar::OldDays
long OldDays(void)
Definition: Calendar.h:60
DE_OPermanentGrassLowYield::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: DE_OPermanentGrassLowYield.h:89
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
de_opgly_cattle_out2
Definition: DE_OPermanentGrassLowYield.h:68
de_opgly_cattle_is_out2
Definition: DE_OPermanentGrassLowYield.h:69
Crop::m_farm
Farm * m_farm
Definition: Farm.h:498
Crop::m_field
LE * m_field
Definition: Farm.h:499
tov_DEOPermanentGrassLowYield
Definition: LandscapeFarmingEnums.h:501
de_opgly_cutting1
Definition: DE_OPermanentGrassLowYield.h:70
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
Crop::m_last_date
int m_last_date
Definition: Farm.h:503
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
fmc_Grazing
Definition: LandscapeFarmingEnums.h:1010
TTypesOfVegetation
TTypesOfVegetation
Values that represent the types of vegetation that are represented in ALMaSS.
Definition: LandscapeFarmingEnums.h:192
DE_OPGLY_BASE
#define DE_OPGLY_BASE
Definition: DE_OPermanentGrassLowYield.h:55
de_opgly_wait
Definition: DE_OPermanentGrassLowYield.h:71
Calendar::DayInYear
int DayInYear(void)
Definition: Calendar.h:58
de_opgly_strigling
Definition: DE_OPermanentGrassLowYield.h:65
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
Farm::CattleOut
virtual bool CattleOut(LE *a_field, double a_user, int a_days)
Start a grazing event on a_field today.
Definition: FarmFuncs.cpp:2368
WARN_BUG
Definition: MapErrorMsg.h:34
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