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

#include <DE_OWinterRape.h>

Inheritance diagram for DE_OWinterRape:
Crop

Public Member Functions

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

◆ DE_OWinterRape()

DE_OWinterRape::DE_OWinterRape ( TTypesOfVegetation  a_tov,
TTypesOfCrops  a_toc,
Landscape a_L 
)
inline
67  : Crop(a_tov, a_toc, a_L)
68  {
71  }

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

Member Function Documentation

◆ Do()

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

Reimplemented from Crop.

32 {
33  /******************** This block can be added to the top of all Crop::Do methods ***********************************************/
34  m_farm = a_farm; // These assignments are necessary, not for this method but for related event calls
35  m_field = a_field;
36  m_ev = a_ev;
37  bool done = false; // The boolean value done indicates when we are totally finished with this plan (i.e. it is set to true).
38  int d1 = 0;
39  int noDates = 1;
40  TTypesOfVegetation l_tov = tov_DEOWinterRape; // The current type - change to match the crop you have
41 /**********************************************To Here *************************************************************************/
42 
43  // Depending what event has occured jump to the correct bit of code
44  switch (m_ev->m_todo)
45  {
46  case de_owr_start:
47  {
49 
50  m_last_date = g_date->DayInYear(15, 8); // Should match the last flexdate below
51  //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
52  std::vector<std::vector<int>> flexdates(2 + 1, std::vector<int>(2, 0));
53  // Set up the date management stuff
54  // Start and stop dates for all events after harvest
55  flexdates[0][1] = g_date->DayInYear(1, 8); // last possible day of harvest - this is in effect day before the earliest date that a following crop can use
56  // Now these are done in pairs, start & end for each operation. If its not used then -1
57  flexdates[1][0] = -1; // This date will be moved back as far as necessary and potentially to flexdates 1 (start op 1)
58  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)
59  flexdates[2][0] = -1; // This date will be moved back as far as necessary and potentially to flexdates 1 (start op 1)
60  flexdates[2][1] = g_date->DayInYear(15, 8); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 2)
61 
62  // 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
63  int isSpring = 0;
64  if (StartUpCrop(isSpring, flexdates, int(de_owr_row_cultivation_three))) break;
65 
66  // End single block date checking code. Please see next line comment as well.
67  // Reinit d1 to first possible starting date.
68  d1 = g_date->OldDays() + g_date->DayInYear(1, 8) + isSpring;
69  // OK, let's go.
70  if (m_farm->IsStockFarmer()) {
72  }
73  else
75  break;
76  }
77  break;
78 
79  case de_owr_fa_manure:
80  if ( m_ev->m_lock || m_farm->DoIt( 75 )) {
81  if (!m_farm->FA_Manure( m_field, 0.0, g_date->DayInYear( 25, 8 ) - g_date->DayInYear())) {
83  break;
84  }
85  }
87  break;
88 
89  case de_owr_fp_manure:
90  if ( m_ev->m_lock || m_farm->DoIt( 50 )) {
91  if (!m_farm->FP_Manure( m_field, 0.0, g_date->DayInYear( 25, 8 ) - g_date->DayInYear())) {
93  break;
94  }
95  }
97  break;
98 
100  if (!m_farm->AutumnPlough( m_field, 0.0, g_date->DayInYear( 25, 8 ) - g_date->DayInYear())) {
102  break;
103  }
105  break;
106 
108  if (!m_farm->AutumnHarrow( m_field, 0.0, g_date->DayInYear( 27, 8 ) - g_date->DayInYear())) {
110  break;
111  }
113  break;
114 
115  case de_owr_autumn_sow:
116  if (!m_farm->AutumnSow( m_field, 0.0, g_date->DayInYear( 10, 9 ) - g_date->DayInYear())) {
118  break;
119  }
121  break;
122 
124  if (!m_farm->RowCultivation( m_field, 0.0, g_date->DayInYear( 30, 9 ) - g_date->DayInYear())) {
126  break;
127  }
128  d1 = g_date->Date() + 7;
129  if ( d1 < g_date->OldDays() + g_date->DayInYear( 8, 10 ))
130  d1 = g_date->OldDays() + g_date->DayInYear( 8, 10 );
132  break;
133 
135  if (m_ev->m_lock || m_farm->DoIt(40)) {
136  if (!m_farm->RowCultivation( m_field, 0.0, g_date->DayInYear( 10, 10 ) - g_date->DayInYear())) {
138  break;
139  }
140  }
141  if (m_farm->IsStockFarmer()) //Stock Farmer Sulphur treatment
142  {
143  SimpleEvent_(g_date->OldDays() + g_date->DayInYear(15, 10), de_owr_fertiFA_S, false, m_farm, m_field); // Sulphur
144  }
145  else SimpleEvent_(g_date->OldDays() + g_date->DayInYear(15, 10), de_owr_fertiFP_S, false, m_farm, m_field); // Sulphur
146  break;
147 
148  case de_owr_fertiFP_S:
149  // Here comes the sulphur for arable farms
150  if (!m_farm->FP_ManganeseSulphate(m_field, 0.0, g_date->DayInYear(30, 10) - g_date->DayInYear())) {
152  break;
153  }
155  break;
156 
157  case de_owr_fertiFA_S:
158  // Here comes the sulphur thread for stock farms
159  if (!m_farm->FA_ManganeseSulphate(m_field, 0.0, g_date->DayInYear(30, 10) - g_date->DayInYear())) {
161  break;
162  }
164  break;
165 
166  case de_owr_fertiFP_B:
167  if (!m_farm->FP_Boron(m_field, 0.0, g_date->DayInYear(30, 10) - g_date->DayInYear())) {
169  break;
170  }
172  break;
173 
174  case de_owr_fertiFA_B:
175  if (!m_farm->FA_Boron(m_field, 0.0, g_date->DayInYear(30, 10) - g_date->DayInYear())) {
177  break;
178  }
180  break;
181 
183  if (!m_farm->RowCultivation( m_field, 0.0, g_date->DayInYear( 30, 4 ) - g_date->DayInYear())) {
185  break;
186  }
187  d1 = g_date->Date() + 5;
188  if ( d1 < g_date->OldDays() + g_date->DayInYear( 10, 7 ))
189  d1 = g_date->OldDays() + g_date->DayInYear( 10, 7 );
190  SimpleEvent_( d1, de_owr_harvest, false, m_farm, m_field);
191  break;
192 
193  case de_owr_harvest:
194  if ( !m_farm->Harvest( m_field, 0.0, m_field->GetMDates(1, 0) - g_date->DayInYear())) {
196  break;
197  }
199  break;
200 
201  case de_owr_straw_chop:
202  if ( !m_farm->StrawChopping( m_field, 0.0, m_field->GetMDates(1, 1) - g_date->DayInYear())) {
204  break;
205  }
206  d1 = g_date->Date() + 1;
207  if ( d1 < g_date->OldDays() + g_date->DayInYear( 15, 7 ))
208  d1 = g_date->OldDays() + g_date->DayInYear( 15, 7 );
210  break;
211 
212  case de_owr_stub_harrow:
213  if ( m_ev->m_lock || m_farm->DoIt( 75 )) {
214  if ( !m_farm->StubbleHarrowing( m_field, 0.0, m_field->GetMDates(1, 2) - g_date->DayInYear())) {
216  break;
217  }
218  }
219  done = true;
220  break;
221 
222  default:
223  g_msg->Warn( WARN_BUG, "DE_OWinterRape::Do(): "
224  "Unknown event type! ", "" );
225  exit( 1 );
226  }
227  return done;
228 }

