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

DK_OSetAside_AnnualFlower class
. More...

#include <DK_OSetAside_AnnualFlower.h>

Inheritance diagram for DK_OSetAside_AnnualFlower:
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_AnnualFlower (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_AnnualFlower class
.

See DK_OSetAside_AnnualFlower.h::DK_OSetAside_AnnualFlowerToDo for a complete list of all possible events triggered codes by the DK_OSetAside_AnnualFlower 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_AnnualFlower()

DK_OSetAside_AnnualFlower::DK_OSetAside_AnnualFlower ( 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(28, 4);
99  }

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

Member Function Documentation

◆ Do()

bool DK_OSetAside_AnnualFlower::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_osaaf_start:
99  {
101 
102  a_field->ClearManagementActionSum();
103  m_field->SetVegPatchy(true);
104  m_last_date = g_date->DayInYear(31, 7); // Should match the last flexdate below
105  //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
106  std::vector<std::vector<int>> flexdates(1 + 1, std::vector<int>(2, 0));
107  // Set up the date management stuff
108  // Start and stop dates for all events after harvest
109  flexdates[0][1] = g_date->DayInYear(31, 7); // last possible day of strigling in this case
110  // Now these are done in pairs, start & end for each operation. If its not used then -1
111  flexdates[1][0] = -1; // This date will be moved back as far as necessary and potentially to flexdates 1 (start op 1)
112  flexdates[1][1] = g_date->DayInYear(31, 7); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 1) - swathing
113 
114  // 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
115  int isSpring = 365;
116  if (StartUpCrop(isSpring, flexdates, int(dk_osaaf_harrow))) break;
117 
118  // End single block date checking code. Please see next line comment as well.
119  // Reinit d1 to first possible starting date.
120 
121  if ((DK_OSAAF_EVERY_2ND_YEAR + g_date->GetYearNumber()) % 2 == 2)
122  {
123  d1 = g_date->OldDays() + g_date->DayInYear(1, 1) + 365;
124  if (g_date->Date() >= d1) {
125  d1 = g_date->Date();
126  }
127  SimpleEvent(d1, dk_osaaf_harrow, false);
128  }
129  else if ((DK_OSAAF_EVERY_2ND_YEAR + g_date->GetYearNumber()) % 2 == 1)
130  {
131  d1 = g_date->OldDays() + g_date->DayInYear(1, 1) + 365;
132  if (g_date->Date() >= d1) {
133  d1 = g_date->Date();
134  }
135  SimpleEvent(d1, dk_osaaf_harrow, false);
136  }
137  else if ((DK_OSAAF_EVERY_2ND_YEAR + g_date->GetYearNumber()) % 2 == 0)
138  {
139  d1 = g_date->OldDays() + g_date->DayInYear(1, 7) + 365;
140  if (g_date->Date() >= d1) {
141  d1 = g_date->Date();
142  }
143  SimpleEvent(d1, dk_osaaf_wait1, false);
144  }
145  break;
146 
147  }
148  break;
149  // LKM: This is the first real farm operation - soil cultivation only needed if establishment of flower og pollinator osetaside (then cutting is not done in that year)
150 
151  case dk_osaaf_harrow:
152  if (a_ev->m_lock || a_farm->DoIt_prob(1.0)) {
153  if (!a_farm->SpringHarrow(a_field, 0.0, g_date->DayInYear(28, 4) - g_date->DayInYear())) {
154  SimpleEvent(g_date->Date() + 1, dk_osaaf_harrow, true);
155  break;
156 
157  }
158  }
159  SimpleEvent(g_date->Date(), dk_osaaf_roll, false);
160  break;
161 
162  case dk_osaaf_roll:
163  if (!a_farm->SpringRoll(a_field, 0.0, g_date->DayInYear(29, 4) - g_date->DayInYear())) {
164  SimpleEvent(g_date->Date() + 1, dk_osaaf_roll, true);
165  break;
166  }
167  SimpleEvent(g_date->Date(), dk_osaaf_sow, false);
168  break;
169 
170  case dk_osaaf_sow:
171  if (!a_farm->SpringSow(a_field, 0.0, g_date->DayInYear(30, 4) - g_date->DayInYear())) {
172  SimpleEvent(g_date->Date() + 1, dk_osaaf_sow, true);
173  break;
174  }
176  break;
177 
178  case dk_osaaf_wait1: //no requirements on cutting the field the following year
179  if (!a_farm->SleepAllDay(a_field, 0.0, m_field->GetMDates(1, 0) - g_date->DayInYear())) {
180  SimpleEvent(g_date->Date() + 1, dk_osaaf_wait1, true);
181  break;
182  }
183  // End of management
184  done = true;
185  m_field->SetVegPatchy(false);
186  break;
187  // So we are done, and somewhere else the farmer will queue up the start event of the next crop
188  // END OF MAIN THREAD
189  default:
190  g_msg->Warn(WARN_BUG, "DK_OSetAside_AnnualFlower::Do(): "
191  "Unknown event type! ", "");
192  exit(1);
193  }
194  return done;
195 }

