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

PTCorkOak class
. More...

#include <PTCorkOak.h>

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

PTCorkOak class
.

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

◆ PTCorkOak()

PTCorkOak::PTCorkOak ( TTypesOfVegetation  a_tov,
TTypesOfCrops  a_toc,
Landscape a_L 
)
inline
78  : Crop(a_tov, a_toc, a_L)
79  {
80  // When we start it off, the first possible date for a farm operation is 5th November
81  // This information is used by other crops when they decide how much post processing of
82  // the management is allowed after harvest before the next crop starts.
83  m_first_date=g_date->DayInYear( 15,3 );//@AAS:Last possible date to do the first operation, i.e. plough or sow
85  }

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

Member Function Documentation

◆ Do()

bool PTCorkOak::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 m_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 - in this case conventional TemporalGrassGrazed.

Reimplemented from Crop.

54 {
55  /******************** This block can be added to the top of all Crop::Do methods ***********************************************/
56  m_farm = a_farm; // These assignments are necessary, not for this method but for related event calls
57  m_field = a_field;
58  m_ev = a_ev;
59  bool done = false; // The boolean value done indicates when we are totally finished with this plan (i.e. it is set to true).
60  int d1 = 0;
61  TTypesOfVegetation l_tov = tov_PTCorkOak; // The current type - change to match the crop you have
62 /**********************************************To Here *************************************************************************/
63 
64  // Depending what event has occured jump to the correct bit of code
65  switch (m_ev->m_todo)
66  {
67  case pt_co_start:
68  {
69  PT_CO_YEARS_AFTER_PLOUGH = 0; // Here, similar to PTPermanentGrassGrazed, the initial conditions for field (no of years after ploughing) should be defined outside the crop management plan,
70  // at the beginning of simulation. For now all fields are starting with 0
71 
73 
74  m_last_date = g_date->DayInYear(1, 7); // Should match the last flexdate below
75  //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
76  std::vector<std::vector<int>> flexdates(1 + 1, std::vector<int>(2, 0));
77  // Set up the date management stuff
78  // Start and stop dates for all events after harvest
79  flexdates[0][1] = g_date->DayInYear(1, 7); // last possible day of harvest - this is in effect day before the earliest date that a following crop can use
80 
81  flexdates[1][0] = -1; // This date will be moved back as far as necessary and potentially to flexdates 1 (start op 1)
82  flexdates[1][1] = g_date->DayInYear(1, 7); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 1)
83 
84  // Below if this is a spring crop use 365, otherwise set this to 0, second parameter is fixed, and the third is the start up operation in the first year
85  int isSpring = 365;
86  if (StartUpCrop(isSpring, flexdates, int(pt_co_spring_plough))) break;
87 
88  // End single block date checking code. Please see next line comment as well.
89  // Reinit d1 to first possible starting date.
90  d1 = g_date->OldDays() + g_date->DayInYear(1, 2) + isSpring;
91  // OK, let's go.
92  // Here we queue up the first event which changes dependent on whether it is a forced spring sow or not
93  SimpleEvent(d1, pt_co_spring_plough, false);
94  break;
95  }
96  break;
97 
98  // This is the first real farm operation
100  if ((PT_CO_YEARS_AFTER_PLOUGH + g_date->GetYearNumber()) % 3 == 0)
101  {
102  if (!m_farm->SpringPlough(m_field, 0.0, g_date->DayInYear(15, 3) - g_date->DayInYear())) {
104  break;
105  }
107 
108  }
110  break;
111  case pt_co_wait:
112  done = true;
113  break;
114  // End of Thread
115  default:
116  g_msg->Warn(WARN_BUG, "PTCorkOak::Do(): "
117  "Unknown event type! ", "");
118  exit(1);
119  }
120  return done;
121 }

References LE::ClearManagementActionSum(), Calendar::Date(), Calendar::DayInYear(), g_date, g_msg, Calendar::GetYearNumber(), Crop::m_ev, Crop::m_farm, Crop::m_field, Crop::m_last_date, FarmEvent::m_todo, Calendar::OldDays(), pt_co_spring_plough, pt_co_start, pt_co_wait, PT_CO_YEARS_AFTER_PLOUGH, Crop::SimpleEvent(), Crop::SimpleEvent_(), Farm::SpringPlough(), Crop::StartUpCrop(), tov_PTCorkOak, MapErrorMsg::Warn(), and WARN_BUG.

◆ SetUpFarmCategoryInformation()

void PTCorkOak::SetUpFarmCategoryInformation ( )
inline
86  {
87  const int elements = 2 + (pt_co_foobar - PTCORKOAK_BASE);
89 
90  FarmManagementCategory catlist[elements] =
91  {
92  fmc_Others, // zero element unused but must be here
93  fmc_Others, //pt_co_start = 1, // Compulsory, must always be 1 (one).
94  fmc_Others, //pt_co_sleep_all_day = PTCORKOAK_BASE,
95  fmc_Others, //pt_co_spring_plough,
96  fmc_Others, //pt_co_wait,
97 
98  // no foobar entry
99 
100  };
101  // Iterate over the catlist elements and copy them to vector
102  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
103 
104  }

References fmc_Others, Crop::m_base_elements_no, Crop::m_ManagementCategories, pt_co_foobar, and PTCORKOAK_BASE.

Referenced by PTCorkOak().


The documentation for this class was generated from the following files:
Farm::SpringPlough
virtual bool SpringPlough(LE *a_field, double a_user, int a_days)
Carry out a ploughing event in the spring on a_field.
Definition: FarmFuncs.cpp:421
LE::ClearManagementActionSum
void ClearManagementActionSum()
clears the management action counters
Definition: Elements.h:247
Calendar::GetYearNumber
int GetYearNumber(void)
Definition: Calendar.h:72
pt_co_start
Definition: PTCorkOak.h:57
g_date
class Calendar * g_date
Definition: Calendar.cpp:37
pt_co_foobar
Definition: PTCorkOak.h:61
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
Crop::SimpleEvent
void SimpleEvent(long a_date, int a_todo, bool a_lock)
Adds an event to this crop management.
Definition: Farm.cpp:747
PTCorkOak::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: PTCorkOak.h:86
Calendar::Date
long Date(void)
Definition: Calendar.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
pt_co_spring_plough
Definition: PTCorkOak.h:59
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
pt_co_wait
Definition: PTCorkOak.h:60
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
PT_CO_YEARS_AFTER_PLOUGH
#define PT_CO_YEARS_AFTER_PLOUGH
A flag used to indicate ploughing status.
Definition: PTCorkOak.h:49
PTCORKOAK_BASE
#define PTCORKOAK_BASE
Definition: PTCorkOak.h:45
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
tov_PTCorkOak
Definition: LandscapeFarmingEnums.h:319
FarmManagementCategory
FarmManagementCategory
Definition: LandscapeFarmingEnums.h:1001
Crop::SimpleEvent_
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.
Definition: Farm.cpp:751