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

#include <DK_OSpringOats.h>

Inheritance diagram for DK_OSpringOats:
Crop

Public Member Functions

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

◆ DK_OSpringOats()

DK_OSpringOats::DK_OSpringOats ( TTypesOfVegetation  a_tov,
TTypesOfCrops  a_toc,
Landscape a_L 
)
inline
70  : Crop(a_tov, a_toc, a_L)
71  {
74  }

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

Member Function Documentation

◆ Do()

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

Reimplemented from Crop.

33 {
34  m_farm = a_farm;
35  m_field = a_field;
36  m_ev = a_ev;
37  bool done = false;
38  int d1;
40 
41  switch ( m_ev->m_todo ) {
42  case dk_oso_start:
43  {
44  a_field->ClearManagementActionSum();
45 
46  DK_OSO_FORCESPRING = false;
47 
48  m_last_date = g_date->DayInYear(16, 8); // Should match the last flexdate below
49  //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
50  std::vector<std::vector<int>> flexdates(1 + 3, std::vector<int>(2, 0));
51  // Set up the date management stuff
52  // Start and stop dates for all events after harvest
53  flexdates[0][1] = g_date->DayInYear(12, 8); // last possible day of swathing
54  // Now these are done in pairs, start & end for each operation. If its not used then -1
55  flexdates[1][0] = -1; // This date will be moved back as far as necessary and potentially to flexdates 1 (start op 1)
56  flexdates[1][1] = g_date->DayInYear(13, 8); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 1) // harvest
57  flexdates[2][0] = -1;
58  flexdates[2][1] = g_date->DayInYear(14, 8); // hay bailing
59  flexdates[3][0] = -1;
60  flexdates[3][1] = g_date->DayInYear(14, 8); // straw chopping
61 
62 
63  // Below if this is a spring crop use 365, otherwise first parameter is always 0, second parameter is fixed, and the third is the start up operation in the first year
64  int isSpring = 365;
65  if (StartUpCrop(isSpring, flexdates, int(dk_oso_spring_harrow1))) break;
66 
67  // End single block date checking code. Please see next line comment as well.
68  // Reinit d1 to first possible starting date.
69  d1 = g_date->OldDays() + g_date->DayInYear(1, 2) + isSpring;
70  if (m_ev->m_forcespring) {
71  int day_num_shift = 365;
72  if (g_date->DayInYear() < 70) day_num_shift = 0;
73  SimpleEvent(g_date->OldDays() + g_date->DayInYear(1, 2) + day_num_shift, dk_oso_spring_harrow1, false);
74  DK_OSO_FORCESPRING = true;
75  break;
76  }
77  else
78  // OK, let's go.
80  }
81  break;
82 
84  if (m_ev->m_lock || m_farm->DoIt_prob(1.0)) {
85  if (!m_farm->SpringHarrow(m_field, 0.0,
86  g_date->DayInYear(28, 3) - g_date->DayInYear())) {
88  break;
89  }
90  }
92  break;
93 
95  if (m_ev->m_lock || m_farm->DoIt_prob(0.5)) { // put to 50% as 100% harrow 1-2 times
96  if (!m_farm->SpringHarrow(m_field, 0.0,
97  g_date->DayInYear(30, 3) - g_date->DayInYear())) {
99  break;
100  }
101  }
102  SimpleEvent(g_date->Date() + 1, dk_oso_slurry_s, false);
103  break;
104 
105  case dk_oso_slurry_s:
106  if (a_farm->IsStockFarmer()) {
107  if (!m_farm->FA_Slurry(m_field, 0.0,
108  g_date->DayInYear(31, 3) - g_date->DayInYear())) {
109  SimpleEvent(g_date->Date() + 1, dk_oso_slurry_s, true);
110  break;
111  }
113  break;
114  }
115  SimpleEvent(g_date->Date() + 1, dk_oso_slurry_p, false);
116  break;
117 
118  case dk_oso_slurry_p:
119  if (!m_farm->FP_Slurry(m_field, 0.0,
120  g_date->DayInYear(31, 3) - g_date->DayInYear())) {
121  SimpleEvent(g_date->Date() + 1, dk_oso_slurry_p, true);
122  break;
123  }
125  break;
126 
128  if (!m_farm->SpringPlough(m_field, 0.0,
129  g_date->DayInYear(30, 4) - g_date->DayInYear())) {
131  break;
132  }
133  SimpleEvent(g_date->Date() + 1, dk_oso_spring_sow, false);
134  break;
135 
136  case dk_oso_spring_sow:
137  if (!m_farm->SpringSow(m_field, 0.0,
138  g_date->DayInYear(1, 5) - g_date->DayInYear())) {
139  SimpleEvent(g_date->Date() + 1, dk_oso_spring_sow, true);
140  break;
141  }
142  SimpleEvent(g_date->Date() + 3, dk_oso_strigling1, false);
143  break;
144 
145  case dk_oso_strigling1:
146  if (!m_farm->Strigling(m_field, 0.0,
147  g_date->DayInYear(4, 5) - g_date->DayInYear())) {
148  SimpleEvent(g_date->Date() + 1, dk_oso_strigling1, true);
149  break;
150  }
151  SimpleEvent(g_date->Date() + 3, dk_oso_strigling2, false);
152  break;
153 
154  case dk_oso_strigling2:
155  if (!m_farm->Strigling(m_field, 0.0,
156  g_date->DayInYear(7, 5) - g_date->DayInYear())) {
157  SimpleEvent(g_date->Date() + 1, dk_oso_strigling2, true);
158  break;
159  }
160  SimpleEvent(g_date->Date() + 1, dk_oso_roll, false);
161  break;
162 
163  case dk_oso_roll:
164  if (m_ev->m_lock || m_farm->DoIt_prob(0.5)) {
165  if (!m_farm->SpringRoll(m_field, 0.0,
166  g_date->DayInYear(8, 5) - g_date->DayInYear())) {
167  SimpleEvent(g_date->Date() + 1, dk_oso_roll, true);
168  break;
169  }
170  }
171  SimpleEvent(g_date->Date() + 7, dk_oso_weed_harrow, false);
172  break;
173 
174  case dk_oso_weed_harrow:
175  if (m_ev->m_lock || m_farm->DoIt_prob(0.8)) { // 80% do weed harrow, 20% row cultivation (as 20% row sow)
176  if (!m_farm->SpringHarrow(m_field, 0.0,
177  g_date->DayInYear(16, 5) - g_date->DayInYear())) {
178  SimpleEvent(g_date->Date() + 1, dk_oso_weed_harrow, true);
179  break;
180  }
181  SimpleEvent(g_date->OldDays() + g_date->DayInYear(1, 7), dk_oso_water, false);
182  break;
183  }
185  break;
186 
187  case dk_oso_row_cultivation:// 80% do weed harrow, 20% row cultivation (as 20% row sow)
188  if (!m_farm->RowCultivation(m_field, 0.0,
189  g_date->DayInYear(16, 5) - g_date->DayInYear())) {
191  break;
192  }
193  SimpleEvent(g_date->OldDays() + g_date->DayInYear(1, 7), dk_oso_water, false);
194  break;
195 
196  case dk_oso_water:
197  if (m_ev->m_lock || m_farm->DoIt_prob(0.50)) {
198  if (!m_farm->Water(m_field, 0.0,
199  g_date->DayInYear(31, 7) - g_date->DayInYear())) {
200  SimpleEvent(g_date->Date() + 1, dk_oso_water, true);
201  break;
202  }
203  }
205  break;
206 
207  case dk_oso_swathing:
208  if (m_ev->m_lock || m_farm->DoIt_prob(0.1)) { // est. 10%
209  if (!m_farm->Swathing(m_field, 0.0, m_field->GetMDates(1, 0) - g_date->DayInYear())) {
210  SimpleEvent(g_date->Date() + 1, dk_oso_swathing, true);
211  break;
212  }
213  SimpleEvent(g_date->Date() + 1, dk_oso_harvest, false);
214  break;
215  }
217  break;
218 
219  case dk_oso_harvest:
220  if (!m_farm->Harvest(m_field, 0.0, m_field->GetMDates(1, 1) - g_date->DayInYear())) {
221  SimpleEvent(g_date->Date() + 1, dk_oso_harvest, true);
222  break;
223  }
224  SimpleEvent(g_date->Date() + 1, dk_oso_hay_bailing, false);
225  break;
226 
227  case dk_oso_hay_bailing:
228  if (m_ev->m_lock || m_farm->DoIt_prob(0.9)) { // est. 90%
229  if (!m_farm->HayBailing(m_field, 0.0, m_field->GetMDates(1, 2) - g_date->DayInYear())) {
230  SimpleEvent(g_date->Date() + 1, dk_oso_hay_bailing, true);
231  break;
232  }
233  done = true;
234  break;
235  }
237  break;
238 
240  if (!m_farm->StrawChopping(m_field, 0.0, m_field->GetMDates(1, 3) - g_date->DayInYear())) {
242  break;
243  }
244 
245  done = true;
246  break;
247 
248  default:
249  g_msg->Warn( WARN_BUG, "DK_OSpringOats::Do(): "
250  "Unknown event type! ", "" );
251  exit( 1 );
252  }
253 
254  return done;
255 }

