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

#include <FI_OStarchPotato_South.h>

Inheritance diagram for FI_OStarchPotato_South:
Crop

Public Member Functions

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

◆ FI_OStarchPotato_South()

FI_OStarchPotato_South::FI_OStarchPotato_South ( TTypesOfVegetation  a_tov,
TTypesOfCrops  a_toc,
Landscape a_L 
)
inline
59  : Crop(a_tov, a_toc, a_L)
60  {
61  m_first_date=g_date->DayInYear(1,12); //
63  }

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

Member Function Documentation

◆ Do()

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

Reimplemented from Crop.

38 {
39  m_farm = a_farm;
40  m_field = a_field;
41  m_ev = a_ev;
42  // int d1;
43 
44  bool done = false;
45 
46  switch (m_ev->m_todo)
47  {
48  case fi_osps_start:
49  {
52 
53  a_field->ClearManagementActionSum();
54 
55  m_field->SetVegPatchy(true); // Root crop so is open until tall
56  // Set up the date management stuff
57  // Could save the start day in case it is needed later
58  // m_field->m_startday = m_ev->m_startday;
59  m_last_date = g_date->DayInYear(1, 10);
60  // Start and stop dates for all events after harvest
61  int noDates = 1;
62  m_field->SetMDates(0, 0, g_date->DayInYear(1, 10));
63  // 0,0 determined by harvest date - used to see if at all possible
64  m_field->SetMDates(1, 0, g_date->DayInYear(1, 10));
65  // Check the next crop for early start, unless it is a spring crop
66  // in which case we ASSUME that no checking is necessary!!!!
67  // So DO NOT implement a crop that runs over the year boundary
68 
69  //new if: do the check only for non-optimising farms and if year>0. (030713 - m_rotation used only in the hidden year, so I modified the condition from >7 to >0)
70  int d1;
71  if (!(m_farm->GetType() == tof_OptimisingFarm && g_date->GetYearNumber() > 0)) {
72 
73  if (m_ev->m_startday > g_date->DayInYear(1, 7))
74  {
75  if (m_field->GetMDates(0, 0) >= m_ev->m_startday)
76  {
77  g_msg->Warn(WARN_BUG, "FI_OStarchPotato_South::Do(): "
78  "Harvest too late for the next crop to start!!!", "");
79  exit(1);
80  }
81  // Now fix any late finishing problems
82  for (int i = 0; i < noDates; i++) {
83  if (m_field->GetMDates(0, i) >= m_ev->m_startday) {
84  m_field->SetMDates(0, i, m_ev->m_startday - 1); //move the starting date
85  }
86  if (m_field->GetMDates(1, i) >= m_ev->m_startday) {
87  m_field->SetMConstants(i, 0);
88  m_field->SetMDates(1, i, m_ev->m_startday - 1); //move the finishing date
89  }
90  }
91  }
92  // Now no operations can be timed after the start of the next crop.
93 
94  // CJT note:
95  // Start single block date checking code to be cut-'n-pasted...
96 
97  if (!m_ev->m_first_year)
98  {
99  // Are we before July 1st?
100  d1 = g_date->OldDays() + g_date->DayInYear(1, 7);
101  if (g_date->Date() < d1)
102  {
103  // Yes, too early. We assumme this is because the last crop was late
104  g_msg->Warn(WARN_BUG, "FI_OStarchPotato_South::Do(): "
105  "Crop start attempt between 1st Jan & 1st July", "");
106  exit(1);
107  }
108  else
109  {
110  d1 = g_date->OldDays() + m_first_date + 365; // Add 365 for spring crop
111  if (g_date->Date() > d1)
112  {
113  // Yes too late - should not happen - raise an error
114  g_msg->Warn(WARN_BUG, "FI_OStarchPotato_South::Do(): "
115  "Crop start attempt after last possible start date", "");
116  exit(1);
117  }
118  }
119  }
120  else
121  {
122  // If this is the first year of running then it is possible to start
123  // on day 0, so need this to tell us what to do:
125  break;
126  }
127  }//if
128 
129  // End single block date checking code. Please see next line
130  // comment as well.
131  // Reinit d1 to first possible starting date.
132  d1 = g_date->OldDays() + g_date->DayInYear(1, 9);
133  // This is the first real farm operation
135  }
136  break;
137  // OK, Let's go - LKM: first treatment, stubble cultivator, do it before the 10 of October - if not done, try again +1 day until the the 10 of October when we succeed - 2% of farmers do this
139  if (m_ev->m_lock || m_farm->DoIt_prob(0.02))
140  {
143  break;
144  }
145  //Here comes a fork of parallel events:
146  SimpleEvent(g_date->OldDays() + g_date->DayInYear(1, 5) + 365, fi_osps_slurry, false); //Slurry thread
147  SimpleEvent(g_date->OldDays() + g_date->DayInYear(1, 5) + 365, fi_osps_n_minerals1, false); //N minerals thread
148  SimpleEvent(g_date->OldDays() + g_date->DayInYear(15, 5) + 365, fi_osps_fertilizer, false); //Sowing thread - main thread
149  break;
150  }
151  else if (m_ev->m_lock || m_farm->DoIt_prob(0.24 / 0.98)) { // autumn plough, done after 15th of October - before the 1st of December - 24% do this
153  break;
154  }
155  else if (m_ev->m_lock || m_farm->DoIt_prob(0.74 / 0.74)) { //Here comes a fork of parallel events:
156  SimpleEvent(g_date->OldDays() + g_date->DayInYear(1, 5) + 365, fi_osps_slurry, false); //Slurry thread
157  SimpleEvent(g_date->OldDays() + g_date->DayInYear(1, 5) + 365, fi_osps_n_minerals1, false); //N minerals thread
158  SimpleEvent(g_date->OldDays() + g_date->DayInYear(1, 5) + 365, fi_osps_spring_plough, false); //Spring plough thread
159  SimpleEvent(g_date->OldDays() + g_date->DayInYear(15, 5) + 365, fi_osps_fertilizer, false); //Sowing thread - main thread
160  break;
161  }
162 
164  if (!m_farm->AutumnPlough(m_field, 0.0, g_date->DayInYear(1, 12) - g_date->DayInYear())) {
166  break;
167  }
168  //Here comes a fork of parallel events:
169  SimpleEvent(g_date->OldDays() + g_date->DayInYear(1, 5) + 365, fi_osps_slurry, false); //Slurry thread
170  SimpleEvent(g_date->OldDays() + g_date->DayInYear(1, 5) + 365, fi_osps_n_minerals1, false); //N minerals thread
171  SimpleEvent(g_date->OldDays() + g_date->DayInYear(15, 5) + 365, fi_osps_fertilizer, false); //Sowing thread - main thread
172  break;
173  // Slurry thread
174  case fi_osps_slurry: // 100% do this, done before 25th of May
175  if (m_ev->m_lock || m_farm->DoIt_prob(1.00)) {
176  if (!m_farm->FP_Slurry(m_field, 0.0, g_date->DayInYear(25, 5) - g_date->DayInYear())) {
177  SimpleEvent(g_date->Date() + 1, fi_osps_slurry, true);
178  break;
179  }
180  }
181  break; //end of Slurry thread
182  // N minerals thread
183  case fi_osps_n_minerals1: //sometimes applied - 10% do this, done before 10th of May
184  if (m_ev->m_lock || m_farm->DoIt_prob(0.10)) {
185  if (!m_farm->FP_NPKS(m_field, 0.0, g_date->DayInYear(10, 5) - g_date->DayInYear())) {
187  break;
188  }
189  }
190  break; //end of N minerals thread
191  // Spring plough thread (the 74% from before)
192  case fi_osps_spring_plough: // done before 25th of May
193  if (!m_farm->SpringPlough(m_field, 0.0, g_date->DayInYear(25, 5) - g_date->DayInYear())) {
195  break;
196  }
197  break; //end of Spring plough thread
198  // Sowing thread - starts with fertilizer, 95% do this, before 30th of May
199  case fi_osps_fertilizer:
200  if (m_ev->m_lock || m_farm->DoIt_prob(0.95)) {
201  if (!m_farm->FP_NPKS(m_field, 0.0, g_date->DayInYear(30, 5) - g_date->DayInYear())) {
202  SimpleEvent(g_date->Date() + 1, fi_osps_fertilizer, true);
203  break;
204  }
205  }
206  // LKM: Queue up next event preseeding cultivation right after - done before the 30th of May
208  break;
210  if (m_ev->m_lock || m_farm->DoIt_prob(0.95)) {
211  if (!m_farm->PreseedingCultivator(m_field, 0.0, g_date->DayInYear(30, 5) - g_date->DayInYear())) {
213  break;
214  }
215  // LKM: Queue up next event planting right after - done before the 30th of May
216  SimpleEvent(g_date->Date(), fi_osps_plant, false);
217  break;
218  }
219  else if (m_ev->m_lock || m_farm->DoIt_prob(0.05 / 0.05)) { // 5% plant with the preseeding cultivation
220  // LKM: Queue up next event planting right after - done before the 30th of May
222  break;
223  }
227  break;
228  }
229  // LKM: Queue up next event harrow, done 7 days after
230  SimpleEvent(g_date->Date() + 7, fi_osps_harrow, false);
231  break;
232  case fi_osps_plant:
233  if (!m_farm->SpringSow(m_field, 0.0, g_date->DayInYear(30, 5) - g_date->DayInYear())) {
234  SimpleEvent(g_date->Date() + 1, fi_osps_plant, true);
235  break;
236  }
237  // LKM: Queue up next event harrow, done 7 days after
238  SimpleEvent(g_date->Date() + 7, fi_osps_harrow, false);
239  break;
240  case fi_osps_harrow: // 98% do this, done before 7th of June
241  if (m_ev->m_lock || m_farm->DoIt_prob(0.98)) {
242  if (!m_farm->SpringHarrow(m_field, 0.0, g_date->DayInYear(7, 6) - g_date->DayInYear())) {
243  SimpleEvent(g_date->Date() + 1, fi_osps_harrow, true);
244  break;
245  }
246  }
247  // LKM: Here comes a fork with parallel events:// LKM: N minerals 2 after the 20th of June
249  break;
250  // N minerals2 thread - done before the 15th of July, 20% do this
251  case fi_osps_n_minerals2:
252  if (m_ev->m_lock || m_farm->DoIt_prob(0.20)) {
253  if (!m_farm->FP_NPKS(m_field, 0.0, g_date->DayInYear(15, 7) - g_date->DayInYear())) {
255  break;
256  }
257  }
258  // LKM: Queue up the next event - harvest done after the 20th of August
260  break;
261  // LKM: do harvest before 7th of October
262  case fi_osps_harvest:
263  if (!m_farm->HarvestLong(m_field, 0.0, g_date->DayInYear(15, 10) - g_date->DayInYear())) {
264  SimpleEvent(g_date->Date() + 1, fi_osps_harvest, true);
265  break;
266  }
267  m_field->SetVegPatchy(false);
268  done = true;
269  break;
270 
271  default:
272  g_msg->Warn(WARN_BUG, "FI_OStarchPotato_South::Do(): "
273  "Unknown event type! ", "");
274  exit(1);
275  }
276  return done;
277 }

