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

PLSpringBarleySpr class
. More...

#include <PLSpringBarleySpr.h>

Inheritance diagram for PLSpringBarleySpr:
Crop

Public Member Functions

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. More...
 
 PLSpringBarleySpr (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

PLSpringBarleySpr class
.

See PLSpringBarleySpr.h::PLSpringBarleySprToDo for a complete list of all possible events triggered codes by the spring barley 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

◆ PLSpringBarleySpr()

PLSpringBarleySpr::PLSpringBarleySpr ( TTypesOfVegetation  a_tov,
TTypesOfCrops  a_toc,
Landscape a_L 
)
inline
82  : Crop(a_tov, a_toc, a_L)
83  {
86  }

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

Member Function Documentation

◆ Do()

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

The one and only method for a crop management plan. All farm actions go through here.

Called every time something is done to the crop by the farmer in the first instance it is always called with m_ev->todo set to start, but susequently will be called whenever the farmer wants to carry out a new operation.
This method details all the management and relationships between operations necessary to grow and ALMaSS crop - in this case conventional spring barley spring.

Reimplemented from Crop.

66 {
67  /******************** This block can be added to the top of all Crop::Do methods ***********************************************/
68  m_farm = a_farm; // These assignments are necessary, not for this method but for related event calls
69  m_field = a_field;
70  m_ev = a_ev;
71  bool done = false; // The boolean value done indicates when we are totally finished with this plan (i.e. it is set to true).
72  bool flag = false;
73  int d1 = 0;
74  int noDates = 1;
75  TTypesOfVegetation l_tov = tov_PLSpringBarleySpr; // The current type - change to match the crop you have
76 /**********************************************To Here *************************************************************************/
77 
78  // Depending what event has occured jump to the correct bit of code
79  switch (m_ev->m_todo)
80  {
81  case pl_sbs_start:
82  {
83  // pl_sbs_start just sets up all the starting conditions and reference dates that are needed to start a pl_sb
85  PL_SBS_DECIDE_TO_GR = false;
86 
87  a_field->ClearManagementActionSum();
88 
89  // Set up the date management stuff
90  // The next bit of code just allows for altering dates after harvest if it is necessary
91  // to allow for a crop which starts its management early.
92 
93  // 5 start and stop dates for all 'movable' events for this crop
94  int noDates = 4;
95  m_field->SetMDates(0, 0, g_date->DayInYear(15, 8)); // last possible day of harvest
96  m_field->SetMDates(1, 0, g_date->DayInYear(20, 8)); // last possible day of starw chopping, equal to harvest in this case
97  m_field->SetMDates(0, 1, 0); // start day of hay bailing (not used as it depend on previous treatment)
98  m_field->SetMDates(1, 1, g_date->DayInYear(25, 8)); // end day of hay bailing
99  m_field->SetMDates(0, 2, 0); // start day of RSM
100  m_field->SetMDates(1, 2, g_date->DayInYear(25, 8)); // end day of RSM
101  m_field->SetMDates(0, 3, 0); // start day of calcium application
102  m_field->SetMDates(1, 3, g_date->DayInYear(25, 8)); // end day of calcium application
103  // Can be up to 10 of these. If the shortening code is triggered
104  // then these will be reduced in value to 0
105 
106  m_field->SetMConstants(0, 1);
107 
108  // Check the next crop for early start, unless it is a spring crop
109  // in which case we ASSUME that no checking is necessary!!!!
110  // So DO NOT implement a crop that runs over the year boundary (i.e. from spring to spring!), at least not without fixing this.
111 
112  //new if: do the check only for non-optimising farms and if year>0. (030713 - m_rotation used only in the hidden year, so I modified the condition from >7 to >0)
113  //optimising farms not used for now so most of related code is removed (but not in 'start' case)
114  if (!(m_farm->GetType() == tof_OptimisingFarm && g_date->GetYearNumber() > 0)) {
115 
116  if (m_ev->m_startday > g_date->DayInYear(1, 7)) {
117  if (m_field->GetMDates(0, 0) >= m_ev->m_startday)
118  {
119  g_msg->Warn(WARN_BUG, "PLSpringBarleySpr::Do(): ", "Harvest too late for the next crop to start!!!");
120  int almassnum = m_field->GetLandscape()->BackTranslateVegTypes(m_ev->m_next_tov);
121  g_msg->Warn("Next Crop ", (double)almassnum); // this causes exit
122  }
123  // Now fix any late finishing problems
124  for (int i = 0; i < noDates; i++) {
125  if (m_field->GetMDates(0, i) >= m_ev->m_startday) {
126  m_field->SetMDates(0, i, m_ev->m_startday - 1); //move the starting date
127  }
128  if (m_field->GetMDates(1, i) >= m_ev->m_startday) {
129  m_field->SetMConstants(i, 0); //change the default value of the MConst (=1) to 0 (necessary to correctly execute farm events in case the finishing date (MDate) was moved)
130  m_field->SetMDates(1, i, m_ev->m_startday - 1); //move the finishing date
131  }
132  }
133  }
134  // Now no operations can be timed after the start of the next crop.
135 
136  if (!m_ev->m_first_year) {
137  int today = g_date->Date();
138  d1 = g_date->OldDays() + m_first_date + 365; // Add 365 for spring crop
139  if (today > d1) {
140  // Yes too late - should not happen - raise an error
141  g_msg->Warn(WARN_BUG, "PLSpringBarleySpr::Do(): " "Crop start attempt after last possible start date", "");
142  exit(1);
143  }
144  }
145  else {
147  break;
148  }
149  }//if
150 
151  // End single block date checking code. Please see next line
152  // comment as well.
153  // Reinit d1 to first possible starting date.
154  d1 = g_date->OldDays() + 365 + g_date->DayInYear(1, 3);
155  // OK, let's go.
157  break;
158  }
159  break;
160 
161  // This is the first real farm operation
163  if (!m_farm->SpringPlough(m_field, 0.0, g_date->DayInYear(25, 3) - g_date->DayInYear())) {
165  break;
166  }
168  break;
170  if (!m_farm->SpringHarrow(m_field, 0.0, g_date->DayInYear(25, 3) - g_date->DayInYear())) {
172  break;
173  }
174  d1 = g_date->Date() + 1;
175  if (d1 < g_date->OldDays() + g_date->DayInYear(10, 3)) {
176  d1 = g_date->OldDays() + g_date->DayInYear(10, 3);
177  }
178  if (m_farm->IsStockFarmer()) //Stock Farmer
179  {
181  }
182  else SimpleEvent_(d1, pl_sbs_ferti_p1, false, m_farm, m_field);
183  break;
184  case pl_sbs_ferti_p1:
185  if (m_ev->m_lock || m_farm->DoIt(88))
186  {
187  if (!m_farm->FP_NPK(m_field, 0.0, g_date->DayInYear(30, 3) - g_date->DayInYear())) {
189  break;
190  }
191  PL_SBS_SPRING_FERTI = true;
192  }
194  break;
195  case pl_sbs_ferti_s1:
196  if (m_ev->m_lock || m_farm->DoIt(88))
197  {
198  if (!m_farm->FA_NPK(m_field, 0.0, g_date->DayInYear(30, 3) - g_date->DayInYear())) {
200  break;
201  }
203  }
205  break;
207  if (PL_SBS_SPRING_FERTI == 1)
208  {
211  break;
212  }
213  }
214  d1 = g_date->Date() + 1;
215  if (d1 < g_date->OldDays() + g_date->DayInYear(20, 3)) {
216  d1 = g_date->OldDays() + g_date->DayInYear(20, 3);
217  }
219  break;
221  // 20% will do preseeding cultivation, the rest will do it together with sow
222  if (m_ev->m_lock || m_farm->DoIt(20))
223  {
226  break;
227  }
229  break;
230  }
232  break;
233  case pl_sbs_spring_sow:
234  if (cfg_seedcoating_springbarley_on.value() && a_field->GetLandscape()->SupplyShouldSpray()) {
235  if (!m_farm->SpringSow(m_field, 0.0, g_date->DayInYear(10, 4) - g_date->DayInYear(),
238  break;
239  }
240  }
241  else {
242  if (!m_farm->SpringSow(m_field, 0.0, g_date->DayInYear(10, 4) - g_date->DayInYear())) {
244  break;
245  }
246  }
247  // Here is a fork leading to four parallel events
248  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(10, 4), pl_sbs_herbicide1, false, m_farm, m_field); // Herbidide thread
249  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 5), pl_sbs_fungicide1, false, m_farm, m_field); // Fungicide thread
250  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(15, 5) + m_date_modifier, pl_sbs_insecticide1, false, m_farm, m_field); // Insecticide thread = MAIN THREAD
251  if (m_farm->IsStockFarmer()) //Stock Farmer // N thread
252  {
254  }
256  if (m_farm->IsStockFarmer()) //Stock Farmer // Microelemnts thread
257  {
259  }
261  break;
263  // 80% will do preseeding cultivation with sow
266  break;
267  }
268  // Here is a fork leading to four parallel events
269  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(10, 4), pl_sbs_herbicide1, false, m_farm, m_field); // Herbidide thread
270  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(1, 5), pl_sbs_fungicide1, false, m_farm, m_field); // Fungicide thread
271  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(15, 5) + m_date_modifier, pl_sbs_insecticide1, false, m_farm, m_field); // Insecticide thread = MAIN THREAD
272  if (m_farm->IsStockFarmer()) //Stock Farmer // N thread
273  {
275  }
277  if (m_farm->IsStockFarmer()) //Stock Farmer // Microelemnts thread
278  {
280  }
282  break;
283  case pl_sbs_ferti_p2:
284  // Here comes N thread
285  if (!m_farm->FP_AmmoniumSulphate(m_field, 0.0, g_date->DayInYear(30, 5) - g_date->DayInYear())) {
287  break;
288  }
289  // End of thread
290  break;
291  case pl_sbs_ferti_s2:
292  if (!m_farm->FA_AmmoniumSulphate(m_field, 0.0, g_date->DayInYear(30, 5) - g_date->DayInYear())) {
294  break;
295  }
296  // End of thread
297  break;
298  case pl_sbs_ferti_p3:
299  // Here comes the mickroelements thread
300  if (m_ev->m_lock || m_farm->DoIt(43))
301  {
302  if (!m_farm->FP_ManganeseSulphate(m_field, 0.0, g_date->DayInYear(30, 5) - g_date->DayInYear())) {
304  break;
305  }
306  }
307  d1 = g_date->Date() + 14;
308  if (d1 < g_date->OldDays() + g_date->DayInYear(25, 5)) {
309  d1 = g_date->OldDays() + g_date->DayInYear(25, 5);
310  }
312  break;
313  case pl_sbs_ferti_s3:
314  if (m_ev->m_lock || m_farm->DoIt(43))
315  {
316  if (!m_farm->FA_ManganeseSulphate(m_field, 0.0, g_date->DayInYear(30, 5) - g_date->DayInYear())) {
318  break;
319  }
320  }
321  d1 = g_date->Date() + 14;
322  if (d1 < g_date->OldDays() + g_date->DayInYear(25, 5)) {
323  d1 = g_date->OldDays() + g_date->DayInYear(25, 5);
324  }
326  break;
327  case pl_sbs_ferti_p4:
328  if (m_ev->m_lock || m_farm->DoIt(3))
329  {
330  if (!m_farm->FP_ManganeseSulphate(m_field, 0.0, g_date->DayInYear(10, 6) - g_date->DayInYear())) {
332  break;
333  }
334  }
335  // End of thread
336  break;
337  case pl_sbs_ferti_s4:
338  if (m_ev->m_lock || m_farm->DoIt(3))
339  {
340  if (!m_farm->FA_ManganeseSulphate(m_field, 0.0, g_date->DayInYear(10, 6) - g_date->DayInYear())) {
342  break;
343  }
344  }
345  // End of thread
346  break;
347  case pl_sbs_herbicide1: // The first of the pesticide managements.
348  // Here comes the herbicide thread
349  if (m_ev->m_lock || m_farm->DoIt(97))
350  {
351  if (m_field->GetGreenBiomass() <= 0) {
353  }
354  else
355  {
356  if (!m_farm->HerbicideTreat(m_field, 0.0, g_date->DayInYear(10, 5) - g_date->DayInYear())) {
358  break;
359  }
360  }
361  }
362  // End of thread
363  break;
364  case pl_sbs_fungicide1:
365  // Here comes the fungicide thread
366  if (m_ev->m_lock || m_farm->DoIt(83))
367  {
368  if (!m_farm->FungicideTreat(m_field, 0.0, g_date->DayInYear(15, 6) - g_date->DayInYear())) {
370  break;
371  }
372  }
374  break;
375  case pl_sbs_fungicide2:
376  if (m_ev->m_lock || m_farm->DoIt(23))
377  {
378  if (!m_farm->FungicideTreat(m_field, 0.0, g_date->DayInYear(15, 6) - g_date->DayInYear())) {
380  break;
381  }
382  }
383  d1 = g_date->Date() + 14;
384  if (d1 < g_date->OldDays() + g_date->DayInYear(20, 5)) {
385  d1 = g_date->OldDays() + g_date->DayInYear(20, 5);
386  }
388  break;
389  case pl_sbs_fungicide3:
390  if (m_ev->m_lock || m_farm->DoIt(4))
391  {
392  if (!m_farm->FungicideTreat(m_field, 0.0, g_date->DayInYear(20, 6) - g_date->DayInYear())) {
394  break;
395  }
396  }
397  // End of thread
398  break;
399  case pl_sbs_insecticide1:
400  // Here comes the insecticide thread = MAIN THREAD
401  if (m_ev->m_lock || m_farm->DoIt(65))
402  {
403  // here we check whether we are using ERA pesticide or not
404  d1 = g_date->DayInYear(15, 6) - g_date->DayInYear();
405  if (!cfg_pest_springbarley_on.value() || !m_field->GetLandscape()->SupplyShouldSpray()) // Not using pesticide spray
406  {
407  flag = m_farm->InsecticideTreat(m_field, 0.0, d1);
408  }
409  else {
411  }
412  if (!flag) {
414  break;
415  }
416  }
418  break;
419  case pl_sbs_insecticide2:
420  if (m_ev->m_lock || m_farm->DoIt(46))
421  {
422  // here we check whether we are using ERA pesticide or not
423  d1 = g_date->DayInYear(30, 6) - g_date->DayInYear();
424  if (!cfg_pest_springbarley_on.value() || !m_field->GetLandscape()->SupplyShouldSpray()) // Not using pesticide spray
425  {
426  flag = m_farm->InsecticideTreat(m_field, 0.0, d1);
427  }
428  else {
430  }
431  if (!flag) {
433  break;
434  }
435  }
437  break;
438  case pl_sbs_harvest:
439  // Here the MAIN thread continues
440  // We don't move harvest days
441  if (!m_farm->Harvest(m_field, 0.0, m_field->GetMDates(0, 0) - g_date->DayInYear())) {
443  break;
444  }
446  break;
448  if (m_farm->IsStockFarmer()) //Stock Farmer
449  {
450  // 10% of stock farmers will do straw chopping, but rest will do hay bailing instead
451  if (m_ev->m_lock || m_farm->DoIt(10))
452  {
453  if (m_field->GetMConstants(0) == 0) {
454  if (!m_farm->StrawChopping(m_field, 0.0, -1)) { // raise an error
455  g_msg->Warn(WARN_BUG, "PLSpringBarleySpr::Do(): failure in 'StrawChopping' execution", "");
456  exit(1);
457  }
458  }
459  else {
460  if (!m_farm->StrawChopping(m_field, 0.0, m_field->GetMDates(1, 0) - g_date->DayInYear())) {
462  break;
463  }
464  else
465  {
466  // Queue up the next event
468  break;
469  }
470  }
471 
472  }
474  break;
475  }
476  else
477  {
478  // 90% of arable farmers will do straw chopping, but rest will do hay bailing instead
479  if (m_ev->m_lock || m_farm->DoIt(90))
480  {
481  if (m_field->GetMConstants(0) == 0) {
482  if (!m_farm->StrawChopping(m_field, 0.0, -1)) { // raise an error
483  g_msg->Warn(WARN_BUG, "PLSpringBarleySpr::Do(): failure in 'StrawChopping' execution", "");
484  exit(1);
485  }
486  }
487  else {
488  if (!m_farm->StrawChopping(m_field, 0.0, m_field->GetMDates(1, 0) - g_date->DayInYear())) {
490  break;
491  }
492  else
493  {
494  // Queue up the next event
496  break;
497  }
498  }
499 
500  }
502  break;
503  }
504  case pl_sbs_hay_bailing:
505  if (m_field->GetMConstants(1) == 0) {
506  if (!m_farm->HayBailing(m_field, 0.0, -1)) { // raise an error
507  g_msg->Warn(WARN_BUG, "PLSpringBarleySpr::Do(): failure in 'HayBailing' execution", "");
508  exit(1);
509  }
510  }
511  else {
512  if (!m_farm->HayBailing(m_field, 0.0, m_field->GetMDates(1, 1) - g_date->DayInYear())) {
514  break;
515  }
516  }
517  if (m_farm->IsStockFarmer()) //Stock Farmer
518  {
520  }
522  break;
523  case pl_sbs_ferti_p5:
524  if (m_ev->m_lock || m_farm->DoIt(18))
525  {
526  if (m_field->GetMConstants(2) == 0) {
527  if (!m_farm->FP_RSM(m_field, 0.0, -1)) { // raise an error
528  g_msg->Warn(WARN_BUG, "PLSpringBarleySpr::Do(): failure in 'FP_RSM' execution", "");
529  exit(1);
530  }
531  }
532  else {
533  if (!m_farm->FP_RSM(m_field, 0.0, m_field->GetMDates(1, 2) - g_date->DayInYear())) {
535  break;
536  }
537  }
538  }
539  if (m_farm->IsStockFarmer()) //Stock Farmer
540  {
542  }
544  break;
545  case pl_sbs_ferti_s5:
546  if (m_ev->m_lock || m_farm->DoIt(18))
547  {
548  if (m_field->GetMConstants(2) == 0) {
549  if (!m_farm->FA_RSM(m_field, 0.0, -1)) { // raise an error
550  g_msg->Warn(WARN_BUG, "PLSpringBarleySpr::Do(): failure in 'FA_RSM' execution", "");
551  exit(1);
552  }
553  }
554  else {
555  if (!m_farm->FA_RSM(m_field, 0.0, m_field->GetMDates(1, 2) - g_date->DayInYear())) {
557  break;
558  }
559  }
560  }
561  if (m_farm->IsStockFarmer()) //Stock Farmer
562  {
564  }
566  break;
567  case pl_sbs_ferti_p6:
568  if (m_ev->m_lock || m_farm->DoIt(23))
569  {
570  if (m_field->GetMConstants(3) == 0) {
571  if (!m_farm->FP_Calcium(m_field, 0.0, -1)) { // raise an error
572  g_msg->Warn(WARN_BUG, "PLSpringBarleySpr::Do(): failure in 'FP_Calcium' execution", "");
573  exit(1);
574  }
575  }
576  else {
577  if (!m_farm->FP_Calcium(m_field, 0.0, m_field->GetMDates(1, 3) - g_date->DayInYear())) {
579  break;
580  }
581  }
582  }
583  done = true;
584  // So we are done, and somwhere else the farmer will queue up the start event of the next crop
585  // END of MAIN THREAD
586  break;
587  case pl_sbs_ferti_s6:
588  if (m_ev->m_lock || m_farm->DoIt(23))
589  {
590  if (m_field->GetMConstants(3) == 0) {
591  if (!m_farm->FA_Calcium(m_field, 0.0, -1)) { // raise an error
592  g_msg->Warn(WARN_BUG, "PLSpringBarleySpr::Do(): failure in 'FA_Calcium' execution", "");
593  exit(1);
594  }
595  }
596  else {
597  if (!m_farm->FA_Calcium(m_field, 0.0, m_field->GetMDates(1, 3) - g_date->DayInYear())) {
599  break;
600  }
601  }
602  }
603  done = true;
604  // So we are done, and somwhere else the farmer will queue up the start event of the next crop
605  // END of MAIN THREAD
606  break;
607  default:
608  g_msg->Warn(WARN_BUG, "PLSpringBarleySpr::Do(): "
609  "Unknown event type! ", "");
610  exit(1);
611  }
612  return done;
613 }

