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

#include <DE_OWinterWheat.h>

Inheritance diagram for DE_OWinterWheat:
Crop

Public Member Functions

virtual bool Do (Farm *a_farm, LE *a_field, FarmEvent *a_ev)
 
 DE_OWinterWheat (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...
 

Constructor & Destructor Documentation

◆ DE_OWinterWheat()

DE_OWinterWheat::DE_OWinterWheat ( TTypesOfVegetation  a_tov,
TTypesOfCrops  a_toc,
Landscape a_L 
)
inline
63  : Crop(a_tov, a_toc, a_L)
64  {
67  }

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

Member Function Documentation

◆ Do()

bool DE_OWinterWheat::Do ( Farm a_farm,
LE a_field,
FarmEvent a_ev 
)
virtual

Reimplemented from Crop.

34 {
35  /******************** This block can be added to the top of all Crop::Do methods ***********************************************/
36  m_farm = a_farm; // These assignments are necessary, not for this method but for related event calls
37  m_field = a_field;
38  m_ev = a_ev;
39  bool done = false; // The boolean value done indicates when we are totally finished with this plan (i.e. it is set to true).
40  bool flag = false;
41  int d1 = 0;
42  int d2 = 0;
43  int noDates = 1;
44  TTypesOfVegetation l_tov = tov_DEOWinterWheat; // The current type - change to match the crop you have
45 /**********************************************To Here *************************************************************************/
46 
47  // Depending what event has occured jump to the correct bit of code
48  switch (m_ev->m_todo)
49  {
50  case de_oww_start:
51  {
53 
54  m_last_date = g_date->DayInYear(15, 9); // Should match the last flexdate below
55  //Create a 2d array of 1 plus the number of operations you use. Change only 4+1 to what you need in the line below
56  std::vector<std::vector<int>> flexdates(6 + 1, std::vector<int>(2, 0));
57  // Set up the date management stuff
58  // Start and stop dates for all events after harvest
59  flexdates[0][1] = g_date->DayInYear(20, 8); // last possible day of harvest - this is in effect day before the earliest date that a following crop can use
60  // Now these are done in pairs, start & end for each operation. If its not used then -1
61  flexdates[1][0] = -1;
62  flexdates[1][1] = g_date->DayInYear(22, 8); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 1)
63  flexdates[2][0] = g_date->DayInYear(23, 8); // This date will be moved back as far as necessary and potentially to flexdates 1 (start op 2)
64  flexdates[2][1] = g_date->DayInYear(23, 8); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 2)
65  flexdates[3][0] = g_date->DayInYear(25, 8); // This date will be moved back as far as necessary and potentially to flexdates 1 (start op 3)
66  flexdates[3][1] = g_date->DayInYear(30, 8); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 3)
67  flexdates[4][0] = -1;
68  flexdates[4][1] = g_date->DayInYear(1, 9); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 4)
69  flexdates[5][0] = -1;
70  flexdates[5][1] = g_date->DayInYear(5, 9); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 5)
71  flexdates[6][0] = -1;
72  flexdates[6][1] = g_date->DayInYear(15, 9); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 6)
73 
74  // Below if this is a spring crop use 365, otherwise set this to 0, second parameter is fixed, and the third is the start up operation in the first year
75  int isSpring = 0;
76  if (StartUpCrop(isSpring, flexdates, int(de_oww_spring_roll1))) break;
77 
78  // End single block date checking code. Please see next line comment as well.
79  // Reinit d1 to first possible starting date.
80  d1 = g_date->OldDays() + g_date->DayInYear(15, 8) + isSpring;
81  // OK, let's go.
82  if (m_farm->IsStockFarmer()) // StockFarmer
83  {
85  }
86  else SimpleEvent_(d1, de_oww_ferti_p1, false, m_farm, m_field);
87  break;
88  }
89  break;
90 
91  case de_oww_ferti_p1:
92  if (m_ev->m_lock || m_farm->DoIt(10))
93  {
94  if (!m_farm->FP_Manure(m_field, 0.0, g_date->DayInYear(30, 9) - g_date->DayInYear())) {
96  break;
97  }
98  }
100  break;
101 
102  case de_oww_ferti_s1:
103  if (m_ev->m_lock || m_farm->DoIt(65))
104  {
105  if (!m_farm->FA_Manure(m_field, 0.0, g_date->DayInYear(30, 9) - g_date->DayInYear())) {
107  break;
108  }
109  }
111  break;
112 
114  if (m_ev->m_lock || m_farm->DoIt(80))
115  {
116  if (!m_farm->AutumnPlough(m_field, 0.0, g_date->DayInYear(30, 9) - g_date->DayInYear())) {
118  break;
119  }
121  de_oww_autumn_sow, false, m_farm, m_field);
122  break;
123  }
124  else
126  break;
127 
129  if (!m_farm->AutumnHarrow(m_field, 0.0, g_date->DayInYear(30, 9) - g_date->DayInYear())) {
131  break;
132  }
134  de_oww_autumn_sow, false, m_farm, m_field);
135  break;
136 
137  case de_oww_autumn_sow:
138  if (!m_farm->AutumnSow(m_field, 0.0, g_date->DayInYear(10, 10) - g_date->DayInYear())) {
140  break;
141  }
142  {
143  long newdate1 = g_date->OldDays() + g_date->DayInYear(10, 9);
144  long newdate2 = g_date->Date() + 10;
145  if (newdate2 > newdate1)
146  newdate1 = newdate2;
147  SimpleEvent_(newdate1, de_oww_strigling1, false, m_farm, m_field);
148  }
149  break;
150 
151  case de_oww_strigling1:
152  if (m_ev->m_lock || m_farm->DoIt(90))
153  {
154  if (!m_farm->Strigling(m_field, 0.0, g_date->DayInYear(10, 10) - g_date->DayInYear())) {
156  break;
157  }
158  }
159  // Next year
161  break;
162 
163  case de_oww_spring_roll1:
164  if (m_ev->m_lock || m_farm->DoIt(5))
165  {
166  if (!m_farm->SpringRoll(m_field, 0.0, g_date->DayInYear(5, 3) - g_date->DayInYear())) {
168  break;
169  }
170  }
172  break;
173  case de_oww_strigling2:
174  if (!m_farm->Strigling(m_field, 0.0, g_date->DayInYear(20, 3) - g_date->DayInYear())) {
176  break;
177  }
179  break;
180 
181  case de_oww_strigling3:
182  if (m_ev->m_lock || m_farm->DoIt(50))
183  {
184  if (!m_farm->Strigling(m_field, 0.0, g_date->DayInYear(15, 4) - g_date->DayInYear())) {
186  break;
187  }
188  }
189  if (m_farm->IsStockFarmer()) // StockFarmer
190  {
192  break;
193  }
194  else
196  break;
197 
198  case de_oww_ferti_s2:
199  if (m_ev->m_lock || m_farm->DoIt(50))
200  {
201  if (!m_farm->FA_Slurry(m_field, 0.0, g_date->DayInYear(30, 5) - g_date->DayInYear())) {
203  break;
204  }
205  }
207  break;
208 
209  case de_oww_harvest:
210  if (!m_farm->Harvest(m_field, 0.0, m_field->GetMDates(1, 0) - g_date->DayInYear())) { // last date 20/8
212  break;
213  }
215  break;
216 
218  if (m_ev->m_lock || m_farm->DoIt_prob(.60))
219  {
220  if (!m_farm->StrawChopping(m_field, 0.0, m_field->GetMDates(1, 1) - g_date->DayInYear())) // last date 22/8
221  {
223  break;
224  }
226  break;
227  }
228  else if (m_ev->m_lock || m_farm->DoIt_prob(.40 / .40)) {
229  d1 = g_date->Date() + 3;
230  if (d1 < m_field->GetMDates(0, 2)) d1 = m_field->GetMDates(0, 2); // start date 23/8
232  break;
233  }
234 
235  case de_oww_hay_turning:
236  if (m_ev->m_lock || m_farm->DoIt_prob(.20 / .40))
237  {
238  if (!m_farm->HayTurning(m_field, 0.0, m_field->GetMDates(1, 2) - g_date->DayInYear())) { // end date 23/8
240  break;
241  }
242  }
243  d1 = g_date->OldDays() + g_date->DayInYear(7, 8);
244  d2 = g_date->Date() + 3;
245  if (d2 > d1) d1 = d2;
246  if (d1 > m_field->GetMDates(0, 3)) d1 = m_field->GetMDates(0, 3); // start date 25/8
248  break;
249 
250  case de_oww_hay_bailing:
251  if (!m_farm->HayBailing(m_field, 0.0, m_field->GetMDates(1, 3) - g_date->DayInYear())) { // end date 30/8
253  break;
254  }
256  break;
257 
258  case de_oww_deep_plough:
259  if (m_ev->m_lock || m_farm->DoIt_prob(.60))
260  {
261  if (!m_farm->DeepPlough(m_field, 0.0,
262  m_field->GetMDates(1, 4) - g_date->DayInYear())) // end date 1/9
263  {
265  break;
266  }
267  done = true;
268  break;
269  }
270  else if (m_ev->m_lock || m_farm->DoIt_prob(.20 / .40)) {
272  break;
273  }
274  else done = true;
275 
277  if (!m_farm->StubbleHarrowing(m_field, 0.0, m_field->GetMDates(1, 5) - g_date->DayInYear())) { // last date 5/9
279  break;
280  }
281  SimpleEvent_(g_date->Date() + 10, de_oww_stubble_harrow2, false, m_farm, m_field); // main thread
282  break;
283 
285  if (!m_farm->StubbleHarrowing(m_field, 0.0, m_field->GetMDates(1, 6) - g_date->DayInYear())) // end date 15/9
286  {
288  break;
289  }
290  done = true;
291  // END OF MAIN THREAD
292  break;
293 
294  default:
295  g_msg->Warn(WARN_BUG, "DE_OWinterWheat::Do(): "
296  "Unknown event type! ", "");
297  exit(1);
298  }
299  return done;
300 }

