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

#include <DK_OSpringWheat.h>

Inheritance diagram for DK_OSpringWheat:
Crop

Public Member Functions

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

DK_OSpringWheat::DK_OSpringWheat ( TTypesOfVegetation  a_tov,
TTypesOfCrops  a_toc,
Landscape a_L 
)
inline
70  : Crop(a_tov, a_toc, a_L)
71  {
72  m_first_date = g_date->DayInYear(28, 3);
74  }

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

Member Function Documentation

◆ Do()

bool DK_OSpringWheat::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_osw_start:
43  {
44  a_field->ClearManagementActionSum();
45  DK_OSW_FORCESPRING = false;
46  m_last_date = g_date->DayInYear(30, 9); // Should match the last flexdate below
47  //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
48  std::vector<std::vector<int>> flexdates(1 + 3, std::vector<int>(2, 0));
49  // Set up the date management stuff
50  // Start and stop dates for all events after harvest
51  flexdates[0][1] = g_date->DayInYear(28, 9); // last possible day of swathing
52  // Now these are done in pairs, start & end for each operation. If its not used then -1
53  flexdates[1][0] = -1; // This date will be moved back as far as necessary and potentially to flexdates 1 (start op 1)
54  flexdates[1][1] = g_date->DayInYear(29, 9); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 1) // harvest
55  flexdates[2][0] = -1;
56  flexdates[2][1] = g_date->DayInYear(30, 9); // hay bailing
57  flexdates[3][0] = -1;
58  flexdates[3][1] = g_date->DayInYear(30, 9); // straw chopping
59 
60 
61  // 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
62  int isSpring = 365;
63  if (StartUpCrop(isSpring, flexdates, int(dk_osw_spring_harrow1))) break;
64 
65  // End single block date checking code. Please see next line comment as well.
66  // Reinit d1 to first possible starting date.
67  d1 = g_date->OldDays() + g_date->DayInYear(1, 2) + isSpring;
68  if (m_ev->m_forcespring) {
69  int day_num_shift = 365;
70  if (g_date->DayInYear() < 70) day_num_shift = 0;
71  SimpleEvent(g_date->OldDays() + g_date->DayInYear(1, 2) + day_num_shift, dk_osw_spring_harrow1, false);
72  DK_OSW_FORCESPRING = true;
73  break;
74  }
75  else
76  // OK, let's go.
78  }
79  break;
80 
82  if (m_ev->m_lock || m_farm->DoIt_prob(1.0)) {
83  if (!m_farm->SpringHarrow(m_field, 0.0,
84  g_date->DayInYear(28, 3) - g_date->DayInYear())) {
86  break;
87  }
88  }
90  break;
91 
93  if (m_ev->m_lock || m_farm->DoIt_prob(0.5)) { // put to 50% as 100% harrow 1-2 times
94  if (!m_farm->SpringHarrow(m_field, 0.0,
95  g_date->DayInYear(30, 3) - g_date->DayInYear())) {
97  break;
98  }
99  }
100  SimpleEvent(g_date->Date() + 1, dk_osw_slurry_s, false);
101  break;
102 
103  case dk_osw_slurry_s:
104  if (a_farm->IsStockFarmer()) {
105  if (!m_farm->FA_Slurry(m_field, 0.0,
106  g_date->DayInYear(31, 3) - g_date->DayInYear())) {
107  SimpleEvent(g_date->Date() + 1, dk_osw_slurry_s, true);
108  break;
109  }
111  break;
112  }
113  SimpleEvent(g_date->Date() + 1, dk_osw_slurry_p, false);
114  break;
115 
116  case dk_osw_slurry_p:
117  if (!m_farm->FP_Slurry(m_field, 0.0,
118  g_date->DayInYear(31, 3) - g_date->DayInYear())) {
119  SimpleEvent(g_date->Date() + 1, dk_osw_slurry_p, true);
120  break;
121  }
123  break;
124 
126  if (!m_farm->SpringPlough(m_field, 0.0,
127  g_date->DayInYear(30, 4) - g_date->DayInYear())) {
129  break;
130  }
131  SimpleEvent(g_date->Date() + 1, dk_osw_spring_sow, false);
132  break;
133 
134  case dk_osw_spring_sow:
135  if (!m_farm->SpringSow(m_field, 0.0,
136  g_date->DayInYear(1, 5) - g_date->DayInYear())) {
137  SimpleEvent(g_date->Date() + 1, dk_osw_spring_sow, true);
138  break;
139  }
140  SimpleEvent(g_date->Date() + 3, dk_osw_strigling1, false);
141  break;
142 
143  case dk_osw_strigling1:
144  if (!m_farm->Strigling(m_field, 0.0,
145  g_date->DayInYear(4, 5) - g_date->DayInYear())) {
146  SimpleEvent(g_date->Date() + 1, dk_osw_strigling1, true);
147  break;
148  }
149  SimpleEvent(g_date->Date() + 3, dk_osw_strigling2, false);
150  break;
151 
152  case dk_osw_strigling2:
153  if (!m_farm->Strigling(m_field, 0.0,
154  g_date->DayInYear(7, 5) - g_date->DayInYear())) {
155  SimpleEvent(g_date->Date() + 1, dk_osw_strigling2, true);
156  break;
157  }
158  SimpleEvent(g_date->Date() + 1, dk_osw_roll, false);
159  break;
160 
161  case dk_osw_roll:
162  if (m_ev->m_lock || m_farm->DoIt_prob(0.5)) {
163  if (!m_farm->SpringRoll(m_field, 0.0,
164  g_date->DayInYear(8, 5) - g_date->DayInYear())) {
165  SimpleEvent(g_date->Date() + 1, dk_osw_roll, true);
166  break;
167  }
168  }
169  SimpleEvent(g_date->Date() + 7, dk_osw_weed_harrow, false);
170  break;
171 
172  case dk_osw_weed_harrow:
173  if (m_ev->m_lock || m_farm->DoIt_prob(0.8)) { // 80% do weed harrow, 20% row cultivation (as 20% row sow)
174  if (!m_farm->SpringHarrow(m_field, 0.0,
175  g_date->DayInYear(16, 5) - g_date->DayInYear())) {
176  SimpleEvent(g_date->Date() + 1, dk_osw_weed_harrow, true);
177  break;
178  }
179  SimpleEvent(g_date->OldDays() + g_date->DayInYear(1, 7), dk_osw_water, false);
180  break;
181  }
183  break;
184 
185  case dk_osw_row_cultivation:// 80% do weed harrow, 20% row cultivation (as 20% row sow)
186  if (!m_farm->RowCultivation(m_field, 0.0,
187  g_date->DayInYear(16, 5) - g_date->DayInYear())) {
189  break;
190  }
191  SimpleEvent(g_date->OldDays() + g_date->DayInYear(1, 7), dk_osw_water, false);
192  break;
193 
194  case dk_osw_water:
195  if (m_ev->m_lock || m_farm->DoIt_prob(0.50)) {
196  if (!m_farm->Water(m_field, 0.0,
197  g_date->DayInYear(31, 7) - g_date->DayInYear())) {
198  SimpleEvent(g_date->Date() + 1, dk_osw_water, true);
199  break;
200  }
201  }
203  break;
204 
205  case dk_osw_swathing:
206  if (m_ev->m_lock || m_farm->DoIt_prob(0.1)) { // est. 10%
207  if (!m_farm->Swathing(m_field, 0.0, m_field->GetMDates(1, 0) - g_date->DayInYear())) {
208  SimpleEvent(g_date->Date() + 1, dk_osw_swathing, true);
209  break;
210  }
211  SimpleEvent(g_date->Date() + 1, dk_osw_harvest, false);
212  break;
213  }
215  break;
216 
217  case dk_osw_harvest:
218  if (!m_farm->Harvest(m_field, 0.0, m_field->GetMDates(1, 1) - g_date->DayInYear())) {
219  SimpleEvent(g_date->Date() + 1, dk_osw_harvest, true);
220  break;
221  }
222  SimpleEvent(g_date->Date() + 1, dk_osw_hay_bailing, false);
223  break;
224 
225  case dk_osw_hay_bailing:
226  if (m_ev->m_lock || m_farm->DoIt_prob(0.9)) { // est. 90%
227  if (!m_farm->HayBailing(m_field, 0.0, m_field->GetMDates(1, 2) - g_date->DayInYear())) {
228  SimpleEvent(g_date->Date() + 1, dk_osw_hay_bailing, true);
229  break;
230  }
231  done = true;
232  break;
233  }
235  break;
236 
238  if (!m_farm->StrawChopping(m_field, 0.0, m_field->GetMDates(1, 3) - g_date->DayInYear())) {
240  break;
241  }
242 
243  done = true;
244  break;
245 
246  default:
247  g_msg->Warn( WARN_BUG, "DK_OSpringWheat::Do(): "
248  "Unknown event type! ", "" );
249  exit( 1 );
250  }
251  if (done) m_ev->m_forcespring = true; // Here we need to force the next crop to spring operation, so set the ev->forcespring to true
252  return done;
253 }

