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

#include <DE_OOats.h>

Inheritance diagram for DE_OOats:
Crop

Public Member Functions

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

DE_OOats::DE_OOats ( TTypesOfVegetation  a_tov,
TTypesOfCrops  a_toc,
Landscape a_L 
)
inline
62  : Crop(a_tov, a_toc, a_L)
63  {
66  }

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

Member Function Documentation

◆ Do()

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

Reimplemented from Crop.

34 {
35  /******************** This block can be added to the top of all Crop::Do methods ***********************************************/
36  m_farm = a_farm; // These assignments are necessary, not for this method but for related event calls
37  m_field = a_field;
38  m_ev = a_ev;
39  bool done = false; // The boolean value done indicates when we are totally finished with this plan (i.e. it is set to true).
40  bool flag = false;
41  int d1 = 0;
42  TTypesOfVegetation l_tov = tov_DEOOats; // The current type - change to match the crop you have
43 /**********************************************To Here *************************************************************************/
44  // Depending what event has occured jump to the correct bit of code
45  switch (m_ev->m_todo)
46  {
47  case de_oo_start:
48  {
50 
51  DE_OO_SOW_DATE = 0;
53 
54  m_last_date = g_date->DayInYear(20, 8); // Should match the last flexdate below
55  //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
56  std::vector<std::vector<int>> flexdates(2 + 1, std::vector<int>(2, 0));
57  // Set up the date management stuff
58  // Start and stop dates for all events after harvest
59  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
60  // Now these are done in pairs, start & end for each operation. If its not used then -1
61  flexdates[1][0] = -1; // This date will be moved back as far as necessary and potentially to flexdates 1 (start op 1)
62  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)
63  flexdates[2][0] = -1; // This date will be moved back as far as necessary and potentially to flexdates 1 (start op 1)
64  flexdates[2][1] = g_date->DayInYear(20, 8); // This date will be moved back as far as necessary and potentially to flexdates 1 (end op 2)
65 
66  // 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
67  int isSpring = 365;
68  if (StartUpCrop(isSpring, flexdates, int(de_oo_spring_harrow))) break;
69 
70  // End single block date checking code. Please see next line comment as well.
71  // Reinit d1 to first possible starting date.
72  d1 = g_date->OldDays() + g_date->DayInYear(5, 3) + isSpring;
73  // OK, let's go.
74  // Here we queue up the first event which changes dependent on whether it is a forced spring sow or not
75  if (m_farm->IsStockFarmer()) {
77  }
78  else {
80  break;
81  }
82  }
83  break;
84 
86  if ( m_ev->m_lock || m_farm->DoIt( 70 ))
87  {
88  if (!m_farm->FA_Manure( m_field, 0.0, g_date->DayInYear( 30,3 ) - g_date->DayInYear())) {
90  break;
91  }
92  }
94  break;
95 
97  if (!m_farm->SpringPlough( m_field, 0.0, g_date->DayInYear( 30,3 ) - g_date->DayInYear())) {
99  break;
100  }
102  break;
103 
104  case de_oo_spring_harrow:
105  if (!m_farm->SpringHarrow( m_field, 0.0, g_date->DayInYear( 30,3 ) - g_date->DayInYear())) {
107  break;
108  }
110  break;
111 
112  case de_oo_spring_sow:
113  if (!m_farm->SpringSow( m_field, 0.0, g_date->DayInYear( 5,4 ) - g_date->DayInYear())) {
115  break;
116  }
118  d1 = g_date->Date();
119  if ( d1 < g_date->OldDays() + g_date->DayInYear( 5,4 )) {
120  d1 = g_date->OldDays() + g_date->DayInYear( 5,4 );
121  }
123  break;
124 
125  case de_oo_spring_roll:
126  if ( m_ev->m_lock || m_farm->DoIt( 40 ))
127  {
128  if (!m_farm->SpringRoll( m_field, 0.0, g_date->DayInYear( 20,4 ) - g_date->DayInYear())) {
130  break;
131  }
132  }
133  d1 = g_date->OldDays() + g_date->DayInYear( 15,4 );
134  if ( d1 < DE_OO_SOW_DATE + 10 ) {
135  d1 = DE_OO_SOW_DATE + 10;
136  }
138  break;
139 
140  case de_oo_strigling_one:
141  if (!m_farm->Strigling( m_field, 0.0, g_date->DayInYear( 30,4 ) - g_date->DayInYear())) {
143  break;
144  }
145  d1 = g_date->Date() + 10;
146  if ( d1 < g_date->OldDays() + g_date->DayInYear( 25,4 ) ) {
147  d1 = g_date->OldDays() + g_date->DayInYear( 25,4 );
148  }
150  break;
151 
152  case de_oo_strigling_two:
153  if (m_ev->m_lock || (cfg_strigling_prop.value() * m_farm->DoIt(60)))
154  {
155  if (!m_farm->Strigling( m_field, 0.0, g_date->DayInYear( 30,5 ) - g_date->DayInYear())) {
157  break;
158  }
159  }
160  d1 = g_date->Date() + 10;
161  if ( d1 < g_date->OldDays() + g_date->DayInYear( 30,5 ) ) {
162  d1 = g_date->OldDays() + g_date->DayInYear( 30,5 );
163  }
165  break;
166 
168  if ( m_ev->m_lock || (cfg_strigling_prop.value() * m_farm->DoIt( 5 )))
169  {
170  if (!m_farm->Strigling( m_field, 0.0, g_date->DayInYear( 30, 6 ) - g_date->DayInYear())) {
172  break;
173  }
174  }
176  break;
177 
178  case de_oo_harvest:
179  if (!m_farm->Harvest( m_field, 0.0, m_field->GetMDates(1, 0) - g_date->DayInYear())) {
181  break;
182  }
184  break;
185 
187  if ( m_ev->m_lock || m_farm->DoIt( 80 ))
188  {
189  if (!m_farm->StrawChopping( m_field, 0.0, m_field->GetMDates(1, 1) - g_date->DayInYear())) {
191  break;
192  }
193  done = true;
194  break;
195  }
197  break;
198 
199  case de_oo_hay_bailing:
200  if (!m_farm->HayBailing( m_field, 0.0, m_field->GetMDates(1, 2) - g_date->DayInYear())) {
202  break;
203  }
204 
205  done = true;
206  break;
207 
208  default:
209  g_msg->Warn( WARN_BUG, "DE_OOats::Do(): "
210  "Unknown event type! ", "" );
211  exit( 1 );
212  }
213  return done;
214 }

