ALMaSS Rabbit ODdox  1.00
The rabbit model description following ODdox protocol
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Crop Class Reference

The base class for all crops. More...

#include <farm.h>

Public Member Functions

virtual ~Crop ()
 
 Crop ()
 
int GetFirstDate (void)
 
virtual bool Do (Farm *a_farm, LE *a_field, FarmEvent *a_ev)
 
void ChooseNextCrop (int a_no_dates)
 Chooses the next crop to grow in a field. More...
 

Protected Member Functions

void SimpleEvent (long a_date, int a_todo, bool a_lock)
 Adds an event to this crop management. More...
 

Protected Attributes

Farmm_farm
 
LEm_field
 
FarmEventm_ev
 
int m_first_date
 
int m_count
 
int m_last_date
 
int m_ddegstoharvest
 

Detailed Description

The base class for all crops.

Definition at line 462 of file farm.h.

Constructor & Destructor Documentation

virtual Crop::~Crop ( )
inlinevirtual

Definition at line 480 of file farm.h.

480 {}
Crop::Crop ( )

Definition at line 248 of file farm.cpp.

249 {
250  m_ddegstoharvest = -1; // Set to -1 to indicate that this is not using ddegs to harvest, this will be reset in descendent classes as needed
251 }
int m_ddegstoharvest
Definition: farm.h:471

Member Function Documentation

void Crop::ChooseNextCrop ( int  a_no_dates)

Chooses the next crop to grow in a field.

The function finds the next crop to grow on a field where the current crop's management has finished. If necessary, it adjusts current crop's management to the new crop.

Definition at line 263 of file farm.cpp.

References cfg_OptimiseBedriftsmodelCrops, cfg_OptimisingFarms, Calendar::DayInYear(), g_date, g_msg, Calendar::GetYearNumber(), OptimisingFarm::Match_crop_to_field(), tof_OptimisingFarm, CfgBool::value(), MapErrorMsg::Warn(), and WARN_BUG.

263  {
264 
268  if(cfg_OptimisingFarms.value()){ // do this only if we have optimising farms
269  if(!cfg_OptimiseBedriftsmodelCrops.value()){ // do this only if we use almass crops!!
270 
271  if (g_date->GetYearNumber()>0){ //changed 030713 since we dont use m_rotation anymore - but we do in the hidden year!
272  OptimisingFarm * opf;
273  if(m_farm->GetType() == tof_OptimisingFarm){ //take only optimising farms
274  opf = dynamic_cast<OptimisingFarm*>(m_farm);
276  //move MDates if necessary, use the new_startdate:
277  if (m_ev->m_startday > g_date->DayInYear(1,7)) {
278  if (m_field->GetMDates(0,0) >=m_ev->m_startday)
279  {
280  g_msg->Warn( WARN_BUG, "Crop::ChooseNextCrop(): ","Harvest too late for the next crop to start!!!" );
281  exit( 1 );
282  }
283  // Now fix any late finishing problems
284  for (int i=0; i<a_no_dates; i++) {
285  if(m_field->GetMDates(0,i)>=m_ev->m_startday) {
286  m_field->SetMDates(0,i,m_ev->m_startday-1); //move the starting date
287  }
288  if(m_field->GetMDates(1,i)>=m_ev->m_startday){
289  m_field->SetMConstants(i,0); //change the default value of the MConst (=1) to 0 (necessary to correctly execute farm events in case the finishing date (MDate) was moved)
290  m_field->SetMDates(1,i,m_ev->m_startday-1); //move the finishing date
291  }
292  }
293  }
294 
295  }
296  }
297  }
298  }
299 
300 }
int m_startday
Definition: farm.h:394
TTypesOfFarm GetType(void)
Definition: farm.h:803
CfgBool cfg_OptimisingFarms("OPTIMISING_FARMS", CFG_CUSTOM, false)
If set to true, the farmer decision making model is active.
int GetYearNumber(void)
Definition: calendar.h:68
A farm that carries out crop, pesticide and fertilizer planning using simplified optimisation or othe...
Definition: farm.h:1885
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
CfgBool cfg_OptimiseBedriftsmodelCrops("OPTIMISE_BEDRIFTSMODEL_CROPS", CFG_CUSTOM, false)
If set to true, the original farm optimisation model&#39;s crop set is used in the farmer decision making...
bool value(void)
Definition: configurator.h:123
int DayInYear(void)
Definition: calendar.h:58
void Match_crop_to_field(LE *a_field)
Finds a crop to be grown on a given field next year.
Definition: farm.cpp:8684
class Calendar * g_date
Definition: calendar.cpp:38
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
Farm * m_farm
Definition: farm.h:465
LE * m_field
Definition: farm.h:466
FarmEvent * m_ev
Definition: farm.h:467
void SetMDates(int a, int b, int c)
Definition: elements.h:336
void SetMConstants(int a, int c)
Definition: elements.h:338
int GetMDates(int a, int b)
Definition: elements.h:335
bool Crop::Do ( Farm a_farm,
LE a_field,
FarmEvent a_ev 
)
virtual

Definition at line 253 of file farm.cpp.

253  {
254  return true;
255 }
int Crop::GetFirstDate ( void  )
inline

Definition at line 482 of file farm.h.

482 { return m_first_date; }
int m_first_date
Definition: farm.h:468
void Crop::SimpleEvent ( long  a_date,
int  a_todo,
bool  a_lock 
)
protected

Adds an event to this crop management.

Definition at line 257 of file farm.cpp.

257  {
258 
259  m_farm->AddNewEvent( m_field->GetVegType(), a_date, m_field, a_todo, m_field->GetRunNum(), a_lock, 0, false, (TTypesOfVegetation) 0 );
260 }
TTypesOfVegetation
virtual TTypesOfVegetation GetVegType(void)
Definition: elements.h:125
void AddNewEvent(TTypesOfVegetation a_event, long a_date, LE *a_field, int a_todo, long a_num, bool a_lock, int a_start, bool a_first_year, TTypesOfVegetation a_crop)
Adds an event to the event queue for a farm.
Definition: farm.cpp:599
Farm * m_farm
Definition: farm.h:465
LE * m_field
Definition: farm.h:466
long GetRunNum(void)
Definition: elements.h:117

Member Data Documentation

int Crop::m_count
protected

Definition at line 469 of file farm.h.

int Crop::m_ddegstoharvest
protected

Definition at line 471 of file farm.h.

FarmEvent* Crop::m_ev
protected

Definition at line 467 of file farm.h.

Farm* Crop::m_farm
protected

Definition at line 465 of file farm.h.

LE* Crop::m_field
protected

Definition at line 466 of file farm.h.

int Crop::m_first_date
protected

Definition at line 468 of file farm.h.

int Crop::m_last_date
protected

Definition at line 470 of file farm.h.


The documentation for this class was generated from the following files: