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

DE_OGrasslandSilageAnnual1 class
. More...

#include <DE_OGrasslandSilageAnnual.h>

Inheritance diagram for DE_OGrasslandSilageAnnual:
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_OGrasslandSilageAnnual (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

DE_OGrasslandSilageAnnual1 class
.

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

◆ DE_OGrasslandSilageAnnual()

DE_OGrasslandSilageAnnual::DE_OGrasslandSilageAnnual ( TTypesOfVegetation  a_tov,
TTypesOfCrops  a_toc,
Landscape a_L 
)
inline
90  : Crop(a_tov, a_toc, a_L)
91  {
92  // When we start it off, the first possible date for a farm operation is 1st October
93  // This information is used by other crops when they decide how much post processing of
94  // the management is allowed after harvest before the next crop starts.
95  m_first_date = g_date->DayInYear(1, 12);
97  }

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

Member Function Documentation

◆ Do()

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

82 {
83  /******************** This block can be added to the top of all Crop::Do methods ***********************************************/
84  m_farm = a_farm; // These assignments are necessary, not for this method but for related event calls
85  m_field = a_field;
86  m_ev = a_ev;
87  bool done = false; // The boolean value done indicates when we are totally finished with this plan (i.e. it is set to true).
88  int d1 = 0;
89  TTypesOfVegetation l_tov = tov_DEOGrasslandSilageAnnual; // The current type - change to match the crop you have
90 /**********************************************To Here *************************************************************************/
91 
92  // Depending what event has occured jump to the correct bit of code e.g. for ww_start jump to line 67 below
93  switch (m_ev->m_todo)
94  {
95  case de_ogsa_start:
96  {
97  // de_ogsa_start just sets up all the starting conditions and reference dates that are needed to start a de_gsa crop off
99 
101 
102  m_last_date = g_date->DayInYear(10, 8); // Should match the last flexdate below
103  //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
104  std::vector<std::vector<int>> flexdates(1 + 1, std::vector<int>(2, 0));
105  // Set up the date management stuff
106  // Start and stop dates for all events after harvest
107  flexdates[0][1] = g_date->DayInYear(10, 8); // last possible day of cut to silage2 - this is in effect day before the earliest date that a following crop can use
108 
109  flexdates[1][0] = -1; // This date will be moved back as far as necessary and potentially to flexdates 1 (start op 1)
110  flexdates[1][1] = g_date->DayInYear(10, 8); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 1)
111 
112  // 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
113  int isSpring = 0;
114  if (StartUpCrop(isSpring, flexdates, int(de_ogsa_preseeding_cultivation))) break;
115 
116  // End single block date checking code. Please see next line comment as well.
117  // Reinit d1 to first possible starting date.
118  d1 = g_date->OldDays() + g_date->DayInYear(1, 9) + isSpring;
119  // OK, let's go.
120  // Here we queue up the first event which changes dependent on whether it is a forced spring sow or not
121  if (m_ev->m_forcespring) {
122  int day_num_shift = 365;
123  if (g_date->DayInYear() < 70) day_num_shift = 0;
124  if (m_farm->IsStockFarmer()) //Stock Farmer
125  {
126  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 3) + day_num_shift, de_ogsa_ferti_s, false, m_farm, m_field);
127  }
128  else SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 3) + day_num_shift, de_ogsa_ferti_p, false, m_farm, m_field);
129  break;
130  }
131  else SimpleEvent(d1, de_ogsa_winter_plough, false);
132  break;
133  }
134  break;
135 
136  // OK, let's go.
137  // LKM: Here we queue up the first event -
138  // winter plough thread
140  if (m_ev->m_lock || m_farm->DoIt(90))
141  {
142  if (!m_farm->WinterPlough(m_field, 0.0, g_date->DayInYear(31, 10) - g_date->DayInYear())) {
143  // If we don't succeed on the first try, then try and try again (until 10/10 when we will succeed)
145  break;
146  }
147  }
148  if (m_farm->IsStockFarmer()) //Stock Farmer
149  {
151  }
152  else SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 3) + 365, de_ogsa_ferti_p, false, m_farm, m_field);
153  break;
154  // slurry thread
155  case de_ogsa_ferti_s:
156  if (m_ev->m_lock || m_farm->DoIt_prob(0.90))
157  {
158  if (!m_farm->FA_Slurry(m_field, 0.0, g_date->DayInYear(30, 3) - g_date->DayInYear())) {
160  break;
161  }
162  }
164  break;
165  case de_ogsa_ferti_p:
166  if (m_ev->m_lock || m_farm->DoIt_prob(0.20))
167  {
168  if (!m_farm->FP_Slurry(m_field, 0.0, g_date->DayInYear(30, 3) - g_date->DayInYear())) {
170  break;
171  }
172  }
174  break; //End of slurry thread
175  //preseeding cultivation - 100% do this
178  g_date->DayInYear(15, 4) - g_date->DayInYear())) {
180  break;
181  }
182  SimpleEvent(g_date->Date() + 1, de_ogsa_sow, false);
183  break;
184  case de_ogsa_sow: // sowing
185  if (!m_farm->SpringSow(m_field, 0.0, g_date->DayInYear(30, 4) - g_date->DayInYear())) {
186  SimpleEvent(g_date->Date() + 1, de_ogsa_sow, true);
187  break;
188  } // first cutting
190  break;
192  // Here comes cutting thread
193  if (!m_farm->CutToSilage(m_field, 0.0, g_date->DayInYear(10, 6) - g_date->DayInYear())) {
195  break;
196  }
198  break;
200  if (m_ev->m_lock || m_farm->DoIt(70))
201  {
202  if (!m_farm->CutToSilage(m_field, 0.0, m_field->GetMDates(1, 0) - g_date->DayInYear())) {
204  break;
205  }
206  }
207  done = true;
208  // So we are done, and somewhere else the farmer will queue up the start event of the next crop
209  // END OF MAIN THREAD
210  break;
211  default:
212  g_msg->Warn(WARN_BUG, "DEOGrasslandSilageAnnual::Do(): "
213  "Unknown event type! ", "");
214  exit(1);
215  }
216  return done;
217 }

