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

DE_OWinterBarley class
. More...

#include <DE_OWinterBarley.h>

Inheritance diagram for DE_OWinterBarley:
Crop

Public Member Functions

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

Detailed Description

DE_OWinterBarley class
.

See DE_OWinterBarley.h::DE_OWinterBarleyToDo for a complete list of all possible events triggered codes by the winter rye management plan. When triggered these events are handled by Farm and are available as information for other objects such as animal and bird models.

Constructor & Destructor Documentation

◆ DE_OWinterBarley()

DE_OWinterBarley::DE_OWinterBarley ( TTypesOfVegetation  a_tov,
TTypesOfCrops  a_toc,
Landscape a_L 
)
inline
103  : Crop(a_tov, a_toc, a_L)
104  {
105  // When we start it off, the first possible date for a farm operation is 1st October
106  // This information is used by other crops when they decide how much post processing of
107  // the management is allowed after harvest before the next crop starts.
108  m_first_date=g_date->DayInYear( 30,9 );
110  }

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

Member Function Documentation

◆ Do()

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

Reimplemented from Crop.

80 {
81  /******************** This block can be added to the top of all Crop::Do methods ***********************************************/
82  m_farm = a_farm; // These assignments are necessary, not for this method but for related event calls
83  m_field = a_field;
84  m_ev = a_ev;
85  bool done = false; // The boolean value done indicates when we are totally finished with this plan (i.e. it is set to true).
86  bool flag = false;
87  int d1 = 0;
88  int d2 = 0;
89  int noDates = 1;
90  TTypesOfVegetation l_tov = tov_DEOWinterBarley; // The current type - change to match the crop you have
91 /**********************************************To Here *************************************************************************/
92 
93  // Depending what event has occured jump to the correct bit of code
94  switch (m_ev->m_todo)
95  {
96  case de_owb_start:
97  {
99 
100  m_last_date = g_date->DayInYear(25, 8); // Should match the last flexdate below
101  //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
102  std::vector<std::vector<int>> flexdates(6 + 1, std::vector<int>(2, 0));
103  // Set up the date management stuff
104  // Start and stop dates for all events after harvest
105  flexdates[0][1] = g_date->DayInYear(31, 7); // last possible day of harvest - this is in effect day before the earliest date that a following crop can use
106  // Now these are done in pairs, start & end for each operation. If its not used then -1
107  flexdates[1][0] = -1;
108  flexdates[1][1] = g_date->DayInYear(2, 8); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 1)
109  flexdates[2][0] = g_date->DayInYear(3, 8); // This date will be moved back as far as necessary and potentially to flexdates 1 (start op 2)
110  flexdates[2][1] = g_date->DayInYear(3, 8); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 2)
111  flexdates[3][0] = g_date->DayInYear(5, 8); // This date will be moved back as far as necessary and potentially to flexdates 1 (start op 3)
112  flexdates[3][1] = g_date->DayInYear(10, 8); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 3)
113  flexdates[4][0] = -1;
114  flexdates[4][1] = g_date->DayInYear(11, 8); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 4)
115  flexdates[5][0] = -1;
116  flexdates[5][1] = g_date->DayInYear(15, 8); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 5)
117  flexdates[6][0] = -1;
118  flexdates[6][1] = g_date->DayInYear(25, 8); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 6)
119 
120  // 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
121  int isSpring = 0;
122  if (StartUpCrop(isSpring, flexdates, int(de_owb_spring_roll1))) break;
123 
124  // End single block date checking code. Please see next line comment as well.
125  // Reinit d1 to first possible starting date.
126  d1 = g_date->OldDays() + g_date->DayInYear(15, 8) + isSpring;
127  // OK, let's go.
128  if (m_farm->IsStockFarmer()) // StockFarmer
129  {
131  }
132  else SimpleEvent_(d1, de_owb_ferti_p1, false, m_farm, m_field);
133  break;
134  }
135  break;
136 
137  case de_owb_ferti_p1:
138  if (m_ev->m_lock || m_farm->DoIt(10))
139  {
140  if (!m_farm->FP_Manure(m_field, 0.0, g_date->DayInYear(30, 9) - g_date->DayInYear())) {
142  break;
143  }
144  }
146  break;
147 
148  case de_owb_ferti_s1:
149  if (m_ev->m_lock || m_farm->DoIt(40))
150  {
151  if (!m_farm->FA_Manure(m_field, 0.0, g_date->DayInYear(30, 9) - g_date->DayInYear())) {
153  break;
154  }
155  }
157  break;
158 
160  if (m_ev->m_lock || m_farm->DoIt(80)) {
161  if (!m_farm->AutumnPlough(m_field, 0.0, g_date->DayInYear(30, 9) - g_date->DayInYear())) {
163  break;
164  }
166  break;
167  }
168  else
170  break;
171 
173  if (!m_farm->StubbleHarrowing(m_field, 0.0, g_date->DayInYear(30, 9) - g_date->DayInYear())) {
175  break;
176  }
178  break;
179 
180  case de_owb_autumn_sow:
181  if (!m_farm->AutumnSow(m_field, 0.0, g_date->DayInYear(10, 10) - g_date->DayInYear())) {
183  break;
184  }
185  {
186  long newdate1 = g_date->OldDays() + g_date->DayInYear(10, 9);
187  long newdate2 = g_date->Date() + 15;
188  if (newdate2 > newdate1)
189  newdate1 = newdate2;
190  SimpleEvent_(newdate1, de_owb_strigling1, false, m_farm, m_field);
191  }
192  break;
193 
194  case de_owb_strigling1:
195  if (m_ev->m_lock || m_farm->DoIt(90)) {
196  if (!m_farm->Strigling(m_field, 0.0, g_date->DayInYear(15, 10) - g_date->DayInYear())) {
198  break;
199  }
200  }
201  // Next year
203  break;
204 
205  case de_owb_spring_roll1:
206  if (m_ev->m_lock || m_farm->DoIt(5))
207  {
208  if (!m_farm->SpringRoll(m_field, 0.0, g_date->DayInYear(5, 3) - g_date->DayInYear())) {
210  break;
211  }
212  }
214  break;
215  case de_owb_strigling2:
216  if (!m_farm->Strigling(m_field, 0.0, g_date->DayInYear(20, 3) - g_date->DayInYear())) {
218  break;
219  }
221  break;
222 
223  case de_owb_strigling3:
224  if (m_ev->m_lock || m_farm->DoIt(30))
225  {
226  if (!m_farm->Strigling(m_field, 0.0, g_date->DayInYear(15, 4) - g_date->DayInYear())) {
228  break;
229  }
230  }
231  if (m_farm->IsStockFarmer()) // StockFarmer
232  {
234  }
236  break;
237 
238  case de_owb_ferti_s2:
239  if (m_ev->m_lock || m_farm->DoIt(30))
240  {
241  if (!m_farm->FA_Slurry(m_field, 0.0, g_date->DayInYear(31, 5) - g_date->DayInYear())) {
243  break;
244  }
245  }
247  break;
248 
249  case de_owb_harvest:
250  if (!m_farm->Harvest(m_field, 0.0, m_field->GetMDates(1, 0) - g_date->DayInYear())) { // last date 20/8
252  break;
253  }
255  break;
256 
258  if (m_ev->m_lock || m_farm->DoIt_prob(.60))
259  {
260  if (!m_farm->StrawChopping(m_field, 0.0, m_field->GetMDates(1, 1) - g_date->DayInYear())) // last date 22/8
261  {
263  break;
264  }
266  break;
267  }
268  else if (m_ev->m_lock || m_farm->DoIt_prob(.40 / .40)) {
269  d1 = g_date->Date() + 3;
270  if (d1 < m_field->GetMDates(0, 2)) d1 = m_field->GetMDates(0, 2); // start date 23/8
272  break;
273  }
274 
275  case de_owb_hay_turning:
276  if (m_ev->m_lock || m_farm->DoIt_prob(.20 / .40))
277  {
278  if (!m_farm->HayTurning(m_field, 0.0, m_field->GetMDates(1, 2) - g_date->DayInYear())) { // end date 23/8
280  break;
281  }
282  }
283  d1 = g_date->OldDays() + g_date->DayInYear(7, 8);
284  d2 = g_date->Date() + 3;
285  if (d2 > d1) d1 = d2;
286  if (d1 > m_field->GetMDates(0, 3)) d1 = m_field->GetMDates(0, 3); // start date 25/8
288  break;
289 
290  case de_owb_hay_bailing:
291  if (!m_farm->HayBailing(m_field, 0.0, m_field->GetMDates(1, 3) - g_date->DayInYear())) { // end date 30/8
293  break;
294  }
296  break;
297 
298  case de_owb_deep_plough:
299  if (m_ev->m_lock || m_farm->DoIt_prob(.60))
300  {
301  if (!m_farm->DeepPlough(m_field, 0.0,
302  m_field->GetMDates(1, 4) - g_date->DayInYear())) // end date 1/9
303  {
305  break;
306  }
307  done = true;
308  break;
309  }
310  else if (m_ev->m_lock || m_farm->DoIt_prob(.20 / .40)) {
312  break;
313  }
314  else done = true;
315 
317  if (!m_farm->StubbleHarrowing(m_field, 0.0, m_field->GetMDates(1, 5) - g_date->DayInYear())) { // last date 5/9
319  break;
320  }
321  SimpleEvent_(g_date->Date() + 10, de_owb_stubble_harrow2, false, m_farm, m_field); // main thread
322  break;
323 
325  if (!m_farm->StubbleHarrowing(m_field, 0.0, m_field->GetMDates(1, 6) - g_date->DayInYear())) // end date 15/9
326  {
328  break;
329  }
330  done = true;
331  // END OF MAIN THREAD
332  break;
333 
334  default:
335  g_msg->Warn(WARN_BUG, "DE_OWinterBarley::Do(): "
336  "Unknown event type! ", "");
337  exit(1);
338  }
339  return done;
340 }