References Farm::AutumnHarrow(), Farm::AutumnPlough(), Farm::AutumnSow(), LE::ClearManagementActionSum(), Calendar::Date(), Calendar::DayInYear(), de_oww_autumn_harrow, de_oww_autumn_plough, de_oww_autumn_sow, de_oww_deep_plough, de_oww_ferti_p1, de_oww_ferti_s1, de_oww_ferti_s2, de_oww_harvest, de_oww_hay_bailing, de_oww_hay_turning, de_oww_spring_roll1, de_oww_start, de_oww_straw_chopping, de_oww_strigling1, de_oww_strigling2, de_oww_strigling3, de_oww_stubble_harrow1, de_oww_stubble_harrow2, Farm::DeepPlough(), Farm::DoIt(), Farm::DoIt_prob(), Farm::FA_Manure(), Farm::FA_Slurry(), Farm::FP_Manure(), g_date, g_msg, LE::GetMDates(), Farm::Harvest(), Farm::HayBailing(), Farm::HayTurning(), Farm::IsStockFarmer(), Crop::m_ev, Crop::m_farm, Crop::m_field, Crop::m_last_date, FarmEvent::m_lock, FarmEvent::m_todo, Calendar::OldDays(), Crop::SimpleEvent_(), Farm::SpringRoll(), Crop::StartUpCrop(), Farm::StrawChopping(), Farm::Strigling(), Farm::StubbleHarrowing(), tov_DEOWinterWheat, MapErrorMsg::Warn(), and WARN_BUG.