References LE::ClearManagementActionSum(), Farm::CutToSilage(), Calendar::Date(), Calendar::DayInYear(), de_ogsa_cut_to_silage1, de_ogsa_cut_to_silage2, de_ogsa_ferti_p, de_ogsa_ferti_s, DE_OGSA_HERBI_DATE, de_ogsa_preseeding_cultivation, de_ogsa_sow, de_ogsa_start, de_ogsa_winter_plough, Farm::DoIt(), Farm::DoIt_prob(), Farm::FA_Slurry(), Farm::FP_Slurry(), g_date, g_msg, LE::GetMDates(), Farm::IsStockFarmer(), Crop::m_ev, Crop::m_farm, Crop::m_field, FarmEvent::m_forcespring, Crop::m_last_date, FarmEvent::m_lock, FarmEvent::m_todo, Calendar::OldDays(), Farm::PreseedingCultivator(), Crop::SimpleEvent(), Crop::SimpleEvent_(), Farm::SpringSow(), Crop::StartUpCrop(), tov_DEOGrasslandSilageAnnual, MapErrorMsg::Warn(), WARN_BUG, and Farm::WinterPlough().

◆ SetUpFarmCategoryInformation()

void DE_OGrasslandSilageAnnual::SetUpFarmCategoryInformation ( )
inline
98  {
99  const int elements = 2 + (de_ogsa_foobar - DE_OGSA_BASE);
101 
102  FarmManagementCategory catlist[elements] =
103  {
104  fmc_Others, // zero element unused but must be here
105  fmc_Others, // de_ogsa_start = 1, // Compulsory, must always be 1 (one).
106  fmc_Others, // de_ogsa_sleep_all_day = DE_OGSA_BASE,
107  fmc_Cultivation, // de_ogsa_winter_plough,
108  fmc_Fertilizer, // de_ogsa_ferti_s,
109  fmc_Fertilizer, // de_ogsa_ferti_p,
110  fmc_Cultivation, // de_ogsa_preseeding_cultivation,
111  fmc_Others, // de_ogsa_sow,
112  fmc_Cutting, // de_ogsa_cut_to_silage1,
113  fmc_Cutting, // de_ogsa_cut_to_silage2,
114 
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 DE_OGSA_BASE, de_ogsa_foobar, fmc_Cultivation, fmc_Cutting, fmc_Fertilizer, fmc_Others, Crop::m_base_elements_no, and Crop::m_ManagementCategories.

Referenced by DE_OGrasslandSilageAnnual().


The documentation for this class was generated from the following files:
LE::GetMDates
int GetMDates(int a, int b)
Definition: Elements.h:405
tov_DEOGrasslandSilageAnnual
Definition: LandscapeFarmingEnums.h:482
FarmEvent::m_forcespring
bool m_forcespring
Definition: Farm.h:392
de_ogsa_ferti_p
Definition: DE_OGrasslandSilageAnnual.h:69
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::PreseedingCultivator
virtual bool PreseedingCultivator(LE *a_field, double a_user, int a_days)
Carry out preseeding cultivation on a_field (tilling set including cultivator and string roller to co...
Definition: FarmFuncs.cpp:312
Farm::IsStockFarmer
bool IsStockFarmer(void)
Definition: Farm.h:961
FarmEvent::m_lock
bool m_lock
Definition: Farm.h:384
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
de_ogsa_cut_to_silage2
Definition: DE_OGrasslandSilageAnnual.h:73
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
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
de_ogsa_ferti_s
Definition: DE_OGrasslandSilageAnnual.h:68
Crop::m_base_elements_no
int m_base_elements_no
Definition: Farm.h:505
de_ogsa_winter_plough
Definition: DE_OGrasslandSilageAnnual.h:67
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_ogsa_start
Definition: DE_OGrasslandSilageAnnual.h:65
de_ogsa_preseeding_cultivation
Definition: DE_OGrasslandSilageAnnual.h:70
fmc_Cutting
Definition: LandscapeFarmingEnums.h:1009
fmc_Fertilizer
Definition: LandscapeFarmingEnums.h:1004
DE_OGrasslandSilageAnnual::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: DE_OGrasslandSilageAnnual.h:98
Calendar::Date
long Date(void)
Definition: Calendar.h:57
de_ogsa_foobar
Definition: DE_OGrasslandSilageAnnual.h:74
fmc_Cultivation
Definition: LandscapeFarmingEnums.h:1008
fmc_Others
Definition: LandscapeFarmingEnums.h:1003
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
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
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
Crop::m_last_date
int m_last_date
Definition: Farm.h:503
de_ogsa_cut_to_silage1
Definition: DE_OGrasslandSilageAnnual.h:72
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
TTypesOfVegetation
TTypesOfVegetation
Values that represent the types of vegetation that are represented in ALMaSS.
Definition: LandscapeFarmingEnums.h:192
DE_OGSA_HERBI_DATE
#define DE_OGSA_HERBI_DATE
A flag used to indicate autumn ploughing status.
Definition: DE_OGrasslandSilageAnnual.h:57
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
de_ogsa_sow
Definition: DE_OGrasslandSilageAnnual.h:71
Calendar::DayInYear
int DayInYear(void)
Definition: Calendar.h:58
DE_OGSA_BASE
#define DE_OGSA_BASE
Definition: DE_OGrasslandSilageAnnual.h:53
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
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