References LE::ClearManagementActionSum(), Calendar::Date(), Calendar::DayInYear(), DK_OSW_FORCESPRING, dk_osw_harvest, dk_osw_hay_bailing, dk_osw_roll, dk_osw_row_cultivation, dk_osw_slurry_p, dk_osw_slurry_s, dk_osw_spring_harrow1, dk_osw_spring_harrow2, dk_osw_spring_plough, dk_osw_spring_sow, dk_osw_start, dk_osw_straw_chopping, dk_osw_strigling1, dk_osw_strigling2, dk_osw_swathing, dk_osw_water, dk_osw_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_DKSpringWheat, MapErrorMsg::Warn(), WARN_BUG, and Farm::Water().

◆ SetUpFarmCategoryInformation()

void DK_OSpringWheat::SetUpFarmCategoryInformation ( )
inline
75  {
76  const int elements = 2 + (dk_osw_foobar - DK_OSW_BASE);
78 
79  FarmManagementCategory catlist[elements] =
80  {
81  fmc_Others, // zero element unused but must be here
82  fmc_Others, // dk_osw_start = 1, // Compulsory, start event must always be 1 (one).
83  fmc_Cultivation, //dk_osw_spring_harrow1 = DK_OSW_BASE,
84  fmc_Cultivation, //dk_osw_spring_harrow2,
85  fmc_Fertilizer, //dk_osw_slurry_s,
86  fmc_Fertilizer, //dk_osw_slurry_p,
87  fmc_Cultivation, //dk_osw_spring_plough,
88  fmc_Others, //dk_osw_spring_sow,
89  fmc_Cultivation, //dk_osw_strigling1,
90  fmc_Cultivation, // dk_osw_strigling2,
91  fmc_Others, // dk_osw_roll,
92  fmc_Cultivation, // dk_osw_weed_harrow,
93  fmc_Cultivation, // dk_osw_row_cultivation,
94  fmc_Watering, // dk_osw_water,
95  fmc_Cutting, // dk_osw_swathing,
96  fmc_Harvest, // dk_osw_harvest,
97  fmc_Others, // dk_osw_hay_bailing,
98  fmc_Cutting, // dk_osw_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_OSW_BASE, dk_osw_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_OSpringWheat().


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
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
dk_osw_spring_harrow1
Definition: DK_OSpringWheat.h:45
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
dk_osw_spring_sow
Definition: DK_OSpringWheat.h:50
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_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::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
dk_osw_slurry_p
Definition: DK_OSpringWheat.h:48
Crop::m_base_elements_no
int m_base_elements_no
Definition: Farm.h:505
DK_OSW_BASE
#define DK_OSW_BASE
Definition: DK_OSpringWheat.h:41
Crop::m_first_date
int m_first_date
Definition: Farm.h:501
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_osw_row_cultivation
Definition: DK_OSpringWheat.h:55
dk_osw_spring_harrow2
Definition: DK_OSpringWheat.h:46
fmc_Cutting
Definition: LandscapeFarmingEnums.h:1009
fmc_Fertilizer
Definition: LandscapeFarmingEnums.h:1004
DK_OSW_FORCESPRING
#define DK_OSW_FORCESPRING
Definition: DK_OSpringWheat.h:39
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_osw_spring_plough
Definition: DK_OSpringWheat.h:49
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_osw_slurry_s
Definition: DK_OSpringWheat.h:47
MapErrorMsg::Warn
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: MapErrorMsg.cpp:69
dk_osw_start
Definition: DK_OSpringWheat.h:44
dk_osw_strigling1
Definition: DK_OSpringWheat.h:51
dk_osw_roll
Definition: DK_OSpringWheat.h:53
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_OSpringWheat::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: DK_OSpringWheat.h:75
dk_osw_swathing
Definition: DK_OSpringWheat.h:57
dk_osw_foobar
Definition: DK_OSpringWheat.h:61
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_osw_harvest
Definition: DK_OSpringWheat.h:58
dk_osw_strigling2
Definition: DK_OSpringWheat.h:52
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
dk_osw_hay_bailing
Definition: DK_OSpringWheat.h:59
dk_osw_weed_harrow
Definition: DK_OSpringWheat.h:54
Calendar::DayInYear
int DayInYear(void)
Definition: Calendar.h:58
dk_osw_water
Definition: DK_OSpringWheat.h:56
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
tov_DKSpringWheat
Definition: LandscapeFarmingEnums.h:414
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
dk_osw_straw_chopping
Definition: DK_OSpringWheat.h:60
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