◆ SetUpFarmCategoryInformation()

void DE_OWinterWheat::SetUpFarmCategoryInformation ( )
inline
68  {
69  const int elements = 2 + (de_oww_foobar - DE_OWINTERWHEAT_BASE);
71 
72  FarmManagementCategory catlist[elements] =
73  {
74  fmc_Others, // zero element unused but must be here
75  fmc_Others, // de_oww_start = 1, // Compulsory, must always be 1 (one).
76  fmc_Others, // de_oww_sleep_all_day = DE_OWINTERWHEAT_BASE,
77  fmc_Fertilizer, // de_oww_ferti_s1,
78  fmc_Fertilizer, // de_oww_ferti_s2,
79  fmc_Fertilizer, // de_oww_ferti_s3,
80  fmc_Fertilizer, // de_oww_ferti_p1,
81  fmc_Fertilizer, // de_oww_ferti_p2,
82  fmc_Cultivation, // de_oww_autumn_plough,
83  fmc_Cultivation, // de_oww_autumn_harrow,
84  fmc_Others, // de_oww_autumn_sow,
85  fmc_Cultivation, // de_oww_strigling1,
86  fmc_Cultivation, // de_oww_strigling2,
87  fmc_Cultivation, // de_oww_strigling3,
88  fmc_Cultivation, // de_oww_spring_roll1,
89  fmc_Harvest, // de_oww_harvest,
90  fmc_Others, // de_oww_hay_turning,
91  fmc_Cutting, // de_oww_straw_chopping,
92  fmc_Others, // de_oww_hay_bailing,
93  fmc_Cultivation, // de_oww_stubble_harrow1,
94  fmc_Cultivation, // de_oww_stubble_harrow2,
95  fmc_Cultivation, // de_oww_deep_plough,
96 
97 
98  // no foobar entry
99 
100  };
101  // Iterate over the catlist elements and copy them to vector
102  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
103 
104  }

