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

DE_OGreenFallow_1years class
. More...

#include <DE_OGreenFallow_1year.h>

Inheritance diagram for DE_OGreenFallow_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_OGreenFallow_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_OGreenFallow_1years class
.

See DE_OGreenFallow_1years.h::DE_OGreenFallow_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_OGreenFallow_1year()

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

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

Member Function Documentation

◆ Do()

bool DE_OGreenFallow_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_DEOGreenFallow_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_ogf1_start:
98  {
100 
101  m_last_date = g_date->DayInYear(29, 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(29, 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(29, 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_ogf1_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_ogf1_sow, false, m_farm, m_field);
120  break;
121  }
122  break;
123 
124  case de_ogf1_sow:
125  if (a_ev->m_lock || a_farm->DoIt(100)) {
126  if (!a_farm->SpringSow(a_field, 0.0, g_date->DayInYear(15, 6) - g_date->DayInYear())) {
127  // If we don't succeed on the first try, then try and try again (until 10/10 when we will succeed)
129  break;
130  }
131  }
132  //here comes next events:
134  break;
135  case de_ogf1_grazing1: // 100% cut or grazed - suggests 50% each
136  if (a_ev->m_lock || a_farm->DoIt(50)) {
137  if (!a_farm->CattleOut(a_field, 0.0,
138  g_date->DayInYear(30, 9) - g_date->DayInYear())) {
140  break;
141  }
143  break;
144  }
146  break;
147  case de_ogf1_cutting1: //
148  if (!a_farm->CutToSilage(a_field, 0.0, m_field->GetMDates(1, 0) - g_date->DayInYear())) {
150  break;
151  }
152  done = true;
153  break;
154  case de_ogf1_cattle_is_out1: // Keep the cattle out there
155  // CattleIsOut() returns false if it is not time to stop grazing
156  if (!m_farm->CattleIsOut(m_field, 0.0, m_field->GetMDates(1, 0) - g_date->DayInYear(), m_field->GetMDates(1, 0))) {
158  break;
159  }
160  done = true;
161  break;
162  // So we are done, and somewhere else the farmer will queue up the start event of the next crop
163  // END OF MAIN THREAD
164  default:
165  g_msg->Warn(WARN_BUG, "DE_OGreenFallow_1year::Do(): "
166  "Unknown event type! ", "");
167  exit(1);
168  }
169  return done;
170 }

References Farm::CattleIsOut(), Farm::CattleOut(), LE::ClearManagementActionSum(), Farm::CutToSilage(), Calendar::Date(), Calendar::DayInYear(), de_ogf1_cattle_is_out1, de_ogf1_cutting1, de_ogf1_grazing1, de_ogf1_sow, de_ogf1_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_DEOGreenFallow_1year, MapErrorMsg::Warn(), and WARN_BUG.

◆ SetUpFarmCategoryInformation()

void DE_OGreenFallow_1year::SetUpFarmCategoryInformation ( )
inline
96  {
97  const int elements = 2 + (de_ogf1_foobar - DE_OGF1_BASE);
99 
100  FarmManagementCategory catlist[elements] =
101  {
102  fmc_Others, // zero element unused but must be here
103  // ALL THE NECESSARY ENTRIES HERE
104  fmc_Others, // de_ogf1_start = 1, // Compulsory, must always be 1 (one).
105  fmc_Others, // de_ogf1_sleep_all_day
106  fmc_Others, // de_ogf1_sow,
107  fmc_Grazing, // de_ogf1_grazing1,
108  fmc_Grazing, // de_ogf1_cattle_is_out1,
109  fmc_Cutting, // de_ogf1_cutting1,
110  // no foobar entry
111 
112  };
113  // Iterate over the catlist elements and copy them to vector
114  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
115 
116  }

References DE_OGF1_BASE, de_ogf1_foobar, fmc_Cutting, fmc_Grazing, fmc_Others, Crop::m_base_elements_no, and Crop::m_ManagementCategories.

Referenced by DE_OGreenFallow_1year().


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_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
de_ogf1_foobar
Definition: DE_OGreenFallow_1year.h:71
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
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
DE_OGreenFallow_1year::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: DE_OGreenFallow_1year.h:96
de_ogf1_sow
Definition: DE_OGreenFallow_1year.h:67
fmc_Cutting
Definition: LandscapeFarmingEnums.h:1009
de_ogf1_cattle_is_out1
Definition: DE_OGreenFallow_1year.h:69
de_ogf1_cutting1
Definition: DE_OGreenFallow_1year.h:70
Calendar::Date
long Date(void)
Definition: Calendar.h:57
fmc_Others
Definition: LandscapeFarmingEnums.h:1003
Calendar::OldDays
long OldDays(void)
Definition: Calendar.h:60
tov_DEOGreenFallow_1year
Definition: LandscapeFarmingEnums.h:483
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_ogf1_start
Definition: DE_OGreenFallow_1year.h:65
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
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
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
DE_OGF1_BASE
#define DE_OGF1_BASE
Definition: DE_OGreenFallow_1year.h:53
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
de_ogf1_grazing1
Definition: DE_OGreenFallow_1year.h:68