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
PTSorghum.h
Go to the documentation of this file.
1 
14 //
15 // PTSorghum.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 PTSORGHUM_H
43 #define PTSORGHUM_H
44 
45 #define PTSORGHUM_BASE 30300
46 
49 #define PT_S_START_FERTI a_field->m_user[1]
50 
56 typedef enum {
57  pt_s_start = 1, // Compulsory, must always be 1 (one).
60  pt_s_ferti_p1, // NPK
76 
78 
79 
88 class PTSorghum: public Crop
89 {
90  public:
91  virtual bool Do( Farm *a_farm, LE *a_field, FarmEvent *a_ev );
92  PTSorghum(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( 30,4 );
99  }
101  const int elements = 2 + (pt_s_foobar - PTSORGHUM_BASE);
103 
104  FarmManagementCategory catlist[elements] =
105  {
106  fmc_Others, // zero element unused but must be here
107  fmc_Others, //pt_s_start = 1, // Compulsory, must always be 1 (one).
108  fmc_Others, //pt_s_sleep_all_day = PTSORGHUM_BASE,
109  fmc_Cultivation, //pt_s_stubble_harrow,
110  fmc_Fertilizer, //pt_s_ferti_p1, // NPK
111  fmc_Fertilizer, //pt_s_ferti_s1,
112  fmc_Cultivation, //pt_s_spring_plough,
113  fmc_Cultivation, //pt_s_spring_harrow,
114  fmc_Others, //pt_s_spring_sow,
115  fmc_Watering, //pt_s_irrigation_start1,
116  fmc_Watering, //pt_s_irrigation1,
117  fmc_Harvest, //pt_s_harvest1,
118  fmc_Others, //pt_s_hay_bailing1,
119  fmc_Fertilizer, //pt_s_ferti_p2, //NPK
120  fmc_Fertilizer, //pt_s_ferti_s2,
121  fmc_Watering, //pt_s_irrigation_start2,
122  fmc_Watering, //pt_s_irrigation2,
123  fmc_Harvest, //pt_s_harvest2,
124  fmc_Others, //pt_s_hay_bailing2,
125 
126  // no foobar entry
127 
128  };
129  // Iterate over the catlist elements and copy them to vector
130  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
131 
132  }
133 };
134 
135 #endif // PTSORGHUM_H
136 
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_s_start
Definition: PTSorghum.h:57
Farm::IsStockFarmer
bool IsStockFarmer(void)
Definition: Farm.h:961
PTSorghum::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: PTSorghum.h:100
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
A struct to hold the information required to trigger a farm event.
Definition: Farm.h:372
Farm::Irrigation
virtual bool Irrigation(LE *a_field, double a_user, int a_days, int a_max)
Generate an 'irrigation' event with a frequency defined by a_freq in the irrigation period on a_field...
Definition: FarmFuncs.cpp:1856
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_s_irrigation_start2
Definition: PTSorghum.h:71
g_date
class Calendar * g_date
Definition: Calendar.cpp:37
Farm::SpringSow
virtual bool SpringSow(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 spring on a_field.
Definition: FarmFuncs.cpp:501
pt_s_ferti_s1
Definition: PTSorghum.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
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
PTSorghumToDo
PTSorghumToDo
Definition: PTSorghum.h:56
Crop
The base class for all crops.
Definition: Farm.h:495
pt_s_harvest1
Definition: PTSorghum.h:67
pt_s_hay_bailing2
Definition: PTSorghum.h:74
Crop::SimpleEvent
void SimpleEvent(long a_date, int a_todo, bool a_lock)
Adds an event to this crop management.
Definition: Farm.cpp:747
pt_s_foobar
Definition: PTSorghum.h:75
Farm::IrrigationStart
virtual bool IrrigationStart(LE *a_field, double a_user, int a_days)
Start a irrigation event on a_field today.
Definition: FarmFuncs.cpp:1834
Landscape
The landscape class containing all environmental and topographical data.
Definition: Landscape.h:142
fmc_Fertilizer
Definition: LandscapeFarmingEnums.h:1004
pt_s_spring_harrow
Definition: PTSorghum.h:63
Calendar::Date
long Date(void)
Definition: Calendar.h:57
pt_s_ferti_p1
Definition: PTSorghum.h:60
g_farm_fixed_crop_enable
CfgBool g_farm_fixed_crop_enable
fmc_Cultivation
Definition: LandscapeFarmingEnums.h:1008
CfgBool
Bool configurator entry class.
Definition: Configurator.h:155
pt_s_irrigation1
Definition: PTSorghum.h:66
Farm::HayBailing
virtual bool HayBailing(LE *a_field, double a_user, int a_days)
Carry out hay bailing on a_field.
Definition: FarmFuncs.cpp:1507
fmc_Others
Definition: LandscapeFarmingEnums.h:1003
tov_PTSorghum
Definition: LandscapeFarmingEnums.h:311
fmc_Watering
Definition: LandscapeFarmingEnums.h:1011
Calendar::OldDays
long OldDays(void)
Definition: Calendar.h:60
pt_s_irrigation2
Definition: PTSorghum.h:72
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
PTSorghum
PTSorghum class .
Definition: PTSorghum.h:88
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_s_ferti_s2
Definition: PTSorghum.h:70
TTypesOfCrops
TTypesOfCrops
Definition: LandscapeFarmingEnums.h:781
LE
Definition: Elements.h:86
PTSORGHUM_BASE
#define PTSORGHUM_BASE
Definition: PTSorghum.h:45
Crop::m_last_date
int m_last_date
Definition: Farm.h:503
pt_s_stubble_harrow
Definition: PTSorghum.h:59
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
Farm
The base class for all farm types.
Definition: Farm.h:755
pt_s_sleep_all_day
Definition: PTSorghum.h:58
fmc_Harvest
Definition: LandscapeFarmingEnums.h:1012
pt_s_ferti_p2
Definition: PTSorghum.h:69
pt_s_spring_sow
Definition: PTSorghum.h:64
pt_s_hay_bailing1
Definition: PTSorghum.h:68
PTSorghum::PTSorghum
PTSorghum(TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape *a_L)
Definition: PTSorghum.h:92
pt_s_irrigation_start1
Definition: PTSorghum.h:65
Calendar::DayInYear
int DayInYear(void)
Definition: Calendar.h:58
pt_s_harvest2
Definition: PTSorghum.h:73
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
pt_s_spring_plough
Definition: PTSorghum.h:62
WARN_BUG
Definition: MapErrorMsg.h:34
PTSorghum::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: PTSorghum.cpp:55
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
Farm::SpringHarrow
virtual bool SpringHarrow(LE *a_field, double a_user, int a_days)
Carry out a harrow event in the spring on a_field.
Definition: FarmFuncs.cpp:459
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