References cfg_pest_product_amounts, cfg_pest_springbarley_on, cfg_seedcoating_product_amounts, cfg_seedcoating_springbarley_on, LE::ClearManagementActionSum(), Calendar::Date(), Calendar::DayInYear(), Farm::DoIt(), Farm::FA_AmmoniumSulphate(), Farm::FA_Calcium(), Farm::FA_ManganeseSulphate(), Farm::FA_NPK(), Farm::FA_RSM(), Farm::FP_AmmoniumSulphate(), Farm::FP_Calcium(), Farm::FP_ManganeseSulphate(), Farm::FP_NPK(), Farm::FP_RSM(), Farm::FungicideTreat(), g_date, g_msg, LE::GetGreenBiomass(), LE::GetMConstants(), LE::GetMDates(), Farm::GetType(), Calendar::GetYearNumber(), Farm::Harvest(), Farm::HayBailing(), Farm::HeavyCultivatorAggregate(), Farm::HerbicideTreat(), Farm::InsecticideTreat(), Farm::IsStockFarmer(), Crop::m_date_modifier, Crop::m_ev, Crop::m_farm, Crop::m_field, Crop::m_first_date, FarmEvent::m_first_year, FarmEvent::m_lock, FarmEvent::m_next_tov, FarmEvent::m_startday, FarmEvent::m_todo, Calendar::OldDays(), PL_SBS_DECIDE_TO_GR, pl_sbs_ferti_p1, pl_sbs_ferti_p2, pl_sbs_ferti_p3, pl_sbs_ferti_p4, pl_sbs_ferti_p5, pl_sbs_ferti_p6, pl_sbs_ferti_s1, pl_sbs_ferti_s2, pl_sbs_ferti_s3, pl_sbs_ferti_s4, pl_sbs_ferti_s5, pl_sbs_ferti_s6, pl_sbs_fungicide1, pl_sbs_fungicide2, pl_sbs_fungicide3, pl_sbs_harvest, pl_sbs_hay_bailing, pl_sbs_heavy_cultivator, pl_sbs_herbicide1, pl_sbs_insecticide1, pl_sbs_insecticide2, pl_sbs_preseeding_cultivator, pl_sbs_preseeding_cultivator_sow, PL_SBS_SPRING_FERTI, pl_sbs_spring_harrow, pl_sbs_spring_plough, pl_sbs_spring_sow, pl_sbs_start, pl_sbs_straw_chopping, ppp_1, Farm::PreseedingCultivator(), Farm::PreseedingCultivatorSow(), Farm::ProductApplication(), LE::SetMConstants(), LE::SetMDates(), Crop::SimpleEvent_(), Farm::SpringHarrow(), Farm::SpringPlough(), Farm::SpringSow(), Farm::StrawChopping(), tof_OptimisingFarm, tov_PLSpringBarleySpr, CfgBool::value(), CfgArray_Double::value(), MapErrorMsg::Warn(), and WARN_BUG.

