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
PTPermanentGrassGrazed.h
Go to the documentation of this file.
1 
14 //
15 // PTPermanentGrassGrazed.h
16 //
17 /*
18 *******************************************************************************************************
19 Copyright (c) 2024, Christopher John Topping, University of Aarhus
20 All rights reserved.
21 
22 Redistribution and use in source and binary forms, with or without modification, are permitted provided
23 that the following conditions are met:
24 
25 Redistributions of source code must retain the above copyright notice, this list of conditions and the
26 following disclaimer.
27 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
28 the following disclaimer in the documentation and/or other materials provided with the distribution.
29 
30 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
31 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
32 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
33 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
34 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
35 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
37 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 ********************************************************************************************************
39 */
40 
41 
42 #ifndef PTPERMANENTGRASSLANDGRAZED_H
43 #define PTPERMANENTGRASSLANDGRAZED_H
44 
45 #define PTPERMANENTGRASSLANDGRAZED_BASE 30000
46 
49 #define PT_PGG_YEARS_AFTER_SOW a_field->m_user[1]
50 #define PT_PGG1_CATTLEOUT_DATE a_field->m_user[2]
51 #define PT_PGG2_CATTLEOUT_DATE a_field->m_user[3]
52 #define PT_PGG3_CATTLEOUT_DATE a_field->m_user[4]
53 #define PT_PGG4_CATTLEOUT_DATE a_field->m_user[5]
54 #define PT_PGG5_CATTLEOUT_DATE a_field->m_user[6]
55 
61 typedef enum {
62  pt_pgg_start = 1, // Compulsory, must always be 1 (one).
64  pt_pgg_cattle_out1,//Out means outside the barns. Out in the field to eat grass.
65  pt_pgg_cattle_is_out1,//Time that the catle is in the field.
74  pt_pgg_ferti_p1,//NPK in non-sowing year
75  pt_pgg_ferti_s1,//NPK in non-sowing year
76  pt_pgg_ferti_p2,//Slurry in sowing year
77  pt_pgg_ferti_s2,//Slurry in sowing year
78  pt_pgg_ferti_s3,//NPK in sowing year
79  pt_pgg_ferti_p3,//NPK in sowing year
80  pt_pgg_ferti_p4,//Calcium
81  pt_pgg_ferti_s4,//Calcium
86  pt_pgg_sow_psc,//Sow with preseeding cultivator
89 
91 
92 
102 {
103  public:
104  virtual bool Do( Farm *a_farm, LE *a_field, FarmEvent *a_ev );
105  PTPermanentGrassGrazed(TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape* a_L) : Crop(a_tov, a_toc, a_L)
106  {
107  // When we start it off, the first possible date for a farm operation is 31th November
108  // This information is used by other crops when they decide how much post processing of
109  // the management is allowed after harvest before the next crop starts.
110  m_first_date=g_date->DayInYear( 10,1 );//Last possible date to do the first operation, i.e. plough or sow
112  }
114  const int elements = 2 + (pt_pgg_foobar - PTPERMANENTGRASSLANDGRAZED_BASE);
116 
117  FarmManagementCategory catlist[elements] =
118  {
119  fmc_Others, // zero element unused but must be here
120  fmc_Others, //pt_pgg_start = 1, // Compulsory, must always be 1 (one).
121  fmc_Others, //pt_pgg_sleep_all_day = PTPERMANENTGRASSLANDGRAZED_BASE,
122  fmc_Grazing, //pt_pgg_cattle_out1,//Out means outside the barns. Out in the field to eat grass.
123  fmc_Grazing, //pt_pgg_cattle_is_out1,//Time that the catle is in the field.
124  fmc_Grazing, //pt_pgg_cattle_out2,
125  fmc_Grazing, //pt_pgg_cattle_is_out2,
126  fmc_Grazing, //pt_pgg_cattle_out3,
127  fmc_Grazing, //pt_pgg_cattle_is_out3,
128  fmc_Grazing, //pt_pgg_cattle_out4,
129  fmc_Grazing, //pt_pgg_cattle_is_out4,
130  fmc_Grazing, //pt_pgg_cattle_out5,
131  fmc_Grazing, //pt_pgg_cattle_is_out5,
132  fmc_Fertilizer, //pt_pgg_ferti_p1,//NPK in non-sowing year
133  fmc_Fertilizer, //pt_pgg_ferti_s1,//NPK in non-sowing year
134  fmc_Fertilizer, //pt_pgg_ferti_p2,//Slurry in sowing year
135  fmc_Fertilizer, //pt_pgg_ferti_s2,//Slurry in sowing year
136  fmc_Fertilizer, //pt_pgg_ferti_s3,//NPK in sowing year
137  fmc_Fertilizer, //pt_pgg_ferti_p3,//NPK in sowing year
138  fmc_Fertilizer, //pt_pgg_ferti_p4,//Calcium
139  fmc_Fertilizer, //pt_pgg_ferti_s4,//Calcium
140  fmc_Fertilizer, //pt_pgg_ferti_p5,//NPK
141  fmc_Fertilizer, //pt_pgg_ferti_s5,//NPK
142  fmc_Cultivation, //pt_pgg_plough,
143  fmc_Others, //pt_pgg_sow,
144  fmc_Cultivation, //pt_pgg_sow_psc,//Sow with preseeding cultivator
145  fmc_Others, //pt_pgg_wait,
146 
147  // no foobar entry
148 
149  };
150  // Iterate over the catlist elements and copy them to vector
151  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
152 
153  }
154 };
155 
156 #endif // PTPERMANENTGRASSLANDGRAZED_H
157 
LE::GetMDates
int GetMDates(int a, int b)
Definition: Elements.h:405
pt_pgg_cattle_is_out2
Definition: PTPermanentGrassGrazed.h:67
Farm::FA_Slurry
virtual bool FA_Slurry(LE *a_field, double a_user, int a_days)
Spready slurry on a_field owned by an stock farmer.
Definition: FarmFuncs.cpp:1067
Farm::IsStockFarmer
bool IsStockFarmer(void)
Definition: Farm.h:961
FarmEvent::m_lock
bool m_lock
Definition: Farm.h:384
PT_PGG_YEARS_AFTER_SOW
#define PT_PGG_YEARS_AFTER_SOW
A flag used to indicate cattle out dates.
Definition: PTPermanentGrassGrazed.h:49
FarmEvent
A struct to hold the information required to trigger a farm event.
Definition: Farm.h:372
LE::ClearManagementActionSum
void ClearManagementActionSum()
clears the management action counters
Definition: Elements.h:247
Farm::FP_NPK
virtual bool FP_NPK(LE *a_field, double a_user, int a_days)
Apply NPK fertilizer, on a_field owned by an arable farmer.
Definition: FarmFuncs.cpp:645
PTPermanentGrassGrazed::PTPermanentGrassGrazed
PTPermanentGrassGrazed(TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape *a_L)
Definition: PTPermanentGrassGrazed.h:105
Calendar::GetYearNumber
int GetYearNumber(void)
Definition: Calendar.h:72
pt_pgg_ferti_p1
Definition: PTPermanentGrassGrazed.h:74
pt_pgg_ferti_p3
Definition: PTPermanentGrassGrazed.h:79
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
PTPermanentGrassGrazed
PTPermanentGrassGrazed class .
Definition: PTPermanentGrassGrazed.h:101
PTPermanentGrassGrazed::Do
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.
Definition: PTPermanentGrassGrazed.cpp:53
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
Farm::FA_NPK
virtual bool FA_NPK(LE *a_field, double a_user, int a_days)
Apply NPK fertilizer to a_field owned by an stock farmer.
Definition: FarmFuncs.cpp:982
Crop
The base class for all crops.
Definition: Farm.h:495
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
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_pgg_cattle_is_out4
Definition: PTPermanentGrassGrazed.h:71
pt_pgg_sow_psc
Definition: PTPermanentGrassGrazed.h:86
Landscape
The landscape class containing all environmental and topographical data.
Definition: Landscape.h:142
fmc_Fertilizer
Definition: LandscapeFarmingEnums.h:1004
pt_pgg_cattle_out4
Definition: PTPermanentGrassGrazed.h:70
pt_pgg_ferti_p2
Definition: PTPermanentGrassGrazed.h:76
pt_pgg_cattle_is_out3
Definition: PTPermanentGrassGrazed.h:69
Calendar::Date
long Date(void)
Definition: Calendar.h:57
pt_pgg_ferti_s5
Definition: PTPermanentGrassGrazed.h:83
fmc_Cultivation
Definition: LandscapeFarmingEnums.h:1008
pt_pgg_ferti_s3
Definition: PTPermanentGrassGrazed.h:78
fmc_Others
Definition: LandscapeFarmingEnums.h:1003
Farm::FA_Calcium
virtual bool FA_Calcium(LE *a_field, double a_user, int a_days)
Calcium applied on a_field owned by a stock farmer.
Definition: FarmFuncs.cpp:1168
pt_pgg_ferti_s1
Definition: PTPermanentGrassGrazed.h:75
pt_pgg_cattle_is_out5
Definition: PTPermanentGrassGrazed.h:73
pt_pgg_ferti_s2
Definition: PTPermanentGrassGrazed.h:77
Calendar::OldDays
long OldDays(void)
Definition: Calendar.h:60
pt_pgg_cattle_out5
Definition: PTPermanentGrassGrazed.h:72
MapErrorMsg::Warn
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: MapErrorMsg.cpp:69
Farm::FP_Calcium
virtual bool FP_Calcium(LE *a_field, double a_user, int a_days)
Calcium applied on a_field owned by an arable farmer.
Definition: FarmFuncs.cpp:954
PT_PGG4_CATTLEOUT_DATE
#define PT_PGG4_CATTLEOUT_DATE
Definition: PTPermanentGrassGrazed.h:53
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
pt_pgg_ferti_s4
Definition: PTPermanentGrassGrazed.h:81
pt_pgg_sow
Definition: PTPermanentGrassGrazed.h:85
Crop::m_farm
Farm * m_farm
Definition: Farm.h:498
Crop::m_field
LE * m_field
Definition: Farm.h:499
pt_pgg_plough
Definition: PTPermanentGrassGrazed.h:84
PT_PGG3_CATTLEOUT_DATE
#define PT_PGG3_CATTLEOUT_DATE
Definition: PTPermanentGrassGrazed.h:52
PTPermanentGrassGrazed::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: PTPermanentGrassGrazed.h:113
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
pt_pgg_cattle_is_out1
Definition: PTPermanentGrassGrazed.h:65
pt_pgg_cattle_out2
Definition: PTPermanentGrassGrazed.h:66
Farm::PreseedingCultivatorSow
virtual bool PreseedingCultivatorSow(LE *a_field, double a_user, int a_days, double a_seed_coating_amount=-1, PlantProtectionProducts a_ppp=ppp_foobar)
Carry out preseeding cultivation together with sow on a_field (tilling and sowing set including culti...
Definition: FarmFuncs.cpp:325
pt_pgg_cattle_out3
Definition: PTPermanentGrassGrazed.h:68
FarmEvent::m_todo
int m_todo
Definition: Farm.h:388
Farm::FP_Slurry
virtual bool FP_Slurry(LE *a_field, double a_user, int a_days)
Apply slurry to a_field owned by an arable farmer.
Definition: FarmFuncs.cpp:823
TTypesOfCrops
TTypesOfCrops
Definition: LandscapeFarmingEnums.h:781
pt_pgg_foobar
Definition: PTPermanentGrassGrazed.h:88
PTPERMANENTGRASSLANDGRAZED_BASE
#define PTPERMANENTGRASSLANDGRAZED_BASE
Definition: PTPermanentGrassGrazed.h:45
LE
Definition: Elements.h:86
Crop::m_last_date
int m_last_date
Definition: Farm.h:503
PT_PGG1_CATTLEOUT_DATE
#define PT_PGG1_CATTLEOUT_DATE
Definition: PTPermanentGrassGrazed.h:50
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
PTPermanentGrassGrazedToDo
PTPermanentGrassGrazedToDo
Definition: PTPermanentGrassGrazed.h:61
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
The base class for all farm types.
Definition: Farm.h:755
pt_pgg_start
Definition: PTPermanentGrassGrazed.h:62
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
PT_PGG2_CATTLEOUT_DATE
#define PT_PGG2_CATTLEOUT_DATE
Definition: PTPermanentGrassGrazed.h:51
pt_pgg_ferti_p4
Definition: PTPermanentGrassGrazed.h:80
pt_pgg_cattle_out1
Definition: PTPermanentGrassGrazed.h:64
Calendar::DayInYear
int DayInYear(void)
Definition: Calendar.h:58
PT_PGG5_CATTLEOUT_DATE
#define PT_PGG5_CATTLEOUT_DATE
Definition: PTPermanentGrassGrazed.h:54
pt_pgg_sleep_all_day
Definition: PTPermanentGrassGrazed.h:63
pt_pgg_wait
Definition: PTPermanentGrassGrazed.h:87
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
pt_pgg_ferti_p5
Definition: PTPermanentGrassGrazed.h:82
WARN_BUG
Definition: MapErrorMsg.h:34
tov_PTPermanentGrassGrazed
Definition: LandscapeFarmingEnums.h:308
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