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

#include <DK_FarmForest_Perm.h>

Inheritance diagram for DK_FarmForest_Perm:
Crop

Public Member Functions

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

DK_FarmForest_Perm::DK_FarmForest_Perm ( TTypesOfVegetation  a_tov,
TTypesOfCrops  a_toc,
Landscape a_L 
)
inline
54  : Crop(a_tov, a_toc, a_L)
55  {
58  }

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

Member Function Documentation

◆ Do()

bool DK_FarmForest_Perm::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;
40 
41  switch ( m_ev->m_todo ) {
42  case dk_ffp_start:
43  {
44  a_field->ClearManagementActionSum();
45 
46  m_last_date = g_date->DayInYear(1, 9); // Should match the last flexdate below
47  //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
48  std::vector<std::vector<int>> flexdates(1 + 1, std::vector<int>(2, 0));
49  // Set up the date management stuff
50  // Start and stop dates for all events after harvest
51  flexdates[0][1] = g_date->DayInYear(1, 9); // last possible day
52  // Now these are done in pairs, start & end for each operation. If its not used then -1
53  flexdates[1][0] = -1; // This date will be moved back as far as necessary and potentially to flexdates 1 (start op 1)
54  flexdates[1][1] = g_date->DayInYear(1, 9); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 1)
55 
56  // 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
57  int isSpring = 365;
58  if (StartUpCrop(isSpring, flexdates, int(dk_ffp_do_nothing_start))) break;
59 
60  // End single block date checking code. Please see next line comment as well.
61  // Reinit d1 to first possible starting date.
62  d1 = g_date->OldDays() + g_date->DayInYear(1, 4) + isSpring;
63  // OK, let's go.
65  }
66  break;
67 
69  SimpleEvent( g_date->OldDays() + g_date->DayInYear( 1, 9 ),
70  dk_ffp_do_nothing_stop, false );
71  break;
72 
74 
75  ChooseNextCrop (1);
76 
77  done = true;
78  break;
79 
80  default:
81  g_msg->Warn( WARN_BUG, "DK_FarmForest_Perm::Do(): "
82  "Unknown event type! ", "" );
83  exit( 1 );
84  }
85 
86  return done;
87 }

References Crop::ChooseNextCrop(), LE::ClearManagementActionSum(), Calendar::DayInYear(), dk_ffp_do_nothing_start, dk_ffp_do_nothing_stop, dk_ffp_start, g_date, g_msg, Crop::m_ev, Crop::m_farm, Crop::m_field, Crop::m_last_date, FarmEvent::m_todo, Calendar::OldDays(), Crop::SimpleEvent(), Crop::StartUpCrop(), tov_DKFarmForest_Perm, MapErrorMsg::Warn(), and WARN_BUG.

◆ SetUpFarmCategoryInformation()

void DK_FarmForest_Perm::SetUpFarmCategoryInformation ( )
inline
59  {
60  const int elements = 2 + (dk_ffp_foobar - DK_FFP_BASE);
62 
63  FarmManagementCategory catlist[elements] =
64  {
65  fmc_Others, // zero element unused but must be here
66  fmc_Others, // dk_ffp_start = 1, // Compulsory, start event must always be 1 (one).
67  fmc_Others, // dk_ffp_do_nothing_start = DK_FFP_BASE,
68  fmc_Others // dk_ffp_do_nothing_stop,
69  // No foobar entry
70  };
71  // Iterate over the catlist elements and copy them to vector
72  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
73  }

References DK_FFP_BASE, dk_ffp_foobar, fmc_Others, Crop::m_base_elements_no, and Crop::m_ManagementCategories.

Referenced by DK_FarmForest_Perm().


The documentation for this class was generated from the following files:
dk_ffp_do_nothing_start
Definition: DK_FarmForest_Perm.h:43
dk_ffp_start
Definition: DK_FarmForest_Perm.h:42
LE::ClearManagementActionSum
void ClearManagementActionSum()
clears the management action counters
Definition: Elements.h:247
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_DKFarmForest_Perm
Definition: LandscapeFarmingEnums.h:450
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_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_ffp_foobar
Definition: DK_FarmForest_Perm.h:45
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
DK_FFP_BASE
#define DK_FFP_BASE
Definition: DK_FarmForest_Perm.h:39
DK_FarmForest_Perm::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: DK_FarmForest_Perm.h:59
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_ffp_do_nothing_stop
Definition: DK_FarmForest_Perm.h:44
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::ChooseNextCrop
void ChooseNextCrop(int a_no_dates)
Chooses the next crop to grow in a field.
Definition: Farm.cpp:756
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
WARN_BUG
Definition: MapErrorMsg.h:34
FarmManagementCategory
FarmManagementCategory
Definition: LandscapeFarmingEnums.h:1001