◆ SetUpFarmCategoryInformation()

void PLSpringBarleySpr::SetUpFarmCategoryInformation ( )
inline
87  {
88  const int elements = 2 + (pl_sbs_foobar - PLSPRINGBARLEYSPR_BASE);
90 
91  FarmManagementCategory catlist[elements] =
92  {
93  fmc_Others, // zero element unused but must be here
94  fmc_Others,//pl_sbs_start = 1, // Compulsory, must always be 1 (one).
95  fmc_Others,//pl_sbs_sleep_all_day = PLSPRINGBARLEYSPR_BASE,
96  fmc_Cultivation,//pl_sbs_spring_plough,
97  fmc_Cultivation,//pl_sbs_spring_harrow,
98  fmc_Fertilizer,//pl_sbs_ferti_p1,
99  fmc_Fertilizer,//pl_sbs_ferti_s1,
100  fmc_Cultivation,//pl_sbs_heavy_cultivator,
101  fmc_Cultivation,//pl_sbs_preseeding_cultivator,
102  fmc_Cultivation,//pl_sbs_preseeding_cultivator_sow, //
103  fmc_Others,//pl_sbs_spring_sow,
104  fmc_Herbicide,//pl_sbs_herbicide1,
105  fmc_Fungicide,//pl_sbs_fungicide1,
106  fmc_Fungicide,//pl_sbs_fungicide2,
107  fmc_Fungicide,//pl_sbs_fungicide3,
108  fmc_Insecticide,//pl_sbs_insecticide1,
109  fmc_Insecticide,//pl_sbs_insecticide2,
110  fmc_Fertilizer,//pl_sbs_ferti_p2,
111  fmc_Fertilizer,//pl_sbs_ferti_s2,
112  fmc_Fertilizer,//pl_sbs_ferti_p3, //
113  fmc_Fertilizer,//pl_sbs_ferti_s3,
114  fmc_Fertilizer,//pl_sbs_ferti_p4,
115  fmc_Fertilizer,//pl_sbs_ferti_s4,
116  fmc_Harvest,//pl_sbs_harvest,
117  fmc_Others,//pl_sbs_straw_chopping,
118  fmc_Others,//pl_sbs_hay_bailing,
119  fmc_Fertilizer,//pl_sbs_ferti_p5,
120  fmc_Fertilizer,//pl_sbs_ferti_s5,
121  fmc_Fertilizer,//pl_sbs_ferti_p6,
122  fmc_Fertilizer//pl_sbs_ferti_s6, //
123  };
124  // Iterate over the catlist elements and copy them to vector
125  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
126 
127  }

