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

#include <DK_OWinterRape.h>

Inheritance diagram for DK_OWinterRape:
Crop

Public Member Functions

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

DK_OWinterRape::DK_OWinterRape ( TTypesOfVegetation  a_tov,
TTypesOfCrops  a_toc,
Landscape a_L 
)
inline
73  : Crop(a_tov, a_toc, a_L)
74  {
75  m_first_date = g_date->DayInYear(15, 8);
77  }

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

Member Function Documentation

◆ Do()

bool DK_OWinterRape::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_oosr_start:
43  {
44  a_field->ClearManagementActionSum();
45  DK_OOSR_EARLY_SLURRY = false;
46  DK_OOSR_ROW_SOW = false;
47  m_last_date = g_date->DayInYear(10, 8); // Should match the last flexdate below
48  //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
49  std::vector<std::vector<int>> flexdates(1 + 1, std::vector<int>(2, 0));
50  // Set up the date management stuff
51  // Start and stop dates for all events after harvest
52  flexdates[0][1] = g_date->DayInYear(9, 8); // last possible day
53  // Now these are done in pairs, start & end for each operation. If its not used then -1
54  flexdates[1][0] = -1; // This date will be moved back as far as necessary and potentially to flexdates 1 (start op 1)
55  flexdates[1][1] = g_date->DayInYear(10, 8); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 1)
56 
57  // 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
58  int isSpring = 0;
59  if (StartUpCrop(isSpring, flexdates, int(dk_oosr_ferti_s))) break;
60 
61  // End single block date checking code. Please see next line comment as well.
62  // Reinit d1 to first possible starting date.
63  d1 = g_date->OldDays() + g_date->DayInYear(1, 7) + isSpring;
64  // OK, let's go.
66  }
67  break;
68 
70  if (!m_farm->AutumnHarrow(m_field, 0.0,
71  g_date->DayInYear(15, 8) - g_date->DayInYear())) {
73  break;
74  }
76  break;
77 
79  if (!m_farm->AutumnHarrow(m_field, 0.0,
80  g_date->DayInYear(16, 8) - g_date->DayInYear())) {
82  break;
83  }
84  SimpleEvent(g_date->Date() + 1, dk_oosr_slurry_s1, false);
85  break;
86 
87  case dk_oosr_slurry_s1:
88  if (m_ev->m_lock || m_farm->DoIt_prob(0.75)) { // 75% do slurry now
89  if (a_farm->IsStockFarmer()) {
90  if (!m_farm->FA_Slurry(m_field, 0.0,
91  g_date->DayInYear(17, 8) - g_date->DayInYear())) {
93  break;
94  }
96  break;
97  }
98  DK_OOSR_EARLY_SLURRY = true;
100  break;
101  }
103  break;
104 
105  case dk_oosr_slurry_p1:
106  if (!m_farm->FP_Slurry(m_field, 0.0,
107  g_date->DayInYear(17, 8) - g_date->DayInYear())) {
108  SimpleEvent(g_date->Date() + 1, dk_oosr_slurry_p1, true);
109  break;
110  }
112  break;
113 
115  if (!m_farm->AutumnPlough(m_field, 0.0,
116  g_date->DayInYear(19, 8) - g_date->DayInYear())) {
118  break;
119  }
121  break;
122 
124  if (m_ev->m_lock || m_farm->DoIt_prob(0.80)) {
126  g_date->DayInYear(20, 8) - g_date->DayInYear())) {
128  break;
129  }
130  DK_OOSR_ROW_SOW = true;
131  SimpleEvent(g_date->OldDays() + g_date->DayInYear(1, 9), dk_oosr_slurry_s2, false); // ferti thread - main thread
132  SimpleEvent(g_date->OldDays() + g_date->DayInYear(15, 9), dk_oosr_row_cultivation1, false); // row cultivation thread
133  break;
134  }
135  SimpleEvent(g_date->Date() + 1, dk_oosr_sow, false);
136  break;
137 
138  case dk_oosr_sow:
139  if (!m_farm->AutumnSow(m_field, 0.0,
140  g_date->DayInYear(20, 8) - g_date->DayInYear())) {
141  SimpleEvent(g_date->Date() + 1, dk_oosr_sow, true);
142  break;
143  }
145  break;
146 
148  if (!m_farm->RowCultivation(m_field, 0.0,
149  g_date->DayInYear(10, 10) - g_date->DayInYear())) {
151  break;
152  }
153  break; // end of thread
154 
155  case dk_oosr_slurry_s2:
156  if (a_farm->IsStockFarmer()) {
157  if (DK_OOSR_EARLY_SLURRY == false) { // 25% do slurry now (not done before sowing)
158  if (!m_farm->FA_Slurry(m_field, 0.0,
159  g_date->DayInYear(30, 9) - g_date->DayInYear())) {
160  SimpleEvent(g_date->Date() + 1, dk_oosr_slurry_s2, true);
161  break;
162  }
163  }
164  SimpleEvent(g_date->OldDays() + g_date->DayInYear(1, 3) + 365, dk_oosr_ferti_s, false);
165  break;
166  }
168  break;
169 
170  case dk_oosr_slurry_p2:
171  if (DK_OOSR_EARLY_SLURRY == false) { // 25% do slurry now (not done before sowing)
172  if (!m_farm->FP_Slurry(m_field, 0.0,
173  g_date->DayInYear(29, 9) - g_date->DayInYear())) {
174  SimpleEvent(g_date->Date() + 1, dk_oosr_slurry_p2, true);
175  break;
176  }
177  }
178  SimpleEvent(g_date->OldDays() + g_date->DayInYear(1, 3) + 365, dk_oosr_ferti_p, false);
179  break;
180 
181  case dk_oosr_ferti_s:
182  if (m_ev->m_lock || m_farm->DoIt_prob(0.5)) { // 50% can do this
184  g_date->DayInYear(29, 3) - g_date->DayInYear())) {
185  SimpleEvent(g_date->Date() + 1, dk_oosr_ferti_s, true);
186  break;
187  }
188  SimpleEvent(g_date->Date() + 1, dk_oosr_slurry_s3, false);
189  break;
190  }
192  break;
193 
194  case dk_oosr_ferti_p:
195  if (m_ev->m_lock || m_farm->DoIt_prob(0.5)) { // 50% can do this
197  g_date->DayInYear(29, 3) - g_date->DayInYear())) {
198  SimpleEvent(g_date->Date() + 1, dk_oosr_ferti_p, true);
199  break;
200  }
201  SimpleEvent(g_date->Date() + 1, dk_oosr_slurry_p3, false);
202  break;
203  }
205  break;
206 
207  case dk_oosr_slurry_s3: // same 50%
208  if (!m_farm->FA_Slurry(m_field, 0.0,
209  g_date->DayInYear(30, 3) - g_date->DayInYear())) {
210  SimpleEvent(g_date->Date() + 1, dk_oosr_slurry_s3, true);
211  break;
212  }
214  break;
215 
216  case dk_oosr_slurry_p3: // same 50%
217  if (!m_farm->FP_Slurry(m_field, 0.0,
218  g_date->DayInYear(30, 3) - g_date->DayInYear())) {
219  SimpleEvent(g_date->Date() + 1, dk_oosr_slurry_p3, true);
220  break;
221  }
223  break;
224 
226  if (m_ev->m_lock || m_farm->DoIt_prob(0.2)) { // 20% do this
227  if (!m_farm->RowCultivation(m_field, 0.0,
228  g_date->DayInYear(31, 3) - g_date->DayInYear())) {
230  break;
231  }
232  }
233  SimpleEvent(g_date->OldDays() + g_date->DayInYear(10, 4), dk_oosr_water, false);
234  break;
235 
236  case dk_oosr_water:
237  if (m_ev->m_lock || m_farm->DoIt_prob(0.50)) {
238  if (!m_farm->Water(m_field, 0.0,
239  g_date->DayInYear(20, 4) - g_date->DayInYear())) {
240  SimpleEvent(g_date->Date() + 1, dk_oosr_water, true);
241  break;
242  }
243  }
245  break;
246 
247  case dk_oosr_swathing:
248  if (!m_farm->Swathing(m_field, 0.0, m_field->GetMDates(1, 0) - g_date->DayInYear())) {
249  SimpleEvent(g_date->Date() + 1, dk_oosr_swathing, true);
250  break;
251  }
252  SimpleEvent(g_date->Date() + 1, dk_oosr_harvest, false);
253  break;
254 
255  case dk_oosr_harvest:
256  if (!m_farm->Harvest(m_field, 0.0, m_field->GetMDates(1, 1) - g_date->DayInYear())) {
257  SimpleEvent(g_date->Date() + 1, dk_oosr_harvest, true);
258  break;
259  }
260  done = true;
261  break;
262 
263  default:
264  g_msg->Warn( WARN_BUG, "DK_OWinterRape::Do(): "
265  "Unknown event type! ", "" );
266  exit( 1 );
267  }
268 
269  return done;
270 }