References LE::ClearManagementActionSum(), Calendar::Date(), Calendar::DayInYear(), DK_OSO_FORCESPRING, dk_oso_harvest, dk_oso_hay_bailing, dk_oso_roll, dk_oso_row_cultivation, dk_oso_slurry_p, dk_oso_slurry_s, dk_oso_spring_harrow1, dk_oso_spring_harrow2, dk_oso_spring_plough, dk_oso_spring_sow, dk_oso_start, dk_oso_straw_chopping, dk_oso_strigling1, dk_oso_strigling2, dk_oso_swathing, dk_oso_water, dk_oso_weed_harrow, Farm::DoIt_prob(), Farm::FA_Slurry(), Farm::FP_Slurry(), g_date, g_msg, LE::GetMDates(), Farm::Harvest(), Farm::HayBailing(), Farm::IsStockFarmer(), Crop::m_ev, Crop::m_farm, Crop::m_field, FarmEvent::m_forcespring, Crop::m_last_date, FarmEvent::m_lock, FarmEvent::m_todo, Calendar::OldDays(), Farm::RowCultivation(), Crop::SimpleEvent(), Farm::SpringHarrow(), Farm::SpringPlough(), Farm::SpringRoll(), Farm::SpringSow(), Crop::StartUpCrop(), Farm::StrawChopping(), Farm::Strigling(), Farm::Swathing(), tov_DKOSpringOats, MapErrorMsg::Warn(), WARN_BUG, and Farm::Water().

