File failed to load: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/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_OSpringRye Class Reference

#include <DE_OSpringRye.h>

Inheritance diagram for DE_OSpringRye:
Crop

Public Member Functions

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

DE_OSpringRye::DE_OSpringRye ( TTypesOfVegetation  a_tov,
TTypesOfCrops  a_toc,
Landscape a_L 
)
inline
62  : Crop(a_tov, a_toc, a_L)
63  {
64  m_first_date = g_date->DayInYear(30, 3);
66  }

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

Member Function Documentation

◆ Do()

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

Reimplemented from Crop.

35 {
36  /******************** This block can be added to the top of all Crop::Do methods ***********************************************/
37  m_farm = a_farm; // These assignments are necessary, not for this method but for related event calls
38  m_field = a_field;
39  m_ev = a_ev;
40  bool done = false; // The boolean value done indicates when we are totally finished with this plan (i.e. it is set to true).
41  bool flag = false;
42  int d1 = 0;
43  int noDates = 1;
44  TTypesOfVegetation l_tov = tov_DEOSpringRye; // The current type - change to match the crop you have
45 /**********************************************To Here *************************************************************************/
46  // Depending what event has occured jump to the correct bit of code
47  switch (m_ev->m_todo)
48  {
49  case de_osr_start:
50  {
52 
53  DE_OSR_SOW_DATE = 0;
55 
56  m_last_date = g_date->DayInYear(20, 8); // Should match the last flexdate below
57  //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
58  std::vector<std::vector<int>> flexdates(2 + 1, std::vector<int>(2, 0));
59  // Set up the date management stuff
60  // Start and stop dates for all events after harvest
61  flexdates[0][1] = g_date->DayInYear(11, 8); // last possible day of harvest - this is in effect day before the earliest date that a following crop can use
62 
63  flexdates[1][0] = -1; // This date will be moved back as far as necessary and potentially to flexdates 1 (start op 1)
64  flexdates[1][1] = g_date->DayInYear(20, 8); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 1) - straw chopping
65  flexdates[2][0] = -1; // This date will be moved back as far as necessary and potentially to flexdates 2 (start op 2)
66  flexdates[2][1] = g_date->DayInYear(20, 8); // This date will be moved back as far as necessary and potentially to flexdates 2 (end op 2) - hay bailing
67 
68  // 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
69  int isSpring = 365;
70  if (StartUpCrop(isSpring, flexdates, int(de_osr_spring_harrow))) break;
71 
72  // End single block date checking code. Please see next line comment as well.
73  // Reinit d1 to first possible starting date.
74  d1 = g_date->OldDays() + g_date->DayInYear(1, 3) + isSpring;
75  // OK, let's go.
76 
77  if (m_farm->IsStockFarmer())
78  {
80  }
81  else
82  {
84  }
85  break;
86  }
87  break;
88 
90  if (m_ev->m_lock || m_farm->DoIt(70))
91  {
92  if (!m_farm->FA_Manure(m_field, 0.0, g_date->DayInYear(30, 3) - g_date->DayInYear())) {
94  break;
95  }
96  }
98  break;
99 
101  if (!m_farm->SpringPlough(m_field, 0.0, g_date->DayInYear(30, 3) - g_date->DayInYear())) {
103  break;
104  }
106  break;
107 
109  if (!m_farm->SpringHarrow(m_field, 0.0, g_date->DayInYear(30, 3) - g_date->DayInYear())) {
111  break;
112  }
114  break;
115 
116  case de_osr_spring_sow:
117  if (!m_farm->SpringSow(m_field, 0.0, g_date->DayInYear(5, 4) - g_date->DayInYear())) {
119  break;
120  }
122  if (m_farm->IsStockFarmer()) {
123  d1 = g_date->Date();
124  if (d1 < g_date->OldDays() + g_date->DayInYear(5, 4)) {
125  d1 = g_date->OldDays() + g_date->DayInYear(5, 4);
126  }
127  }
129  break;
130 
131  case de_osr_spring_roll:
132  if (m_ev->m_lock || m_farm->DoIt(40))
133  {
134  if (!m_farm->SpringRoll(m_field, 0.0, g_date->DayInYear(20, 4) - g_date->DayInYear())) {
136  break;
137  }
138  }
139  d1 = g_date->OldDays() + g_date->DayInYear(15, 4);
140  if (d1 < DE_OSR_SOW_DATE + 10) {
141  d1 = DE_OSR_SOW_DATE + 10;
142  }
144  break;
145 
147  if (!m_farm->Strigling(m_field, 0.0, g_date->DayInYear(30, 4) - g_date->DayInYear())) {
149  break;
150  }
151  d1 = g_date->Date() + 10;
152  if (d1 < g_date->OldDays() + g_date->DayInYear(25, 4)) {
153  d1 = g_date->OldDays() + g_date->DayInYear(25, 4);
154  }
156  break;
157 
159  if (m_ev->m_lock || (cfg_strigling_prop.value() * m_farm->DoIt(60)))
160  {
161  if (!m_farm->Strigling(m_field, 0.0, g_date->DayInYear(30, 5) - g_date->DayInYear())) {
163  break;
164  }
165  }
166  d1 = g_date->Date() + 10;
167  if (d1 < g_date->OldDays() + g_date->DayInYear(30, 5)) {
168  d1 = g_date->OldDays() + g_date->DayInYear(30, 5);
169  }
171  break;
172 
174  if (m_ev->m_lock || (cfg_strigling_prop.value() * m_farm->DoIt(5)))
175  {
176  if (!m_farm->Strigling(m_field, 0.0, g_date->DayInYear(30, 6) - g_date->DayInYear())) {
178  break;
179  }
180  }
182  de_osr_harvest, false, m_farm, m_field);
183  break;
184 
185  case de_osr_harvest:
186  if (!m_farm->Harvest(m_field, 0.0, m_field->GetMDates(1, 0) - g_date->DayInYear())) {
188  break;
189  }
191  break;
192 
194  if (m_ev->m_lock || m_farm->DoIt(80))
195  {
196  if (!m_farm->StrawChopping(m_field, 0.0, m_field->GetMDates(1, 1) - g_date->DayInYear())) {
198  break;
199  }
200  done = true;
201  break;
202  }
204  break;
205 
206  case de_osr_hay_bailing:
207  if (!m_farm->HayBailing(m_field, 0.0, m_field->GetMDates(1, 2) - g_date->DayInYear())) {
209  break;
210  }
211 
212  done = true;
213  break;
214 
215  default:
216  g_msg->Warn(WARN_BUG, "DE_OSpringRye::Do(): "
217  "Unknown event type! ", "");
218  exit(1);
219  }
220 
221  return done;
222 }