References Farm::AutumnHarrow(), Farm::AutumnPlough(), Farm::AutumnSow(), LE::ClearManagementActionSum(), Calendar::Date(), Calendar::DayInYear(), dk_oosr_autumn_harrow1, dk_oosr_autumn_harrow2, dk_oosr_autumn_plough, dk_oosr_cultivator_sow, DK_OOSR_EARLY_SLURRY, dk_oosr_ferti_p, dk_oosr_ferti_s, dk_oosr_harvest, dk_oosr_row_cultivation1, dk_oosr_row_cultivation2, DK_OOSR_ROW_SOW, dk_oosr_slurry_p1, dk_oosr_slurry_p2, dk_oosr_slurry_p3, dk_oosr_slurry_s1, dk_oosr_slurry_s2, dk_oosr_slurry_s3, dk_oosr_sow, dk_oosr_start, dk_oosr_swathing, dk_oosr_water, Farm::DoIt_prob(), Farm::FA_AmmoniumSulphate(), Farm::FA_Slurry(), Farm::FP_AmmoniumSulphate(), Farm::FP_Slurry(), g_date, g_msg, LE::GetMDates(), Farm::Harvest(), Farm::IsStockFarmer(), Crop::m_ev, Crop::m_farm, Crop::m_field, Crop::m_last_date, FarmEvent::m_lock, FarmEvent::m_todo, Calendar::OldDays(), Farm::PreseedingCultivatorSow(), Farm::RowCultivation(), Crop::SimpleEvent(), Crop::StartUpCrop(), Farm::Swathing(), tov_DKOWinterRape, MapErrorMsg::Warn(), WARN_BUG, and Farm::Water().