References DE_OWINTERWHEAT_BASE, de_oww_foobar, fmc_Cultivation, fmc_Cutting, fmc_Fertilizer, fmc_Harvest, fmc_Others, Crop::m_base_elements_no, and Crop::m_ManagementCategories.

Referenced by DE_OWinterWheat().


The documentation for this class was generated from the following files:
LE::GetMDates
int GetMDates(int a, int b)
Definition: Elements.h:405
de_oww_ferti_s1
Definition: DE_OWinterWheat.h:36
de_oww_strigling3
Definition: DE_OWinterWheat.h:46
de_oww_hay_bailing
Definition: DE_OWinterWheat.h:51
Farm::SpringRoll
virtual bool SpringRoll(LE *a_field, double a_user, int a_days)
Carry out a roll event in the spring on a_field.
Definition: FarmFuncs.cpp:487
tov_DEOWinterWheat
Definition: LandscapeFarmingEnums.h:497
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
Farm::Strigling
virtual bool Strigling(LE *a_field, double a_user, int a_days)
Carry out a mechanical weeding on a_field.
Definition: FarmFuncs.cpp:1206
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
de_oww_strigling1
Definition: DE_OWinterWheat.h:44
de_oww_straw_chopping
Definition: DE_OWinterWheat.h:50
LE::ClearManagementActionSum
void ClearManagementActionSum()
clears the management action counters
Definition: Elements.h:247
Farm::DoIt
bool DoIt(double a_probability)
Return chance out of 0 to 100.
Definition: Farm.cpp:856
de_oww_autumn_harrow
Definition: DE_OWinterWheat.h:42
de_oww_stubble_harrow2
Definition: DE_OWinterWheat.h:53
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
Farm::FA_Manure
virtual bool FA_Manure(LE *a_field, double a_user, int a_days)
Spread manure on a_field owned by an stock farmer.
Definition: FarmFuncs.cpp:1110
Crop::m_base_elements_no
int m_base_elements_no
Definition: Farm.h:505
de_oww_spring_roll1
Definition: DE_OWinterWheat.h:47
Crop::m_first_date
int m_first_date
Definition: Farm.h:501
de_oww_deep_plough
Definition: DE_OWinterWheat.h:54
DE_OWINTERWHEAT_BASE
#define DE_OWINTERWHEAT_BASE
Definition: DE_OWinterWheat.h:31
de_oww_hay_turning
Definition: DE_OWinterWheat.h:49
de_oww_start
Definition: DE_OWinterWheat.h:34
Farm::FP_Manure
virtual bool FP_Manure(LE *a_field, double a_user, int a_days)
Spread manure on a_field owned by an arable farmer.
Definition: FarmFuncs.cpp:896
de_oww_harvest
Definition: DE_OWinterWheat.h:48
fmc_Cutting
Definition: LandscapeFarmingEnums.h:1009
de_oww_ferti_s2
Definition: DE_OWinterWheat.h:37
fmc_Fertilizer
Definition: LandscapeFarmingEnums.h:1004
de_oww_autumn_plough
Definition: DE_OWinterWheat.h:41
Calendar::Date
long Date(void)
Definition: Calendar.h:57
fmc_Cultivation
Definition: LandscapeFarmingEnums.h:1008
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
Farm::StrawChopping
virtual bool StrawChopping(LE *a_field, double a_user, int a_days)
Carry out straw chopping on a_field.
Definition: FarmFuncs.cpp:1475
DE_OWinterWheat::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: DE_OWinterWheat.h:68
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
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
de_oww_stubble_harrow1
Definition: DE_OWinterWheat.h:52
de_oww_ferti_p1
Definition: DE_OWinterWheat.h:39
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
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
TTypesOfVegetation
TTypesOfVegetation
Values that represent the types of vegetation that are represented in ALMaSS.
Definition: LandscapeFarmingEnums.h:192
Farm::DeepPlough
virtual bool DeepPlough(LE *a_field, double a_user, int a_days)
Carry out a deep ploughing event on a_field.
Definition: FarmFuncs.cpp:408
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
Crop::Crop
Crop(TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape *a_L)
Definition: Farm.cpp:733
de_oww_autumn_sow
Definition: DE_OWinterWheat.h:43
de_oww_foobar
Definition: DE_OWinterWheat.h:55
Farm::HayTurning
virtual bool HayTurning(LE *a_field, double a_user, int a_days)
Carry out hay turning on a_field.
Definition: FarmFuncs.cpp:1491
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
WARN_BUG
Definition: MapErrorMsg.h:34
de_oww_strigling2
Definition: DE_OWinterWheat.h:45
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