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

PTTurnipGrazed class
. More...

#include <PTTurnipGrazed.h>

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

PTTurnipGrazed class
.

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

◆ PTTurnipGrazed()

PTTurnipGrazed::PTTurnipGrazed ( TTypesOfVegetation  a_tov,
TTypesOfCrops  a_toc,
Landscape a_L 
)
inline
82  : Crop(a_tov, a_toc, a_L)
83  {
84  // When we start it off, the first possible date for a farm operation is 5th November
85  // This information is used by other crops when they decide how much post processing of
86  // the management is allowed after harvest before the next crop starts.
87  m_first_date=g_date->DayInYear( 10,11 ); // change back to 10.11 when tested in rotation
89  }

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

Member Function Documentation

◆ Do()

bool PTTurnipGrazed::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 TurnipGrazed.

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_PTTurnipGrazed; // 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_tg_start:
68  {
70 
72 
73  // Reinit d1 to first possible starting date.
74  d1 = g_date->OldDays() + g_date->DayInYear(10, 10);
75  // OK, let's go.
76  // Here we queue up the first event which changes dependent on whether it is a forced spring sow or not
78  break;
79  }
80  break;
81 
82  // This is the first real farm operation
84  if (!m_farm->StubbleHarrowing(m_field, 0.0, g_date->DayInYear(10, 11) - g_date->DayInYear())) {
86  break;
87  }
89  break;
91  if (!m_farm->AutumnPlough(m_field, 0.0, g_date->DayInYear(11, 11) - g_date->DayInYear())) {
93  break;
94  }
96  break;
98  if (!m_farm->AutumnHarrow(m_field, 0.0, g_date->DayInYear(12, 11) - g_date->DayInYear())) {
100  break;
101  }
103  break;
104  case pt_tg_autumn_sow:
105  if (!m_farm->AutumnSow(m_field, 0.0, g_date->DayInYear(13, 11) - g_date->DayInYear())) {
107  break;
108  }
110  break;
111  case pt_tg_cattle_out:
112  if (!m_farm->CattleOutLowGrazing(m_field, 0.0, g_date->DayInYear(5, 12) - g_date->DayInYear())) {
114  break;
115  }
118  break;
119  case pt_tg_cattle_is_out: // Keep the cattle out there
122  break;
123  }
124  // The plan is finished
125  // Calling sleep_all_day to move to the next year d1 = g_date->OldDays() + 365 + m_field->GetMDates(0, 0);
126  d1 = g_date->OldDays() + g_date->DayInYear(1, 1) + 365;
127  SimpleEvent(d1, pt_tg_sleep_all_day, false);
128  break;
129  case pt_tg_sleep_all_day:
130  if (!a_farm->SleepAllDay(a_field, 0.0, m_field->GetMDates(1, 0) - g_date->DayInYear())) {
132  break;
133  }
134  done = true;
135  break;
136  default:
137  g_msg->Warn(WARN_BUG, "PTTurnipGrazed::Do(): "
138  "Unknown event type! ", "");
139  exit(1);
140  }
141  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
142  return done;
143 }

References Farm::AutumnHarrow(), Farm::AutumnPlough(), Farm::AutumnSow(), Farm::CattleIsOutLow2(), Farm::CattleOutLowGrazing(), LE::ClearManagementActionSum(), Calendar::Date(), Calendar::DayInYear(), g_date, g_msg, LE::GetMDates(), Crop::m_ev, Crop::m_farm, Crop::m_field, FarmEvent::m_forcespring, FarmEvent::m_todo, Calendar::OldDays(), PT_TG1_CATTLEOUT_DATE, pt_tg_autumn_harrow, pt_tg_autumn_plough, pt_tg_autumn_sow, pt_tg_cattle_is_out, pt_tg_cattle_out, pt_tg_sleep_all_day, pt_tg_start, pt_tg_stubble_harrow, Crop::SimpleEvent(), Crop::SimpleEvent_(), Farm::SleepAllDay(), Farm::StubbleHarrowing(), tov_PTTurnipGrazed, MapErrorMsg::Warn(), and WARN_BUG.

◆ SetUpFarmCategoryInformation()