References Farm::AutumnPlough(), LE::ClearManagementActionSum(), Calendar::Date(), Calendar::DayInYear(), Farm::DoIt_prob(), fi_osps_autumn_plough, FI_OSPS_DECIDE_TO_FI, FI_OSPS_DECIDE_TO_HERB, fi_osps_fertilizer, fi_osps_harrow, fi_osps_harvest, fi_osps_n_minerals1, fi_osps_n_minerals2, fi_osps_plant, fi_osps_preseeding_cultivation, fi_osps_preseeding_plant, fi_osps_slurry, fi_osps_spring_plough, fi_osps_start, fi_osps_stubble_cultivator, Farm::FP_NPKS(), Farm::FP_Slurry(), g_date, g_msg, LE::GetMDates(), Farm::GetType(), Calendar::GetYearNumber(), Farm::HarvestLong(), Crop::m_ev, Crop::m_farm, Crop::m_field, Crop::m_first_date, FarmEvent::m_first_year, Crop::m_last_date, FarmEvent::m_lock, FarmEvent::m_startday, FarmEvent::m_todo, Calendar::OldDays(), Farm::PreseedingCultivator(), Farm::PreseedingCultivatorSow(), LE::SetMConstants(), LE::SetMDates(), LE::SetVegPatchy(), Crop::SimpleEvent(), Farm::SpringHarrow(), Farm::SpringPlough(), Farm::SpringSow(), Farm::StubbleCultivatorHeavy(), tof_OptimisingFarm, MapErrorMsg::Warn(), and WARN_BUG.