◆ SetUpFarmCategoryInformation()

void DK_OSpringOats::SetUpFarmCategoryInformation ( )
inline
75  {
76  const int elements = 2 + (dk_oso_foobar - DK_OSO_BASE);
78 
79  FarmManagementCategory catlist[elements] =
80  {
81  fmc_Others, // zero element unused but must be here
82  fmc_Others, // dk_oso_start = 1, // Compulsory, start event must always be 1 (one).
83  fmc_Cultivation, //dk_oso_spring_harrow1 = DK_OSO_BASE,
84  fmc_Cultivation, //dk_oso_spring_harrow2,
85  fmc_Fertilizer, //dk_oso_slurry_s,
86  fmc_Fertilizer, //dk_oso_slurry_p,
87  fmc_Cultivation, //dk_oso_spring_plough,
88  fmc_Others, //dk_oso_spring_sow,
89  fmc_Cultivation, //dk_oso_strigling1,
90  fmc_Cultivation, // dk_oso_strigling2,
91  fmc_Others, // dk_oso_roll,
92  fmc_Cultivation, // dk_oso_weed_harrow,
93  fmc_Cultivation, // dk_oso_row_cultivation,
94  fmc_Watering, // dk_oso_water,
95  fmc_Cutting, // dk_oso_swathing,
96  fmc_Harvest, // dk_oso_harvest,
97  fmc_Others, // dk_oso_hay_bailing,
98  fmc_Cutting, // dk_oso_straw_chopping,
99  // No foobar entry
100  };
101  // Iterate over the catlist elements and copy them to vector
102  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
103  }