References LE::ClearManagementActionSum(), Calendar::Date(), Calendar::DayInYear(), DK_OSAAF_EVERY_2ND_YEAR, dk_osaaf_harrow, dk_osaaf_roll, dk_osaaf_sow, dk_osaaf_start, dk_osaaf_wait1, Farm::DoIt_prob(), g_date, g_msg, LE::GetMDates(), Calendar::GetYearNumber(), Crop::m_ev, Crop::m_farm, Crop::m_field, Crop::m_last_date, FarmEvent::m_lock, FarmEvent::m_todo, Calendar::OldDays(), LE::SetVegPatchy(), Crop::SimpleEvent(), Farm::SleepAllDay(), Farm::SpringHarrow(), Farm::SpringRoll(), Farm::SpringSow(), Crop::StartUpCrop(), tov_DKOSetAside_AnnualFlower, MapErrorMsg::Warn(), and WARN_BUG.

◆ SetUpFarmCategoryInformation()

void DK_OSetAside_AnnualFlower::SetUpFarmCategoryInformation ( )
inline
100  {
101  const int elements = 2 + (dk_osaaf_foobar - DK_OSAAF_BASE);
103 
104  FarmManagementCategory catlist[elements] =
105  {
106  fmc_Others, // zero element unused but must be here
107  fmc_Others, // dk_osaaf_start = 1, // Compulsory, must always be 1 (one).
108  fmc_Cultivation, // dk_osaaf_harrow = DK_SA_BASE
109  fmc_Cultivation, // dk_osaaf_roll
110  fmc_Others, // dk_osaaf_wait1,
111  fmc_Others, // dk_osaaf_wait2,
112  fmc_Others, // dk_osaaf_sow,
113  fmc_Cutting, // dk_osaaf_cutting,
114  fmc_Cultivation, // dk_osaaf_strigling,
115  fmc_Cutting, // dk_osaaf_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_OSAAF_BASE, dk_osaaf_foobar, fmc_Cultivation, fmc_Cutting, fmc_Others, Crop::m_base_elements_no, and Crop::m_ManagementCategories.

Referenced by DK_OSetAside_AnnualFlower().


The documentation for this class was generated from the following files:
LE::GetMDates
int GetMDates(int a, int b)
Definition: Elements.h:405
Farm::SpringRoll
virtual bool SpringRoll(LE *a_field, double a_user, int a_days)
Carry out a roll event in the spring on a_field.
Definition: FarmFuncs.cpp:487
tov_DKOSetAside_AnnualFlower
Definition: LandscapeFarmingEnums.h:394
dk_osaaf_sow
Definition: DK_OSetAside_AnnualFlower.h:72
FarmEvent::m_lock
bool m_lock
Definition: Farm.h:384
LE::ClearManagementActionSum
void ClearManagementActionSum()
clears the management action counters
Definition: Elements.h:247
Calendar::GetYearNumber
int GetYearNumber(void)
Definition: Calendar.h:72
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
dk_osaaf_wait1
Definition: DK_OSetAside_AnnualFlower.h:69
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
dk_osaaf_start
Definition: DK_OSetAside_AnnualFlower.h:67
Crop::m_first_date
int m_first_date
Definition: Farm.h:501
DK_OSAAF_EVERY_2ND_YEAR
#define DK_OSAAF_EVERY_2ND_YEAR
Definition: DK_OSetAside_AnnualFlower.h:53
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
DK_OSAAF_BASE
#define DK_OSAAF_BASE
Definition: DK_OSetAside_AnnualFlower.h:56
Calendar::Date
long Date(void)
Definition: Calendar.h:57
fmc_Cultivation
Definition: LandscapeFarmingEnums.h:1008
dk_osaaf_roll
Definition: DK_OSetAside_AnnualFlower.h:71
dk_osaaf_foobar
Definition: DK_OSetAside_AnnualFlower.h:76
fmc_Others
Definition: LandscapeFarmingEnums.h:1003
LE::SetVegPatchy
void SetVegPatchy(bool p)
Definition: Elements.h:229
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
dk_osaaf_harrow
Definition: DK_OSetAside_AnnualFlower.h:68
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::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
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_OSetAside_AnnualFlower::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: DK_OSetAside_AnnualFlower.h:100
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_ev
FarmEvent * m_ev
Definition: Farm.h:500
WARN_BUG
Definition: MapErrorMsg.h:34
FarmManagementCategory
FarmManagementCategory
Definition: LandscapeFarmingEnums.h:1001
Farm::SpringHarrow
virtual bool SpringHarrow(LE *a_field, double a_user, int a_days)
Carry out a harrow event in the spring on a_field.
Definition: FarmFuncs.cpp:459