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

DK_OSetAside_SummerMow class
. More...

#include <DK_OSetAside_SummerMow.h>

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

DK_OSetAside_SummerMow class
.

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

◆ DK_OSetAside_SummerMow()

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

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

Member Function Documentation

◆ Do()

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

Reimplemented from Crop.

88 {
89  m_field = a_field; // this is needed because of possible calls to other methods and currently we do not pass parameters.
90  m_farm = a_farm; // this is needed because of possible calls to other methods and currently we do not pass parameters.
91  m_ev = a_ev;
92  bool done = false; // The boolean value done indicates when we are totally finished with this plan (i.e. it is set to true).
93  int d1 = 0;
95  // Depending what event has occured jump to the correct bit of code e.g. for ww_start jump to line 67 below
96  switch (a_ev->m_todo)
97  {
98  case dk_osasm_start:
99  {
100  a_field->ClearManagementActionSum();
101  m_field->SetVegPatchy(true);
102  m_last_date = g_date->DayInYear(11, 11); // 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(3 + 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(25, 10); // last possible day of cutting in this case
108  // Now these are done in pairs, start & end for each operation. If its not used then -1
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(26, 10); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 1) - strigling
111  flexdates[2][0] = -1; // This date will be moved back as far as necessary and potentially to flexdates 2 (start op 2)
112  flexdates[2][1] = g_date->DayInYear(26, 10); // This date will be moved back as far as necessary and potentially to flexdates 2 (end op 2) - herbicide
113  flexdates[3][0] = -1; // This date will be moved back as far as necessary and potentially to flexdates 3 (start op 3)
114  flexdates[3][1] = g_date->DayInYear(11, 11); // This date will be moved back as far as necessary and potentially to flexdates 3 (end op 3) - swathing
115 
116  // Below if this is a spring crop use 365, otherwise first parameter is always 0, second parameter is fixed, and the third is the start up operation in the first year
117  if (StartUpCrop(0, flexdates, int(dk_osasm_wait1))) break;
118 
119  if (m_ev->m_forcespring) {
120  int day_num_shift = 365;
121  if (g_date->DayInYear() < 70) day_num_shift = 0;
122  SimpleEvent(g_date->OldDays() + g_date->DayInYear(1, 3) + day_num_shift, dk_osasm_wait1, false);
123  break;
124  }
125  // End single block date checking code. Please see next line comment as well.
126  // Reinit d1 to first possible starting date.
127  d1 = g_date->OldDays() + g_date->DayInYear(1, 9);
128  // OK, let's go.
129  // Here we queue up the first event which changes dependent on whether it is a forced spring sow or no
130  if (g_date->Date() >= d1) {
131  d1 = g_date->Date();
132  }
133  SimpleEvent(d1, dk_osasm_wait2, false);
134  break;
135 
136  }
137  break;
138  // LKM: This is the first real farm operation
139 
140  case dk_osasm_wait2:
141  if (!a_farm->SleepAllDay(a_field, 0.0, g_date->DayInYear(31, 12) - g_date->DayInYear())) {
142  SimpleEvent(g_date->Date() + 1, dk_osasm_wait2, true);
143  break;
144  }
145  SimpleEvent(g_date->OldDays() + g_date->DayInYear(1, 3) + 365, dk_osasm_wait1, false);
146  break;
147 
148  case dk_osasm_wait1:
149  if (!a_farm->SleepAllDay(a_field, 0.0, g_date->DayInYear(1, 8) - g_date->DayInYear())) {
150  SimpleEvent(g_date->Date() + 1, dk_osasm_wait1, true);
151  break;
152  }
154  break;
155 
156  case dk_osasm_cutting: // only allowed between 1 of aug to 25 of oct (when summer cutting)
157  if (!a_farm->CutToHay(a_field, 0.0, m_field->GetMDates(1, 0) - g_date->DayInYear())) {
158  SimpleEvent(g_date->Date() + 1, dk_osasm_cutting, true);
159  break;
160  }
161  SimpleEvent(g_date->Date() + 1, dk_osasm_strigling, false);
162  break;
163 
164  case dk_osasm_strigling:
165  if (a_ev->m_lock || a_farm->DoIt(100)) {
166  if (!a_farm->Strigling(a_field, 0.0, m_field->GetMDates(1, 1) - g_date->DayInYear())) {
167  SimpleEvent(g_date->Date() + 1, dk_osasm_strigling, true);
168  break;
169  }
170  }
171  SimpleEvent(g_date->Date() + 14, dk_osasm_swathing, false);
172  break;
173 
174  case dk_osasm_swathing:
175  if (a_field->GetVegBiomass() > 0)
176  {
177  if (!a_farm->Swathing(a_field, 0.0, m_field->GetMDates(1, 3) - g_date->DayInYear())) {
178  SimpleEvent(g_date->Date() + 1, dk_osasm_swathing, true);
179  break;
180  }
181  }
182  done = true;
183  m_field->SetVegPatchy(false);
184  break;
185  // So we are done, and somewhere else the farmer will queue up the start event of the next crop
186  // END OF MAIN THREAD
187  default:
188  g_msg->Warn(WARN_BUG, "DK_OSetAside_SummerMow::Do(): "
189  "Unknown event type! ", "");
190  exit(1);
191  }
192  return done;
193 }

