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

DK_OptimalFlowerMix1 class
. More...

#include <DK_OptimalFlowerMix1.h>

Inheritance diagram for DK_OptimalFlowerMix1:
Crop

Public Member Functions

virtual bool Do (Farm *a_farm, LE *a_field, FarmEvent *a_ev)
 
 DK_OptimalFlowerMix1 (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_OptimalFlowerMix1 class
.

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

DK_OptimalFlowerMix1::DK_OptimalFlowerMix1 ( TTypesOfVegetation  a_tov,
TTypesOfCrops  a_toc,
Landscape a_L 
)
inline
63  : Crop(a_tov, a_toc, a_L)
64  {
65  // When we start it off, the first possible date for a farm operation
66  // This information is used by other crops when they decide how much post processing of
67  // the management is allowed after harvest before the next crop starts.
68  m_first_date = g_date->DayInYear(28, 4);
70  }

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

Member Function Documentation

◆ Do()

bool DK_OptimalFlowerMix1::Do ( Farm a_farm,
LE a_field,
FarmEvent a_ev 
)
virtual

Reimplemented from Crop.

33 {
34  m_farm = a_farm;
35  m_field = a_field;
36  m_ev = a_ev;
37  bool done = false;
38  int d1;
39  TTypesOfVegetation l_tov = tov_DKOptimalFlowerMix1; // this is the first of three management following each other - starting with establishment of annual flowers
40 
41  switch ( m_ev->m_todo ) {
42  case dk_ofm1_start:
43  {
44  a_field->ClearManagementActionSum();
45  m_last_date = g_date->DayInYear(30, 11); // Should match the last flexdate below
46  //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
47  std::vector<std::vector<int>> flexdates(1 + 1, std::vector<int>(2, 0));
48  // Set up the date management stuff
49  // Start and stop dates for all events after harvest
50  flexdates[0][1] = g_date->DayInYear(30, 11); // last possible day of strigling in this case
51  // Now these are done in pairs, start & end for each operation. If its not used then -1
52  flexdates[1][0] = -1; // This date will be moved back as far as necessary and potentially to flexdates 1 (start op 1)
53  flexdates[1][1] = g_date->DayInYear(30, 11); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 1) - swathing
54 
55  // 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
56  int isSpring = 365;
57  if (StartUpCrop(isSpring, flexdates, int(dk_ofm1_harrow))) break;
58 
59  // End single block date checking code. Please see next line comment as well.
60  // Reinit d1 to first possible starting date.
61 
62  d1 = g_date->OldDays() + g_date->DayInYear(1, 1) + 365;
63  if (g_date->Date() >= d1) {
64  d1 = g_date->Date();
65  }
66  SimpleEvent(d1, dk_ofm1_harrow, false);
67  break;
68 
69  }
70  break;
71  // 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)
72 
73  case dk_ofm1_harrow:
74  if (a_ev->m_lock || a_farm->DoIt_prob(1.0)) {
75  if (!a_farm->SpringHarrow(a_field, 0.0, g_date->DayInYear(28, 4) - g_date->DayInYear())) {
76  SimpleEvent(g_date->Date() + 1, dk_ofm1_harrow, true);
77  break;
78 
79  }
80  }
81  SimpleEvent(g_date->Date(), dk_ofm1_roll, false);
82  break;
83 
84  case dk_ofm1_roll:
85  if (!a_farm->SpringRoll(a_field, 0.0, g_date->DayInYear(29, 4) - g_date->DayInYear())) {
86  SimpleEvent(g_date->Date() + 1, dk_ofm1_roll, true);
87  break;
88  }
89  SimpleEvent(g_date->Date(), dk_ofm1_sow, false);
90  break;
91 
92  case dk_ofm1_sow:
93  if (!a_farm->SpringSow(a_field, 0.0, g_date->DayInYear(30, 4) - g_date->DayInYear())) {
94  SimpleEvent(g_date->Date() + 1, dk_ofm1_sow, true);
95  break;
96  }
98  break;
99 
100  case dk_ofm1_wait: //no requirements on cutting the field the following year
101  if (!a_farm->SleepAllDay(a_field, 0.0, m_field->GetMDates(1, 0) - g_date->DayInYear())) {
102  SimpleEvent(g_date->Date() + 1, dk_ofm1_wait, true);
103  break;
104  }
105  // End of management
106  done = true;
107  break;
108  // So we are done, and somewhere else the farmer will queue up the start event of the next crop (DK_OptimalFlowerMix2)
109  // END OF MAIN THREAD
110  default:
111  g_msg->Warn(WARN_BUG, "DK_OptimalFlowerMix1::Do(): "
112  "Unknown event type! ", "");
113  exit(1);
114  }
115  if (done) m_ev->m_forcespring = true; // Here we need to force the next crop to spring operation, so set the ev->forcespring to true
116  return done;
117 }

