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

DE_GreenFallow_1years class
. More...

#include <DE_GreenFallow_1year.h>

Inheritance diagram for DE_GreenFallow_1year:
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_GreenFallow_1year (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_GreenFallow_1years class
.

See DE_GreenFallow_1years.h::DEGreenFallow_1yearsToDo for a complete list of all possible events triggered codes by the winter wheat 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_GreenFallow_1year()

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

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

Member Function Documentation

◆ Do()

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

Reimplemented from Crop.

84 {
85  /******************** This block can be added to the top of all Crop::Do methods ***********************************************/
86  m_farm = a_farm; // These assignments are necessary, not for this method but for related event calls
87  m_field = a_field;
88  m_ev = a_ev;
89  bool done = false; // The boolean value done indicates when we are totally finished with this plan (i.e. it is set to true).
90  int d1 = 0;
91  TTypesOfVegetation l_tov = tov_DEGreenFallow_1year; // The current type - change to match the crop you have
92 /**********************************************To Here *************************************************************************/
93 
94  // Depending what event has occured jump to the correct bit of code e.g. for ww_start jump to line 67 below
95  switch (m_ev->m_todo)
96  {
97  case de_gf1_start:
98  {
100 
101  m_last_date = g_date->DayInYear(30, 9); // Should match the last flexdate below
102  //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
103  std::vector<std::vector<int>> flexdates(1 + 1, std::vector<int>(2, 0));
104  // Set up the date management stuff
105  // Start and stop dates for all events after harvest
106  flexdates[0][1] = g_date->DayInYear(30, 9); // last possible day of cattle out / cut to silage - this is in effect day before the earliest date that a following crop can use
107 
108  flexdates[1][0] = -1; // This date will be moved back as far as necessary and potentially to flexdates 1 (start op 1)
109  flexdates[1][1] = g_date->DayInYear(30, 9); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 1)
110 
111  // 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
112  int isSpring = 365;
113  if (StartUpCrop(isSpring, flexdates, int(de_gf1_sow))) break;
114 
115  // End single block date checking code. Please see next line comment as well.
116  // Reinit d1 to first possible starting date.
117  d1 = g_date->OldDays() + g_date->DayInYear(1, 5) + isSpring;
118  // OK, let's go.
119  SimpleEvent_(d1, de_gf1_sow, false, m_farm, m_field);
120  break;
121  }
122  break;
123 
124  case de_gf1_sow:
125  if (!a_farm->SpringSow(a_field, 0.0, g_date->DayInYear(15, 6) - g_date->DayInYear())) {
126  SimpleEvent_(g_date->Date() + 1, de_gf1_sow, true, m_farm, m_field);
127  break;
128  }
130  break;
131  case de_gf1_grazing1: // 100% cut or grazed - suggests 50% each
132  if (a_ev->m_lock || a_farm->DoIt(50)) {
133  if (!a_farm->CattleOut(a_field, 0.0,
134  g_date->DayInYear(30, 9) - g_date->DayInYear())) {
136  break;
137  }
139  break;
140  }
142  break;
143  case de_gf1_cutting1: //
144  if (!a_farm->CutToSilage(a_field, 0.0, m_field->GetMDates(1, 0) - g_date->DayInYear())) {
146  break;
147  }
148  done = true;
149  break;
150  case de_gf1_cattle_is_out1: // Keep the cattle out there
151  // CattleIsOut() returns false if it is not time to stop grazing
152  if (!m_farm->CattleIsOut(m_field, 0.0, m_field->GetMDates(1, 0) - g_date->DayInYear(), m_field->GetMDates(1, 0))) {
154  break;
155  }
156  done = true;
157  break;
158  // So we are done, and somewhere else the farmer will queue up the start event of the next crop
159  // END OF MAIN THREAD
160  default:
161  g_msg->Warn(WARN_BUG, "DE_GreenFallow_1year::Do(): "
162  "Unknown event type! ", "");
163  exit(1);
164  }
165  return done;
166 }

References Farm::CattleIsOut(), Farm::CattleOut(), LE::ClearManagementActionSum(), Farm::CutToSilage(), Calendar::Date(), Calendar::DayInYear(), de_gf1_cattle_is_out1, de_gf1_cutting1, de_gf1_grazing1, de_gf1_sow, de_gf1_start, 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_(), Farm::SpringSow(), Crop::StartUpCrop(), tov_DEGreenFallow_1year, MapErrorMsg::Warn(), and WARN_BUG.

◆ SetUpFarmCategoryInformation()

void DE_GreenFallow_1year::SetUpFarmCategoryInformation ( )
inline
95  {
96  const int elements = 2 + (de_gf1_foobar - DE_GF1_BASE);
98 
99  FarmManagementCategory catlist[elements] =
100  {
101  fmc_Others, // zero element unused but must be here
102  // ALL THE NECESSARY ENTRIES HERE
103  fmc_Others, // de_gf1_start = 1, // Compulsory, must always be 1 (one).
104  fmc_Others, // de_gf1_sleep_all_day
105  fmc_Others, // de_gf1_sow,
106  fmc_Grazing, // de_gf1_grazing1,
107  fmc_Grazing, // de_gf1_cattle_is_out1,
108  fmc_Cutting, // de_gf1_cutting1,
109  // no foobar entry
110 
111  };
112  // Iterate over the catlist elements and copy them to vector
113  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
114 
115  }

References DE_GF1_BASE, de_gf1_foobar, fmc_Cutting, fmc_Grazing, fmc_Others, Crop::m_base_elements_no, and Crop::m_ManagementCategories.

Referenced by DE_GreenFallow_1year().


The documentation for this class was generated from the following files:
LE::GetMDates
int GetMDates(int a, int b)
Definition: Elements.h:405
DE_GF1_BASE
#define DE_GF1_BASE
Definition: DE_GreenFallow_1year.h:53
de_gf1_cattle_is_out1
Definition: DE_GreenFallow_1year.h:68
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
de_gf1_sow
Definition: DE_GreenFallow_1year.h:66
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
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
fmc_Cutting
Definition: LandscapeFarmingEnums.h:1009
Calendar::Date
long Date(void)
Definition: Calendar.h:57
de_gf1_start
Definition: DE_GreenFallow_1year.h:64
tov_DEGreenFallow_1year
Definition: LandscapeFarmingEnums.h:475
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
de_gf1_grazing1
Definition: DE_GreenFallow_1year.h:67
FarmEvent::m_todo
int m_todo
Definition: Farm.h:388
DE_GreenFallow_1year::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: DE_GreenFallow_1year.h:95
Crop::m_last_date
int m_last_date
Definition: Farm.h:503
de_gf1_foobar
Definition: DE_GreenFallow_1year.h:70
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_gf1_cutting1
Definition: DE_GreenFallow_1year.h:69
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
Crop::m_forcespringpossible
bool m_forcespringpossible
Used to signal that the crop can be forced to start in spring.
Definition: Farm.h:508
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