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
PTShrubPastures.h
Go to the documentation of this file.
1 
14 //
15 // PTShrubPastures.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 PTSHRUBPASTURES_H
43 #define PTSHRUBPASTURES_H
44 
45 #define PTSHRUBPASTURES_BASE 31000
46 
49 #define PT_SP1_CATTLEOUT_DATE a_field->m_user[1]
50 #define PT_SP2_CATTLEOUT_DATE a_field->m_user[2]
51 #define PT_SP3_CATTLEOUT_DATE a_field->m_user[3]
52 #define PT_SP_YEARS_AFTER_PLOUGH a_field->m_user[4]
53 
59 typedef enum {
60  pt_sp_start = 1, // Compulsory, must always be 1 (one).
71 
73 
74 
83 class PTShrubPastures: public Crop
84 {
85  public:
86  virtual bool Do( Farm *a_farm, LE *a_field, FarmEvent *a_ev );
87  PTShrubPastures(TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape* a_L) : Crop(a_tov, a_toc, a_L)
88  {
89  // When we start it off, the first possible date for a farm operation is 31th November
90  // This information is used by other crops when they decide how much post processing of
91  // the management is allowed after harvest before the next crop starts.
92  m_first_date=g_date->DayInYear( 10,1 );//Last possible date to do the first operation, i.e. plough or sow
94  }
96  const int elements = 2 + (pt_sp_foobar - PTSHRUBPASTURES_BASE);
98 
99  FarmManagementCategory catlist[elements] =
100  {
101  fmc_Others, // zero element unused but must be here
102  fmc_Others, //pt_sp_start = 1, // Compulsory, must always be 1 (one).
103  fmc_Others, //pt_sp_sleep_all_day = PTSHRUBPASTURES_BASE,
104  fmc_Grazing, //pt_sp_cattle_out1,
105  fmc_Grazing, //pt_sp_cattle_is_out1,
106  fmc_Grazing, //pt_sp_spring_plough,
107  fmc_Grazing, //pt_sp_cattle_out2,
108  fmc_Grazing, //pt_sp_cattle_is_out2,
109  fmc_Grazing, //pt_sp_cattle_out3,
110  fmc_Grazing, //pt_sp_cattle_is_out3,
111  fmc_Others, //pt_sp_wait,
112 
113  // no foobar entry
114 
115  };
116  // Iterate over the catlist elements and copy them to vector
117  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
118 
119  }
120 };
121 
122 #endif // PTSHRUBPASTURES_H
123 
LE::GetMDates
int GetMDates(int a, int b)
Definition: Elements.h:405
FarmEvent::m_forcespring
bool m_forcespring
Definition: Farm.h:392
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
pt_sp_cattle_is_out2
Definition: PTShrubPastures.h:66
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
Calendar::GetYearNumber
int GetYearNumber(void)
Definition: Calendar.h:72
PT_SP3_CATTLEOUT_DATE
#define PT_SP3_CATTLEOUT_DATE
Definition: PTShrubPastures.h:51
PT_SP1_CATTLEOUT_DATE
#define PT_SP1_CATTLEOUT_DATE
A flag used to indicate cattle out dates.
Definition: PTShrubPastures.h:49
g_date
class Calendar * g_date
Definition: Calendar.cpp:37
PTShrubPasturesToDo
PTShrubPasturesToDo
Definition: PTShrubPastures.h:59
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
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
tov_PTShrubPastures
Definition: LandscapeFarmingEnums.h:318
PTShrubPastures
PTShrubPastures class .
Definition: PTShrubPastures.h:83
Landscape
The landscape class containing all environmental and topographical data.
Definition: Landscape.h:142
pt_sp_start
Definition: PTShrubPastures.h:60
pt_sp_cattle_out3
Definition: PTShrubPastures.h:67
Calendar::Date
long Date(void)
Definition: Calendar.h:57
pt_sp_sleep_all_day
Definition: PTShrubPastures.h:61
pt_sp_cattle_out1
Definition: PTShrubPastures.h:62
g_farm_fixed_crop_enable
CfgBool g_farm_fixed_crop_enable
CfgBool
Bool configurator entry class.
Definition: Configurator.h:155
fmc_Others
Definition: LandscapeFarmingEnums.h:1003
pt_sp_cattle_is_out1
Definition: PTShrubPastures.h:63
pt_sp_spring_plough
Definition: PTShrubPastures.h:64
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
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
PT_SP2_CATTLEOUT_DATE
#define PT_SP2_CATTLEOUT_DATE
Definition: PTShrubPastures.h:50
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_sp_cattle_out2
Definition: PTShrubPastures.h:65
pt_sp_wait
Definition: PTShrubPastures.h:69
PTShrubPastures::PTShrubPastures
PTShrubPastures(TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape *a_L)
Definition: PTShrubPastures.h:87
TTypesOfCrops
TTypesOfCrops
Definition: LandscapeFarmingEnums.h:781
PT_SP_YEARS_AFTER_PLOUGH
#define PT_SP_YEARS_AFTER_PLOUGH
Definition: PTShrubPastures.h:52
LE
Definition: Elements.h:86
Crop::m_last_date
int m_last_date
Definition: Farm.h:503
PTShrubPastures::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: PTShrubPastures.cpp:55
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
PTSHRUBPASTURES_BASE
#define PTSHRUBPASTURES_BASE
Definition: PTShrubPastures.h:45
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
PTShrubPastures::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: PTShrubPastures.h:95
Calendar::DayInYear
int DayInYear(void)
Definition: Calendar.h:58
pt_sp_cattle_is_out3
Definition: PTShrubPastures.h:68
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
WARN_BUG
Definition: MapErrorMsg.h:34
pt_sp_foobar
Definition: PTShrubPastures.h:70
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