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

#include <DK_OptimalFlowerMix2.h>

Inheritance diagram for DK_OptimalFlowerMix2:
Crop

Public Member Functions

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

Constructor & Destructor Documentation

◆ DK_OptimalFlowerMix2()

DK_OptimalFlowerMix2::DK_OptimalFlowerMix2 ( TTypesOfVegetation  a_tov,
TTypesOfCrops  a_toc,
Landscape a_L 
)
inline

Member Function Documentation

◆ Do()

bool DK_OptimalFlowerMix2::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_DKOptimalFlowerMix2; // this is the second of three management following each other - perennial flowers
40 
41  switch ( m_ev->m_todo ) {
42  case dk_ofm2_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 swathing 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) - harvest
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_ofm2_wait1))) 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 
64  SimpleEvent(d1, dk_ofm2_wait1, false);
65  break;
66 
67  }
68  break;
69  // LKM: This is the first real farm operation - perennial flowers - no actions required
70 
71  case dk_ofm2_wait1:
72  if (!a_farm->SleepAllDay(a_field, 0.0, g_date->DayInYear(1, 4) - g_date->DayInYear())) {
73  SimpleEvent(g_date->Date() + 1, dk_ofm2_wait1, true);
74  break;
75  }
77  break;
78 
79  case dk_ofm2_wait2:
80  if (!a_farm->SleepAllDay(a_field, 0.0, m_field->GetMDates(1, 0) - g_date->DayInYear())) {
81  SimpleEvent(g_date->Date() + 1, dk_ofm2_wait2, true);
82  break;
83  }
84  // End of management
85  done = true;
86  break;
87 
88  // So we are done, and somewhere else the farmer will queue up the start event of the next crop (DK_OptimalFlowerMix3)
89  default:
90  g_msg->Warn( WARN_BUG, "DK_OptimalFlowerMix2::Do(): "
91  "Unknown event type! ", "" );
92  exit( 1 );
93  }
94  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
95  return done;
96 }

References LE::ClearManagementActionSum(), Calendar::Date(), Calendar::DayInYear(), dk_ofm2_start, dk_ofm2_wait1, dk_ofm2_wait2, g_date, g_msg, LE::GetMDates(), Crop::m_ev, Crop::m_farm, Crop::m_field, FarmEvent::m_forcespring, Crop::m_last_date, FarmEvent::m_todo, Calendar::OldDays(), Crop::SimpleEvent(), Farm::SleepAllDay(), Crop::StartUpCrop(), tov_DKOptimalFlowerMix2, MapErrorMsg::Warn(), and WARN_BUG.

◆ SetUpFarmCategoryInformation()

void DK_OptimalFlowerMix2::SetUpFarmCategoryInformation ( )
inline
57  {
58  const int elements = 2 + (dk_ofm2_foobar - DK_OFM2_BASE);
60 
61  FarmManagementCategory catlist[elements] =
62  {
63  fmc_Others, // zero element unused but must be here
64  fmc_Others, // dk_ofm2_start = 1, // Compulsory, start event must always be 1 (one).
65  fmc_Others, // dk_ofm2_wait1 = DK_OFM2_BASE,
66  fmc_Others, //dk_ofm2_wait2,
67  // No foobar entry
68  };
69  // Iterate over the catlist elements and copy them to vector
70  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
71  }

References DK_OFM2_BASE, dk_ofm2_foobar, fmc_Others, Crop::m_base_elements_no, and Crop::m_ManagementCategories.

Referenced by DK_OptimalFlowerMix2().


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
LE::ClearManagementActionSum
void ClearManagementActionSum()
clears the management action counters
Definition: Elements.h:247
DK_OFM2_BASE
#define DK_OFM2_BASE
Definition: DK_OptimalFlowerMix2.h:39
dk_ofm2_wait2
Definition: DK_OptimalFlowerMix2.h:43
g_date
class Calendar * g_date
Definition: Calendar.cpp:37
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
tov_DKOptimalFlowerMix2
Definition: LandscapeFarmingEnums.h:437
Crop::SimpleEvent
void SimpleEvent(long a_date, int a_todo, bool a_lock)
Adds an event to this crop management.
Definition: Farm.cpp:747
Calendar::Date
long Date(void)
Definition: Calendar.h:57
DK_OptimalFlowerMix2::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: DK_OptimalFlowerMix2.h:57
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
dk_ofm2_wait1
Definition: DK_OptimalFlowerMix2.h:42
dk_ofm2_foobar
Definition: DK_OptimalFlowerMix2.h:44
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
dk_ofm2_start
Definition: DK_OptimalFlowerMix2.h:41
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
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