◆ SetUpFarmCategoryInformation()

void DK_OWinterRape::SetUpFarmCategoryInformation ( )
inline
78  {
79  const int elements = 2 + (dk_oosr_foobar - DK_OOSR_BASE);
81 
82  FarmManagementCategory catlist[elements] =
83  {
84  fmc_Others, // zero element unused but must be here
85  fmc_Others, // dk_oosr_start = 1, // Compulsory, start event must always be 1 (one).
86  fmc_Cultivation, // dk_oosr_autumn_harrow1 = DK_OOSR_BASE,
87  fmc_Cultivation, // dk_oosr_autumn_harrow2,
88  fmc_Fertilizer, // dk_oosr_slurry_s1,
89  fmc_Fertilizer, // dk_oosr_slurry_p1,
90  fmc_Cultivation, // dk_oosr_autumn_plough,
91  fmc_Cultivation, // dk_oosr_cultivator_sow, // if row sown
92  fmc_Others, // dk_oosr_sow,
93  fmc_Cultivation, // dk_oosr_row_cultivation1,
94  fmc_Fertilizer, // dk_oosr_slurry_s2,
95  fmc_Fertilizer, // dk_oosr_slurry_p2,
96  fmc_Fertilizer, // dk_oosr_ferti_s,
97  fmc_Fertilizer, // dk_oosr_ferti_p,
98  fmc_Fertilizer, // dk_oosr_slurry_s3,
99  fmc_Fertilizer, // dk_oosr_slurry_p3,
100  fmc_Cultivation, // dk_oosr_row_cultivation2,
101  fmc_Watering, // dk_oosr_water,
102  fmc_Cutting, // dk_oosr_swathing,
103  fmc_Harvest, // dk_oosr_harvest,
104  };
105  // Iterate over the catlist elements and copy them to vector
106  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
107  }