◆ SetUpFarmCategoryInformation()

void FI_OStarchPotato_South::SetUpFarmCategoryInformation ( )
inline
64  {
65  const int elements = 2 + (fi_osps_foobar - FI_OSPS_BASE);
67 
68  FarmManagementCategory catlist[elements] =
69  {
70  fmc_Others, // zero element unused but must be here
71  fmc_Others, // fi_osps_start = 1, // Compulsory, start event must always be 1 (one).
72  fmc_Harvest, // fi_osps_harvest = FI_OSPS_BASE,
73  fmc_Cultivation, // fi_osps_stubble_cultivator,
74  fmc_Cultivation, // fi_osps_autumn_plough,
75  fmc_Fertilizer, // fi_osps_slurry,
76  fmc_Cultivation, // fi_osps_spring_plough,
77  fmc_Fertilizer, // fi_osps_n_minerals1,
78  fmc_Fertilizer, // fi_osps_n_minerals2,
79  fmc_Cultivation, // fi_osps_preseeding_cultivation,
80  fmc_Fertilizer, // fi_osps_fertilizer,
81  fmc_Cultivation, // fi_osps_preseeding_plant,
82  fmc_Others, // fi_osps_plant,
83  fmc_Cultivation // fi_osps_harrow,
84 
85 
86  // no foobar entry
87 
88  };
89  // Iterate over the catlist elements and copy them to vector
90  copy(begin(catlist), end(catlist), back_inserter(m_ManagementCategories));
91 
92  }