References Farm::AutumnPlough(), Farm::AutumnSow(), LE::ClearManagementActionSum(), Calendar::Date(), Calendar::DayInYear(), de_owb_autumn_harrow, de_owb_autumn_plough, de_owb_autumn_sow, de_owb_deep_plough, de_owb_ferti_p1, de_owb_ferti_s1, de_owb_ferti_s2, de_owb_harvest, de_owb_hay_bailing, de_owb_hay_turning, de_owb_spring_roll1, de_owb_start, de_owb_straw_chopping, de_owb_strigling1, de_owb_strigling2, de_owb_strigling3, de_owb_stubble_harrow1, de_owb_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_DEOWinterBarley, MapErrorMsg::Warn(), and WARN_BUG.

◆ SetUpFarmCategoryInformation()

void DE_OWinterBarley::SetUpFarmCategoryInformation ( )
inline
111  {
112  const int elements = 2 + (de_owb_foobar - DE_OWINTERBARLEY_BASE);
114 
115  FarmManagementCategory catlist[elements] =
116  {
117  fmc_Others, // zero element unused but must be here
118  fmc_Others, // de_owb_start = 1, // Compulsory, must always be 1 (one).
119  fmc_Others, // de_owb_sleep_all_day = DE_OWINTERBARLEY_BASE,
120  fmc_Fertilizer, // de_owb_ferti_s1,
121  fmc_Fertilizer, // de_owb_ferti_s2,
122  fmc_Fertilizer, // de_owb_ferti_s3,
123  fmc_Fertilizer, // de_owb_ferti_p1,
124  fmc_Fertilizer, // de_owb_ferti_p2,
125  fmc_Cultivation, // de_owb_autumn_plough,
126  fmc_Cultivation, // de_owb_autumn_harrow,
127  fmc_Others, // de_owb_autumn_sow,
128  fmc_Cultivation, // de_owb_strigling1,
129  fmc_Cultivation, // de_owb_strigling2,
130  fmc_Cultivation, // de_owb_strigling3,
131  fmc_Cultivation, // de_owb_spring_roll1,
132  fmc_Harvest, // de_owb_harvest,
133  fmc_Others, // de_owb_hay_turning,
134  fmc_Cutting, // de_owb_straw_chopping,
135  fmc_Others, // de_owb_hay_bailing,
136  fmc_Cultivation, // de_owb_stubble_harrow1,
137  fmc_Cultivation, // de_owb_stubble_harrow2,
138  fmc_Cultivation, // de_owb_deep_plough,
139  fmc_Others, // de_owb_catch_all,
140 
141 
142  // no foobar entry
143 
144  };
145  // Iterate over the catlist elements and copy them to vector
146  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
147 
148  }