References cfg_strigling_prop, LE::ClearManagementActionSum(), Calendar::Date(), Calendar::DayInYear(), DE_OSR_DID_STRIGLING_ONE, de_osr_fertmanure_stock, de_osr_harvest, de_osr_hay_bailing, DE_OSR_SOW_DATE, de_osr_spring_harrow, de_osr_spring_plough, de_osr_spring_roll, de_osr_spring_sow, de_osr_start, de_osr_straw_chopping, de_osr_strigling_one, de_osr_strigling_three, de_osr_strigling_two, Farm::DoIt(), Farm::FA_Manure(), g_date, g_msg, LE::GetMDates(), Farm::Harvest(), Farm::HayBailing(), 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::SpringHarrow(), Farm::SpringPlough(), Farm::SpringRoll(), Farm::SpringSow(), Crop::StartUpCrop(), Farm::StrawChopping(), Farm::Strigling(), tov_DEOSpringRye, CfgFloat::value(), MapErrorMsg::Warn(), and WARN_BUG.

◆ SetUpFarmCategoryInformation()

void DE_OSpringRye::SetUpFarmCategoryInformation ( )
inline
67  {
68  const int elements = 2 + (de_osr_foobar - DE_OSPRINGRYE_BASE);
70 
71  FarmManagementCategory catlist[elements] =
72  {
73  fmc_Others, // zero element unused but must be here
74  fmc_Others, // de_osr_start = 1, // Compulsory, start event must always be 1 (one).
75  fmc_Others, // de_osr_sleep_all_day = DE_OSPRINGRYE_BASE,
76  fmc_Cultivation, // de_osr_autumn_plough,
77  fmc_Fertilizer, // de_osr_fertmanure_stock,
78  fmc_Cultivation, // de_osr_spring_plough,
79  fmc_Cultivation, // de_osr_spring_harrow,
80  fmc_Fertilizer, // de_osr_fertslurry_stock,
81  fmc_Others, // de_osr_spring_sow,
82  fmc_Cultivation, // de_osr_spring_roll,
83  fmc_Cultivation, // de_osr_strigling_one,
84  fmc_Cultivation, // de_osr_strigling_two,
85  fmc_Cultivation, // de_osr_strigling_three,
86  fmc_Harvest, // de_osr_harvest,
87  fmc_Cutting, // de_osr_straw_chopping,
88  fmc_Others, // de_osr_hay_bailing,
89 
90 
91  // no foobar entry
92 
93  };
94  // Iterate over the catlist elements and copy them to vector
95  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
96 
97  }