References LE::ClearManagementActionSum(), Calendar::Date(), Calendar::DayInYear(), dk_ofm1_harrow, dk_ofm1_roll, dk_ofm1_sow, dk_ofm1_start, dk_ofm1_wait, Farm::DoIt_prob(), g_date, g_msg, LE::GetMDates(), Crop::m_ev, Crop::m_farm, Crop::m_field, FarmEvent::m_forcespring, Crop::m_last_date, FarmEvent::m_lock, FarmEvent::m_todo, Calendar::OldDays(), Crop::SimpleEvent(), Farm::SleepAllDay(), Farm::SpringHarrow(), Farm::SpringRoll(), Farm::SpringSow(), Crop::StartUpCrop(), tov_DKOptimalFlowerMix1, MapErrorMsg::Warn(), and WARN_BUG.

◆ SetUpFarmCategoryInformation()

void DK_OptimalFlowerMix1::SetUpFarmCategoryInformation ( )
inline
71  {
72  const int elements = 2 + (dk_ofm1_foobar - DK_OFM1_BASE);
74 
75  FarmManagementCategory catlist[elements] =
76  {
77  fmc_Others, // zero element unused but must be here
78  fmc_Others, // dk_ofm1_start = 1, // Compulsory, must always be 1 (one).
79  fmc_Cultivation, // dk_ofm1_harrow = DK_SA_BASE
80  fmc_Cultivation, // dk_ofm1_roll
81  fmc_Others, // dk_ofm1_wait,
82  fmc_Others, // dk_ofm1_sow,
83 
84  // no foobar entry
85 
86  };
87  // Iterate over the catlist elements and copy them to vector
88  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
89 
90  }

References DK_OFM1_BASE, dk_ofm1_foobar, fmc_Cultivation, fmc_Others, Crop::m_base_elements_no, and Crop::m_ManagementCategories.

Referenced by DK_OptimalFlowerMix1().


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::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
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_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
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
DK_OFM1_BASE
#define DK_OFM1_BASE
Definition: DK_OptimalFlowerMix1.h:40
Crop::SimpleEvent
void SimpleEvent(long a_date, int a_todo, bool a_lock)
Adds an event to this crop management.
Definition: Farm.cpp:747
dk_ofm1_foobar
Definition: DK_OptimalFlowerMix1.h:47
dk_ofm1_roll
Definition: DK_OptimalFlowerMix1.h:45
dk_ofm1_sow
Definition: DK_OptimalFlowerMix1.h:46
Calendar::Date
long Date(void)
Definition: Calendar.h:57
fmc_Cultivation
Definition: LandscapeFarmingEnums.h:1008
fmc_Others
Definition: LandscapeFarmingEnums.h:1003
Calendar::OldDays
long OldDays(void)
Definition: Calendar.h:60
tov_DKOptimalFlowerMix1
Definition: LandscapeFarmingEnums.h:436
dk_ofm1_wait
Definition: DK_OptimalFlowerMix1.h:44
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::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
DK_OptimalFlowerMix1::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: DK_OptimalFlowerMix1.h:71
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
dk_ofm1_start
Definition: DK_OptimalFlowerMix1.h:42
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
dk_ofm1_harrow
Definition: DK_OptimalFlowerMix1.h:43
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