References de_owb_foobar, DE_OWINTERBARLEY_BASE, fmc_Cultivation, fmc_Cutting, fmc_Fertilizer, fmc_Harvest, fmc_Others, Crop::m_base_elements_no, and Crop::m_ManagementCategories.

Referenced by DE_OWinterBarley().


The documentation for this class was generated from the following files:
LE::GetMDates
int GetMDates(int a, int b)
Definition: Elements.h:405
de_owb_straw_chopping
Definition: DE_OWinterBarley.h:81
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
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
DE_OWINTERBARLEY_BASE
#define DE_OWINTERBARLEY_BASE
Definition: DE_OWinterBarley.h:53
de_owb_ferti_s2
Definition: DE_OWinterBarley.h:68
Farm::IsStockFarmer
bool IsStockFarmer(void)
Definition: Farm.h:961
de_owb_strigling3
Definition: DE_OWinterBarley.h:77
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
de_owb_ferti_p1
Definition: DE_OWinterBarley.h:70
FarmEvent::m_lock
bool m_lock
Definition: Farm.h:384
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
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
de_owb_stubble_harrow2
Definition: DE_OWinterBarley.h:84
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
de_owb_hay_bailing
Definition: DE_OWinterBarley.h:82
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_owb_autumn_plough
Definition: DE_OWinterBarley.h:72
fmc_Cutting
Definition: LandscapeFarmingEnums.h:1009
fmc_Fertilizer
Definition: LandscapeFarmingEnums.h:1004
de_owb_hay_turning
Definition: DE_OWinterBarley.h:80
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
de_owb_strigling1
Definition: DE_OWinterBarley.h:75
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
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
de_owb_ferti_s1
Definition: DE_OWinterBarley.h:67
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
de_owb_harvest
Definition: DE_OWinterBarley.h:79
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
de_owb_deep_plough
Definition: DE_OWinterBarley.h:85
FarmEvent::m_todo
int m_todo
Definition: Farm.h:388
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
tov_DEOWinterBarley
Definition: LandscapeFarmingEnums.h:494
TTypesOfVegetation
TTypesOfVegetation
Values that represent the types of vegetation that are represented in ALMaSS.
Definition: LandscapeFarmingEnums.h:192
de_owb_autumn_sow
Definition: DE_OWinterBarley.h:74
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
de_owb_spring_roll1
Definition: DE_OWinterBarley.h:78
fmc_Harvest
Definition: LandscapeFarmingEnums.h:1012
de_owb_autumn_harrow
Definition: DE_OWinterBarley.h:73
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_owb_start
Definition: DE_OWinterBarley.h:65
de_owb_stubble_harrow1
Definition: DE_OWinterBarley.h:83
de_owb_strigling2
Definition: DE_OWinterBarley.h:76
DE_OWinterBarley::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: DE_OWinterBarley.h:111
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
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
de_owb_foobar
Definition: DE_OWinterBarley.h:87
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