References FI_OSPS_BASE, fi_osps_foobar, fmc_Cultivation, fmc_Fertilizer, fmc_Harvest, fmc_Others, Crop::m_base_elements_no, and Crop::m_ManagementCategories.

Referenced by FI_OStarchPotato_South().


The documentation for this class was generated from the following files:
LE::GetMDates
int GetMDates(int a, int b)
Definition: Elements.h:405
Farm::PreseedingCultivator
virtual bool PreseedingCultivator(LE *a_field, double a_user, int a_days)
Carry out preseeding cultivation on a_field (tilling set including cultivator and string roller to co...
Definition: FarmFuncs.cpp:312
LE::SetMDates
void SetMDates(int a, int b, int c)
Definition: Elements.h:406
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
fi_osps_preseeding_plant
Definition: FI_OStarchPotato_South.h:47
FarmEvent::m_lock
bool m_lock
Definition: Farm.h:384
Farm::StubbleCultivatorHeavy
virtual bool StubbleCultivatorHeavy(LE *a_field, double a_user, int a_days)
Carry out a stubble cultivation event on a_field. This is non-inversion type of cultivation which can...
Definition: FarmFuncs.cpp:245
LE::ClearManagementActionSum
void ClearManagementActionSum()
clears the management action counters
Definition: Elements.h:247
Calendar::GetYearNumber
int GetYearNumber(void)
Definition: Calendar.h:72
FarmEvent::m_first_year
bool m_first_year
Definition: Farm.h:386
fi_osps_slurry
Definition: FI_OStarchPotato_South.h:41
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
fi_osps_stubble_cultivator
Definition: FI_OStarchPotato_South.h:39
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
Farm::GetType
TTypesOfFarm GetType(void)
Definition: Farm.h:956
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
FarmEvent::m_startday
int m_startday
Definition: Farm.h:385
fi_osps_plant
Definition: FI_OStarchPotato_South.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
fmc_Fertilizer
Definition: LandscapeFarmingEnums.h:1004
FI_OStarchPotato_South::SetUpFarmCategoryInformation
void SetUpFarmCategoryInformation()
Definition: FI_OStarchPotato_South.h:64
Calendar::Date
long Date(void)
Definition: Calendar.h:57
FI_OSPS_DECIDE_TO_FI
#define FI_OSPS_DECIDE_TO_FI
Definition: FI_OStarchPotato_South.h:34
fmc_Cultivation
Definition: LandscapeFarmingEnums.h:1008
fmc_Others
Definition: LandscapeFarmingEnums.h:1003
LE::SetVegPatchy
void SetVegPatchy(bool p)
Definition: Elements.h:229
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
fi_osps_start
Definition: FI_OStarchPotato_South.h:37
FI_OSPS_BASE
#define FI_OSPS_BASE
Definition: FI_OStarchPotato_South.h:31
fi_osps_n_minerals2
Definition: FI_OStarchPotato_South.h:44
Crop::m_farm
Farm * m_farm
Definition: Farm.h:498
Crop::m_field
LE * m_field
Definition: Farm.h:499
fi_osps_harvest
Definition: FI_OStarchPotato_South.h:38
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
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
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::HarvestLong
virtual bool HarvestLong(LE *a_field, double a_user, int a_days)
Carry out a harvest on a_field (only differs in the DoIt chance cf harvest)
Definition: FarmFuncs.cpp:1421
fi_osps_preseeding_cultivation
Definition: FI_OStarchPotato_South.h:45
tof_OptimisingFarm
Definition: LandscapeFarmingEnums.h:696
fi_osps_spring_plough
Definition: FI_OStarchPotato_South.h:42
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
fi_osps_autumn_plough
Definition: FI_OStarchPotato_South.h:40
FI_OSPS_DECIDE_TO_HERB
#define FI_OSPS_DECIDE_TO_HERB
Definition: FI_OStarchPotato_South.h:33
fi_osps_harrow
Definition: FI_OStarchPotato_South.h:49
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
fi_osps_foobar
Definition: FI_OStarchPotato_South.h:50
fi_osps_fertilizer
Definition: FI_OStarchPotato_South.h:46
fi_osps_n_minerals1
Definition: FI_OStarchPotato_South.h:43
LE::SetMConstants
void SetMConstants(int a, int c)
Definition: Elements.h:408
Crop::m_ev
FarmEvent * m_ev
Definition: Farm.h:500
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
Farm::FP_NPKS
virtual bool FP_NPKS(LE *a_field, double a_user, int a_days)
Apply NPKS fertilizer, on a_field owned by an arable farmer.
Definition: FarmFuncs.cpp:630