References DK_OOSR_BASE, dk_oosr_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_OWinterRape().


The documentation for this class was generated from the following files:
LE::GetMDates
int GetMDates(int a, int b)
Definition: Elements.h:405
dk_oosr_slurry_s2
Definition: DK_OWinterRape.h:54
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::IsStockFarmer
bool IsStockFarmer(void)
Definition: Farm.h:961
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
dk_oosr_slurry_s3
Definition: DK_OWinterRape.h:58
FarmEvent::m_lock
bool m_lock
Definition: Farm.h:384
LE::ClearManagementActionSum
void ClearManagementActionSum()
clears the management action counters
Definition: Elements.h:247
tov_DKOWinterRape
Definition: LandscapeFarmingEnums.h:402
dk_oosr_row_cultivation2
Definition: DK_OWinterRape.h:60
DK_OOSR_BASE
#define DK_OOSR_BASE
Definition: DK_OWinterRape.h:42
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_oosr_start
Definition: DK_OWinterRape.h:45
dk_oosr_foobar
Definition: DK_OWinterRape.h:64
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_oosr_autumn_harrow1
Definition: DK_OWinterRape.h:46
Crop::SimpleEvent
void SimpleEvent(long a_date, int a_todo, bool a_lock)
Adds an event to this crop management.
Definition: Farm.cpp:747
fmc_Cutting
Definition: LandscapeFarmingEnums.h:1009
dk_oosr_autumn_harrow2
Definition: DK_OWinterRape.h:47
fmc_Fertilizer
Definition: LandscapeFarmingEnums.h:1004
DK_OWinterRape::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: DK_OWinterRape.h:78
dk_oosr_sow
Definition: DK_OWinterRape.h:52
Calendar::Date
long Date(void)
Definition: Calendar.h:57
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
dk_oosr_harvest
Definition: DK_OWinterRape.h:63
fmc_Others
Definition: LandscapeFarmingEnums.h:1003
fmc_Watering
Definition: LandscapeFarmingEnums.h:1011
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
dk_oosr_slurry_p2
Definition: DK_OWinterRape.h:55
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_oosr_slurry_p3
Definition: DK_OWinterRape.h:59
dk_oosr_slurry_s1
Definition: DK_OWinterRape.h:48
Crop::m_farm
Farm * m_farm
Definition: Farm.h:498
dk_oosr_ferti_p
Definition: DK_OWinterRape.h:57
Crop::m_field
LE * m_field
Definition: Farm.h:499
dk_oosr_autumn_plough
Definition: DK_OWinterRape.h:50
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
dk_oosr_water
Definition: DK_OWinterRape.h:61
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
dk_oosr_ferti_s
Definition: DK_OWinterRape.h:56
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
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
dk_oosr_row_cultivation1
Definition: DK_OWinterRape.h:53
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
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
Farm::AutumnHarrow
virtual bool AutumnHarrow(LE *a_field, double a_user, int a_days)
Carry out a harrow event in the autumn on a_field.
Definition: FarmFuncs.cpp:285
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
TTypesOfVegetation
TTypesOfVegetation
Values that represent the types of vegetation that are represented in ALMaSS.
Definition: LandscapeFarmingEnums.h:192
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
dk_oosr_swathing
Definition: DK_OWinterRape.h:62
fmc_Harvest
Definition: LandscapeFarmingEnums.h:1012
dk_oosr_slurry_p1
Definition: DK_OWinterRape.h:49
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
DK_OOSR_ROW_SOW
#define DK_OOSR_ROW_SOW
Definition: DK_OWinterRape.h:40
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
DK_OOSR_EARLY_SLURRY
#define DK_OOSR_EARLY_SLURRY
Definition: DK_OWinterRape.h:39
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
WARN_BUG
Definition: MapErrorMsg.h:34
FarmManagementCategory
FarmManagementCategory
Definition: LandscapeFarmingEnums.h:1001
dk_oosr_cultivator_sow
Definition: DK_OWinterRape.h:51