References DK_OSO_BASE, dk_oso_foobar, fmc_Cultivation, fmc_Cutting, fmc_Fertilizer, fmc_Harvest, fmc_Others, fmc_Watering, Crop::m_base_elements_no, and Crop::m_ManagementCategories.

Referenced by DK_OSpringOats().


The documentation for this class was generated from the following files:
LE::GetMDates
int GetMDates(int a, int b)
Definition: Elements.h:405
FarmEvent::m_forcespring
bool m_forcespring
Definition: Farm.h:392
DK_OSpringOats::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: DK_OSpringOats.h:75
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
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::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
dk_oso_strigling2
Definition: DK_OSpringOats.h:52
LE::ClearManagementActionSum
void ClearManagementActionSum()
clears the management action counters
Definition: Elements.h:247
dk_oso_strigling1
Definition: DK_OSpringOats.h:51
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
dk_oso_spring_plough
Definition: DK_OSpringOats.h:49
dk_oso_slurry_s
Definition: DK_OSpringOats.h:47
dk_oso_roll
Definition: DK_OSpringOats.h:53
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
tov_DKOSpringOats
Definition: LandscapeFarmingEnums.h:398
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
dk_oso_swathing
Definition: DK_OSpringOats.h:57
DK_OSO_BASE
#define DK_OSO_BASE
Definition: DK_OSpringOats.h:41
dk_oso_start
Definition: DK_OSpringOats.h:44
dk_oso_harvest
Definition: DK_OSpringOats.h:58
dk_oso_slurry_p
Definition: DK_OSpringOats.h:48
Crop::SimpleEvent
void SimpleEvent(long a_date, int a_todo, bool a_lock)
Adds an event to this crop management.
Definition: Farm.cpp:747
dk_oso_hay_bailing
Definition: DK_OSpringOats.h:59
fmc_Cutting
Definition: LandscapeFarmingEnums.h:1009
fmc_Fertilizer
Definition: LandscapeFarmingEnums.h:1004
dk_oso_spring_sow
Definition: DK_OSpringOats.h:50
dk_oso_row_cultivation
Definition: DK_OSpringOats.h:55
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
dk_oso_straw_chopping
Definition: DK_OSpringOats.h:60
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
fmc_Watering
Definition: LandscapeFarmingEnums.h:1011
Calendar::OldDays
long OldDays(void)
Definition: Calendar.h:60
dk_oso_water
Definition: DK_OSpringOats.h:56
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
DK_OSO_FORCESPRING
#define DK_OSO_FORCESPRING
Definition: DK_OSpringOats.h:39
dk_oso_spring_harrow2
Definition: DK_OSpringOats.h:46
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
Farm::FP_Slurry
virtual bool FP_Slurry(LE *a_field, double a_user, int a_days)
Apply slurry to a_field owned by an arable farmer.
Definition: FarmFuncs.cpp:823
dk_oso_spring_harrow1
Definition: DK_OSpringOats.h:45
Farm::RowCultivation
virtual bool RowCultivation(LE *a_field, double a_user, int a_days)
Carry out a harrowing between crop rows on a_field.
Definition: FarmFuncs.cpp:1183
Farm::Water
virtual bool Water(LE *a_field, double a_user, int a_days)
Carry out a watering on a_field.
Definition: FarmFuncs.cpp:1330
Crop::m_last_date
int m_last_date
Definition: Farm.h:503
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
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
Farm::Swathing
virtual bool Swathing(LE *a_field, double a_user, int a_days)
Cut the crop on a_field and leave it lying (probably rape)
Definition: FarmFuncs.cpp:1350
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
dk_oso_weed_harrow
Definition: DK_OSpringOats.h:54
dk_oso_foobar
Definition: DK_OSpringOats.h:61
WARN_BUG
Definition: MapErrorMsg.h:34
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