References cfg_strigling_prop, LE::ClearManagementActionSum(), Calendar::Date(), Calendar::DayInYear(), DE_OO_DID_STRIGLING_ONE, de_oo_fertmanure_stock, de_oo_harvest, de_oo_hay_bailing, DE_OO_SOW_DATE, de_oo_spring_harrow, de_oo_spring_plough, de_oo_spring_roll, de_oo_spring_sow, de_oo_start, de_oo_straw_chopping, de_oo_strigling_one, de_oo_strigling_three, de_oo_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_DEOOats, CfgFloat::value(), MapErrorMsg::Warn(), and WARN_BUG.

◆ SetUpFarmCategoryInformation()

void DE_OOats::SetUpFarmCategoryInformation ( )
inline
67  {
68  const int elements = 2 + (de_oo_foobar - DE_OOATS_BASE);
70 
71  FarmManagementCategory catlist[elements] =
72  {
73  fmc_Others, // zero element unused but must be here
74  fmc_Others, // de_oo_start = 1, // Compulsory, start event must always be 1 (one).
75  fmc_Others, // de_oo_sleep_all_day = DE_OOATS_BASE,
76  fmc_Cultivation, // de_oo_autumn_plough = DE_OOATS_BASE,
77  fmc_Fertilizer, // de_oo_fertmanure_stock,
78  fmc_Cultivation, // de_oo_spring_plough,
79  fmc_Cultivation, // de_oo_spring_harrow,
80  fmc_Fertilizer, // de_oo_fertslurry_stock,
81  fmc_Others, // de_oo_spring_sow,
82  fmc_Cultivation, // de_oo_spring_roll,
83  fmc_Cultivation, // de_oo_strigling_one,
84  fmc_Cultivation, // de_oo_strigling_two,
85  fmc_Cultivation, // de_oo_strigling_three,
86  fmc_Harvest, // de_oo_harvest,
87  fmc_Cutting, // de_oo_straw_chopping,
88  fmc_Others, // de_oo_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_oo_foobar, DE_OOATS_BASE, fmc_Cultivation, fmc_Cutting, fmc_Fertilizer, fmc_Harvest, fmc_Others, Crop::m_base_elements_no, and Crop::m_ManagementCategories.

Referenced by DE_OOats().


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
de_oo_strigling_two
Definition: DE_OOats.h:47
de_oo_start
Definition: DE_OOats.h:37
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
LE::ClearManagementActionSum
void ClearManagementActionSum()
clears the management action counters
Definition: Elements.h:247
de_oo_hay_bailing
Definition: DE_OOats.h:51
Farm::DoIt
bool DoIt(double a_probability)
Return chance out of 0 to 100.
Definition: Farm.cpp:856
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
de_oo_strigling_three
Definition: DE_OOats.h:48
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_oo_spring_roll
Definition: DE_OOats.h:45
DE_OO_SOW_DATE
#define DE_OO_SOW_DATE
Definition: DE_OOats.h:33
fmc_Cutting
Definition: LandscapeFarmingEnums.h:1009
de_oo_spring_plough
Definition: DE_OOats.h:41
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
de_oo_foobar
Definition: DE_OOats.h:52
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
tov_DEOOats
Definition: LandscapeFarmingEnums.h:487
de_oo_spring_harrow
Definition: DE_OOats.h:42
DE_OOATS_BASE
#define DE_OOATS_BASE
Definition: DE_OOats.h:31
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_oo_strigling_one
Definition: DE_OOats.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
Crop::m_last_date
int m_last_date
Definition: Farm.h:503
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
de_oo_spring_sow
Definition: DE_OOats.h:44
TTypesOfVegetation
TTypesOfVegetation
Values that represent the types of vegetation that are represented in ALMaSS.
Definition: LandscapeFarmingEnums.h:192
de_oo_straw_chopping
Definition: DE_OOats.h:50
fmc_Harvest
Definition: LandscapeFarmingEnums.h:1012
DE_OOats::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: DE_OOats.h:67
DE_OO_DID_STRIGLING_ONE
#define DE_OO_DID_STRIGLING_ONE
Definition: DE_OOats.h:34
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
de_oo_fertmanure_stock
Definition: DE_OOats.h:40
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
cfg_strigling_prop
CfgFloat cfg_strigling_prop
de_oo_harvest
Definition: DE_OOats.h:49
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
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