References fmc_Cultivation, fmc_Fertilizer, fmc_Fungicide, fmc_Harvest, fmc_Herbicide, fmc_Insecticide, fmc_Others, Crop::m_base_elements_no, Crop::m_ManagementCategories, pl_sbs_foobar, and PLSPRINGBARLEYSPR_BASE.

Referenced by PLSpringBarleySpr().


The documentation for this class was generated from the following files:
LE::GetMDates
int GetMDates(int a, int b)
Definition: Elements.h:405
pl_sbs_ferti_p1
Definition: PLSpringBarleySpr.h:41
fmc_Insecticide
Definition: LandscapeFarmingEnums.h:1005
Farm::PreseedingCultivator
virtual bool PreseedingCultivator(LE *a_field, double a_user, int a_days)
Carry out preseeding cultivation on a_field (tilling set including cultivator and string roller to co...
Definition: FarmFuncs.cpp:312
LE::SetMDates
void SetMDates(int a, int b, int c)
Definition: Elements.h:406
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
Farm::HerbicideTreat
virtual bool HerbicideTreat(LE *a_field, double a_user, int a_days)
Apply herbicide to a_field.
Definition: FarmFuncs.cpp:2025
pl_sbs_ferti_p4
Definition: PLSpringBarleySpr.h:57
Farm::IsStockFarmer
bool IsStockFarmer(void)
Definition: Farm.h:961
PL_SBS_SPRING_FERTI
#define PL_SBS_SPRING_FERTI
A flag used to indicate autumn ploughing status.
Definition: PLSpringBarleySpr.h:28
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
Farm::FP_ManganeseSulphate
virtual bool FP_ManganeseSulphate(LE *a_field, double a_user, int a_days)
Apply Manganse Sulphate to a_field owned by an arable farmer.
Definition: FarmFuncs.cpp:840
cfg_pest_product_amounts
CfgArray_Double cfg_pest_product_amounts
Amount of pesticide applied in grams of active substance per hectare for each of the 10 pesticides.
Farm::ProductApplication
virtual bool ProductApplication(LE *a_field, double a_user, int a_days, double a_applicationrate, PlantProtectionProducts a_ppp, bool a_isgranularpesticide=false, int a_orcharddrifttype=0)
Apply test pesticide to a_field.
Definition: FarmFuncs.cpp:2267
pl_sbs_preseeding_cultivator_sow
Definition: PLSpringBarleySpr.h:45
LE::GetMConstants
int GetMConstants(int a)
Definition: Elements.h:407
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
Farm::DoIt
bool DoIt(double a_probability)
Return chance out of 0 to 100.
Definition: Farm.cpp:856
Calendar::GetYearNumber
int GetYearNumber(void)
Definition: Calendar.h:72
FarmEvent::m_first_year
bool m_first_year
Definition: Farm.h:386
tov_PLSpringBarleySpr
Definition: LandscapeFarmingEnums.h:246
pl_sbs_ferti_p5
Definition: PLSpringBarleySpr.h:62
pl_sbs_fungicide1
Definition: PLSpringBarleySpr.h:48
g_date
class Calendar * g_date
Definition: Calendar.cpp:37
pl_sbs_ferti_s5
Definition: PLSpringBarleySpr.h:63
fmc_Herbicide
Definition: LandscapeFarmingEnums.h:1006
PLSpringBarleySpr::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: PLSpringBarleySpr.h:87
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
PL_SBS_DECIDE_TO_GR
#define PL_SBS_DECIDE_TO_GR
Definition: PLSpringBarleySpr.h:29
Farm::GetType
TTypesOfFarm GetType(void)
Definition: Farm.h:956
pl_sbs_ferti_p3
Definition: PLSpringBarleySpr.h:55
Crop::m_base_elements_no
int m_base_elements_no
Definition: Farm.h:505
cfg_seedcoating_product_amounts
CfgArray_Double cfg_seedcoating_product_amounts
Amount of seed coating pesticide applied in grams of active substance per hectare for each of the 10 ...
Crop::m_first_date
int m_first_date
Definition: Farm.h:501
FarmEvent::m_startday
int m_startday
Definition: Farm.h:385
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
Farm::FungicideTreat
virtual bool FungicideTreat(LE *a_field, double a_user, int a_days)
Apply fungicide to a_field.
Definition: FarmFuncs.cpp:2101
pl_sbs_fungicide2
Definition: PLSpringBarleySpr.h:49
pl_sbs_spring_harrow
Definition: PLSpringBarleySpr.h:40
pl_sbs_preseeding_cultivator
Definition: PLSpringBarleySpr.h:44
CfgBool::value
bool value() const
Definition: Configurator.h:164
pl_sbs_start
Definition: PLSpringBarleySpr.h:37
pl_sbs_ferti_p6
Definition: PLSpringBarleySpr.h:64
Farm::FA_RSM
virtual bool FA_RSM(LE *a_field, double a_user, int a_days)
RSM (ammonium nitrate solution) applied on a_field owned by a stock farmer.
Definition: FarmFuncs.cpp:1154
fmc_Fertilizer
Definition: LandscapeFarmingEnums.h:1004
Calendar::Date
long Date(void)
Definition: Calendar.h:57
pl_sbs_heavy_cultivator
Definition: PLSpringBarleySpr.h:43
Farm::FP_AmmoniumSulphate
virtual bool FP_AmmoniumSulphate(LE *a_field, double a_user, int a_days)
Apply Ammonium Sulphate to a_field owned by an arable farmer.
Definition: FarmFuncs.cpp:882
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::FA_Calcium
virtual bool FA_Calcium(LE *a_field, double a_user, int a_days)
Calcium applied on a_field owned by a stock farmer.
Definition: FarmFuncs.cpp:1168
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
Farm::FA_ManganeseSulphate
virtual bool FA_ManganeseSulphate(LE *a_field, double a_user, int a_days)
Apply manganese sulphate to a_field owned by an stock farmer.
Definition: FarmFuncs.cpp:1095
Calendar::OldDays
long OldDays(void)
Definition: Calendar.h:60
pl_sbs_ferti_p2
Definition: PLSpringBarleySpr.h:53
pl_sbs_hay_bailing
Definition: PLSpringBarleySpr.h:61
MapErrorMsg::Warn
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: MapErrorMsg.cpp:69
pl_sbs_herbicide1
Definition: PLSpringBarleySpr.h:47
Farm::FP_Calcium
virtual bool FP_Calcium(LE *a_field, double a_user, int a_days)
Calcium applied on a_field owned by an arable farmer.
Definition: FarmFuncs.cpp:954
pl_sbs_straw_chopping
Definition: PLSpringBarleySpr.h:60
pl_sbs_ferti_s1
Definition: PLSpringBarleySpr.h:42
FarmEvent::m_next_tov
TTypesOfVegetation m_next_tov
Definition: Farm.h:390
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
CfgArray_Double::value
std::vector< double > value() const
Definition: Configurator.h:219
pl_sbs_spring_sow
Definition: PLSpringBarleySpr.h:46
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::InsecticideTreat
virtual bool InsecticideTreat(LE *a_field, double a_user, int a_days)
Apply insecticide to a_field.
Definition: FarmFuncs.cpp:2135
LE::GetGreenBiomass
virtual double GetGreenBiomass(void)
Definition: Elements.h:160
cfg_seedcoating_springbarley_on
CfgBool cfg_seedcoating_springbarley_on
Turn on seed coating for spring barley.
tof_OptimisingFarm
Definition: LandscapeFarmingEnums.h:696
PLSPRINGBARLEYSPR_BASE
#define PLSPRINGBARLEYSPR_BASE
Definition: PLSpringBarleySpr.h:24
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
Farm::FA_AmmoniumSulphate
virtual bool FA_AmmoniumSulphate(LE *a_field, double a_user, int a_days)
Apply ammonium sulphate to a_field owned by an stock farmer.
Definition: FarmFuncs.cpp:1081
cfg_pest_springbarley_on
CfgBool cfg_pest_springbarley_on
Turn on pesticides for spring barley.
TTypesOfVegetation
TTypesOfVegetation
Values that represent the types of vegetation that are represented in ALMaSS.
Definition: LandscapeFarmingEnums.h:192
pl_sbs_harvest
Definition: PLSpringBarleySpr.h:59
Crop::m_date_modifier
static int m_date_modifier
Holds a value that shifts test pesticide use by this many days in crops modified to use it.
Definition: Farm.h:514
Farm::FP_RSM
virtual bool FP_RSM(LE *a_field, double a_user, int a_days)
RSM (ammonium nitrate solution) applied on a_field owned by an arable farmer.
Definition: FarmFuncs.cpp:940
fmc_Harvest
Definition: LandscapeFarmingEnums.h:1012
Calendar::DayInYear
int DayInYear(void)
Definition: Calendar.h:58
pl_sbs_ferti_s6
Definition: PLSpringBarleySpr.h:65
pl_sbs_ferti_s2
Definition: PLSpringBarleySpr.h:54
pl_sbs_ferti_s4
Definition: PLSpringBarleySpr.h:58
Crop::Crop
Crop(TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape *a_L)
Definition: Farm.cpp:733
pl_sbs_fungicide3
Definition: PLSpringBarleySpr.h:50
pl_sbs_insecticide2
Definition: PLSpringBarleySpr.h:52
LE::SetMConstants
void SetMConstants(int a, int c)
Definition: Elements.h:408
pl_sbs_insecticide1
Definition: PLSpringBarleySpr.h:51
pl_sbs_foobar
Definition: PLSpringBarleySpr.h:66
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
pl_sbs_spring_plough
Definition: PLSpringBarleySpr.h:39
WARN_BUG
Definition: MapErrorMsg.h:34
ppp_1
Definition: LandscapeFarmingEnums.h:1079
Farm::HeavyCultivatorAggregate
virtual bool HeavyCultivatorAggregate(LE *a_field, double a_user, int a_days)
Carry out a heavy cultivation event on a_field. This is non-inversion type of cultivation which can b...
Definition: FarmFuncs.cpp:259
fmc_Fungicide
Definition: LandscapeFarmingEnums.h:1007
pl_sbs_ferti_s3
Definition: PLSpringBarleySpr.h:56
FarmManagementCategory
FarmManagementCategory
Definition: LandscapeFarmingEnums.h:1001
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