References Farm::AutumnHarrow(), Farm::AutumnPlough(), Farm::AutumnSow(), LE::ClearManagementActionSum(), Calendar::Date(), Calendar::DayInYear(), de_owr_autumn_harrow, de_owr_autumn_plough, de_owr_autumn_sow, de_owr_fa_manure, de_owr_fertiFA_B, de_owr_fertiFA_S, de_owr_fertiFP_B, de_owr_fertiFP_S, de_owr_fp_manure, de_owr_harvest, de_owr_row_cultivation_one, de_owr_row_cultivation_three, de_owr_row_cultivation_two, de_owr_start, de_owr_straw_chop, de_owr_stub_harrow, Farm::DoIt(), Farm::FA_Boron(), Farm::FA_ManganeseSulphate(), Farm::FA_Manure(), Farm::FP_Boron(), Farm::FP_ManganeseSulphate(), Farm::FP_Manure(), 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::RowCultivation(), Crop::SimpleEvent_(), Crop::StartUpCrop(), Farm::StrawChopping(), Farm::StubbleHarrowing(), tov_DEOWinterRape, MapErrorMsg::Warn(), and WARN_BUG.

◆ SetUpFarmCategoryInformation()

void DE_OWinterRape::SetUpFarmCategoryInformation ( )
inline
72  {
73  const int elements = 2 + (de_owr_foobar - DE_OWINTERRAPE_BASE);
75 
76  FarmManagementCategory catlist[elements] =
77  {
78  fmc_Others, // zero element unused but must be here
79  fmc_Others, // de_owr_start = 1, // Compulsory, start event must always be 1 (one).
80  fmc_Others, // de_owr_fa_sleep_all_day = DE_OWINTERRAPE_BASE,
81  fmc_Fertilizer, // de_owr_fa_manure,
82  fmc_Fertilizer, // de_owr_fp_manure,
83  fmc_Cultivation, // de_owr_autumn_plough,
84  fmc_Cultivation, // de_owr_autumn_harrow,
85  fmc_Others, // de_owr_autumn_sow,
86  fmc_Cultivation, // de_owr_row_cultivation_one,
87  fmc_Cultivation, // de_owr_row_cultivation_two,
88  fmc_Fertilizer, // de_owr_fertiFP_S,
89  fmc_Fertilizer, // de_owr_fertiFA_S,
90  fmc_Fertilizer, // de_owr_fertiFP_B,
91  fmc_Fertilizer, // de_owr_fertiFA_B,
92  fmc_Cultivation, // de_owr_row_cultivation_three,
93  fmc_Harvest, // de_owr_harvest,
94  fmc_Cutting, // de_owr_straw_chop,
95  fmc_Cultivation, // de_owr_stub_harrow,
96 
97 
98  // no foobar entry
99 
100  };
101  // Iterate over the catlist elements and copy them to vector
102  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
103 
104  }