void PTTurnipGrazed::SetUpFarmCategoryInformation ( )
inline
90  {
91  const int elements = 2 + (pt_tg_foobar - PTTURNIPGRAZED_BASE);
93 
94  FarmManagementCategory catlist[elements] =
95  {
96  fmc_Others, // zero element unused but must be here
97  fmc_Others, //pt_tg_start = 1, // Compulsory, must always be 1 (one).
98  fmc_Others, //pt_tg_sleep_all_day = PTTURNIPGRAZED_BASE,
99  fmc_Cultivation, //pt_tg_stubble_harrow,
100  fmc_Cultivation, //pt_tg_autumn_plough,
101  fmc_Cultivation, //pt_tg_autumn_harrow,
102  fmc_Others, //pt_tg_autumn_sow,
103  fmc_Grazing, //pt_tg_cattle_out,
104  fmc_Grazing, //pt_tg_cattle_is_out,
105 
106  // no foobar entry
107 
108  };
109  // Iterate over the catlist elements and copy them to vector
110  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
111 
112  }

References fmc_Cultivation, fmc_Grazing, fmc_Others, Crop::m_base_elements_no, Crop::m_ManagementCategories, pt_tg_foobar, and PTTURNIPGRAZED_BASE.

Referenced by PTTurnipGrazed().


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
pt_tg_foobar
Definition: PTTurnipGrazed.h:65
g_date
class Calendar * g_date
Definition: Calendar.cpp:37
PTTURNIPGRAZED_BASE
#define PTTURNIPGRAZED_BASE
Definition: PTTurnipGrazed.h:45
Crop::m_base_elements_no
int m_base_elements_no
Definition: Farm.h:505
pt_tg_cattle_is_out
Definition: PTTurnipGrazed.h:64
Crop::m_first_date
int m_first_date
Definition: Farm.h:501
Farm::CattleIsOutLow2
virtual bool CattleIsOutLow2(LE *a_field, double a_user, int a_days, int a_max, int a_max_days)
Generate a 'cattle_out_low2' event for every day the cattle are on a_field, cattle is low grazing and...
Definition: FarmFuncs.cpp:2607
Crop::SimpleEvent
void SimpleEvent(long a_date, int a_todo, bool a_lock)
Adds an event to this crop management.
Definition: Farm.cpp:747
Farm::CattleOutLowGrazing
virtual bool CattleOutLowGrazing(LE *a_field, double a_user, int a_days)
Start a extensive grazing event on a_field today.
Definition: FarmFuncs.cpp:2439
PT_TG1_CATTLEOUT_DATE
#define PT_TG1_CATTLEOUT_DATE
A flag used to indicate cattle out dates.
Definition: PTTurnipGrazed.h:49
pt_tg_autumn_harrow
Definition: PTTurnipGrazed.h:61
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
pt_tg_sleep_all_day
Definition: PTTurnipGrazed.h:58
MapErrorMsg::Warn
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: MapErrorMsg.cpp:69
pt_tg_cattle_out
Definition: PTTurnipGrazed.h:63
PTTurnipGrazed::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: PTTurnipGrazed.h:90
pt_tg_autumn_plough
Definition: PTTurnipGrazed.h:60
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
pt_tg_start
Definition: PTTurnipGrazed.h:57
Farm::AutumnPlough
virtual bool AutumnPlough(LE *a_field, double a_user, int a_days)
Carry out a ploughing event in the autumn on a_field.
Definition: FarmFuncs.cpp:212
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
Farm::AutumnHarrow
virtual bool AutumnHarrow(LE *a_field, double a_user, int a_days)
Carry out a harrow event in the autumn on a_field.
Definition: FarmFuncs.cpp:285
fmc_Grazing
Definition: LandscapeFarmingEnums.h:1010
TTypesOfVegetation
TTypesOfVegetation
Values that represent the types of vegetation that are represented in ALMaSS.
Definition: LandscapeFarmingEnums.h:192
Farm::AutumnSow
virtual bool AutumnSow(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 autumn on a_field.
Definition: FarmFuncs.cpp:360
Calendar::DayInYear
int DayInYear(void)
Definition: Calendar.h:58
pt_tg_autumn_sow
Definition: PTTurnipGrazed.h:62
Crop::Crop
Crop(TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape *a_L)
Definition: Farm.cpp:733
pt_tg_stubble_harrow
Definition: PTTurnipGrazed.h:59
tov_PTTurnipGrazed
Definition: LandscapeFarmingEnums.h:313
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
WARN_BUG
Definition: MapErrorMsg.h:34
FarmManagementCategory
FarmManagementCategory
Definition: LandscapeFarmingEnums.h:1001
Farm::StubbleHarrowing
virtual bool StubbleHarrowing(LE *a_field, double a_user, int a_days)
Carry out stubble harrowing on a_field.
Definition: FarmFuncs.cpp:1523
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