References LE::ClearManagementActionSum(), Farm::CutToHay(), Calendar::Date(), Calendar::DayInYear(), dk_osasm_cutting, dk_osasm_start, dk_osasm_strigling, dk_osasm_swathing, dk_osasm_wait1, dk_osasm_wait2, Farm::DoIt(), g_date, g_msg, LE::GetMDates(), LE::GetVegBiomass(), Crop::m_ev, Crop::m_farm, Crop::m_field, FarmEvent::m_forcespring, Crop::m_last_date, FarmEvent::m_lock, FarmEvent::m_todo, Calendar::OldDays(), LE::SetVegPatchy(), Crop::SimpleEvent(), Farm::SleepAllDay(), Crop::StartUpCrop(), Farm::Strigling(), Farm::Swathing(), tov_DKOSetAside_SummerMow, MapErrorMsg::Warn(), and WARN_BUG.

◆ SetUpFarmCategoryInformation()

void DK_OSetAside_SummerMow::SetUpFarmCategoryInformation ( )
inline
100  {
101  const int elements = 2 + (dk_osasm_foobar - DK_OSASM_BASE);
103 
104  FarmManagementCategory catlist[elements] =
105  {
106  fmc_Others, // zero element unused but must be here
107  fmc_Others, // dk_osasm_start = 1, // Compulsory, must always be 1 (one).
108  fmc_Cultivation, // dk_osasm_harrow = DK_SA_BASE
109  fmc_Cultivation, // dk_osasm_roll
110  fmc_Others, // dk_osasm_wait1,
111  fmc_Others, // dk_osasm_wait2,
112  fmc_Others, // dk_osasm_sow,
113  fmc_Cutting, // dk_osasm_cutting,
114  fmc_Cultivation, // dk_osasm_strigling,
115  fmc_Cutting, // dk_osasm_swathing,
116 
117  // no foobar entry
118 
119  };
120  // Iterate over the catlist elements and copy them to vector
121  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
122 
123  }

References DK_OSASM_BASE, dk_osasm_foobar, fmc_Cultivation, fmc_Cutting, fmc_Others, Crop::m_base_elements_no, and Crop::m_ManagementCategories.

Referenced by DK_OSetAside_SummerMow().


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_forcespring
bool m_forcespring
Definition: Farm.h:392
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
FarmEvent::m_lock
bool m_lock
Definition: Farm.h:384
LE::ClearManagementActionSum
void ClearManagementActionSum()
clears the management action counters
Definition: Elements.h:247
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
dk_osasm_strigling
Definition: DK_OSetAside_SummerMow.h:74
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
LE::GetVegBiomass
virtual double GetVegBiomass(void)
Definition: Elements.h:164
Crop::SimpleEvent
void SimpleEvent(long a_date, int a_todo, bool a_lock)
Adds an event to this crop management.
Definition: Farm.cpp:747
fmc_Cutting
Definition: LandscapeFarmingEnums.h:1009
Calendar::Date
long Date(void)
Definition: Calendar.h:57
fmc_Cultivation
Definition: LandscapeFarmingEnums.h:1008
dk_osasm_swathing
Definition: DK_OSetAside_SummerMow.h:75
dk_osasm_wait1
Definition: DK_OSetAside_SummerMow.h:69
fmc_Others
Definition: LandscapeFarmingEnums.h:1003
LE::SetVegPatchy
void SetVegPatchy(bool p)
Definition: Elements.h:229
dk_osasm_foobar
Definition: DK_OSetAside_SummerMow.h:76
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
dk_osasm_wait2
Definition: DK_OSetAside_SummerMow.h:70
Farm::SleepAllDay
virtual bool SleepAllDay(LE *a_field, double a_user, int a_days)
Nothing to to today on a_field.
Definition: FarmFuncs.cpp:272
Crop::m_last_date
int m_last_date
Definition: Farm.h:503
DK_OSetAside_SummerMow::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: DK_OSetAside_SummerMow.h:100
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
dk_osasm_cutting
Definition: DK_OSetAside_SummerMow.h:73
DK_OSASM_BASE
#define DK_OSASM_BASE
Definition: DK_OSetAside_SummerMow.h:56
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
Farm::Swathing
virtual bool Swathing(LE *a_field, double a_user, int a_days)
Cut the crop on a_field and leave it lying (probably rape)
Definition: FarmFuncs.cpp:1350
dk_osasm_start
Definition: DK_OSetAside_SummerMow.h:67
tov_DKOSetAside_SummerMow
Definition: LandscapeFarmingEnums.h:396
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
WARN_BUG
Definition: MapErrorMsg.h:34
FarmManagementCategory
FarmManagementCategory
Definition: LandscapeFarmingEnums.h:1001