References DE_OWINTERRAPE_BASE, de_owr_foobar, fmc_Cultivation, fmc_Cutting, fmc_Fertilizer, fmc_Harvest, fmc_Others, Crop::m_base_elements_no, and Crop::m_ManagementCategories.

Referenced by DE_OWinterRape().


The documentation for this class was generated from the following files:
LE::GetMDates
int GetMDates(int a, int b)
Definition: Elements.h:405
de_owr_autumn_plough
Definition: DE_OWinterRape.h:42
de_owr_harvest
Definition: DE_OWinterRape.h:52
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
FarmEvent::m_lock
bool m_lock
Definition: Farm.h:384
de_owr_autumn_harrow
Definition: DE_OWinterRape.h:43
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
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_owr_start
Definition: DE_OWinterRape.h:38
de_owr_fp_manure
Definition: DE_OWinterRape.h:41
g_date
class Calendar * g_date
Definition: Calendar.cpp:37
de_owr_fertiFA_S
Definition: DE_OWinterRape.h:48
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
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
de_owr_straw_chop
Definition: DE_OWinterRape.h:53
de_owr_fertiFP_B
Definition: DE_OWinterRape.h:49
Farm::FP_Manure
virtual bool FP_Manure(LE *a_field, double a_user, int a_days)
Spread manure on a_field owned by an arable farmer.
Definition: FarmFuncs.cpp:896
fmc_Cutting
Definition: LandscapeFarmingEnums.h:1009
fmc_Fertilizer
Definition: LandscapeFarmingEnums.h:1004
de_owr_foobar
Definition: DE_OWinterRape.h:55
Calendar::Date
long Date(void)
Definition: Calendar.h:57
fmc_Cultivation
Definition: LandscapeFarmingEnums.h:1008
fmc_Others
Definition: LandscapeFarmingEnums.h:1003
tov_DEOWinterRape
Definition: LandscapeFarmingEnums.h:495
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_OWINTERRAPE_BASE
#define DE_OWINTERRAPE_BASE
Definition: DE_OWinterRape.h:35
de_owr_stub_harrow
Definition: DE_OWinterRape.h:54
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
MapErrorMsg::Warn
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: MapErrorMsg.cpp:69
Farm::FA_Boron
virtual bool FA_Boron(LE *a_field, double a_user, int a_days)
Apply soluble Boron to a_field owned by a stock farmer.
Definition: FarmFuncs.cpp:868
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
Farm::FP_Boron
virtual bool FP_Boron(LE *a_field, double a_user, int a_days)
Apply soluble Boron to a_field owned by an arable farmer.
Definition: FarmFuncs.cpp:854
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::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
de_owr_row_cultivation_two
Definition: DE_OWinterRape.h:46
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
de_owr_fertiFP_S
Definition: DE_OWinterRape.h:47
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
fmc_Harvest
Definition: LandscapeFarmingEnums.h:1012
Calendar::DayInYear
int DayInYear(void)
Definition: Calendar.h:58
de_owr_autumn_sow
Definition: DE_OWinterRape.h:44
de_owr_fertiFA_B
Definition: DE_OWinterRape.h:50
de_owr_fa_manure
Definition: DE_OWinterRape.h:40
Crop::Crop
Crop(TTypesOfVegetation a_tov, TTypesOfCrops a_toc, Landscape *a_L)
Definition: Farm.cpp:733
de_owr_row_cultivation_three
Definition: DE_OWinterRape.h:51
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
de_owr_row_cultivation_one
Definition: DE_OWinterRape.h:45
WARN_BUG
Definition: MapErrorMsg.h:34
FarmManagementCategory
FarmManagementCategory
Definition: LandscapeFarmingEnums.h:1001
Farm::StubbleHarrowing
virtual bool StubbleHarrowing(LE *a_field, double a_user, int a_days)
Carry out stubble harrowing on a_field.
Definition: FarmFuncs.cpp:1523
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
DE_OWinterRape::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: DE_OWinterRape.h:72