References DE_OSPRINGRYE_BASE, de_osr_foobar, fmc_Cultivation, fmc_Cutting, fmc_Fertilizer, fmc_Harvest, fmc_Others, Crop::m_base_elements_no, and Crop::m_ManagementCategories.

Referenced by DE_OSpringRye().


The documentation for this class was generated from the following files:
LE::GetMDates
int GetMDates(int a, int b)
Definition: Elements.h:405
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_DEOSpringRye
Definition: LandscapeFarmingEnums.h:491
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
cfg_strigling_prop
CfgFloat cfg_strigling_prop
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
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_osr_hay_bailing
Definition: DE_OSpringRye.h:51
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
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
CfgFloat::value
double value() const
Definition: Configurator.h:142
Crop::m_base_elements_no
int m_base_elements_no
Definition: Farm.h:505
de_osr_straw_chopping
Definition: DE_OSpringRye.h:50
Crop::m_first_date
int m_first_date
Definition: Farm.h:501
de_osr_foobar
Definition: DE_OSpringRye.h:52
de_osr_harvest
Definition: DE_OSpringRye.h:49
de_osr_spring_sow
Definition: DE_OSpringRye.h:44
fmc_Cutting
Definition: LandscapeFarmingEnums.h:1009
fmc_Fertilizer
Definition: LandscapeFarmingEnums.h:1004
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_osr_strigling_three
Definition: DE_OSpringRye.h:48
de_osr_spring_harrow
Definition: DE_OSpringRye.h:42
de_osr_spring_roll
Definition: DE_OSpringRye.h:45
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
DE_OSpringRye::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: DE_OSpringRye.h:67
de_osr_fertmanure_stock
Definition: DE_OSpringRye.h:40
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_osr_strigling_two
Definition: DE_OSpringRye.h:47
Crop::m_last_date
int m_last_date
Definition: Farm.h:503
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
de_osr_spring_plough
Definition: DE_OSpringRye.h:41
DE_OSPRINGRYE_BASE
#define DE_OSPRINGRYE_BASE
Definition: DE_OSpringRye.h:31
TTypesOfVegetation
TTypesOfVegetation
Values that represent the types of vegetation that are represented in ALMaSS.
Definition: LandscapeFarmingEnums.h:192
DE_OSR_DID_STRIGLING_ONE
#define DE_OSR_DID_STRIGLING_ONE
Definition: DE_OSpringRye.h:34
fmc_Harvest
Definition: LandscapeFarmingEnums.h:1012
de_osr_strigling_one
Definition: DE_OSpringRye.h:46
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
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
WARN_BUG
Definition: MapErrorMsg.h:34
de_osr_start
Definition: DE_OSpringRye.h:37
DE_OSR_SOW_DATE
#define DE_OSR_SOW_DATE
Definition: DE_OSpringRye.h:33
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