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
PTGrassGrazed.h
Go to the documentation of this file.
1 
14 //
15 // PTGrassGrazed.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 PTGRASSGRAZED_H
43 #define PTGRASSGRAZED_H
44 
45 #define PTGRASSGRAZED_BASE 30200
46 
49 #define PT_GG1_CATTLEOUT_DATE a_field->m_user[1]
50 #define PT_GG2_CATTLEOUT_DATE a_field->m_user[2]
51 #define PT_GG_CULT_SOW a_field->m_user[3]
52 
58 typedef enum {
59  pt_gg_start = 1, // Compulsory, must always be 1 (one).
76 
78 
79 
88 class PTGrassGrazed: public Crop
89 {
90  public:
91  virtual bool Do( Farm *a_farm, LE *a_field, FarmEvent *a_ev );
92  PTGrassGrazed(TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape* a_L) : Crop(a_tov, a_toc, a_L)
93  {
94  // When we start it off, the first possible date for a farm operation is 5th November
95  // This information is used by other crops when they decide how much post processing of
96  // the management is allowed after harvest before the next crop starts.
97  m_first_date=g_date->DayInYear( 20,10 );//@AAS:Last possible date to do the first operation, i.e. plough or sow
99  }
101  const int elements = 2 + (pt_gg_foobar - PTGRASSGRAZED_BASE);
103 
104  FarmManagementCategory catlist[elements] =
105  {
106  fmc_Others, // zero element unused but must be here
107  fmc_Others, //pt_gg_start = 1, // Compulsory, must always be 1 (one).
108  fmc_Others, //pt_gg_sleep_all_day = PTGRASSGRAZED_BASE,
109  fmc_Cultivation, //pt_gg_stubble_harrow,
110  fmc_Cultivation, //pt_gg_autumn_plough,
111  fmc_Cultivation, //pt_gg_autumn_harrow,
112  fmc_Fertilizer, //pt_gg_ferti_p1,
113  fmc_Fertilizer, //pt_gg_ferti_s1,
114  fmc_Others, //pt_gg_autumn_sow,
115  fmc_Cultivation, //pt_gg_autumn_roll,
116  fmc_Cultivation, //pt_gg_preseeding_cultivator_sow,
117  fmc_Grazing, //pt_gg_cattle_out1,
118  fmc_Grazing, //pt_gg_cattle_is_out1,
119  fmc_Harvest, //pt_gg_harvest,
120  fmc_Grazing, //pt_gg_cattle_out2,
121  fmc_Grazing, //pt_gg_cattle_is_out2,
122  fmc_Others, //pt_gg_wait,
123 
124  // no foobar entry
125 
126  };
127  // Iterate over the catlist elements and copy them to vector
128  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
129 
130  }
131 };
132 
133 #endif // PTGRASSGRAZED_H
134 
LE::GetMDates
int GetMDates(int a, int b)
Definition: Elements.h:405
Farm::IsStockFarmer
bool IsStockFarmer(void)
Definition: Farm.h:961
PT_GG1_CATTLEOUT_DATE
#define PT_GG1_CATTLEOUT_DATE
A flag used to indicate cattle out dates.
Definition: PTGrassGrazed.h:49
PTGrassGrazed::PTGrassGrazed
PTGrassGrazed(TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape *a_L)
Definition: PTGrassGrazed.h:92
PT_GG_CULT_SOW
#define PT_GG_CULT_SOW
Definition: PTGrassGrazed.h:51
Farm::Harvest
virtual bool Harvest(LE *a_field, double a_user, int a_days)
Carry out a harvest on a_field.
Definition: FarmFuncs.cpp:1364
FarmEvent::m_lock
bool m_lock
Definition: Farm.h:384
pt_gg_ferti_s1
Definition: PTGrassGrazed.h:65
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
pt_gg_foobar
Definition: PTGrassGrazed.h:75
pt_gg_ferti_p1
Definition: PTGrassGrazed.h:64
PT_GG2_CATTLEOUT_DATE
#define PT_GG2_CATTLEOUT_DATE
Definition: PTGrassGrazed.h:50
pt_gg_autumn_harrow
Definition: PTGrassGrazed.h:63
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
pt_gg_cattle_is_out1
Definition: PTGrassGrazed.h:70
Crop::m_base_elements_no
int m_base_elements_no
Definition: Farm.h:505
PTGrassGrazed
PTGrassGrazed class .
Definition: PTGrassGrazed.h:88
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
pt_gg_harvest
Definition: PTGrassGrazed.h:71
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
Crop::SimpleEvent
void SimpleEvent(long a_date, int a_todo, bool a_lock)
Adds an event to this crop management.
Definition: Farm.cpp:747
PTGRASSGRAZED_BASE
#define PTGRASSGRAZED_BASE
Definition: PTGrassGrazed.h:45
PTGrassGrazed::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: PTGrassGrazed.cpp:53
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
Landscape
The landscape class containing all environmental and topographical data.
Definition: Landscape.h:142
fmc_Fertilizer
Definition: LandscapeFarmingEnums.h:1004
PTGrassGrazedToDo
PTGrassGrazedToDo
Definition: PTGrassGrazed.h:58
Calendar::Date
long Date(void)
Definition: Calendar.h:57
fmc_Cultivation
Definition: LandscapeFarmingEnums.h:1008
pt_gg_sleep_all_day
Definition: PTGrassGrazed.h:60
fmc_Others
Definition: LandscapeFarmingEnums.h:1003
Calendar::OldDays
long OldDays(void)
Definition: Calendar.h:60
pt_gg_cattle_out1
Definition: PTGrassGrazed.h:69
pt_gg_autumn_sow
Definition: PTGrassGrazed.h:66
MapErrorMsg::Warn
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: MapErrorMsg.cpp:69
pt_gg_wait
Definition: PTGrassGrazed.h:74
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
PTGrassGrazed::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: PTGrassGrazed.h:100
pt_gg_autumn_roll
Definition: PTGrassGrazed.h:67
Crop::m_farm
Farm * m_farm
Definition: Farm.h:498
Crop::m_field
LE * m_field
Definition: Farm.h:499
pt_gg_autumn_plough
Definition: PTGrassGrazed.h:62
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
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
FarmEvent::m_todo
int m_todo
Definition: Farm.h:388
Farm::AutumnRoll
virtual bool AutumnRoll(LE *a_field, double a_user, int a_days)
Carry out a roll event in the autumn on a_field.
Definition: FarmFuncs.cpp:299
pt_gg_cattle_out2
Definition: PTGrassGrazed.h:72
TTypesOfCrops
TTypesOfCrops
Definition: LandscapeFarmingEnums.h:781
LE
Definition: Elements.h:86
g_weather
class Weather * g_weather
Definition: Weather.cpp:49
Crop::m_last_date
int m_last_date
Definition: Farm.h:503
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
pt_gg_start
Definition: PTGrassGrazed.h:59
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
The base class for all farm types.
Definition: Farm.h:755
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
fmc_Harvest
Definition: LandscapeFarmingEnums.h:1012
Calendar::DayInYear
int DayInYear(void)
Definition: Calendar.h:58
pt_gg_cattle_is_out2
Definition: PTGrassGrazed.h:73
pt_gg_stubble_harrow
Definition: PTGrassGrazed.h:61
tov_PTGrassGrazed
Definition: LandscapeFarmingEnums.h:310
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
pt_gg_preseeding_cultivator_sow
Definition: PTGrassGrazed.h:68
WARN_BUG
Definition: MapErrorMsg.h:34
FarmManagementCategory
FarmManagementCategory
Definition: LandscapeFarmingEnums.h:1001
Weather::GetRainPeriod
double GetRainPeriod(long a_date, unsigned int a_period)
Definition: Weather.cpp:688
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