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

The base class for all farm types. More...

#include <farm.h>

Inheritance diagram for Farm:
AgroChemIndustryCerealFarm1 AgroChemIndustryCerealFarm2 AgroChemIndustryCerealFarm3 ConventionalCattle ConventionalPig ConventionalPlant ConvMarginalJord NoPesticideBaseFarm NoPesticideNoPFarm OptimisingFarm OrganicCattle OrganicPig OrganicPlant PesticideTrialControl PesticideTrialToxicControl PesticideTrialTreatment UserDefinedFarm UserDefinedFarm1 UserDefinedFarm10 UserDefinedFarm11 UserDefinedFarm12 UserDefinedFarm13 UserDefinedFarm14 UserDefinedFarm15 UserDefinedFarm16 UserDefinedFarm17 UserDefinedFarm2 UserDefinedFarm3 UserDefinedFarm4 UserDefinedFarm5 UserDefinedFarm6 UserDefinedFarm7 UserDefinedFarm8 UserDefinedFarm9

Public Member Functions

virtual void Management (void)
 Starts the main management loop for the farm and performs some error checking. More...
 
virtual void InitiateManagement (void)
 Kicks off the farm's management. More...
 
void AddField (LE *a_newfield)
 Adds a field to a farm. More...
 
void RemoveField (LE *a_field)
 Removes a field from a farm. More...
 
 Farm (FarmManager *a_manager)
 Farm constructor - creates an instance of each possible crop type. More...
 
virtual ~Farm (void)
 Farm destructor - deletes all crop instances and empties event queues. More...
 
void SetFarmNumber (int a_farm_num)
 
int GetFarmNumber (void)
 
virtual bool Spraying_herbicides (TTypesOfVegetation)
 
virtual bool Spraying_fungins (TTypesOfVegetation)
 
virtual double Prob_multiplier ()
 
void Assign_rotation (vector< TTypesOfVegetation >a_new_rotation)
 
polylistListOpenFields (int a_openness)
 Returns a list of fields with openness above a_openness. More...
 
void Centroids ()
 Finds farm's centroids - x and y. More...
 
int GetNoFields ()
 Returns the number of the fields owned. More...
 
int GetNoOpenFields (int a_openness)
 Returns the number of the fields above an openness of a_openness. More...
 
int GetAreaOpenFields (int a_openness)
 Returns the area of the fields above an openness of a_openness. More...
 
APoint GetValidCoords ()
 Returns the valid coordinates of the first field owned by a farm. More...
 
int GetMaxOpenness ()
 Returns the maximum openness score of the fields. More...
 
virtual bool SleepAllDay (LE *a_field, double a_user, int a_days)
 Nothing to to today on a_field. More...
 
virtual bool AutumnPlough (LE *a_field, double a_user, int a_days)
 Carry out a ploughing event in the autumn on a_field. More...
 
virtual bool AutumnHarrow (LE *a_field, double a_user, int a_days)
 Carry out a harrow event in the autumn on a_field. More...
 
virtual bool AutumnRoll (LE *a_field, double a_user, int a_days)
 Carry out a roll event in the autumn on a_field. More...
 
virtual bool AutumnSow (LE *a_field, double a_user, int a_days)
 Carry out a sowing event in the autumn on a_field. More...
 
virtual bool WinterPlough (LE *a_field, double a_user, int a_days)
 Carry out a ploughing event in the winter on a_field. More...
 
virtual bool DeepPlough (LE *a_field, double a_user, int a_days)
 Carry out a deep ploughing event on a_field. More...
 
virtual bool SpringPlough (LE *a_field, double a_user, int a_days)
 Carry out a ploughing event in the spring on a_field. More...
 
virtual bool SpringHarrow (LE *a_field, double a_user, int a_days)
 Carry out a harrow event in the spring on a_field. More...
 
virtual bool SpringRoll (LE *a_field, double a_user, int a_days)
 Carry out a roll event in the spring on a_field. More...
 
virtual bool SpringSow (LE *a_field, double a_user, int a_days)
 Carry out a sowing event in the spring on a_field. More...
 
virtual bool HerbicideTreat (LE *a_field, double a_user, int a_days)
 Apply herbicide to a_field. More...
 
virtual bool GrowthRegulator (LE *a_field, double a_user, int a_days)
 Apply growth regulator to a_field. More...
 
virtual bool FungicideTreat (LE *a_field, double a_user, int a_days)
 Apply fungicide to a_field. More...
 
virtual bool InsecticideTreat (LE *a_field, double a_user, int a_days)
 Apply insecticide to a_field. More...
 
virtual bool SynInsecticideTreat (LE *a_field, double a_user, int a_days)
 Apply special insecticide to a_field. More...
 
virtual bool ProductApplication0 (LE *a_field, double a_user, int a_days)
 Apply test pesticide to a_field. More...
 
virtual bool ProductApplication1 (LE *a_field, double a_user, int a_days)
 Apply test pesticide to a_field. More...
 
virtual bool Molluscicide (LE *a_field, double a_user, int a_days)
 Apply molluscidie to a_field. More...
 
virtual bool RowCultivation (LE *a_field, double a_user, int a_days)
 Carry out a harrowing between crop rows on a_field. More...
 
virtual bool Strigling (LE *a_field, double a_user, int a_days)
 Carry out a mechanical weeding on a_field. More...
 
virtual bool StriglingSow (LE *a_field, double a_user, int a_days)
 Carry out a mechanical weeding followed by sowing on a_field. More...
 
virtual bool HillingUp (LE *a_field, double a_user, int a_days)
 Do hilling up on a_field, probably of potatoes. More...
 
virtual bool Water (LE *a_field, double a_user, int a_days)
 Carry out a watering on a_field. More...
 
virtual bool Swathing (LE *a_field, double a_user, int a_days)
 Cut the crop on a_field and leave it lying (probably rape) More...
 
virtual bool Harvest (LE *a_field, double a_user, int a_days)
 Carry out a harvest on a_field. More...
 
virtual bool HarvestLong (LE *a_field, double a_user, int a_days)
 Carry out a harvest on a_field. More...
 
virtual bool CattleOut (LE *a_field, double a_user, int a_days)
 Start a grazing event on a_field today. More...
 
virtual bool CattleOutLowGrazing (LE *a_field, double a_user, int a_days)
 Start a extensive grazing event on a_field today. More...
 
virtual bool CattleIsOut (LE *a_field, double a_user, int a_days, int a_max)
 Generate a 'cattle_out' event for every day the cattle are on a_field. More...
 
virtual bool CattleIsOutLow (LE *a_field, double a_user, int a_days, int a_max)
 Generate a 'cattle_out_low' event for every day the cattle are on a_field. More...
 
virtual bool PigsOut (LE *a_field, double a_user, int a_days)
 Generate a 'pigs_out' event for every day the cattle are on a_field. More...
 
virtual bool PigsAreOut (LE *a_field, double a_user, int a_days)
 Start a pig grazing event on a_field today or soon. More...
 
virtual bool PigsAreOutForced (LE *a_field, double a_user, int a_days)
 Start a pig grazing event on a_field today - no exceptions. More...
 
virtual bool CutToHay (LE *a_field, double a_user, int a_days)
 Carry out hay cutting on a_field. More...
 
virtual bool CutWeeds (LE *a_field, double a_user, int a_days)
 Carry out weed topping on a_field. More...
 
virtual bool CutToSilage (LE *a_field, double a_user, int a_days)
 Cut vegetation for silage on a_field. More...
 
virtual bool CutOrch (LE *a_field, double a_user, int a_days)
 Cut vegetation on orchard crop. //based on cut to silage - values from cutting function of orchard. More...
 
virtual bool StrawChopping (LE *a_field, double a_user, int a_days)
 Carry out straw chopping on a_field. More...
 
virtual bool HayTurning (LE *a_field, double a_user, int a_days)
 Carry out hay turning on a_field. More...
 
virtual bool HayBailing (LE *a_field, double a_user, int a_days)
 Carry out hay bailing on a_field. More...
 
virtual bool BurnStrawStubble (LE *a_field, double a_user, int a_days)
 Burn stubble on a_field. More...
 
virtual bool StubbleHarrowing (LE *a_field, double a_user, int a_days)
 Carry out stubble harrowing on a_field. More...
 
virtual bool FP_NPKS (LE *a_field, double a_user, int a_days)
 Apply NPKS fertilizer, on a_field owned by an arable farmer. More...
 
virtual bool FP_NPK (LE *a_field, double a_user, int a_days)
 Apply NPK fertilizer, on a_field owned by an arable farmer. More...
 
virtual bool FP_PK (LE *a_field, double a_user, int a_days)
 Apply PK fertilizer, on a_field owned by an arable farmer. More...
 
virtual bool FP_LiquidNH3 (LE *a_field, double a_user, int a_days)
 Apply liquid ammonia fertilizer to a_field owned by an arable farmer. More...
 
virtual bool FP_Slurry (LE *a_field, double a_user, int a_days)
 Apply slurry to a_field owned by an arable farmer. More...
 
virtual bool FP_ManganeseSulphate (LE *a_field, double a_user, int a_days)
 Apply Manganse Sulphate to a_field owned by an arable farmer. More...
 
virtual bool FP_Manure (LE *a_field, double a_user, int a_days)
 Spread manure on a_field owned by an arable farmer. More...
 
virtual bool FP_GreenManure (LE *a_field, double a_user, int a_days)
 Spread green manure on a_field owned by an arable farmer. More...
 
virtual bool FP_Sludge (LE *a_field, double a_user, int a_days)
 Spread sewege on a_field owned by an arable farmer. More...
 
virtual bool FA_NPK (LE *a_field, double a_user, int a_days)
 Apply NPK fertilizer to a_field owned by an stock farmer. More...
 
virtual bool FA_PK (LE *a_field, double a_user, int a_days)
 Apply PK fertilizer to a_field owned by an stock farmer. More...
 
virtual bool FA_Slurry (LE *a_field, double a_user, int a_days)
 Spready slurry on a_field owned by an stock farmer. More...
 
virtual bool FA_AmmoniumSulphate (LE *a_field, double a_user, int a_days)
 Apply ammonium supahte to a_field owned by an stock farmer. More...
 
virtual bool FA_Manure (LE *a_field, double a_user, int a_days)
 Spread manure on a_field owned by an stock farmer. More...
 
virtual bool FA_GreenManure (LE *a_field, double a_user, int a_days)
 Spread green manure on a_field owned by an stock farmer. More...
 
virtual bool FA_Sludge (LE *a_field, double a_user, int a_days)
 Spread sewege sludge on a_field owned by an stock farmer. More...
 
virtual bool Trial_PesticideTreat (LE *a_field, double a_user, int a_days)
 Special pesticide trial functionality. More...
 
virtual bool Trial_PesticideTreat_DateLimited (LE *a_field, double, int)
 Special pesticide trial functionality. More...
 
virtual bool Trial_PesticideTreat_GS (LE *a_field, double a_user, int a_days)
 Special pesticide trial functionality. More...
 
virtual bool Trial_ToxicControl (LE *a_field, double a_user, int a_days)
 Special pesticide trial functionality. More...
 
virtual bool Trial_Control (LE *a_field, double a_user, int a_days)
 Special pesticide trial functionality. More...
 
virtual bool Glyphosate (LE *a_field, double a_user, int a_days)
 
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. More...
 
bool DoIt (int a_probability)
 Return chance out of 100. More...
 
TTypesOfFarm GetType (void)
 
int GetArea (void)
 Returns the area of arable fields owned by that farm. More...
 
int GetTotalArea (void)
 Returns the area of all fields owned by that farm. More...
 
double GetAreaDouble (void)
 Returns the area of arable fields owned by that farm. More...
 
bool IsStockFarmer (void)
 
virtual void MakeStockFarmer (void)
 
int GetIntensity (void)
 
APoint GetCentroids ()
 
TTypesOfVegetation GetPreviousCrop (int a_index)
 
TTypesOfVegetation GetCrop (int a_index)
 
TTypesOfVegetation GetNextCrop (int a_index)
 
void AddHunter (Hunter *a_hunter)
 
bool RemoveHunter (Hunter *a_hunter)
 

Protected Member Functions

int GetFirstDate (TTypesOfVegetation a_tov)
 Gets the start date for a crop type. More...
 
int GetNextCropStartDate (LE *a_field, TTypesOfVegetation &a_curr_veg)
 Returns the start date of the next crop in the rotation. More...
 
virtual int GetFirstCropIndex (TTypesOfLandscapeElement a_type)
 Gets the first crop for the farm. More...
 
virtual int GetNextCropIndex (int a_rot_index)
 Returns the next crop in the rotation. More...
 
virtual void HandleEvents (void)
 If there are events to carry out do this, and perhaps start a new crop. More...
 
bool LeSwitch (FarmEvent *ev)
 Call do function for any crop with an outstanding event. Signal if the crop has terminated. More...
 
void CheckRotationManagementLoop (FarmEvent *ev)
 
void ReadRotation (std::string fname)
 Reads a rotation file into the rotation. More...
 
void AssignPermanentCrop (TTypesOfVegetation tov, int pct)
 Used to assign a permanent crop to an otherwise rotational field polygon. More...
 
int InvIntPartition (vector< tpct > *items, int target)
 Finds all possible sums of the integers in the items array. More...
 

Protected Attributes

FarmManagerm_OurManager
 Pointer to the FarmManager. More...
 
LowPriority< FarmEvent * > m_queue
 
vector< LE * > m_fields
 
vector< TTypesOfVegetationm_rotation
 
vector< PermCropDatam_PermCrops
 
TTypesOfFarm m_farmtype
 
HunterList m_HuntersList
 A list of hunters allocated to this farm. More...
 
bool m_stockfarmer
 
int m_farm_num
 
int m_rotation_sync_index
 
int m_intensity
 
int m_farm_centroidx
 Farm's centroid, value x. Equal to the average of the x centroid values of all farm's fields. More...
 
int m_farm_centroidy
 Farm's centroid, value y. Equal to the average of the y centroid values of all farm's fields. More...
 
Carrots * m_carrots
 
BroadBeans * m_broadbeans
 
FodderGrass * m_foddergrass
 
CloverGrassGrazed1 * m_CGG1
 
CloverGrassGrazed2 * m_CGG2
 
FieldPeas * m_fieldpeas
 
FieldPeasSilage * m_fieldpeassilage
 
Fodderbeet * m_fodderbeet
 
Sugarbeet * m_sugarbeet
 
OFodderbeet * m_ofodderbeet
 
Maize * m_maize
 
MaizeSilage * m_maizesilage
 
OMaizeSilage * m_omaizesilage
 
OBarleyPeaCloverGrass * m_OBarleyPCG
 
OCarrots * m_ocarrots
 
OCloverGrassGrazed1 * m_OCGG1
 
OCloverGrassGrazed2 * m_OCGG2
 
OCloverGrassSilage1 * m_OCGS1
 
OFieldPeas * m_ofieldpeas
 
OFieldPeasSilage * m_ofieldpeassilage
 
OFirstYearDanger * m_ofirstyeardanger
 
OGrazingPigs * m_ograzingpigs
 
OrchardCrop * m_orchardcrop
 
Oats * m_oats
 
OOats * m_ooats
 
OPermanentGrassGrazed * m_opermgrassgrazed
 
OPotatoes * m_opotatoes
 
OSeedGrass1 * m_oseedgrass1
 
OSeedGrass2 * m_oseedgrass2
 
OSpringBarley * m_ospringbarley
 
OSpringBarleyExt * m_ospringbarleyext
 
OSpringBarleyPigs * m_ospringbarleypigs
 
OSBarleySilage * m_osbarleysilage
 
OTriticale * m_otriticale
 
OWinterBarley * m_owinterbarley
 
OWinterBarleyExt * m_owinterbarleyext
 
OWinterRape * m_owinterrape
 
OWinterRye * m_owinterrye
 
OWinterWheatUndersown * m_owinterwheatundersown
 
OWinterWheat * m_owinterwheat
 
OWinterWheatUndersownExt * m_owinterwheatundersownext
 
PermanentGrassGrazed * m_permgrassgrazed
 
PermanentGrassLowYield * m_permgrasslowyield
 
PermanentGrassTussocky * m_permgrasstussocky
 
PermanentSetAside * m_permanentsetaside
 
Potatoes * m_potatoes
 
PotatoesIndustry * m_potatoesindustry
 
SeedGrass1 * m_seedgrass1
 
SeedGrass2 * m_seedgrass2
 
SetAside * m_setaside
 
SpringBarley * m_springbarley
 
SpringBarleySpr * m_springbarleyspr
 
SpringBarleySKManagement * m_springbarleyskmanagement
 
SpringBarleyPTreatment * m_springbarleyptreatment
 
SpringBarleyCloverGrass * m_sbarleyclovergrass
 
SpringBarleySeed * m_springbarleyseed
 
SpringBarleySilage * m_springbarleysilage
 
SpringRape * m_springrape
 
Triticale * m_triticale
 
WinterBarley * m_winterbarley
 
WinterRape * m_winterrape
 
WinterRye * m_winterrye
 
WinterWheat * m_winterwheat
 
WWheatPControl * m_wwheatpcontrol
 
WWheatPToxicControl * m_wwheatptoxiccontrol
 
WWheatPTreatment * m_wwheatptreatment
 
AgroChemIndustryCereal * m_agrochemindustrycereal
 
WinterWheatStrigling * m_winterwheatstrigling
 
WinterWheatStriglingCulm * m_winterwheatstriglingculm
 
WinterWheatStriglingSingle * m_winterwheatstriglingsingle
 
SpringBarleyCloverGrassStrigling * m_springbarleyclovergrassstrigling
 
SpringBarleyStrigling * m_springbarleystrigling
 
SpringBarleyStriglingCulm * m_springbarleystriglingculm
 
SpringBarleyStriglingSingle * m_springbarleystriglingsingle
 
MaizeStrigling * m_maizestrigling
 
WinterRapeStrigling * m_winterrapestrigling
 
WinterRyeStrigling * m_winterryestrigling
 
WinterBarleyStrigling * m_winterbarleystrigling
 
FieldPeasStrigling * m_fieldpeasstrigling
 
SpringBarleyPeaCloverGrassStrigling * m_springbarleypeaclovergrassstrigling
 
YoungForestCrop * m_youngforest
 

Detailed Description

The base class for all farm types.

Definition at line 683 of file farm.h.

Constructor & Destructor Documentation

Farm::Farm ( FarmManager a_manager)

Farm constructor - creates an instance of each possible crop type.

Definition at line 862 of file farm.cpp.

863 {
864  m_OurManager = a_manager;
865  m_carrots = new Carrots;
866  m_broadbeans = new BroadBeans;
867  m_CGG1 = new CloverGrassGrazed1;
868  m_CGG2 = new CloverGrassGrazed2;
869  m_fieldpeas = new FieldPeas;
870  m_fieldpeassilage = new FieldPeasSilage;
871  m_fodderbeet = new Fodderbeet;
872  m_sugarbeet = new Sugarbeet;
873  m_ofodderbeet = new OFodderbeet;
874  m_foddergrass = new FodderGrass;
875  m_maize = new Maize;
876  m_maizesilage = new MaizeSilage;
877  m_omaizesilage = new OMaizeSilage;
878  m_OBarleyPCG = new OBarleyPeaCloverGrass;
879  m_ocarrots = new OCarrots;
880  m_OCGG1 = new OCloverGrassGrazed1;
881  m_OCGG2 = new OCloverGrassGrazed2;
882  m_OCGS1 = new OCloverGrassSilage1;
883  m_ofieldpeas = new OFieldPeas;
884  m_ofieldpeassilage = new OFieldPeasSilage;
885  m_ofirstyeardanger = new OFirstYearDanger;
886  m_ograzingpigs = new OGrazingPigs;
887  m_orchardcrop = new OrchardCrop;
888  m_oats = new Oats;
889  m_ooats = new OOats;
890  m_opermgrassgrazed = new OPermanentGrassGrazed;
891  m_opotatoes = new OPotatoes;
892  m_oseedgrass1 = new OSeedGrass1;
893  m_oseedgrass2 = new OSeedGrass2;
894  m_ospringbarley = new OSpringBarley;
895  m_osbarleysilage = new OSBarleySilage;
896  m_ospringbarleyext = new OSpringBarleyExt;
897  m_ospringbarleypigs = new OSpringBarleyPigs;
898  m_owinterbarley = new OWinterBarley;
899  m_owinterbarleyext = new OWinterBarleyExt;
900  m_owinterrape = new OWinterRape;
901  m_owinterrye = new OWinterRye;
902  m_owinterwheat = new OWinterWheat;
903  m_owinterwheatundersown = new OWinterWheatUndersown;
904  m_owinterwheatundersownext = new OWinterWheatUndersownExt;
905  m_permanentsetaside = new PermanentSetAside;
906  m_permgrassgrazed = new PermanentGrassGrazed;
907  m_permgrasslowyield = new PermanentGrassLowYield;
908  m_permgrasstussocky = new PermanentGrassTussocky;
909  m_potatoes = new Potatoes;
910  m_potatoesindustry = new PotatoesIndustry;
911  m_sbarleyclovergrass = new SpringBarleyCloverGrass;
912  m_seedgrass1 = new SeedGrass1;
913  m_seedgrass2 = new SeedGrass2;
914  m_setaside = new SetAside;
915  m_springbarley = new SpringBarley;
916  m_springbarleyspr = new SpringBarleySpr;
917  m_springbarleyptreatment = new SpringBarleyPTreatment;
918  m_springbarleyskmanagement = new SpringBarleySKManagement;
919  m_springbarleyseed = new SpringBarleySeed;
920  m_springbarleysilage = new SpringBarleySilage;
921  m_springrape = new SpringRape;
922  m_triticale = new Triticale;
923  m_otriticale = new OTriticale;
924  m_winterbarley = new WinterBarley;
925  m_winterrape = new WinterRape;
926  m_winterrye = new WinterRye;
927  m_winterwheat = new WinterWheat;
928  m_wwheatpcontrol = new WWheatPControl;
929  m_wwheatptoxiccontrol = new WWheatPToxicControl;
930  m_wwheatptreatment = new WWheatPTreatment;
931  m_agrochemindustrycereal = new AgroChemIndustryCereal;
932  m_winterwheatstrigling = new WinterWheatStrigling;
933  m_winterwheatstriglingsingle = new WinterWheatStriglingSingle;
934  m_winterwheatstriglingculm = new WinterWheatStriglingCulm;
935  m_springbarleyclovergrassstrigling = new SpringBarleyCloverGrassStrigling;
936  m_springbarleystrigling = new SpringBarleyStrigling;
937  m_springbarleystriglingsingle = new SpringBarleyStriglingSingle;
938  m_springbarleystriglingculm = new SpringBarleyStriglingCulm;
939  m_maizestrigling = new MaizeStrigling;
940  m_winterrapestrigling = new WinterRapeStrigling;
941  m_winterryestrigling = new WinterRyeStrigling;
942  m_winterbarleystrigling = new WinterBarleyStrigling;
943  m_fieldpeasstrigling = new FieldPeasStrigling;
944  m_springbarleypeaclovergrassstrigling = new SpringBarleyPeaCloverGrassStrigling;
945  m_youngforest = new YoungForestCrop;
947  // Defaults that need to be overridden when necessary
948  m_stockfarmer = false;
949  m_intensity = 0;
950  m_HuntersList.resize(0); // Set the number of hunters to zero at the start.
951 }
PermanentGrassGrazed * m_permgrassgrazed
Definition: farm.h:909
PotatoesIndustry * m_potatoesindustry
Definition: farm.h:914
OGrazingPigs * m_ograzingpigs
Definition: farm.h:889
int m_rotation_sync_index
Definition: farm.h:847
OTriticale * m_otriticale
Definition: farm.h:901
FieldPeasStrigling * m_fieldpeasstrigling
Definition: farm.h:946
SpringBarleySpr * m_springbarleyspr
Definition: farm.h:919
OPotatoes * m_opotatoes
Definition: farm.h:894
OCloverGrassGrazed1 * m_OCGG1
Definition: farm.h:883
SetAside * m_setaside
Definition: farm.h:917
Triticale * m_triticale
Definition: farm.h:926
OWinterWheatUndersown * m_owinterwheatundersown
Definition: farm.h:906
OWinterBarley * m_owinterbarley
Definition: farm.h:902
OOats * m_ooats
Definition: farm.h:892
SpringRape * m_springrape
Definition: farm.h:925
SeedGrass2 * m_seedgrass2
Definition: farm.h:916
OWinterWheat * m_owinterwheat
Definition: farm.h:907
SpringBarley * m_springbarley
Definition: farm.h:918
SpringBarleySeed * m_springbarleyseed
Definition: farm.h:923
OMaizeSilage * m_omaizesilage
Definition: farm.h:880
AgroChemIndustryCereal * m_agrochemindustrycereal
Definition: farm.h:934
OCarrots * m_ocarrots
Definition: farm.h:882
OWinterRape * m_owinterrape
Definition: farm.h:904
Sugarbeet * m_sugarbeet
Definition: farm.h:876
CloverGrassGrazed1 * m_CGG1
Definition: farm.h:871
FodderGrass * m_foddergrass
Definition: farm.h:870
OFodderbeet * m_ofodderbeet
Definition: farm.h:877
CloverGrassGrazed2 * m_CGG2
Definition: farm.h:872
WinterRapeStrigling * m_winterrapestrigling
Definition: farm.h:943
WinterRye * m_winterrye
Definition: farm.h:929
WinterRape * m_winterrape
Definition: farm.h:928
MaizeStrigling * m_maizestrigling
Definition: farm.h:942
OWinterWheatUndersownExt * m_owinterwheatundersownext
Definition: farm.h:908
OSeedGrass2 * m_oseedgrass2
Definition: farm.h:896
SpringBarleyStriglingCulm * m_springbarleystriglingculm
Definition: farm.h:940
WinterBarleyStrigling * m_winterbarleystrigling
Definition: farm.h:945
PermanentSetAside * m_permanentsetaside
Definition: farm.h:912
SpringBarleyCloverGrassStrigling * m_springbarleyclovergrassstrigling
Definition: farm.h:938
Maize * m_maize
Definition: farm.h:878
WinterWheatStriglingCulm * m_winterwheatstriglingculm
Definition: farm.h:936
OSpringBarley * m_ospringbarley
Definition: farm.h:897
SpringBarleySKManagement * m_springbarleyskmanagement
Definition: farm.h:920
WinterRyeStrigling * m_winterryestrigling
Definition: farm.h:944
Fodderbeet * m_fodderbeet
Definition: farm.h:875
bool m_stockfarmer
Definition: farm.h:845
FieldPeasSilage * m_fieldpeassilage
Definition: farm.h:874
Oats * m_oats
Definition: farm.h:891
PermanentGrassTussocky * m_permgrasstussocky
Definition: farm.h:911
WinterBarley * m_winterbarley
Definition: farm.h:927
FarmManager * m_OurManager
Pointer to the FarmManager.
Definition: farm.h:837
WinterWheatStriglingSingle * m_winterwheatstriglingsingle
Definition: farm.h:937
SpringBarleySilage * m_springbarleysilage
Definition: farm.h:924
OCloverGrassGrazed2 * m_OCGG2
Definition: farm.h:884
int m_intensity
Definition: farm.h:848
OFieldPeas * m_ofieldpeas
Definition: farm.h:886
OSeedGrass1 * m_oseedgrass1
Definition: farm.h:895
OPermanentGrassGrazed * m_opermgrassgrazed
Definition: farm.h:893
WWheatPControl * m_wwheatpcontrol
Definition: farm.h:931
SpringBarleyStriglingSingle * m_springbarleystriglingsingle
Definition: farm.h:941
SeedGrass1 * m_seedgrass1
Definition: farm.h:915
WWheatPTreatment * m_wwheatptreatment
Definition: farm.h:933
MaizeSilage * m_maizesilage
Definition: farm.h:879
OWinterRye * m_owinterrye
Definition: farm.h:905
OFirstYearDanger * m_ofirstyeardanger
Definition: farm.h:888
OSpringBarleyPigs * m_ospringbarleypigs
Definition: farm.h:899
SpringBarleyCloverGrass * m_sbarleyclovergrass
Definition: farm.h:922
OWinterBarleyExt * m_owinterbarleyext
Definition: farm.h:903
OSBarleySilage * m_osbarleysilage
Definition: farm.h:900
OBarleyPeaCloverGrass * m_OBarleyPCG
Definition: farm.h:881
YoungForestCrop * m_youngforest
Definition: farm.h:948
SpringBarleyPTreatment * m_springbarleyptreatment
Definition: farm.h:921
Potatoes * m_potatoes
Definition: farm.h:913
SpringBarleyPeaCloverGrassStrigling * m_springbarleypeaclovergrassstrigling
Definition: farm.h:947
WWheatPToxicControl * m_wwheatptoxiccontrol
Definition: farm.h:932
BroadBeans * m_broadbeans
Definition: farm.h:869
OFieldPeasSilage * m_ofieldpeassilage
Definition: farm.h:887
SpringBarleyStrigling * m_springbarleystrigling
Definition: farm.h:939
Carrots * m_carrots
Definition: farm.h:868
HunterList m_HuntersList
A list of hunters allocated to this farm.
Definition: farm.h:844
PermanentGrassLowYield * m_permgrasslowyield
Definition: farm.h:910
FieldPeas * m_fieldpeas
Definition: farm.h:873
WinterWheat * m_winterwheat
Definition: farm.h:930
WinterWheatStrigling * m_winterwheatstrigling
Definition: farm.h:935
OCloverGrassSilage1 * m_OCGS1
Definition: farm.h:885
OrchardCrop * m_orchardcrop
Definition: farm.h:890
OSpringBarleyExt * m_ospringbarleyext
Definition: farm.h:898
Farm::~Farm ( void  )
virtual

Farm destructor - deletes all crop instances and empties event queues.

Definition at line 958 of file farm.cpp.

References LowPriPair< ELEMTYPE >::m_element.

958  {
959  delete m_carrots;
960  delete m_broadbeans;
961  delete m_CGG2;
962  delete m_CGG1;
963  delete m_fieldpeas;
964  delete m_fieldpeassilage;
965  delete m_fodderbeet;
966  delete m_sugarbeet;
967  delete m_ofodderbeet;
968  delete m_foddergrass;
969  delete m_maizesilage;
970  delete m_omaizesilage;
971  delete m_maize;
972  delete m_ocarrots;
973  delete m_OCGG1;
974  delete m_OCGG2;
975  delete m_OCGS1;
976  delete m_ofieldpeas;
977  delete m_ofieldpeassilage;
978  delete m_ofirstyeardanger;
979  delete m_ograzingpigs;
980  delete m_orchardcrop;
981  delete m_ooats;
982  delete m_oats;
983  delete m_opermgrassgrazed;
984  delete m_opotatoes;
985  delete m_ospringbarley;
986  delete m_ospringbarleyext;
987  delete m_osbarleysilage;
988  delete m_ospringbarleypigs;
989  delete m_owinterbarley;
990  delete m_owinterbarleyext;
991  delete m_owinterrape;
992  delete m_owinterrye;
995  delete m_OBarleyPCG;
996  delete m_permanentsetaside;
997  delete m_permgrassgrazed;
998  delete m_permgrasstussocky;
999  delete m_permgrasslowyield;
1000  delete m_potatoes;
1001  delete m_potatoesindustry;
1002  delete m_sbarleyclovergrass;
1003  delete m_seedgrass2;
1004  delete m_seedgrass1;
1005  delete m_setaside;
1006  delete m_springbarley;
1007  delete m_springbarleyptreatment;
1009  delete m_springbarleyseed;
1010  delete m_springrape;
1011  delete m_springbarleysilage;
1012  delete m_agrochemindustrycereal;
1013  delete m_triticale;
1014  delete m_winterbarley;
1015  delete m_winterrape;
1016  delete m_winterrye;
1017  delete m_winterwheat;
1018  delete m_wwheatpcontrol;
1019  delete m_wwheatptoxiccontrol;
1020  delete m_wwheatptreatment;
1021  delete m_winterwheatstrigling;
1025  delete m_springbarleystrigling;
1028  delete m_maizestrigling;
1029  delete m_winterrapestrigling;
1030  delete m_winterryestrigling;
1031  delete m_winterbarleystrigling;
1032  delete m_fieldpeasstrigling;
1034  delete m_youngforest;
1036 
1037  while ( !m_queue.Empty() ) {
1038  pair = m_queue.Bottom();
1039  m_queue.Pop();
1040  delete pair.m_element;
1041  }
1042 }
PermanentGrassGrazed * m_permgrassgrazed
Definition: farm.h:909
PotatoesIndustry * m_potatoesindustry
Definition: farm.h:914
OGrazingPigs * m_ograzingpigs
Definition: farm.h:889
FieldPeasStrigling * m_fieldpeasstrigling
Definition: farm.h:946
OPotatoes * m_opotatoes
Definition: farm.h:894
OCloverGrassGrazed1 * m_OCGG1
Definition: farm.h:883
SetAside * m_setaside
Definition: farm.h:917
Triticale * m_triticale
Definition: farm.h:926
OWinterWheatUndersown * m_owinterwheatundersown
Definition: farm.h:906
OWinterBarley * m_owinterbarley
Definition: farm.h:902
OOats * m_ooats
Definition: farm.h:892
SpringRape * m_springrape
Definition: farm.h:925
SeedGrass2 * m_seedgrass2
Definition: farm.h:916
SpringBarley * m_springbarley
Definition: farm.h:918
SpringBarleySeed * m_springbarleyseed
Definition: farm.h:923
OMaizeSilage * m_omaizesilage
Definition: farm.h:880
void Pop()
Definition: lowqueue.h:124
AgroChemIndustryCereal * m_agrochemindustrycereal
Definition: farm.h:934
OCarrots * m_ocarrots
Definition: farm.h:882
OWinterRape * m_owinterrape
Definition: farm.h:904
Sugarbeet * m_sugarbeet
Definition: farm.h:876
CloverGrassGrazed1 * m_CGG1
Definition: farm.h:871
FodderGrass * m_foddergrass
Definition: farm.h:870
OFodderbeet * m_ofodderbeet
Definition: farm.h:877
CloverGrassGrazed2 * m_CGG2
Definition: farm.h:872
WinterRapeStrigling * m_winterrapestrigling
Definition: farm.h:943
WinterRye * m_winterrye
Definition: farm.h:929
WinterRape * m_winterrape
Definition: farm.h:928
MaizeStrigling * m_maizestrigling
Definition: farm.h:942
OWinterWheatUndersownExt * m_owinterwheatundersownext
Definition: farm.h:908
SpringBarleyStriglingCulm * m_springbarleystriglingculm
Definition: farm.h:940
WinterBarleyStrigling * m_winterbarleystrigling
Definition: farm.h:945
PermanentSetAside * m_permanentsetaside
Definition: farm.h:912
SpringBarleyCloverGrassStrigling * m_springbarleyclovergrassstrigling
Definition: farm.h:938
Maize * m_maize
Definition: farm.h:878
WinterWheatStriglingCulm * m_winterwheatstriglingculm
Definition: farm.h:936
OSpringBarley * m_ospringbarley
Definition: farm.h:897
SpringBarleySKManagement * m_springbarleyskmanagement
Definition: farm.h:920
WinterRyeStrigling * m_winterryestrigling
Definition: farm.h:944
Fodderbeet * m_fodderbeet
Definition: farm.h:875
FieldPeasSilage * m_fieldpeassilage
Definition: farm.h:874
Oats * m_oats
Definition: farm.h:891
LowPriority< FarmEvent * > m_queue
Definition: farm.h:838
PermanentGrassTussocky * m_permgrasstussocky
Definition: farm.h:911
bool Empty(void)
Definition: lowqueue.h:129
WinterBarley * m_winterbarley
Definition: farm.h:927
WinterWheatStriglingSingle * m_winterwheatstriglingsingle
Definition: farm.h:937
SpringBarleySilage * m_springbarleysilage
Definition: farm.h:924
OCloverGrassGrazed2 * m_OCGG2
Definition: farm.h:884
OFieldPeas * m_ofieldpeas
Definition: farm.h:886
ELEMTYPE m_element
Definition: lowqueue.h:88
OPermanentGrassGrazed * m_opermgrassgrazed
Definition: farm.h:893
WWheatPControl * m_wwheatpcontrol
Definition: farm.h:931
SpringBarleyStriglingSingle * m_springbarleystriglingsingle
Definition: farm.h:941
SeedGrass1 * m_seedgrass1
Definition: farm.h:915
WWheatPTreatment * m_wwheatptreatment
Definition: farm.h:933
MaizeSilage * m_maizesilage
Definition: farm.h:879
OWinterRye * m_owinterrye
Definition: farm.h:905
OFirstYearDanger * m_ofirstyeardanger
Definition: farm.h:888
OSpringBarleyPigs * m_ospringbarleypigs
Definition: farm.h:899
SpringBarleyCloverGrass * m_sbarleyclovergrass
Definition: farm.h:922
OWinterBarleyExt * m_owinterbarleyext
Definition: farm.h:903
OSBarleySilage * m_osbarleysilage
Definition: farm.h:900
OBarleyPeaCloverGrass * m_OBarleyPCG
Definition: farm.h:881
YoungForestCrop * m_youngforest
Definition: farm.h:948
SpringBarleyPTreatment * m_springbarleyptreatment
Definition: farm.h:921
Potatoes * m_potatoes
Definition: farm.h:913
SpringBarleyPeaCloverGrassStrigling * m_springbarleypeaclovergrassstrigling
Definition: farm.h:947
WWheatPToxicControl * m_wwheatptoxiccontrol
Definition: farm.h:932
BroadBeans * m_broadbeans
Definition: farm.h:869
OFieldPeasSilage * m_ofieldpeassilage
Definition: farm.h:887
LowPriPair< ELEMTYPE > Bottom(void)
Definition: lowqueue.h:134
SpringBarleyStrigling * m_springbarleystrigling
Definition: farm.h:939
Carrots * m_carrots
Definition: farm.h:868
PermanentGrassLowYield * m_permgrasslowyield
Definition: farm.h:910
FieldPeas * m_fieldpeas
Definition: farm.h:873
WinterWheat * m_winterwheat
Definition: farm.h:930
WinterWheatStrigling * m_winterwheatstrigling
Definition: farm.h:935
OCloverGrassSilage1 * m_OCGS1
Definition: farm.h:885
OrchardCrop * m_orchardcrop
Definition: farm.h:890
OSpringBarleyExt * m_ospringbarleyext
Definition: farm.h:898
Used in event handling.
Definition: lowqueue.h:83

Member Function Documentation

void Farm::AddField ( LE a_newfield)

Adds a field to a farm.

Definition at line 1161 of file farm.cpp.

References LE::GetElementType(), tole_Orchard, tole_PermanentSetaside, tole_PermPasture, tole_PermPastureLowYield, tole_PermPastureTussocky, and tole_YoungForest.

1161  {
1162  int i = (int) m_fields.size();
1163 
1164  m_fields.resize( i + 1 );
1165  m_fields[ i ] = a_newfield;
1166  // Must set the rot index to something other than -1, but identify it as not usefully set as yet.
1167  TTypesOfLandscapeElement ele = a_newfield->GetElementType();
1168  switch (ele) {
1170  case tole_YoungForest:
1171  case tole_PermPasture:
1174  case tole_Orchard:
1175  m_fields[ i ]->SetRotIndex(-2);
1176  break;
1177  default:
1178  m_fields[ i ]->SetRotIndex(-1);
1179  }
1180 }
vector< LE * > m_fields
Definition: farm.h:839
virtual TTypesOfLandscapeElement GetElementType(void)
Definition: elements.h:113
TTypesOfLandscapeElement
void Farm::AddHunter ( Hunter *  a_hunter)
inline

Definition at line 824 of file farm.h.

824  {
825  m_HuntersList.push_back( a_hunter );
826  }
HunterList m_HuntersList
A list of hunters allocated to this farm.
Definition: farm.h:844
void Farm::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 at line 599 of file farm.cpp.

600  {
601  FarmEvent * ev = new FarmEvent( a_event, a_field, a_todo, a_run, a_lock, a_start, a_first_year, a_crop );
602  m_queue.Push( ev, a_date );
603 }
A struct to hold the information required to trigger a farm event.
Definition: farm.h:391
LowPriority< FarmEvent * > m_queue
Definition: farm.h:838
void Push(ELEMTYPE a_element, long a_priority)
Definition: lowqueue.h:119
void Farm::Assign_rotation ( vector< TTypesOfVegetation a_new_rotation)

Definition at line 1201 of file farm.cpp.

Referenced by FarmManager::Switch_rotation().

1201  {
1202 
1203  m_rotation.clear();
1204  m_rotation = a_new_rotation;
1205 
1206 }
vector< TTypesOfVegetation > m_rotation
Definition: farm.h:840
void Farm::AssignPermanentCrop ( TTypesOfVegetation  tov,
int  pct 
)
protected

Used to assign a permanent crop to an otherwise rotational field polygon.

Definition at line 1973 of file farm.cpp.

References CompPcts(), GetArea(), tpct::index, InvIntPartition(), m_fields, tpct::pct, and tov_Undefined.

Referenced by OptimisingFarm::InitiateManagement().

1973  {
1974  // Assumes that m_fields has all the fields already in it, and those that are occupied by permanent tole types
1975  // are denoted by -2 or -4 in rotindex, -1 is unassigned - can't use enum because positive values have other meanings
1976  // First get the areas of all fields and then convert these to percentages
1977  tpct a_tpct;
1978  vector<LE*> fields_cpy;
1979  fields_cpy.resize(m_fields.size());
1980  copy(m_fields.begin(), m_fields.end(), fields_cpy.begin());
1981  vector<tpct> pcts;
1982  double area = 0.0;
1983  int sz = (int) fields_cpy.size();
1984  for (int i=sz-1; i>=0; i--) {
1985  if ( fields_cpy[i]->GetRotIndex()<-1) {
1986  if (fields_cpy[i]->GetRotIndex()==-4) area += fields_cpy[i]->GetArea();
1987  fields_cpy.erase(fields_cpy.begin()+i);
1988  }
1989  else area += fields_cpy[i]->GetArea();
1990  }
1991  // Here we can take action if we only have a single field (could extend this if it was thought worth it)
1992  int fnos = (int) fields_cpy.size();
1993  if (fnos<1) return; // No fields to allocate, jump out
1994  else if (fnos<2) {
1995  // Use the pct as the chance that our single field is assigned
1996  if (random(100)>=pct) return;
1997  else {
1998  // Add field by default
1999  fields_cpy[0]->SetRotIndex(-4);
2000  // Assign the crop
2001  fields_cpy[0]->SetVegType(tov, tov_Undefined);
2002  return;
2003  }
2004  }
2005  for (int i=0; i<fnos; i++) {
2006  a_tpct.pct = (int) floor(0.5+((fields_cpy[i]->GetArea()/area)*100));
2007  a_tpct.index = i;
2008  pcts.push_back(a_tpct);
2009  }
2010  // We need to look for combinations of fields that are close to our target.
2011  // First we can sort the array and ignore any that are greater than pct
2012  sort (pcts.begin(), pcts.end(), CompPcts); // results in ordering on increasing pct
2013  // now remove all those with pct>target+10% to save loads of time in the inverse integer partition
2014  int index=-1;
2015  int ind=0;
2016  int apct=pct+10; // Lets assume we have a tolerance of 10%
2017  while ((index==-1) && (ind< (int)pcts.size())) {
2018  if (pcts[ind++].pct>apct) index=ind;
2019  }
2020  if (index!=-1) pcts.erase(pcts.begin()+index,pcts.end());
2021  // Now find the best combination of fields to get close to our target & set them
2022  int bits = InvIntPartition(&pcts,pct);
2023  int mask=1;
2024  ind = 0;
2025  int used=0;
2026  //double pctused = 0.0;
2027  double check = 0.0;
2028  for (int h=0; h< (int)pcts.size(); h++) check+=fields_cpy[pcts[h].index]->GetArea();
2029  while (bits>0) {
2030  if ((bits & mask) > 0) {
2031  // Set the field as non-rotating
2032  fields_cpy[pcts[ind].index]->SetRotIndex(-4);
2033  // Assign the crop
2034  fields_cpy[pcts[ind].index]->SetVegType(tov, tov_Undefined);
2035  used += (int) fields_cpy[pcts[ind].index]->GetArea();
2036  //pctused = used/area;
2037  bits -= mask;
2038  }
2039  mask = mask << 1;
2040  ind++;
2041  }
2042 }
vector< LE * > m_fields
Definition: farm.h:839
int InvIntPartition(vector< tpct > *items, int target)
Finds all possible sums of the integers in the items array.
Definition: farm.cpp:2045
int pct
Definition: farm.h:384
int GetArea(void)
Returns the area of arable fields owned by that farm.
Definition: farm.cpp:1045
bool CompPcts(tpct i, tpct j)
Used for sorting a farmers field size vector.
Definition: farm.cpp:245
Used for storing farmers field size vectors.
Definition: farm.h:382
int index
Definition: farm.h:383
bool Farm::AutumnHarrow ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out a harrow event in the autumn on a_field.

Definition at line 154 of file farmfuncs.cpp.

References autumn_harrow, DO_IT_PROB, g_weather, LE::GetUnsprayedMarginPolyRef(), LE::InsectMortality(), Weather::Raining(), LE::SetLastTreatment(), Landscape::SupplyLEPointer(), LE::Trace(), and LE::ZeroVeg().

155 {
156 
157  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
158  a_field->Trace( autumn_harrow );
159  a_field->SetLastTreatment( autumn_harrow );
160  // Apply 90% mortality to the insects
161  a_field->InsectMortality( 0.1 );
162  // Reduce the vegetation to zero
163  a_field->ZeroVeg();
164  int pref=a_field->GetUnsprayedMarginPolyRef();
165  if (pref!=-1){
166  // Must have an unsprayed margin so need to pass the information on to it
167  LE* um=g_landscape_p->SupplyLEPointer(pref);
169  um->InsectMortality( 0.1 );
170  um->ZeroVeg();
171  }
172  return true;
173  }
174  return false;
175 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
bool Raining(void)
Definition: weather.h:432
virtual void InsectMortality(double)
Definition: elements.h:159
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
virtual void ZeroVeg(void)
Definition: elements.h:174
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::AutumnPlough ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out a ploughing event in the autumn on a_field.

Definition at line 100 of file farmfuncs.cpp.

References autumn_plough, DO_IT_PROB, g_weather, LE::GetUnsprayedMarginPolyRef(), LE::InsectMortality(), Weather::Raining(), LE::SetLastTreatment(), Landscape::SupplyLEPointer(), LE::Trace(), and LE::ZeroVeg().

101 {
102 
103  // LE is a pointer to the field element
104  // a_user is a pointer to the farm
105  // a_days is the end of the operation time - today
106  // if a_days <0 then the time to do it is passed
107  // the line below reads 'plough if last day possible OR if not raining and pass a probability test
108  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
109  // this bit sets up the events to occur when ploughing occurs
110  // The trace below is for debugging checks
111  a_field->Trace( autumn_plough );
112  // Record the event for this field, so other objects can find out it has happened
113  a_field->SetLastTreatment( autumn_plough );
114  // Apply mortality to the insects present, in this case 90%. This only affects the general insect model, any ALMaSS model species need to take their specific action.
115  a_field->InsectMortality( 0.1 );
116  // Reduce the vegetation, in this case to zero
117  a_field->ZeroVeg();
118  // If the field has a field margin, then do all this to the field margin too. In events that don't occur on an unsprayed margin, e.g. insecticide, then is part is skipped.
119  int pref=a_field->GetUnsprayedMarginPolyRef();
120  if (pref!=-1){
121  // Must have an unsprayed margin so need to pass the information on to it
122  LE* um=g_landscape_p->SupplyLEPointer(pref);
124  um->InsectMortality( 0.1 );
125  um->ZeroVeg();
126  }
127  return true; // completed
128  }
129  return false; // not completed
130 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
bool Raining(void)
Definition: weather.h:432
virtual void InsectMortality(double)
Definition: elements.h:159
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
virtual void ZeroVeg(void)
Definition: elements.h:174
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::AutumnRoll ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out a roll event in the autumn on a_field.

Definition at line 181 of file farmfuncs.cpp.

References autumn_roll, DO_IT_PROB, g_weather, LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), Landscape::SupplyLEPointer(), LE::Trace(), and LE::ZeroVeg().

182 {
183 
184  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
185  a_field->Trace( autumn_roll );
186  a_field->SetLastTreatment( autumn_roll );
187  a_field->ZeroVeg();
188  int pref=a_field->GetUnsprayedMarginPolyRef();
189  if (pref!=-1){
190  // Must have an unsprayed margin so need to pass the information on to it
191  LE* um=g_landscape_p->SupplyLEPointer(pref);
193  um->ZeroVeg();
194  }
195  return true;
196  }
197  return false;
198 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
bool Raining(void)
Definition: weather.h:432
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
virtual void ZeroVeg(void)
Definition: elements.h:174
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::AutumnSow ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out a sowing event in the autumn on a_field.

Definition at line 204 of file farmfuncs.cpp.

References autumn_sow, DO_IT_PROB, g_weather, LE::GetUnsprayedMarginPolyRef(), LE::GetVegType(), Weather::Raining(), LE::SetGrowthPhase(), LE::SetLastSownVeg(), LE::SetLastTreatment(), sow, Landscape::SupplyLEPointer(), LE::Trace(), and LE::ZeroVeg().

205 {
206 
207  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
208  a_field->Trace( autumn_sow );
209  a_field->SetLastTreatment( autumn_sow );
210  a_field->SetGrowthPhase( sow );
211  a_field->SetLastSownVeg(a_field->GetVegType());
212  // Reduce the vegetation to zero
213  a_field->ZeroVeg();
214  int pref=a_field->GetUnsprayedMarginPolyRef();
215  if (pref!=-1){
216  // Must have an unsprayed margin so need to pass the information on to it
217  LE* um=g_landscape_p->SupplyLEPointer(pref);
219  um->SetGrowthPhase( sow );
220  um->ZeroVeg();
221  um->SetLastSownVeg(um->GetVegType());
222  }
223  return true;
224  }
225  return false;
226 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
void SetLastSownVeg(TTypesOfVegetation a_tov)
Records the last vegetation type to be sown.
Definition: elements.h:287
class Weather * g_weather
Definition: weather.cpp:41
virtual TTypesOfVegetation GetVegType(void)
Definition: elements.h:125
bool Raining(void)
Definition: weather.h:432
Definition: plants.h:51
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
virtual void SetGrowthPhase(int)
Definition: elements.h:170
virtual void ZeroVeg(void)
Definition: elements.h:174
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::BurnStrawStubble ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Burn stubble on a_field.

Definition at line 1864 of file farmfuncs.cpp.

References burn_straw_stubble, Calendar::Date(), DO_IT_PROB, EL_TRAMLINE_DECAYTIME, g_date, g_weather, Weather::GetRainPeriod(), LE::GetUnsprayedMarginPolyRef(), LE::InsectMortality(), LE::ReduceVeg(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

1865 {
1866 
1867  if ( (0 >= a_days) && (g_weather->GetRainPeriod(g_date->Date(),3)>0.1))
1868  {
1869  return true;
1870  }
1871  if ( (0 >= a_days) || ((g_weather->GetRainPeriod(g_date->Date(),3)<0.1)
1872  && DoIt(DO_IT_PROB)))
1873  {
1874  a_field->Trace( burn_straw_stubble );
1876  a_field->InsectMortality( 0.4 );
1877  a_field->ReduceVeg( 0.2 );
1879  int pref=a_field->GetUnsprayedMarginPolyRef();
1880  if (pref!=-1){
1881  // Must have an unsprayed margin so need to pass the information on to it
1882  LE* um=g_landscape_p->SupplyLEPointer(pref);
1884  um->ReduceVeg( 0.2 );
1885  um->InsectMortality( 0.4 );
1887  }
1888  return true;
1889  }
1890  return false;
1891 }
long Date(void)
Definition: calendar.h:57
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
virtual void ReduceVeg(double)
Definition: elements.h:175
virtual void InsectMortality(double)
Definition: elements.h:159
class Calendar * g_date
Definition: calendar.cpp:38
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
double GetRainPeriod(long a_date, unsigned int a_period)
Definition: weather.cpp:278
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::CattleIsOut ( LE a_field,
double  a_user,
int  a_days,
int  a_max 
)
virtual

Generate a 'cattle_out' event for every day the cattle are on a_field.

This is the main grazing method and as such is called by all grazed field management plans each day the cattle are out.

Definition at line 1602 of file farmfuncs.cpp.

References cattle_out, Calendar::DayInYear(), g_date, LE::GetUnsprayedMarginPolyRef(), LE::GetVegBiomass(), LE::GrazeVegetation(), l_farm_cattle_veg_reduce, LE::SetLastTreatment(), Landscape::SupplyLEPointer(), LE::ToggleCattleGrazing(), LE::Trace(), and CfgFloat::value().

1603 {
1607  double biomass = a_field->GetVegBiomass();
1608  if (biomass > 100.0)
1609  {
1610  a_field->SetLastTreatment(cattle_out);
1611  a_field->Trace(cattle_out);
1612  // Reduce the vegetation because of grazing
1613  //double h=a_field->GetVegHeight();
1614  //double reduc = 1-(l_farm_cattle_veg_reduce.value()*((h-15)/15));
1615  //a_field->ReduceVeg_Extended( reduc );
1616  a_field->GrazeVegetation( l_farm_cattle_veg_reduce.value( ), false );
1617  int pref = a_field->GetUnsprayedMarginPolyRef();
1618  if (pref != -1)
1619  {
1620  // Must have an unsprayed margin so need to pass the information on to it
1621  LE* um = g_landscape_p->SupplyLEPointer(pref);
1624  }
1625  }
1626  int d1 = g_date->DayInYear(10, 9);
1627  if (d1 > a_max) d1 = a_max;
1628  if ((((g_date->DayInYear() > d1) && (10 >= a_days)) && DoIt(10)) || (0 >= a_days))
1629  {
1630  a_field->ToggleCattleGrazing();
1631  int pref = a_field->GetUnsprayedMarginPolyRef();
1632  if (pref != -1){
1633  // Must have an unsprayed margin so need to pass the information on to it
1634  LE* um = g_landscape_p->SupplyLEPointer(pref);
1635  um->ToggleCattleGrazing();
1636  }
1637  return true;
1638  }
1639  return false;
1640 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
static CfgFloat l_farm_cattle_veg_reduce("FARM_CATTLE_VEG_REDUCE", CFG_CUSTOM, 1.5)
double value(void)
Definition: configurator.h:107
Definition: elements.h:81
virtual double GetVegBiomass(void)
Definition: elements.h:154
int DayInYear(void)
Definition: calendar.h:58
virtual void ToggleCattleGrazing(void)
Definition: elements.h:161
class Calendar * g_date
Definition: calendar.cpp:38
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
virtual void GrazeVegetation(double, bool)
Definition: elements.h:225
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::CattleIsOutLow ( LE a_field,
double  a_user,
int  a_days,
int  a_max 
)
virtual

Generate a 'cattle_out_low' event for every day the cattle are on a_field.

Definition at line 1646 of file farmfuncs.cpp.

References cattle_out_low, Calendar::DayInYear(), g_date, LE::GetUnsprayedMarginPolyRef(), LE::GetVegBiomass(), LE::GrazeVegetation(), l_farm_cattle_veg_reduce2, LE::SetLastTreatment(), Landscape::SupplyLEPointer(), LE::ToggleCattleGrazing(), LE::Trace(), and CfgFloat::value().

1647 {
1648 
1649  // Generate a 'cattle_in_out' event for every day the cattle is on the
1650  // field.
1651  double biomass = a_field->GetVegBiomass();
1652  if (biomass > 100.0)
1653  {
1654  a_field->SetLastTreatment(cattle_out_low);
1655  a_field->Trace(cattle_out_low);
1656  // Reduce the vegetation because of grazing
1657  //double h=a_field->GetVegHeight();
1658  //double reduc = 1-(l_farm_cattle_veg_reduce2.value()*((h-15)/15));
1659  //a_field->ReduceVeg_Extended( reduc );
1660  a_field->GrazeVegetation( l_farm_cattle_veg_reduce2.value( ), false );
1661  int pref = a_field->GetUnsprayedMarginPolyRef();
1662  if (pref != -1)
1663  {
1664  // Must have an unsprayed margin so need to pass the information on to it
1665  LE* um = g_landscape_p->SupplyLEPointer(pref);
1668  }
1669  }
1670  int d1 = g_date->DayInYear(10, 9);
1671  if (d1 > a_max) d1 = a_max;
1672  if ((((g_date->DayInYear() > d1) && (10 >= a_days)) && DoIt(10)) || (0 >= a_days))
1673  {
1674  a_field->ToggleCattleGrazing();
1675  int pref = a_field->GetUnsprayedMarginPolyRef();
1676  if (pref != -1){
1677  // Must have an unsprayed margin so need to pass the information on to it
1678  LE* um = g_landscape_p->SupplyLEPointer(pref);
1679  um->ToggleCattleGrazing();
1680  }
1681  return true;
1682  }
1683  return false;
1684 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
double value(void)
Definition: configurator.h:107
Definition: elements.h:81
virtual double GetVegBiomass(void)
Definition: elements.h:154
int DayInYear(void)
Definition: calendar.h:58
virtual void ToggleCattleGrazing(void)
Definition: elements.h:161
class Calendar * g_date
Definition: calendar.cpp:38
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
static CfgFloat l_farm_cattle_veg_reduce2("FARM_CATTLE_VEG_REDUCE_LOW", CFG_CUSTOM, 1.00)
Landscape * g_landscape_p
Definition: Landscape.cpp:238
virtual void GrazeVegetation(double, bool)
Definition: elements.h:225
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::CattleOut ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Start a grazing event on a_field today.

This is the main initiate grazing method and as such is called by all grazed field management plans at the moment cattle are put out.

Definition at line 1538 of file farmfuncs.cpp.

References cattle_out, DO_IT_PROB, LE::GetUnsprayedMarginPolyRef(), LE::GrazeVegetation(), l_farm_cattle_veg_reduce, LE::SetLastTreatment(), Landscape::SupplyLEPointer(), LE::ToggleCattleGrazing(), LE::Trace(), and CfgFloat::value().

1539 {
1543  if ((0 >= a_days) || DoIt( DO_IT_PROB ))
1544  {
1545  a_field->ToggleCattleGrazing();
1546  a_field->Trace( cattle_out );
1547  a_field->SetLastTreatment( cattle_out );
1548  // Reduce the vegetation because of grazing
1549  //double h=a_field->GetVegHeight();
1550  //double reduc = 1-(l_farm_cattle_veg_reduce.value()*((h-15)/15));
1551  //a_field->ReduceVeg_Extended( reduc );
1552  a_field->GrazeVegetation( l_farm_cattle_veg_reduce.value(), false );
1553  int pref = a_field->GetUnsprayedMarginPolyRef();
1554  if (pref != -1)
1555  {
1556  // Must have an unsprayed margin so need to pass the information on to it
1557  // This happens if all arable fields are given unsprayed margins - they have no effect on grass unless it is sprayed with pesticides
1558  LE* um = g_landscape_p->SupplyLEPointer( pref );
1559  um->ToggleCattleGrazing();
1562  }
1563  return true;
1564  }
1565  return false;
1566 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
static CfgFloat l_farm_cattle_veg_reduce("FARM_CATTLE_VEG_REDUCE", CFG_CUSTOM, 1.5)
double value(void)
Definition: configurator.h:107
Definition: elements.h:81
virtual void ToggleCattleGrazing(void)
Definition: elements.h:161
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
virtual void GrazeVegetation(double, bool)
Definition: elements.h:225
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::CattleOutLowGrazing ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Start a extensive grazing event on a_field today.

Definition at line 1572 of file farmfuncs.cpp.

References cattle_out_low, DO_IT_PROB, LE::GetUnsprayedMarginPolyRef(), LE::GrazeVegetation(), l_farm_cattle_veg_reduce2, LE::SetLastTreatment(), Landscape::SupplyLEPointer(), LE::ToggleCattleGrazing(), LE::Trace(), and CfgFloat::value().

1573 {
1574 
1575  if ( (0 >= a_days)|| DoIt(DO_IT_PROB)) {
1576  a_field->ToggleCattleGrazing();
1577  a_field->Trace( cattle_out_low );
1578  a_field->SetLastTreatment( cattle_out_low );
1579  // Reduce the vegetation because of grazing
1580  //double h=a_field->GetVegHeight();
1581  //double reduc = 1-(l_farm_cattle_veg_reduce.value()*((h-15)/15));
1582  //a_field->ReduceVeg_Extended( reduc );
1583  a_field->GrazeVegetation( l_farm_cattle_veg_reduce2.value( ), false );
1584  int pref=a_field->GetUnsprayedMarginPolyRef();
1585  if (pref!=-1){
1586  // Must have an unsprayed margin so need to pass the information on to it
1587  // This happens if all arable fields are given unsprayed margins - they have no effect on grass unless it is sprayed with pesticides
1588  LE* um=g_landscape_p->SupplyLEPointer(pref);
1589  um->ToggleCattleGrazing();
1592  }
1593  return true;
1594  }
1595  return false;
1596 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
double value(void)
Definition: configurator.h:107
Definition: elements.h:81
virtual void ToggleCattleGrazing(void)
Definition: elements.h:161
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
static CfgFloat l_farm_cattle_veg_reduce2("FARM_CATTLE_VEG_REDUCE_LOW", CFG_CUSTOM, 1.00)
Landscape * g_landscape_p
Definition: Landscape.cpp:238
virtual void GrazeVegetation(double, bool)
Definition: elements.h:225
void Trace(int a_value)
Definition: elements.cpp:459
void Farm::Centroids ( )

Finds farm's centroids - x and y.

Calculate a farm's centroid as an average of its fields' centroids.

Definition at line 4857 of file farm.cpp.

References m_farm_centroidx, m_farm_centroidy, and m_fields.

Referenced by FarmManager::FindNeighbours().

4857  {
4860  int sum_centroidx = 0;
4861  int sum_centroidy = 0;
4862  int no_fields = (int)m_fields.size();
4863  for (int i=0; i<no_fields; i++){
4864  sum_centroidx += m_fields[i]->GetCentroidX();
4865  sum_centroidy += m_fields[i]->GetCentroidY();
4866  }
4867  m_farm_centroidx = sum_centroidx/no_fields;
4868  m_farm_centroidy = sum_centroidy/no_fields;
4869 }
vector< LE * > m_fields
Definition: farm.h:839
int m_farm_centroidy
Farm&#39;s centroid, value y. Equal to the average of the y centroid values of all farm&#39;s fields...
Definition: farm.h:863
int m_farm_centroidx
Farm&#39;s centroid, value x. Equal to the average of the x centroid values of all farm&#39;s fields...
Definition: farm.h:861
void Farm::CheckRotationManagementLoop ( FarmEvent ev)
protected

Rotation error check function

Definition at line 641 of file farm.cpp.

References Calendar::Date(), g_date, g_msg, LE::GetMgtLoopDetectCount(), LE::GetMgtLoopDetectDate(), FarmEvent::m_field, LE::SetMgtLoopDetectCount(), MapErrorMsg::Warn(), and WARN_BUG.

641  {
642  if ( ev->m_field->GetMgtLoopDetectDate() == g_date->Date() ) {
643  // The last crop managment plan stopped on the same day as
644  // it was started.
645 
646  // Bump loop counter.
648 
649  if ( ev->m_field->GetMgtLoopDetectCount() > ( long )( m_rotation.size() + 2 ) ) {
650  // We have a loop.
651  char errornum[ 20 ];
652  sprintf( errornum, "%d", m_farmtype );
653  g_msg->Warn( WARN_BUG, "Rotation management loop detected in farmtype ", errornum );
654  exit( 1 );
655  }
656  } else {
657  ev->m_field->SetMgtLoopDetectCount( 0 );
658  }
659 }
long Date(void)
Definition: calendar.h:57
long GetMgtLoopDetectCount(void)
Definition: elements.h:121
vector< TTypesOfVegetation > m_rotation
Definition: farm.h:840
LE * m_field
Definition: farm.h:400
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
TTypesOfFarm m_farmtype
Definition: farm.h:842
long GetMgtLoopDetectDate(void)
Definition: elements.h:119
class Calendar * g_date
Definition: calendar.cpp:38
void SetMgtLoopDetectCount(long a_num)
Definition: elements.h:122
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
bool Farm::CutOrch ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Cut vegetation on orchard crop. //based on cut to silage - values from cutting function of orchard.

Definition at line 1988 of file farmfuncs.cpp.

References DO_IT_PROB, g_weather, LE::GetUnsprayedMarginPolyRef(), harvest1, LE::InsectMortality(), mow, Weather::Raining(), LE::ReduceVeg_Extended(), LE::SetGrowthPhase(), LE::SetLastTreatment(), LE::SetMownDecay(), LE::SetVegParameters(), Landscape::SupplyLEPointer(), LE::Trace(), and CfgFloat::value().

1989 {
1990 
1991  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
1992  a_field->Trace( mow ); //? tried to do=mow...
1993  a_field->SetLastTreatment( mow );
1994  a_field->SetMownDecay( 12 ); // 12 days of not suitable
1995  //ReduceVeg_Extended( 0.2 );
1996  //a_field->InsectMortality( 0.4 );
1997  a_field->SetGrowthPhase( harvest1 );
1998  //m_DateCut = a_today; ?? what to substitute it with?
1999 
2000  a_field->SetVegParameters( l_el_o_cut_height.value(), l_el_o_cut_total.value(), l_el_o_cut_green.value(), 0 ); //is 0 ok for weed biomass
2001 
2002  int pref=a_field->GetUnsprayedMarginPolyRef();
2003  if (pref!=-1){
2004  // Must have an unsprayed margin so need to pass the information on to it
2005  LE* um=g_landscape_p->SupplyLEPointer(pref);
2006  um->SetLastTreatment( mow );
2007  um->ReduceVeg_Extended( 0.2 ); //are these values ok?
2008  um->InsectMortality( 0.4 );
2010  }
2011  return true;
2012  }
2013  return false;
2014 }
CfgFloat l_el_o_cut_height
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
virtual void SetVegParameters(double, double, double, double)
Definition: elements.h:166
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
double value(void)
Definition: configurator.h:107
Definition: elements.h:81
void SetMownDecay(int a_decaytime_days)
Definition: elements.h:308
class Weather * g_weather
Definition: weather.cpp:41
virtual void ReduceVeg_Extended(double)
Definition: elements.h:176
bool Raining(void)
Definition: weather.h:432
CfgFloat l_el_o_cut_green
virtual void InsectMortality(double)
Definition: elements.h:159
Definition: treatment.h:82
CfgFloat l_el_o_cut_total
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
virtual void SetGrowthPhase(int)
Definition: elements.h:170
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::CutToHay ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out hay cutting on a_field.

Definition at line 1897 of file farmfuncs.cpp.

References cut_to_hay, Calendar::Date(), DO_IT_PROB, EL_TRAMLINE_DECAYTIME, g_date, g_weather, Weather::GetRainPeriod(), LE::GetUnsprayedMarginPolyRef(), harvest1, LE::InsectMortality(), LE::ReduceVeg_Extended(), LE::SetGrowthPhase(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), LE::SetVegHeight(), Landscape::SupplyLEPointer(), and LE::Trace().

1898 {
1899 
1900  if ( (0 >= a_days) || ((g_weather->GetRainPeriod(g_date->Date(),5)<0.1)
1901  && DoIt(DO_IT_PROB)))
1902  {
1903  a_field->Trace( cut_to_hay );
1904  a_field->SetLastTreatment( cut_to_hay );
1905  a_field->SetGrowthPhase(harvest1);
1906  a_field->InsectMortality(0.4);
1907  a_field->ReduceVeg_Extended( 0.2 );
1908  a_field->SetVegHeight(10);
1909  //a_field->ResetDigestability();
1911  int pref=a_field->GetUnsprayedMarginPolyRef();
1912  if (pref!=-1){
1913  // Must have an unsprayed margin so need to pass the information on to it
1914  LE* um=g_landscape_p->SupplyLEPointer(pref);
1916  um->SetGrowthPhase(harvest1);
1917  um->InsectMortality(0.4);
1918  um->ReduceVeg_Extended( 0.2 );
1919  um->SetVegHeight( 10);
1921  }
1922  return true;
1923  }
1924  return false;
1925 }
long Date(void)
Definition: calendar.h:57
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
virtual void SetVegHeight(double)
Definition: elements.h:165
class Weather * g_weather
Definition: weather.cpp:41
virtual void ReduceVeg_Extended(double)
Definition: elements.h:176
virtual void InsectMortality(double)
Definition: elements.h:159
class Calendar * g_date
Definition: calendar.cpp:38
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
virtual void SetGrowthPhase(int)
Definition: elements.h:170
double GetRainPeriod(long a_date, unsigned int a_period)
Definition: weather.cpp:278
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::CutToSilage ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Cut vegetation for silage on a_field.

Definition at line 1957 of file farmfuncs.cpp.

References cut_to_silage, DO_IT_PROB, EL_TRAMLINE_DECAYTIME, g_weather, LE::GetUnsprayedMarginPolyRef(), LE::InsectMortality(), Weather::Raining(), LE::ReduceVeg_Extended(), LE::ResetDigestability(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), LE::SetVegHeight(), Landscape::SupplyLEPointer(), and LE::Trace().

1958 {
1959 
1960  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
1961  a_field->Trace( cut_to_silage );
1962  a_field->SetLastTreatment( cut_to_silage );
1963  a_field->ReduceVeg_Extended( 0.2 );
1964  a_field->InsectMortality( 0.4 );
1965  a_field->SetVegHeight( 10 );
1967  //a_field->ResetDigestability();
1968  int pref=a_field->GetUnsprayedMarginPolyRef();
1969  if (pref!=-1){
1970  // Must have an unsprayed margin so need to pass the information on to it
1971  LE* um=g_landscape_p->SupplyLEPointer(pref);
1973  um->ReduceVeg_Extended( 0.2 );
1974  um->InsectMortality( 0.4 );
1975  um->SetVegHeight( 10 );
1977  um->ResetDigestability();
1978  }
1979  return true;
1980  }
1981  return false;
1982 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
virtual void SetVegHeight(double)
Definition: elements.h:165
class Weather * g_weather
Definition: weather.cpp:41
virtual void ResetDigestability()
sets growth record to zero in descendent classes
Definition: elements.h:370
virtual void ReduceVeg_Extended(double)
Definition: elements.h:176
bool Raining(void)
Definition: weather.h:432
virtual void InsectMortality(double)
Definition: elements.h:159
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::CutWeeds ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out weed topping on a_field.

Definition at line 1931 of file farmfuncs.cpp.

References cut_weeds, DO_IT_PROB, EL_TRAMLINE_DECAYTIME, g_weather, LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::ReduceVeg(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

1932 {
1933 
1934  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB)))
1935  {
1936  a_field->Trace( cut_weeds );
1937  a_field->SetLastTreatment( cut_weeds );
1938  a_field->ReduceVeg( 0.8 );
1940  int pref=a_field->GetUnsprayedMarginPolyRef();
1941  if (pref!=-1){
1942  // Must have an unsprayed margin so need to pass the information on to it
1943  LE* um=g_landscape_p->SupplyLEPointer(pref);
1944  um->SetLastTreatment( cut_weeds );
1945  um->ReduceVeg( 0.8 );
1947  }
1948  return true;
1949  }
1950  return false;
1951 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
virtual void ReduceVeg(double)
Definition: elements.h:175
bool Raining(void)
Definition: weather.h:432
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::DeepPlough ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out a deep ploughing event on a_field.

Definition at line 257 of file farmfuncs.cpp.

References deep_ploughing, DO_IT_PROB, g_weather, LE::GetUnsprayedMarginPolyRef(), LE::InsectMortality(), Weather::Raining(), LE::SetLastTreatment(), Landscape::SupplyLEPointer(), LE::Trace(), and LE::ZeroVeg().

258 {
259 
260  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
261  a_field->Trace( deep_ploughing );
262  a_field->SetLastTreatment( deep_ploughing );
263  // Apply 90% mortality to the insects
264  a_field->InsectMortality( 0.1 );
265  // Reduce the vegetation to zero
266  a_field->ZeroVeg();
267  int pref=a_field->GetUnsprayedMarginPolyRef();
268  if (pref!=-1){
269  // Must have an unsprayed margin so need to pass the information on to it
270  LE* um=g_landscape_p->SupplyLEPointer(pref);
272  um->InsectMortality( 0.1 );
273  um->ZeroVeg();
274  }
275  return true;
276  }
277  return false;
278 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
bool Raining(void)
Definition: weather.h:432
virtual void InsectMortality(double)
Definition: elements.h:159
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
virtual void ZeroVeg(void)
Definition: elements.h:174
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::DoIt ( int  a_probability)

Return chance out of 100.

Definition at line 610 of file farm.cpp.

610  {
611  return ( a_probability > ( int )( rand() % 100 ) );
612 }
bool Farm::FA_AmmoniumSulphate ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply ammonium supahte to a_field owned by an stock farmer.

Definition at line 684 of file farmfuncs.cpp.

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fa_ammoniumsulphate, g_weather, LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

685 {
686 
687  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
688  a_field->Trace( fa_ammoniumsulphate );
691  int pref=a_field->GetUnsprayedMarginPolyRef();
692  if (pref!=-1){
693  // Must have an unsprayed margin so need to pass the information on to it
694  LE* um=g_landscape_p->SupplyLEPointer(pref);
697  }
698  return true;
699  }
700  return false;
701 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
bool Raining(void)
Definition: weather.h:432
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::FA_GreenManure ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Spread green manure on a_field owned by an stock farmer.

Definition at line 734 of file farmfuncs.cpp.

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fa_greenmanure, g_weather, LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

735 {
736 
737  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
738  a_field->Trace( fa_greenmanure );
739  a_field->SetLastTreatment( fa_greenmanure );
741  int pref=a_field->GetUnsprayedMarginPolyRef();
742  if (pref!=-1){
743  // Must have an unsprayed margin so need to pass the information on to it
744  LE* um=g_landscape_p->SupplyLEPointer(pref);
747  }
748  return true;
749  }
750  return false;
751 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
bool Raining(void)
Definition: weather.h:432
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::FA_Manure ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Spread manure on a_field owned by an stock farmer.

Definition at line 708 of file farmfuncs.cpp.

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fa_manure, g_weather, Weather::GetTemp(), LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

709 {
710 
711  if ( (0 >= a_days) || ((g_weather->GetTemp()>0)&&
712  !g_weather->Raining() && DoIt(DO_IT_PROB)))
713 {
714  a_field->Trace( fa_manure );
715  a_field->SetLastTreatment( fa_manure );
717  int pref=a_field->GetUnsprayedMarginPolyRef();
718  if (pref!=-1){
719  // Must have an unsprayed margin so need to pass the information on to it
720  LE* um=g_landscape_p->SupplyLEPointer(pref);
723  }
724  return true;
725  }
726  return false;
727 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
double GetTemp(long a_date)
Get the temperature on a particular date.
Definition: weather.h:417
bool Raining(void)
Definition: weather.h:432
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::FA_NPK ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply NPK fertilizer to a_field owned by an stock farmer.

Definition at line 611 of file farmfuncs.cpp.

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fa_npk, g_weather, LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

612 {
613 
614  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
615  a_field->Trace( fa_npk );
616  a_field->SetLastTreatment( fa_npk );
618  int pref=a_field->GetUnsprayedMarginPolyRef();
619  if (pref!=-1){
620  // Must have an unsprayed margin so need to pass the information on to it
621  LE* um=g_landscape_p->SupplyLEPointer(pref);
622  um->SetLastTreatment( fa_npk );
624  }
625  return true;
626  }
627  return false;
628 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
bool Raining(void)
Definition: weather.h:432
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::FA_PK ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply PK fertilizer to a_field owned by an stock farmer.

Definition at line 635 of file farmfuncs.cpp.

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fa_pk, g_weather, LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

636 {
637 
638  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
639  a_field->Trace( fa_pk );
640  a_field->SetLastTreatment( fa_pk );
642  int pref=a_field->GetUnsprayedMarginPolyRef();
643  if (pref!=-1){
644  // Must have an unsprayed margin so need to pass the information on to it
645  LE* um=g_landscape_p->SupplyLEPointer(pref);
646  um->SetLastTreatment( fa_pk );
648  }
649  return true;
650  }
651  return false;
652 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
bool Raining(void)
Definition: weather.h:432
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::FA_Sludge ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Spread sewege sludge on a_field owned by an stock farmer.

Definition at line 758 of file farmfuncs.cpp.

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fa_sludge, g_weather, Weather::GetTemp(), LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

759 {
760 
761  if ( (0 >= a_days) || ((g_weather->GetTemp()>0)&&
762  !g_weather->Raining() && DoIt(DO_IT_PROB)))
763 {
764  a_field->Trace( fa_sludge );
765  a_field->SetLastTreatment( fa_sludge );
767  int pref=a_field->GetUnsprayedMarginPolyRef();
768  if (pref!=-1){
769  // Must have an unsprayed margin so need to pass the information on to it
770  LE* um=g_landscape_p->SupplyLEPointer(pref);
773  }
774  return true;
775  }
776  return false;
777 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
double GetTemp(long a_date)
Get the temperature on a particular date.
Definition: weather.h:417
bool Raining(void)
Definition: weather.h:432
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::FA_Slurry ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Spready slurry on a_field owned by an stock farmer.

Definition at line 659 of file farmfuncs.cpp.

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fa_slurry, g_weather, Weather::GetTemp(), LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

660 {
661 
662  if ( (0 >= a_days) || ((g_weather->GetTemp()>0)&&
663  !g_weather->Raining() && DoIt(DO_IT_PROB)))
664 {
665  a_field->Trace( fa_slurry );
666  a_field->SetLastTreatment( fa_slurry );
668  int pref=a_field->GetUnsprayedMarginPolyRef();
669  if (pref!=-1){
670  // Must have an unsprayed margin so need to pass the information on to it
671  LE* um=g_landscape_p->SupplyLEPointer(pref);
674  }
675  return true;
676  }
677  return false;
678 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
double GetTemp(long a_date)
Get the temperature on a particular date.
Definition: weather.h:417
bool Raining(void)
Definition: weather.h:432
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::FP_GreenManure ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Spread green manure on a_field owned by an arable farmer.

Definition at line 561 of file farmfuncs.cpp.

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fp_greenmanure, g_weather, LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

562 {
563 
564  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
565  a_field->Trace( fp_greenmanure );
566  a_field->SetLastTreatment( fp_greenmanure );
568  int pref=a_field->GetUnsprayedMarginPolyRef();
569  if (pref!=-1){
570  // Must have an unsprayed margin so need to pass the information on to it
571  LE* um=g_landscape_p->SupplyLEPointer(pref);
574  }
575  return true;
576  }
577  return false;
578 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
bool Raining(void)
Definition: weather.h:432
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::FP_LiquidNH3 ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply liquid ammonia fertilizer to a_field owned by an arable farmer.

Definition at line 462 of file farmfuncs.cpp.

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fp_liquidNH3, g_weather, LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

463 {
464 
465  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
466  a_field->Trace( fp_liquidNH3 );
467  a_field->SetLastTreatment( fp_liquidNH3 );
469  int pref=a_field->GetUnsprayedMarginPolyRef();
470  if (pref!=-1){
471  // Must have an unsprayed margin so need to pass the information on to it
472  LE* um=g_landscape_p->SupplyLEPointer(pref);
475  }
476  return true;
477  }
478  return false;
479 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
bool Raining(void)
Definition: weather.h:432
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::FP_ManganeseSulphate ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply Manganse Sulphate to a_field owned by an arable farmer.

Definition at line 512 of file farmfuncs.cpp.

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fp_manganesesulphate, g_weather, LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

513 {
514 
515  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
516  a_field->Trace( fp_manganesesulphate );
519  int pref=a_field->GetUnsprayedMarginPolyRef();
520  if (pref!=-1){
521  // Must have an unsprayed margin so need to pass the information on to it
522  LE* um=g_landscape_p->SupplyLEPointer(pref);
525  }
526  return true;
527  }
528  return false;
529 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
bool Raining(void)
Definition: weather.h:432
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::FP_Manure ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Spread manure on a_field owned by an arable farmer.

Definition at line 536 of file farmfuncs.cpp.

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fp_manure, g_weather, Weather::GetTemp(), LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

537 {
538 
539  if ( (0 >= a_days) || ((g_weather->GetTemp()>0)&&
540  !g_weather->Raining() && DoIt(DO_IT_PROB))) {
541  a_field->Trace( fp_manure );
542  a_field->SetLastTreatment( fp_manure );
544  int pref=a_field->GetUnsprayedMarginPolyRef();
545  if (pref!=-1){
546  // Must have an unsprayed margin so need to pass the information on to it
547  LE* um=g_landscape_p->SupplyLEPointer(pref);
550  }
551  return true;
552  }
553  return false;
554 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
double GetTemp(long a_date)
Get the temperature on a particular date.
Definition: weather.h:417
bool Raining(void)
Definition: weather.h:432
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::FP_NPK ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply NPK fertilizer, on a_field owned by an arable farmer.

Definition at line 414 of file farmfuncs.cpp.

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fp_npk, g_weather, LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

415 {
416 
417  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
418  a_field->Trace( fp_npk );
419  a_field->SetLastTreatment( fp_npk );
421  int pref=a_field->GetUnsprayedMarginPolyRef();
422  if (pref!=-1){
423  // Must have an unsprayed margin so need to pass the information on to it
424  LE* um=g_landscape_p->SupplyLEPointer(pref);
427  }
428  return true;
429  }
430  return false;
431 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
bool Raining(void)
Definition: weather.h:432
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::FP_NPKS ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply NPKS fertilizer, on a_field owned by an arable farmer.

Definition at line 387 of file farmfuncs.cpp.

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fp_npks, g_weather, LE::GetUnsprayedMarginPolyRef(), harvest1, LE::InsectMortality(), Weather::Raining(), LE::SetGrowthPhase(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), sleep_all_day, Landscape::SupplyLEPointer(), and LE::Trace().

388 {
389 
390  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
391  a_field->Trace( fp_npks );
392  a_field->SetLastTreatment( fp_npks );
394  int pref=a_field->GetUnsprayedMarginPolyRef();
395 if (pref!=-1){
396  // Must have an unsprayed margin so need to pass the information on to it
397  LE* um=g_landscape_p->SupplyLEPointer(pref);
399  um->SetGrowthPhase( harvest1 );
400  um->InsectMortality( 0.4 );
402 }
403 
404  return true;
405  }
406  return false;
407 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
bool Raining(void)
Definition: weather.h:432
virtual void InsectMortality(double)
Definition: elements.h:159
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
virtual void SetGrowthPhase(int)
Definition: elements.h:170
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::FP_PK ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply PK fertilizer, on a_field owned by an arable farmer.

Definition at line 438 of file farmfuncs.cpp.

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fp_pk, g_weather, LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

439 {
440 
441  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
442  a_field->Trace( fp_pk );
443  a_field->SetLastTreatment( fp_pk );
445  int pref=a_field->GetUnsprayedMarginPolyRef();
446  if (pref!=-1){
447  // Must have an unsprayed margin so need to pass the information on to it
448  LE* um=g_landscape_p->SupplyLEPointer(pref);
449  um->SetLastTreatment(fp_pk);
451  }
452  return true;
453  }
454  return false;
455 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
bool Raining(void)
Definition: weather.h:432
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::FP_Sludge ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Spread sewege on a_field owned by an arable farmer.

Definition at line 585 of file farmfuncs.cpp.

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fp_sludge, g_weather, Weather::GetTemp(), LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

586 {
587  //
588  if ( (0 >= a_days) || ((g_weather->GetTemp()>0)&&
589  !g_weather->Raining() && DoIt(DO_IT_PROB)))
590 {
591  a_field->Trace( fp_sludge );
592  a_field->SetLastTreatment( fp_sludge );
594  int pref=a_field->GetUnsprayedMarginPolyRef();
595  if (pref!=-1){
596  // Must have an unsprayed margin so need to pass the information on to it
597  LE* um=g_landscape_p->SupplyLEPointer(pref);
600  }
601  return true;
602  }
603  return false;
604 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
double GetTemp(long a_date)
Get the temperature on a particular date.
Definition: weather.h:417
bool Raining(void)
Definition: weather.h:432
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::FP_Slurry ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply slurry to a_field owned by an arable farmer.

Definition at line 486 of file farmfuncs.cpp.

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fp_slurry, g_weather, Weather::GetTemp(), LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

487 {
488 
489  if ( (0 >= a_days) || ((g_weather->GetTemp()>0)&&
490  !g_weather->Raining() && DoIt(DO_IT_PROB)))
491 {
492  a_field->Trace( fp_slurry );
493  a_field->SetLastTreatment( fp_slurry );
495  int pref=a_field->GetUnsprayedMarginPolyRef();
496  if (pref!=-1){
497  // Must have an unsprayed margin so need to pass the information on to it
498  LE* um=g_landscape_p->SupplyLEPointer(pref);
501  }
502  return true;
503  }
504  return false;
505 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
double GetTemp(long a_date)
Get the temperature on a particular date.
Definition: weather.h:417
bool Raining(void)
Definition: weather.h:432
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::FungicideTreat ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply fungicide to a_field.

Reimplemented in OptimisingFarm.

Definition at line 902 of file farmfuncs.cpp.

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fungicide_treat, g_weather, LE::GetSignal(), Weather::GetWind(), LE_SIG_NO_FUNGICIDE, Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), and LE::Trace().

903 {
904 
905  if (0 >= a_days)
906  {
907  if ( ( ! a_field->GetSignal() & LE_SIG_NO_FUNGICIDE ))
908  {
909  a_field->Trace( fungicide_treat );
910  a_field->SetLastTreatment( fungicide_treat );
912  }
913  return true;
914  }
915  else if ( (g_weather->GetWind()<4.5) &&
916  (!g_weather->Raining()) && DoIt(DO_IT_PROB)) {
917  if ( ! (a_field->GetSignal() & LE_SIG_NO_FUNGICIDE) ) {
918  a_field->Trace( fungicide_treat );
919  a_field->SetLastTreatment( fungicide_treat );
921  }
922  return true;
923  }
924  return false;
925 }
#define LE_SIG_NO_FUNGICIDE
Definition: elements.h:40
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
double GetWind(long a_date)
Definition: weather.h:425
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
class Weather * g_weather
Definition: weather.cpp:41
bool Raining(void)
Definition: weather.h:432
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
LE_Signal GetSignal(void)
Definition: elements.h:107
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
int Farm::GetArea ( void  )

Returns the area of arable fields owned by that farm.

Definition at line 1045 of file farm.cpp.

References tole_Field.

Referenced by OptimisingFarm::ActualProfit(), AssignPermanentCrop(), FarmManager::DumpFarmAreas(), and OptimisingFarm::Match_crop_to_field().

1045  {
1046  int area = 0;
1047  for (unsigned int i = 0; i < m_fields.size(); i++) {
1048  if (m_fields[i]->GetElementType() == tole_Field) area += (int)m_fields[i]->GetArea();
1049  }
1050  return area;
1051 }
vector< LE * > m_fields
Definition: farm.h:839
double Farm::GetAreaDouble ( void  )

Returns the area of arable fields owned by that farm.

Definition at line 1064 of file farm.cpp.

References tole_Field.

Referenced by OptimisingFarm::findTotalArea(), and FarmManager::Save_diff_farm_types_areas().

1064  {
1065  double area = 0;
1066  for ( unsigned int i = 0; i < m_fields.size(); i++ ) {
1067  if (m_fields[i]->GetElementType()==tole_Field) area += m_fields[i]->GetArea();
1068  }
1069  return area;
1070 }
vector< LE * > m_fields
Definition: farm.h:839
int GetArea(void)
Returns the area of arable fields owned by that farm.
Definition: farm.cpp:1045
int Farm::GetAreaOpenFields ( int  a_openness)

Returns the area of the fields above an openness of a_openness.

Returns the area of fields owned by that farm with an openness above a_openness

Definition at line 1083 of file farm.cpp.

1084 {
1085  int area = 0;
1086  for (unsigned int i = 0; i < m_fields.size(); i++) {
1087  if (m_fields[i]->GetOpenness() > a_openness) area += int(m_fields[i]->GetArea());
1088  }
1089  return area;
1090 }
vector< LE * > m_fields
Definition: farm.h:839
int GetArea(void)
Returns the area of arable fields owned by that farm.
Definition: farm.cpp:1045
APoint Farm::GetCentroids ( )
inline

Definition at line 810 of file farm.h.

810 { APoint pt; pt.m_x = m_farm_centroidx; pt.m_y = m_farm_centroidy; return pt; }
int m_farm_centroidy
Farm&#39;s centroid, value y. Equal to the average of the y centroid values of all farm&#39;s fields...
Definition: farm.h:863
int m_farm_centroidx
Farm&#39;s centroid, value x. Equal to the average of the x centroid values of all farm&#39;s fields...
Definition: farm.h:861
TTypesOfVegetation Farm::GetCrop ( int  a_index)
inline

Definition at line 816 of file farm.h.

816  {
817  return m_rotation[a_index];
818  }
vector< TTypesOfVegetation > m_rotation
Definition: farm.h:840
int Farm::GetFarmNumber ( void  )
inline
int Farm::GetFirstCropIndex ( TTypesOfLandscapeElement  a_type)
protectedvirtual

Gets the first crop for the farm.

This method also synchronises farm rotations either within or between farms if needed. This is useful to try simple what if scenarios.

Definition at line 1099 of file farm.cpp.

References g_farm_fixed_rotation_enable, g_farm_fixed_rotation_farms_async, and CfgBool::value().

1099  {
1100  // If g_farm_fixed_rotation, then determine the first
1101  // crop number in the rotation rotation number.
1103 
1105  // We are running all the farms synchronized, so
1106  // simply set the first crop to run on all farm fields.
1107  return 0;
1108  }
1109 
1110  // Each farm runs its fields sync'ed but independently from
1111  // the other farmers.
1112 
1113  // Determine if this farm has selected its own start index
1114  // and set it if not. m_rotation_sync_index is initialized
1115  // to -1 by the Farm::Farm() constructor.
1116  if ( -1 == m_rotation_sync_index ) {
1117  m_rotation_sync_index = (int) (rand() % m_rotation.size());
1118  }
1119  // Return farm localized rotation index.
1120  return m_rotation_sync_index;
1121  }
1122 
1123  // Not synchronised, but we want to follow our rotation sequence, so check
1124  // if we have started this process, if not set the sync value.
1125  // afterwards just increment this.
1126  if ( -1 == m_rotation_sync_index ) {
1127  m_rotation_sync_index = (int) (rand() % m_rotation.size());
1128  }
1129  else m_rotation_sync_index = (int) ((m_rotation_sync_index+1) % m_rotation.size());
1130  return m_rotation_sync_index;
1131 }
int m_rotation_sync_index
Definition: farm.h:847
CfgBool g_farm_fixed_rotation_farms_async("FARM_FIXED_ROTATION_FARMS_ASYNC", CFG_CUSTOM, false)
vector< TTypesOfVegetation > m_rotation
Definition: farm.h:840
bool value(void)
Definition: configurator.h:123
CfgBool g_farm_fixed_rotation_enable("FARM_FIXED_ROTATION_ENABLE", CFG_CUSTOM, false)
int Farm::GetFirstDate ( TTypesOfVegetation  a_tov)
protected

Gets the start date for a crop type.

Definition at line 1288 of file farm.cpp.

References tov_AgroChemIndustryCereal, tov_BroadBeans, tov_Carrots, tov_CloverGrassGrazed1, tov_CloverGrassGrazed2, tov_FieldPeas, tov_FieldPeasSilage, tov_FodderBeet, tov_FodderGrass, tov_Maize, tov_MaizeSilage, tov_Oats, tov_OBarleyPeaCloverGrass, tov_OCarrots, tov_OCloverGrassGrazed1, tov_OCloverGrassGrazed2, tov_OCloverGrassSilage1, tov_OFieldPeas, tov_OFirstYearDanger, tov_OFodderBeet, tov_OGrazingPigs, tov_OMaizeSilage, tov_OOats, tov_OPermanentGrassGrazed, tov_OPotatoes, tov_OrchardCrop, tov_OSBarleySilage, tov_OSpringBarley, tov_OSpringBarleyExt, tov_OSpringBarleyPigs, tov_OTriticale, tov_OWinterBarley, tov_OWinterBarleyExt, tov_OWinterRape, tov_OWinterRye, tov_OWinterWheat, tov_OWinterWheatUndersown, tov_OWinterWheatUndersownExt, tov_PermanentGrassGrazed, tov_PermanentGrassLowYield, tov_PermanentGrassTussocky, tov_PermanentSetaside, tov_Potatoes, tov_SeedGrass1, tov_SeedGrass2, tov_Setaside, tov_SpringBarley, tov_SpringBarleyCloverGrass, tov_SpringBarleyPTreatment, tov_SpringBarleySeed, tov_SpringBarleySilage, tov_SpringBarleySKManagement, tov_SpringBarleySpr, tov_SpringBarleyStrigling, tov_SpringBarleyStriglingCulm, tov_SpringBarleyStriglingSingle, tov_SpringRape, tov_SugarBeet, tov_Triticale, tov_WinterBarley, tov_WinterRape, tov_WinterRye, tov_WinterWheat, tov_WinterWheatStrigling, tov_WinterWheatStriglingCulm, tov_WinterWheatStriglingSingle, tov_WWheatPControl, tov_WWheatPToxicControl, tov_WWheatPTreatment, and tov_YoungForest.

1288  {
1289  switch ( a_tov2 ) {
1290  case tov_Carrots:
1291  return m_carrots->GetFirstDate();
1292  case tov_BroadBeans:
1293  return m_broadbeans->GetFirstDate( );
1294  case tov_FodderGrass:
1295  return m_foddergrass->GetFirstDate();
1297  return m_CGG1->GetFirstDate();
1299  return m_CGG2->GetFirstDate();
1300  case tov_FieldPeas:
1301  return m_fieldpeas->GetFirstDate();
1302  case tov_FieldPeasSilage:
1303  return m_fieldpeassilage->GetFirstDate();
1304  case tov_FodderBeet:
1305  return m_fodderbeet->GetFirstDate();
1306  case tov_SugarBeet:
1307  return m_sugarbeet->GetFirstDate();
1308  case tov_OFodderBeet:
1309  return m_ofodderbeet->GetFirstDate();
1310  case tov_Maize:
1311  return m_maize->GetFirstDate();
1312  case tov_OMaizeSilage:
1313  return m_omaizesilage->GetFirstDate();
1314  case tov_MaizeSilage:
1315  return m_maizesilage->GetFirstDate();
1317  return m_OBarleyPCG->GetFirstDate();
1318  case tov_OCarrots:
1319  return m_ocarrots->GetFirstDate();
1321  return m_OCGG1->GetFirstDate();
1323  return m_OCGG2->GetFirstDate();
1325  return m_OCGS1->GetFirstDate();
1326  case tov_OFieldPeas:
1327  return m_ofieldpeas->GetFirstDate();
1328  case tov_OFirstYearDanger:
1329  return m_ofirstyeardanger->GetFirstDate();
1330  case tov_OGrazingPigs:
1331  return m_ograzingpigs->GetFirstDate();
1332  case tov_OrchardCrop:
1333  return m_orchardcrop->GetFirstDate();
1334  case tov_OOats:
1335  return m_ooats->GetFirstDate();
1336  case tov_Oats:
1337  return m_oats->GetFirstDate();
1339  return m_opermgrassgrazed->GetFirstDate();
1340  case tov_OPotatoes:
1341  return m_opotatoes->GetFirstDate();
1342  case tov_OSpringBarley:
1343  return m_ospringbarley->GetFirstDate();
1344  case tov_OSBarleySilage:
1345  return m_osbarleysilage->GetFirstDate();
1346  case tov_OSpringBarleyExt:
1347  return m_ospringbarleyext->GetFirstDate();
1348  case tov_OSpringBarleyPigs:
1349  return m_ospringbarleypigs->GetFirstDate();
1350  case tov_OWinterBarley:
1351  return m_owinterbarley->GetFirstDate();
1352  case tov_OWinterBarleyExt:
1353  return m_owinterbarleyext->GetFirstDate();
1354  case tov_OWinterRape:
1355  return m_owinterrape->GetFirstDate();
1356  case tov_OWinterRye:
1357  return m_owinterrye->GetFirstDate();
1359  return m_owinterwheatundersown->GetFirstDate();
1360  case tov_OWinterWheat:
1361  return m_owinterwheat->GetFirstDate();
1363  return m_owinterwheatundersownext->GetFirstDate();
1365  return m_permgrassgrazed->GetFirstDate();
1367  return m_permgrasslowyield->GetFirstDate();
1368  case tov_PermanentGrassTussocky: // Only used for tole_PermPastureTussocky
1369  return m_permgrasstussocky->GetFirstDate();
1370  case tov_PermanentSetaside:
1371  return m_permanentsetaside->GetFirstDate();
1372  case tov_Potatoes:
1373  return m_potatoes->GetFirstDate();
1374  case tov_SeedGrass1:
1375  return m_seedgrass1->GetFirstDate();
1376  case tov_SeedGrass2:
1377  return m_seedgrass2->GetFirstDate();
1378  case tov_Setaside:
1379  return m_setaside->GetFirstDate();
1380  case tov_SpringBarley:
1381  return m_springbarley->GetFirstDate();
1382  case tov_SpringBarleySpr:
1383  return m_springbarleyspr->GetFirstDate();
1385  return m_springbarleyptreatment->GetFirstDate();
1387  return m_springbarleyskmanagement->GetFirstDate();
1389  return m_sbarleyclovergrass->GetFirstDate();
1390  case tov_SpringBarleySeed:
1391  return m_springbarleyseed->GetFirstDate();
1393  return m_springbarleysilage->GetFirstDate();
1395  return m_springbarleystrigling->GetFirstDate();
1397  return m_springbarleystriglingsingle->GetFirstDate();
1399  return m_springbarleystriglingculm->GetFirstDate();
1400  case tov_SpringRape:
1401  return m_springrape->GetFirstDate();
1402  case tov_Triticale:
1403  return m_triticale->GetFirstDate();
1404  case tov_OTriticale:
1405  return m_otriticale->GetFirstDate();
1406  case tov_WinterBarley:
1407  return m_winterbarley->GetFirstDate();
1408  case tov_WinterRape:
1409  return m_winterrape->GetFirstDate();
1410  case tov_WinterRye:
1411  return m_winterrye->GetFirstDate();
1412  case tov_WinterWheat:
1413  return m_winterwheat->GetFirstDate();
1415  return m_winterwheatstrigling->GetFirstDate();
1417  return m_winterwheatstriglingsingle->GetFirstDate();
1419  return m_winterwheatstriglingculm->GetFirstDate();
1420  case tov_WWheatPControl:
1421  return m_wwheatpcontrol->GetFirstDate();
1423  return m_wwheatptoxiccontrol->GetFirstDate();
1424  case tov_WWheatPTreatment:
1425  return m_wwheatptreatment->GetFirstDate();
1427  return m_agrochemindustrycereal->GetFirstDate();
1428  case tov_YoungForest:
1429  return m_youngforest->GetFirstDate();
1430  default:
1431  return 0;
1432  }
1433 }
PermanentGrassGrazed * m_permgrassgrazed
Definition: farm.h:909
OGrazingPigs * m_ograzingpigs
Definition: farm.h:889
OTriticale * m_otriticale
Definition: farm.h:901
SpringBarleySpr * m_springbarleyspr
Definition: farm.h:919
OPotatoes * m_opotatoes
Definition: farm.h:894
OCloverGrassGrazed1 * m_OCGG1
Definition: farm.h:883
SetAside * m_setaside
Definition: farm.h:917
Triticale * m_triticale
Definition: farm.h:926
OWinterWheatUndersown * m_owinterwheatundersown
Definition: farm.h:906
OWinterBarley * m_owinterbarley
Definition: farm.h:902
OOats * m_ooats
Definition: farm.h:892
SpringRape * m_springrape
Definition: farm.h:925
SeedGrass2 * m_seedgrass2
Definition: farm.h:916
OWinterWheat * m_owinterwheat
Definition: farm.h:907
SpringBarley * m_springbarley
Definition: farm.h:918
SpringBarleySeed * m_springbarleyseed
Definition: farm.h:923
OMaizeSilage * m_omaizesilage
Definition: farm.h:880
AgroChemIndustryCereal * m_agrochemindustrycereal
Definition: farm.h:934
OCarrots * m_ocarrots
Definition: farm.h:882
OWinterRape * m_owinterrape
Definition: farm.h:904
Sugarbeet * m_sugarbeet
Definition: farm.h:876
CloverGrassGrazed1 * m_CGG1
Definition: farm.h:871
FodderGrass * m_foddergrass
Definition: farm.h:870
OFodderbeet * m_ofodderbeet
Definition: farm.h:877
CloverGrassGrazed2 * m_CGG2
Definition: farm.h:872
WinterRye * m_winterrye
Definition: farm.h:929
WinterRape * m_winterrape
Definition: farm.h:928
OWinterWheatUndersownExt * m_owinterwheatundersownext
Definition: farm.h:908
SpringBarleyStriglingCulm * m_springbarleystriglingculm
Definition: farm.h:940
PermanentSetAside * m_permanentsetaside
Definition: farm.h:912
Maize * m_maize
Definition: farm.h:878
WinterWheatStriglingCulm * m_winterwheatstriglingculm
Definition: farm.h:936
OSpringBarley * m_ospringbarley
Definition: farm.h:897
SpringBarleySKManagement * m_springbarleyskmanagement
Definition: farm.h:920
Fodderbeet * m_fodderbeet
Definition: farm.h:875
FieldPeasSilage * m_fieldpeassilage
Definition: farm.h:874
Oats * m_oats
Definition: farm.h:891
PermanentGrassTussocky * m_permgrasstussocky
Definition: farm.h:911
WinterBarley * m_winterbarley
Definition: farm.h:927
WinterWheatStriglingSingle * m_winterwheatstriglingsingle
Definition: farm.h:937
SpringBarleySilage * m_springbarleysilage
Definition: farm.h:924
OCloverGrassGrazed2 * m_OCGG2
Definition: farm.h:884
OFieldPeas * m_ofieldpeas
Definition: farm.h:886
OPermanentGrassGrazed * m_opermgrassgrazed
Definition: farm.h:893
WWheatPControl * m_wwheatpcontrol
Definition: farm.h:931
SpringBarleyStriglingSingle * m_springbarleystriglingsingle
Definition: farm.h:941
SeedGrass1 * m_seedgrass1
Definition: farm.h:915
WWheatPTreatment * m_wwheatptreatment
Definition: farm.h:933
MaizeSilage * m_maizesilage
Definition: farm.h:879
OWinterRye * m_owinterrye
Definition: farm.h:905
OFirstYearDanger * m_ofirstyeardanger
Definition: farm.h:888
OSpringBarleyPigs * m_ospringbarleypigs
Definition: farm.h:899
SpringBarleyCloverGrass * m_sbarleyclovergrass
Definition: farm.h:922
OWinterBarleyExt * m_owinterbarleyext
Definition: farm.h:903
OSBarleySilage * m_osbarleysilage
Definition: farm.h:900
OBarleyPeaCloverGrass * m_OBarleyPCG
Definition: farm.h:881
YoungForestCrop * m_youngforest
Definition: farm.h:948
SpringBarleyPTreatment * m_springbarleyptreatment
Definition: farm.h:921
Potatoes * m_potatoes
Definition: farm.h:913
WWheatPToxicControl * m_wwheatptoxiccontrol
Definition: farm.h:932
BroadBeans * m_broadbeans
Definition: farm.h:869
SpringBarleyStrigling * m_springbarleystrigling
Definition: farm.h:939
Carrots * m_carrots
Definition: farm.h:868
PermanentGrassLowYield * m_permgrasslowyield
Definition: farm.h:910
FieldPeas * m_fieldpeas
Definition: farm.h:873
WinterWheat * m_winterwheat
Definition: farm.h:930
WinterWheatStrigling * m_winterwheatstrigling
Definition: farm.h:935
OCloverGrassSilage1 * m_OCGS1
Definition: farm.h:885
OrchardCrop * m_orchardcrop
Definition: farm.h:890
OSpringBarleyExt * m_ospringbarleyext
Definition: farm.h:898
int Farm::GetIntensity ( void  )
inline

Definition at line 809 of file farm.h.

809 { return m_intensity; }
int m_intensity
Definition: farm.h:848
int Farm::GetMaxOpenness ( )
inline

Returns the maximum openness score of the fields.

Definition at line 718 of file farm.h.

Referenced by FarmManager::CheckOpenness(), FarmManager::FindClosestFarmOpenness(), FarmManager::FindClosestFarmOpennessProb(), FarmManager::FindClosestFarmOpennessProbNearRoostIsBest(), FarmManager::FindClosestFarmOpennessProbSmallIsBest(), FarmManager::FindFarmWithOpenness(), and FarmManager::FindOpennessFarm().

719  {
720  int op = 0;
721  for (int i = 0; i < m_fields.size(); i++)
722  {
723  int openness = m_fields[i]->GetOpenness();
724  if (openness > op) op = openness;
725  }
726  return op;
727  }
vector< LE * > m_fields
Definition: farm.h:839
TTypesOfVegetation Farm::GetNextCrop ( int  a_index)
inline

Definition at line 819 of file farm.h.

819  {
820  int ind = a_index + 1;
821  if (ind >= (int)m_rotation.size()) ind = ind - (int)m_rotation.size();
822  return m_rotation[ind];
823  }
vector< TTypesOfVegetation > m_rotation
Definition: farm.h:840
int Farm::GetNextCropIndex ( int  a_rot_index)
protectedvirtual

Returns the next crop in the rotation.

Also provides the possibility of over-riding rotations using configuration settings

Definition at line 1141 of file farm.cpp.

References g_farm_enable_crop_rotation, and CfgBool::value().

1141  {
1143  // Rotation not enabled.
1144  return a_rot_index;
1145  }
1146 
1147  if ( a_rot_index == -1 )
1148  return -1;
1149 
1150  if ( ( unsigned int ) ( ++a_rot_index ) == m_rotation.size() ) //AM comm: the last crop was the last element of the vector - so go back to the element zero; otherwise just add 1 to the index
1151  a_rot_index = 0;
1152 
1153  return a_rot_index;
1154 }
CfgBool g_farm_enable_crop_rotation("FARM_ENABLE_CROP_ROTATION", CFG_CUSTOM, true)
vector< TTypesOfVegetation > m_rotation
Definition: farm.h:840
bool value(void)
Definition: configurator.h:123
int Farm::GetNextCropStartDate ( LE a_field,
TTypesOfVegetation a_curr_veg 
)
protected

Returns the start date of the next crop in the rotation.

Definition at line 666 of file farm.cpp.

References g_farm_fixed_crop_enable, LE::GetRotIndex(), and CfgBool::value().

666  {
667  TTypesOfVegetation l_tov2;
668 
669  if ( a_field->GetRotIndex() < 0 || g_farm_fixed_crop_enable.value() //|| g_farm_test_crop.value()
670  ) {
671  l_tov2 = a_curr_veg; // don't do it if no rotation
672  } else {
673  l_tov2 = m_rotation[ GetNextCropIndex( a_field->GetRotIndex() ) ];
674  }
675  a_curr_veg = l_tov2;
676  return GetFirstDate( l_tov2 );
677 }
CfgBool g_farm_fixed_crop_enable("FARM_FIXED_CROP_ENABLE", CFG_CUSTOM, false)
TTypesOfVegetation
virtual int GetNextCropIndex(int a_rot_index)
Returns the next crop in the rotation.
Definition: farm.cpp:1141
vector< TTypesOfVegetation > m_rotation
Definition: farm.h:840
bool value(void)
Definition: configurator.h:123
int GetRotIndex(void)
Definition: elements.h:303
int GetFirstDate(TTypesOfVegetation a_tov)
Gets the start date for a crop type.
Definition: farm.cpp:1288
int Farm::GetNoFields ( )
inline

Returns the number of the fields owned.

Definition at line 710 of file farm.h.

710 { return (int) m_fields.size(); }
vector< LE * > m_fields
Definition: farm.h:839
int Farm::GetNoOpenFields ( int  a_openness)

Returns the number of the fields above an openness of a_openness.

Returns the number of fields owned by that farm with an openness above a_openness

Definition at line 1073 of file farm.cpp.

1074 {
1075  int num = 0;
1076  for (unsigned int i = 0; i < m_fields.size(); i++) {
1077  if (m_fields[i]->GetOpenness() > a_openness) num++;
1078  }
1079  return num;
1080 }
vector< LE * > m_fields
Definition: farm.h:839
TTypesOfVegetation Farm::GetPreviousCrop ( int  a_index)
inline

Definition at line 811 of file farm.h.

Referenced by Field::GetPreviousCrop().

811  {
812  int ind = a_index - 1;
813  if (ind < 0) ind = (int)m_rotation.size() - 1;
814  return m_rotation[ind];
815  }
vector< TTypesOfVegetation > m_rotation
Definition: farm.h:840
int Farm::GetTotalArea ( void  )

Returns the area of all fields owned by that farm.

Definition at line 1054 of file farm.cpp.

1054  {
1055  int area = 0;
1056  for (unsigned int i = 0; i < m_fields.size(); i++)
1057  {
1058  area += (int)m_fields[i]->GetArea();
1059  }
1060  return area;
1061 }
vector< LE * > m_fields
Definition: farm.h:839
int GetArea(void)
Returns the area of arable fields owned by that farm.
Definition: farm.cpp:1045
TTypesOfFarm Farm::GetType ( void  )
inline
APoint Farm::GetValidCoords ( )
inline

Returns the valid coordinates of the first field owned by a farm.

Definition at line 716 of file farm.h.

716 { APoint pt; pt.m_x = m_fields[0]->GetValidX(); pt.m_y = m_fields[0]->GetValidY(); return pt; }
vector< LE * > m_fields
Definition: farm.h:839
bool Farm::Glyphosate ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Definition at line 2102 of file farmfuncs.cpp.

References glyphosate, LE::InsectMortality(), LE::ReduceVeg_Extended(), LE::SetLastTreatment(), and LE::Trace().

2103 {
2104  // Will always do this at the first chance
2105  a_field->Trace( glyphosate );
2106  a_field->SetLastTreatment( glyphosate );
2107  a_field->InsectMortality( 0.5 );
2108  a_field->ReduceVeg_Extended( 0.05 );
2109  return true;
2110 }
virtual void ReduceVeg_Extended(double)
Definition: elements.h:176
virtual void InsectMortality(double)
Definition: elements.h:159
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::GrowthRegulator ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply growth regulator to a_field.

Definition at line 873 of file farmfuncs.cpp.

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, g_weather, LE::GetSignal(), Weather::GetWind(), growth_regulator, LE_SIG_NO_GROWTH_REG, Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), and LE::Trace().

874 {
875 
876  if (0 >= a_days)
877  {
878  if ( (!g_weather->Raining()) && (g_weather->GetWind()<4.5) &&
879  (!(a_field->GetSignal() & LE_SIG_NO_GROWTH_REG) )) {
880  a_field->Trace( growth_regulator );
883  }
884  return true;
885  }
886  else if ( (g_weather->GetWind()<4.5) &&
887  (!g_weather->Raining()) && DoIt(DO_IT_PROB)) {
888  if ( ! (a_field->GetSignal() & LE_SIG_NO_GROWTH_REG) ) {
889  a_field->Trace( growth_regulator );
892  }
893  return true;
894  }
895  return false;
896 }
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
double GetWind(long a_date)
Definition: weather.h:425
#define LE_SIG_NO_GROWTH_REG
Definition: elements.h:43
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
class Weather * g_weather
Definition: weather.cpp:41
bool Raining(void)
Definition: weather.h:432
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
LE_Signal GetSignal(void)
Definition: elements.h:107
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
void Farm::HandleEvents ( void  )
protectedvirtual

If there are events to carry out do this, and perhaps start a new crop.

Call the management plan for the current crop and it this return done=true starts the next management.

Sets the new index to the rotation.

Save the new veg type as the LE vegetation type

Reimplemented in OptimisingFarm.

Definition at line 684 of file farm.cpp.

References LE::BumpRunNum(), Calendar::Date(), g_date, g_farm_fixed_crop_enable, g_farm_fixed_crop_type, g_letype, LE::GetRotIndex(), LE::GetRunNum(), LE::GetVegType(), LowPriPair< ELEMTYPE >::m_element, FarmEvent::m_field, LowPriPair< ELEMTYPE >::m_pri, PROG_START, LE::ResetTrace(), LE::SetMgtLoopDetectDate(), LE::SetRotIndex(), LE::SetVegStore(), LE::SetVegType(), tov_Undefined, LE_TypeClass::TranslateVegTypes(), CfgInt::value(), and CfgBool::value().

684  {
685  if ( m_queue.Empty() )
686  return;
687 
689  FarmEvent * ev = pair.m_element;
690  while ( pair.m_pri <= g_date->Date() ) {
691  m_queue.Pop();
693  if ( LeSwitch( ev ) ) {
694  // This crop management plan has terminated.
695 
696  // First check for an infinite loop in the rotation scheme,
697  // ie. a scenario where all crops decide not to run given
698  // the date.
700 
701  // Outdate any remaining events for this field.
702  ev->m_field->BumpRunNum();
703 
704  // Crop treatment done, select and initiate new crop if in rotation.
705  TTypesOfVegetation new_veg = ev->m_field->GetVegType();
706 
707  if ( ev->m_field->GetRotIndex() >= 0 ) {
708  int new_index = GetNextCropIndex( ev->m_field->GetRotIndex() );
709  new_veg = m_rotation[ new_index ];
710  // Running in fixed crop mode?
713  }
715  ev->m_field->SetRotIndex( new_index );
717  ev->m_field->SetVegType(new_veg, tov_Undefined);
718  }
719 
720  // Reset the event list for this field.
721  ev->m_field->ResetTrace();
722  // Reset event timeout counter.
723  ev->m_field->SetVegStore( 0 );
724 
725  // The next bit simply determines the start date of the next crop in
726  // the rotation and passes this to the start crop event.
727  // The crop is responsible for raising an error if the next crop is
728  // not possible or otherwise handling the problem
729 
730  // 19/5-2003: Note: This code was moved out into a dedicated
731  // method of the Farm class, GetNextCropStartDate(), as precisely
732  // the same piece of code needs to be run during initialization of
733  // farm management.
734  TTypesOfVegetation l_tov = new_veg;
735  int l_nextcropstartdate = GetNextCropStartDate( ev->m_field, l_tov );
736 
737  // Create 'start' event for today and put it on the queue.
738  AddNewEvent( new_veg, g_date->Date(), ev->m_field, PROG_START, ev->m_field->GetRunNum(),
739  false, l_nextcropstartdate, false, l_tov );
740 
741  // Set starting date for rotation mgmt loop detection.
743  }
744 
745  delete ev;
746 
747  if ( m_queue.Empty() )
748  return;
749  pair = m_queue.Bottom();
750  ev = pair.m_element;
751  }
752 }
#define PROG_START
Definition: farm.h:76
long Date(void)
Definition: calendar.h:57
int GetNextCropStartDate(LE *a_field, TTypesOfVegetation &a_curr_veg)
Returns the start date of the next crop in the rotation.
Definition: farm.cpp:666
virtual void SetVegType(TTypesOfVegetation, TTypesOfVegetation)
Definition: elements.h:164
bool LeSwitch(FarmEvent *ev)
Call do function for any crop with an outstanding event. Signal if the crop has terminated.
Definition: farm.cpp:331
CfgBool g_farm_fixed_crop_enable("FARM_FIXED_CROP_ENABLE", CFG_CUSTOM, false)
void SetRotIndex(int a_index)
Definition: elements.h:301
void Pop()
Definition: lowqueue.h:124
TTypesOfVegetation
virtual int GetNextCropIndex(int a_rot_index)
Returns the next crop in the rotation.
Definition: farm.cpp:1141
vector< TTypesOfVegetation > m_rotation
Definition: farm.h:840
void BumpRunNum(void)
Definition: elements.h:118
virtual TTypesOfVegetation GetVegType(void)
Definition: elements.h:125
class LE_TypeClass * g_letype
Definition: elements.cpp:265
LE * m_field
Definition: farm.h:400
CfgInt g_farm_fixed_crop_type("FARM_FIXED_CROP_TYPE", CFG_CUSTOM, 22)
bool value(void)
Definition: configurator.h:123
A struct to hold the information required to trigger a farm event.
Definition: farm.h:391
LowPriority< FarmEvent * > m_queue
Definition: farm.h:838
bool Empty(void)
Definition: lowqueue.h:129
TTypesOfVegetation TranslateVegTypes(int VegReference)
Definition: elements.cpp:2692
int GetRotIndex(void)
Definition: elements.h:303
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
class Calendar * g_date
Definition: calendar.cpp:38
ELEMTYPE m_element
Definition: lowqueue.h:88
void ResetTrace(void)
Definition: elements.cpp:463
int value(void)
Definition: configurator.h:92
void SetVegStore(int a_veg)
Definition: elements.h:127
void SetMgtLoopDetectDate(long a_num)
Definition: elements.h:120
long m_pri
Definition: lowqueue.h:89
long GetRunNum(void)
Definition: elements.h:117
LowPriPair< ELEMTYPE > Bottom(void)
Definition: lowqueue.h:134
Used in event handling.
Definition: lowqueue.h:83
void CheckRotationManagementLoop(FarmEvent *ev)
Definition: farm.cpp:641
bool Farm::Harvest ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out a harvest on a_field.

Reimplemented in OptimisingFarm.

Definition at line 1397 of file farmfuncs.cpp.

References Calendar::Date(), DO_IT_PROB, EL_TRAMLINE_DECAYTIME, g_date, g_weather, LE::GetInsectPop(), Weather::GetRainPeriod(), LE::GetUnsprayedMarginPolyRef(), harvest, harvest1, LE::InsectMortality(), LE::RecalculateBugsNStuff(), LE::ResetDigestability(), LE::SetBirdMaize(), LE::SetBirdSeed(), LE::SetGrowthPhase(), LE::SetInsectPop(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

1398 {
1399  //5 days good weather before
1400  if ((0 >= a_days) || ((g_weather->GetRainPeriod(g_date->Date(), 5) < 0.1) && DoIt(DO_IT_PROB))) {
1401  a_field->Trace(harvest);
1402  a_field->SetLastTreatment(harvest);
1403  a_field->SetGrowthPhase(harvest1);
1404  // Here we have to do a little skip to avoid too low insect populations after harvest, but a correct veg biomass
1405  a_field->InsectMortality(0.4);
1406  double insects = a_field->GetInsectPop();
1407  a_field->ResetDigestability();
1408  a_field->RecalculateBugsNStuff();
1409  a_field->SetInsectPop(insects);
1411  int pref = a_field->GetUnsprayedMarginPolyRef();
1412  // Are we a cereal crop? If so we need to have some spilled grain
1413  double someseed = 0.0;
1414  double somemaize = 0.0;
1415  if (dynamic_cast<VegElement*>(a_field)->IsMatureCereal()) {
1416  someseed = m_OurManager->GetSpilledGrain();
1417  }
1418  else if (dynamic_cast<VegElement*>(a_field)->IsMaize()) {
1419  somemaize = m_OurManager->GetSpilledMaize();
1420  }
1421  else {
1422  someseed = 0.0;
1423  somemaize = 0.0;
1424  }
1425  a_field->SetBirdSeed( someseed );
1426  a_field->SetBirdMaize( somemaize );
1427  if (pref != -1){
1428  // Must have an unsprayed margin so need to pass the information on to it
1429  LE* um = g_landscape_p->SupplyLEPointer(pref);
1431  um->SetGrowthPhase(harvest1);
1432  um->InsectMortality(0.4);
1434  um->ResetDigestability();
1435  um->RecalculateBugsNStuff();
1436  um->SetBirdSeed( someseed );
1437  um->SetBirdMaize( somemaize );
1438  }
1439  return true;
1440  }
1441  return false;
1442 }
long Date(void)
Definition: calendar.h:57
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
virtual void SetInsectPop(double)
Definition: elements.h:157
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
virtual void ResetDigestability()
sets growth record to zero in descendent classes
Definition: elements.h:370
double GetSpilledGrain()
Returns the average amount of spilled grain in KJ/m2 this year.
Definition: farm.cpp:2584
virtual void InsectMortality(double)
Definition: elements.h:159
FarmManager * m_OurManager
Pointer to the FarmManager.
Definition: farm.h:837
class Calendar * g_date
Definition: calendar.cpp:38
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
double GetSpilledMaize()
Returns the average amount of spilled maize in KJ/m2 this year.
Definition: farm.cpp:2601
Landscape * g_landscape_p
Definition: Landscape.cpp:238
void SetBirdMaize(double a_forage)
Definition: elements.h:207
virtual void SetGrowthPhase(int)
Definition: elements.h:170
virtual void RecalculateBugsNStuff(void)
Definition: elements.h:132
void SetBirdSeed(double a_forage)
Definition: elements.h:201
double GetRainPeriod(long a_date, unsigned int a_period)
Definition: weather.cpp:278
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
virtual double GetInsectPop(void)
Definition: elements.h:156
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::HarvestLong ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out a harvest on a_field.

Definition at line 1449 of file farmfuncs.cpp.

References Calendar::Date(), DO_IT_PROB_LONG, EL_TRAMLINE_DECAYTIME, g_date, g_weather, LE::GetInsectPop(), Weather::GetRainPeriod(), LE::GetUnsprayedMarginPolyRef(), harvest, harvest1, LE::InsectMortality(), LE::RecalculateBugsNStuff(), LE::ResetDigestability(), LE::SetBirdMaize(), LE::SetBirdSeed(), LE::SetGrowthPhase(), LE::SetInsectPop(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

1450 {
1451 
1452  //5 days good weather before
1453  if ((0 >= a_days) ||
1455  ) {
1456  a_field->Trace(harvest);
1457  a_field->SetLastTreatment(harvest);
1458  a_field->SetGrowthPhase(harvest1);
1459  // Here we have to do a little skip to avoid too low insect populations after harvest, but a correct veg biomass
1460  a_field->InsectMortality(0.4);
1461  double insects = a_field->GetInsectPop();
1462  a_field->ResetDigestability();
1463  a_field->RecalculateBugsNStuff();
1464  a_field->SetInsectPop(insects);
1466  int pref = a_field->GetUnsprayedMarginPolyRef();
1467  double someseed = 0.0; //No bird seed or maize forage on sugar beet (which is currently (March 2015) the only crop using HarvestLong.
1468  a_field->SetBirdSeed( someseed );
1469  a_field->SetBirdMaize( someseed );
1470  if (pref != -1){
1471  // Must have an unsprayed margin so need to pass the information on to it
1472  LE* um = g_landscape_p->SupplyLEPointer(pref);
1474  um->SetGrowthPhase(harvest1);
1475  um->InsectMortality(0.4);
1477  um->ResetDigestability();
1478  um->RecalculateBugsNStuff();
1479  um->SetBirdSeed( someseed );
1480  um->SetBirdMaize( someseed );
1481  }
1482  return true;
1483  }
1484  return false;
1485 }
long Date(void)
Definition: calendar.h:57
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
virtual void SetInsectPop(double)
Definition: elements.h:157
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
#define DO_IT_PROB_LONG
Definition: farmfuncs.cpp:59
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
virtual void ResetDigestability()
sets growth record to zero in descendent classes
Definition: elements.h:370
virtual void InsectMortality(double)
Definition: elements.h:159
class Calendar * g_date
Definition: calendar.cpp:38
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
void SetBirdMaize(double a_forage)
Definition: elements.h:207
virtual void SetGrowthPhase(int)
Definition: elements.h:170
virtual void RecalculateBugsNStuff(void)
Definition: elements.h:132
void SetBirdSeed(double a_forage)
Definition: elements.h:201
double GetRainPeriod(long a_date, unsigned int a_period)
Definition: weather.cpp:278
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
virtual double GetInsectPop(void)
Definition: elements.h:156
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::HayBailing ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out hay bailing on a_field.

Definition at line 1812 of file farmfuncs.cpp.

References Calendar::Date(), DO_IT_PROB, EL_TRAMLINE_DECAYTIME, g_date, g_weather, Weather::GetRainPeriod(), LE::GetUnsprayedMarginPolyRef(), hay_bailing, LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

1813 {
1814 
1815  if ( (0 >= a_days) ||
1816  ((g_weather->GetRainPeriod(g_date->Date(),5)<0.1) && DoIt(DO_IT_PROB))
1817  ) {
1818  a_field->Trace( hay_bailing );
1819  a_field->SetLastTreatment( hay_bailing );
1821  int pref=a_field->GetUnsprayedMarginPolyRef();
1822  if (pref!=-1){
1823  // Must have an unsprayed margin so need to pass the information on to it
1824  LE* um=g_landscape_p->SupplyLEPointer(pref);
1827  }
1828  return true;
1829  }
1830  return false;
1831 }
long Date(void)
Definition: calendar.h:57
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
class Calendar * g_date
Definition: calendar.cpp:38
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
double GetRainPeriod(long a_date, unsigned int a_period)
Definition: weather.cpp:278
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::HayTurning ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out hay turning on a_field.

Definition at line 1787 of file farmfuncs.cpp.

References Calendar::Date(), DO_IT_PROB, EL_TRAMLINE_DECAYTIME, g_date, g_weather, Weather::GetRainPeriod(), LE::GetUnsprayedMarginPolyRef(), hay_turning, LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

1788 {
1789 
1790  if ( (0 >= a_days) ||
1791  ((g_weather->GetRainPeriod(g_date->Date(),5)<0.1) && DoIt(DO_IT_PROB))
1792  ) {
1793  a_field->Trace( hay_turning );
1794  a_field->SetLastTreatment( hay_turning );
1796  int pref=a_field->GetUnsprayedMarginPolyRef();
1797  if (pref!=-1){
1798  // Must have an unsprayed margin so need to pass the information on to it
1799  LE* um=g_landscape_p->SupplyLEPointer(pref);
1802  }
1803  return true;
1804  }
1805  return false;
1806 }
long Date(void)
Definition: calendar.h:57
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
class Calendar * g_date
Definition: calendar.cpp:38
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
double GetRainPeriod(long a_date, unsigned int a_period)
Definition: weather.cpp:278
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::HerbicideTreat ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply herbicide to a_field.

Reimplemented in OptimisingFarm.

Definition at line 784 of file farmfuncs.cpp.

References DO_IT_PROB, EL_HERBICIDE_DELAYTIME, EL_TRAMLINE_DECAYTIME, g_weather, LE::GetSignal(), Weather::GetWind(), herbicide_treat, l_farm_herbicide_kills, LE_SIG_NO_HERBICIDE, Weather::Raining(), LE::ReduceWeedBiomass(), LE::SetHerbicideDelay(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), LE::Trace(), and CfgBool::value().

785 {
786 
787  if (0 >= a_days) // Must do this
788  {
789  if (((a_field->GetSignal() & LE_SIG_NO_HERBICIDE)==0 ))
790  {
791  a_field->Trace( herbicide_treat );
792  a_field->SetLastTreatment( herbicide_treat );
794  {
795  a_field->ReduceWeedBiomass( 0.05 );
796  }
799  }
800  return true;
801  }
802  else if ((g_weather->GetWind()<4.5) && (!g_weather->Raining()) && DoIt(DO_IT_PROB))
803  {
804  if ( !(a_field->GetSignal() & LE_SIG_NO_HERBICIDE) )
805  {
806  a_field->Trace( herbicide_treat );
807  a_field->SetLastTreatment( herbicide_treat );
809  {
810  a_field->ReduceWeedBiomass( 0.05 );
811  }
814  }
815  return true;
816  }
817  return false;
818 }
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
#define LE_SIG_NO_HERBICIDE
Definition: elements.h:45
double GetWind(long a_date)
Definition: weather.h:425
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
class Weather * g_weather
Definition: weather.cpp:41
bool value(void)
Definition: configurator.h:123
bool Raining(void)
Definition: weather.h:432
#define EL_HERBICIDE_DELAYTIME
Definition: elements.h:58
static CfgBool l_farm_herbicide_kills("FARM_PESTICIDE_KILLS", CFG_CUSTOM, true)
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
LE_Signal GetSignal(void)
Definition: elements.h:107
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void SetHerbicideDelay(int a_decaytime_days)
Definition: elements.h:306
virtual void ReduceWeedBiomass(double)
Definition: elements.h:160
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::HillingUp ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Do hilling up on a_field, probably of potatoes.

Definition at line 1318 of file farmfuncs.cpp.

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, g_weather, LE::GetUnsprayedMarginPolyRef(), hilling_up, LE::InsectMortality(), Weather::Raining(), LE::ReduceWeedBiomass(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

1319 {
1320 
1321  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
1322  a_field->Trace( hilling_up );
1323  a_field->SetLastTreatment( hilling_up );
1324  a_field->InsectMortality( 0.75 );
1325  a_field->ReduceWeedBiomass( 0.25 );
1327  int pref=a_field->GetUnsprayedMarginPolyRef();
1328  if (pref!=-1){
1329  // Must have an unsprayed margin so need to pass the information on to it
1330  LE* um=g_landscape_p->SupplyLEPointer(pref);
1332  um->ReduceWeedBiomass( 0.25 );
1333  um->InsectMortality( 0.75 );
1335  }
1336  return true;
1337  }
1338  return false;
1339 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
bool Raining(void)
Definition: weather.h:432
virtual void InsectMortality(double)
Definition: elements.h:159
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
virtual void ReduceWeedBiomass(double)
Definition: elements.h:160
void Trace(int a_value)
Definition: elements.cpp:459
void Farm::InitiateManagement ( void  )
virtual

Kicks off the farm's management.

Reimplemented in OptimisingFarm, and UserDefinedFarm.

Definition at line 1227 of file farm.cpp.

References Calendar::Date(), g_date, g_farm_fixed_crop_enable, g_farm_fixed_crop_type, g_letype, g_msg, janfirst, PROG_START, tole_Orchard, tole_PermanentSetaside, tole_PermPasture, tole_PermPastureLowYield, tole_PermPastureTussocky, tole_YoungForest, tov_OrchardCrop, tov_PermanentGrassGrazed, tov_PermanentGrassLowYield, tov_PermanentGrassTussocky, tov_PermanentSetaside, tov_Undefined, tov_YoungForest, LE_TypeClass::TranslateVegTypes(), CfgInt::value(), CfgBool::value(), and MapErrorMsg::Warn().

Referenced by UserDefinedFarm::InitiateManagement(), and OptimisingFarm::InitiateManagement().

1227  {
1228  for ( unsigned int i = 0; i < m_fields.size(); i++ ) {
1229  int rot_index = m_fields[ i ]->GetRotIndex();
1231  // If the field has been designated as non-rotating and therefore already has its veg type, then skip it.
1232  if ( rot_index < -1 ) {
1233  // Check for any type of permanent element type with management plan.
1234  TTypesOfLandscapeElement ele = m_fields[ i ]->GetElementType();
1235  switch (ele) {
1237  new_veg = tov_PermanentGrassLowYield;
1238  break;
1239  case tole_YoungForest:
1240  new_veg = tov_YoungForest;
1241  break;
1242  case tole_PermPasture:
1243  new_veg = tov_PermanentGrassGrazed;
1244  break;
1246  new_veg = tov_PermanentGrassTussocky;
1247  break;
1249  new_veg = tov_PermanentSetaside;
1250  break;
1251  case tole_Orchard:
1252  new_veg = tov_OrchardCrop;
1253  break;
1254  default:
1255  if (rot_index != -4) {
1256  // Error
1257  g_msg->Warn("Unexpected negative value in Farm::InitiateManagement","");
1258  exit(0);
1259  } else new_veg = m_fields[ i ]->GetVegType();
1260  }
1261  }
1262  else {
1263  rot_index = GetFirstCropIndex( m_fields[ i ]->GetElementType() );
1264  new_veg = m_rotation[ rot_index ];
1265  }
1266  // Running in fixed crop mode?
1267  if ( g_farm_fixed_crop_enable.value() ) {
1268  int fv = g_farm_fixed_crop_type.value();
1269  new_veg = g_letype->TranslateVegTypes( fv );
1270  }
1271  m_fields[ i ]->SetVegType( new_veg, tov_Undefined );
1272  m_fields[ i ]->SetRotIndex( rot_index );
1273  m_fields[ i ]->SetGrowthPhase( janfirst );
1274  // Reset event timeout counter. We are now 800 days from
1275  // oblivion.
1276  long prog_start_date = g_date->Date();
1277  m_fields[ i ]->SetVegStore( 0 );
1278  TTypesOfVegetation l_tov = new_veg;
1279  int l_nextcropstartdate = GetNextCropStartDate( m_fields[ i ], l_tov );
1280  AddNewEvent( new_veg, prog_start_date, m_fields[ i ], PROG_START, 0, false, l_nextcropstartdate, true, l_tov );
1281  }
1282 }
#define PROG_START
Definition: farm.h:76
virtual int GetFirstCropIndex(TTypesOfLandscapeElement a_type)
Gets the first crop for the farm.
Definition: farm.cpp:1099
long Date(void)
Definition: calendar.h:57
int GetNextCropStartDate(LE *a_field, TTypesOfVegetation &a_curr_veg)
Returns the start date of the next crop in the rotation.
Definition: farm.cpp:666
vector< LE * > m_fields
Definition: farm.h:839
CfgBool g_farm_fixed_crop_enable("FARM_FIXED_CROP_ENABLE", CFG_CUSTOM, false)
TTypesOfVegetation
vector< TTypesOfVegetation > m_rotation
Definition: farm.h:840
class LE_TypeClass * g_letype
Definition: elements.cpp:265
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
CfgInt g_farm_fixed_crop_type("FARM_FIXED_CROP_TYPE", CFG_CUSTOM, 22)
bool value(void)
Definition: configurator.h:123
TTypesOfVegetation TranslateVegTypes(int VegReference)
Definition: elements.cpp:2692
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
class Calendar * g_date
Definition: calendar.cpp:38
int value(void)
Definition: configurator.h:92
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
TTypesOfLandscapeElement
bool Farm::InsecticideTreat ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply insecticide to a_field.

Reimplemented in OptimisingFarm.

Definition at line 967 of file farmfuncs.cpp.

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, g_weather, LE::GetSignal(), Weather::GetWind(), LE::Insecticide(), insecticide_treat, l_farm_insecticide_kills, LE_SIG_NO_INSECTICIDE, Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), LE::Trace(), and CfgBool::value().

968 {
969 
970  if (0 >= a_days)
971  {
972  if (( ! (a_field->GetSignal() & LE_SIG_NO_INSECTICIDE) ))
973  {
974  // **CJT** Turn this code on to use the pesticide engine with insecticides
975  // g_pest->DailyQueueAdd( a_field, l_pest_insecticide_amount.value());
976  //
977  a_field->Trace( insecticide_treat );
980  {
981  a_field->Insecticide( 0.36 );
982  }
984  }
985  return true;
986  }
987  else if ( (g_weather->GetWind()<4.5) &&
988  (!g_weather->Raining()) && DoIt(DO_IT_PROB)) {
989  if ( ! (a_field->GetSignal() & LE_SIG_NO_INSECTICIDE )) {
990 // **CJT** Turn this code on to use the pesticide engine with insecticides
991 // g_pest->DailyQueueAdd( a_field, l_pest_insecticide_amount.value());
992 //
993  a_field->Trace( insecticide_treat );
996  a_field->Insecticide( 0.36 );
997  }
999  }
1000  return true;
1001  }
1002  return false;
1003 }
static CfgBool l_farm_insecticide_kills("FARM_INSECTICIDE_KILLS", CFG_CUSTOM, true)
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
double GetWind(long a_date)
Definition: weather.h:425
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
class Weather * g_weather
Definition: weather.cpp:41
bool value(void)
Definition: configurator.h:123
bool Raining(void)
Definition: weather.h:432
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
LE_Signal GetSignal(void)
Definition: elements.h:107
virtual void Insecticide(double)
Definition: elements.h:158
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
#define LE_SIG_NO_INSECTICIDE
Definition: elements.h:41
int Farm::InvIntPartition ( vector< tpct > *  items,
int  target 
)
protected

Finds all possible sums of the integers in the items array.

Definition at line 2045 of file farm.cpp.

References g_msg, GetFarmNumber(), and MapErrorMsg::Warn().

Referenced by AssignPermanentCrop().

2045  {
2046  //Figure out how many bitmasks we need...
2047  //4 bits have a maximum value of 15, so we need 15 masks.
2048  //Calculated as:
2049  // (2 ^ ItemCount) - 1
2050  int sz = (int) items->size();
2051  if (sz>63) {
2052  g_msg->Warn("Too many potential fields in UserDefinedFarm::InvIntPartition: ",sz);
2053  g_msg->Warn("Farm Number: ",GetFarmNumber());
2054  exit(1);
2055  }
2056  long int calcs = (1 << sz);
2057  //Spit out the corresponding calculation for each bitmask
2058  int sum;
2059  int found = 0;
2060  int diff = 100;
2061  for (long int i=1; i<calcs; i++) {
2062  //Get the items from our array that correspond to
2063  //the on bits in our mask
2064  sum = 0;
2065  int mask = 1;
2066  for (int bit=0; bit<sz; bit++) {
2067  if ((i & mask) > 0) {
2068  sum+=(*items)[bit].pct;
2069  }
2070  mask = mask << 1;
2071  }
2072 
2073  if (abs(sum-target) < diff ){
2074  found = i;
2075  diff = abs(sum-target);
2076  if (diff<1) break; //added 01.11.12 to prevent from checking all the combinations when the right one is found
2077  }
2078  }
2079  return found;
2080 }
int GetFarmNumber(void)
Definition: farm.h:698
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
bool Farm::IsStockFarmer ( void  )
inline

Definition at line 807 of file farm.h.

807 { return m_stockfarmer; }
bool m_stockfarmer
Definition: farm.h:845
bool Farm::LeSwitch ( FarmEvent ev)
protected

Call do function for any crop with an outstanding event. Signal if the crop has terminated.

Definition at line 331 of file farm.cpp.

References g_msg, LE::GetRunNum(), FarmEvent::m_event, FarmEvent::m_field, FarmEvent::m_run, FarmEvent::m_todo, LE::m_tried_to_do, tov_AgroChemIndustryCereal, tov_BroadBeans, tov_Carrots, tov_CloverGrassGrazed1, tov_CloverGrassGrazed2, tov_FieldPeas, tov_FieldPeasSilage, tov_FieldPeasStrigling, tov_FodderBeet, tov_FodderGrass, tov_Maize, tov_MaizeSilage, tov_MaizeStrigling, tov_Oats, tov_OBarleyPeaCloverGrass, tov_OCarrots, tov_OCloverGrassGrazed1, tov_OCloverGrassGrazed2, tov_OCloverGrassSilage1, tov_OFieldPeas, tov_OFieldPeasSilage, tov_OFodderBeet, tov_OGrazingPigs, tov_OMaizeSilage, tov_OOats, tov_OPermanentGrassGrazed, tov_OPotatoes, tov_OrchardCrop, tov_OSBarleySilage, tov_OSeedGrass1, tov_OSeedGrass2, tov_OSpringBarley, tov_OSpringBarleyExt, tov_OSpringBarleyPigs, tov_OTriticale, tov_OWinterBarley, tov_OWinterBarleyExt, tov_OWinterRape, tov_OWinterRye, tov_OWinterWheat, tov_OWinterWheatUndersown, tov_OWinterWheatUndersownExt, tov_PermanentGrassGrazed, tov_PermanentGrassLowYield, tov_PermanentGrassTussocky, tov_PermanentSetaside, tov_Potatoes, tov_PotatoesIndustry, tov_SeedGrass1, tov_SeedGrass2, tov_Setaside, tov_SpringBarley, tov_SpringBarleyCloverGrass, tov_SpringBarleyCloverGrassStrigling, tov_SpringBarleyPeaCloverGrassStrigling, tov_SpringBarleyPTreatment, tov_SpringBarleySeed, tov_SpringBarleySilage, tov_SpringBarleySKManagement, tov_SpringBarleySpr, tov_SpringBarleyStrigling, tov_SpringBarleyStriglingCulm, tov_SpringBarleyStriglingSingle, tov_SpringRape, tov_SugarBeet, tov_Triticale, tov_WinterBarley, tov_WinterBarleyStrigling, tov_WinterRape, tov_WinterRapeStrigling, tov_WinterRye, tov_WinterRyeStrigling, tov_WinterWheat, tov_WinterWheatStrigling, tov_WinterWheatStriglingCulm, tov_WinterWheatStriglingSingle, tov_WWheatPControl, tov_WWheatPToxicControl, tov_WWheatPTreatment, tov_YoungForest, MapErrorMsg::Warn(), and WARN_FILE.

331  {
332  // Ignore this event if it is from the execution of
333  // a previous management plan.
334  if (ev->m_field->GetRunNum() > ev->m_run)
335  return false;
336  // Store what we are trying to do this time.
337  // ***FN*** To be cleaned up later.
338  ev->m_field->m_tried_to_do = ev->m_todo;
339 
340  bool done;
341 
342  switch (ev->m_event) {
343  case tov_Carrots:
344  done = m_carrots->Do( this, ev->m_field, ev );
345  break;
346  case tov_BroadBeans:
347  done = m_broadbeans->Do( this, ev->m_field, ev );
348  break;
349  case tov_FodderGrass:
350  done = m_foddergrass->Do( this, ev->m_field, ev );
351  break;
353  done = m_CGG1->Do( this, ev->m_field, ev );
354  break;
356  done = m_CGG2->Do( this, ev->m_field, ev );
357  break;
358  case tov_FieldPeas:
359  done = m_fieldpeas->Do( this, ev->m_field, ev );
360  break;
361  case tov_FieldPeasSilage:
362  done = m_fieldpeassilage->Do( this, ev->m_field, ev );
363  break;
364  case tov_FodderBeet:
365  done = m_fodderbeet->Do( this, ev->m_field, ev );
366  break;
367  case tov_SugarBeet:
368  done = m_sugarbeet->Do( this, ev->m_field, ev );
369  break;
370  case tov_OFodderBeet:
371  done = m_ofodderbeet->Do( this, ev->m_field, ev );
372  break;
373  case tov_Maize:
374  done = m_maize->Do( this, ev->m_field, ev );
375  break;
377  done = m_OBarleyPCG->Do( this, ev->m_field, ev );
378  break;
379  case tov_OCarrots:
380  done = m_ocarrots->Do( this, ev->m_field, ev );
381  break;
383  done = m_OCGS1->Do( this, ev->m_field, ev );
384  break;
386  done = m_OCGG1->Do( this, ev->m_field, ev );
387  break;
389  done = m_OCGG2->Do( this, ev->m_field, ev );
390  break;
391  case tov_OFieldPeas:
392  done = m_ofieldpeas->Do( this, ev->m_field, ev );
393  break;
395  done = m_ofieldpeassilage->Do( this, ev->m_field, ev );
396  break;
397  case tov_OGrazingPigs:
398  done = m_ograzingpigs->Do( this, ev->m_field, ev );
399  break;
400  case tov_OrchardCrop:
401  done = m_orchardcrop->Do( this, ev->m_field, ev );
402  break;
403  case tov_OOats:
404  done = m_ooats->Do( this, ev->m_field, ev );
405  break;
406  case tov_Oats:
407  done = m_oats->Do( this, ev->m_field, ev );
408  break;
410  done = m_opermgrassgrazed->Do( this, ev->m_field, ev );
411  break;
412  case tov_OPotatoes:
413  done = m_opotatoes->Do( this, ev->m_field, ev );
414  break;
415  case tov_OSpringBarley:
416  done = m_ospringbarley->Do( this, ev->m_field, ev );
417  break;
418  case tov_OSBarleySilage:
419  done = m_osbarleysilage->Do( this, ev->m_field, ev );
420  break;
421  case tov_OSeedGrass1:
422  done = m_oseedgrass1->Do( this, ev->m_field, ev );
423  break;
424  case tov_OSeedGrass2:
425  done = m_oseedgrass2->Do( this, ev->m_field, ev );
426  break;
428  done = m_ospringbarleyext->Do( this, ev->m_field, ev );
429  break;
431  done = m_ospringbarleypigs->Do( this, ev->m_field, ev );
432  break;
433  case tov_OWinterBarley:
434  done = m_owinterbarley->Do( this, ev->m_field, ev );
435  break;
437  done = m_owinterbarleyext->Do( this, ev->m_field, ev );
438  break;
440  done = m_owinterwheatundersown->Do( this, ev->m_field, ev );
441  break;
442  case tov_OWinterWheat:
443  done = m_owinterwheat->Do( this, ev->m_field, ev );
444  break;
446  done = m_owinterwheatundersownext->Do( this, ev->m_field, ev );
447  break;
448  case tov_OWinterRape:
449  done = m_owinterrape->Do( this, ev->m_field, ev );
450  break;
451  case tov_OWinterRye:
452  done = m_owinterrye->Do( this, ev->m_field, ev );
453  break;
455  done = m_permgrassgrazed->Do( this, ev->m_field, ev );
456  break;
458  done = m_permgrasslowyield->Do( this, ev->m_field, ev );
459  break;
461  done = m_permgrasstussocky->Do( this, ev->m_field, ev );
462  break;
464  done = m_permanentsetaside->Do( this, ev->m_field, ev );
465  break;
466  case tov_Potatoes:
467  done = m_potatoes->Do( this, ev->m_field, ev );
468  break;
470  done = m_potatoesindustry->Do( this, ev->m_field, ev );
471  break;
472  case tov_SeedGrass1:
473  done = m_seedgrass1->Do( this, ev->m_field, ev );
474  break;
475  case tov_SeedGrass2:
476  done = m_seedgrass2->Do( this, ev->m_field, ev );
477  break;
478  case tov_Setaside:
479  done = m_setaside->Do( this, ev->m_field, ev );
480  break;
481  case tov_SpringBarley:
482  done = m_springbarley->Do( this, ev->m_field, ev );
483  break;
484  case tov_SpringBarleySpr:
485  done = m_springbarleyspr->Do( this, ev->m_field, ev );
486  break;
488  done = m_springbarleyptreatment->Do( this, ev->m_field, ev );
489  break;
491  done = m_springbarleyskmanagement->Do( this, ev->m_field, ev );
492  break;
494  done = m_sbarleyclovergrass->Do( this, ev->m_field, ev );
495  break;
497  done = m_springbarleyseed->Do( this, ev->m_field, ev );
498  break;
500  done = m_springbarleysilage->Do( this, ev->m_field, ev );
501  break;
502  case tov_SpringRape:
503  done = m_springrape->Do( this, ev->m_field, ev );
504  break;
505  case tov_Triticale:
506  done = m_triticale->Do( this, ev->m_field, ev );
507  break;
508  case tov_OTriticale:
509  done = m_otriticale->Do( this, ev->m_field, ev );
510  break;
511  case tov_WinterBarley:
512  done = m_winterbarley->Do( this, ev->m_field, ev );
513  break;
514  case tov_WinterRape:
515  done = m_winterrape->Do( this, ev->m_field, ev );
516  break;
517  case tov_WinterRye:
518  done = m_winterrye->Do( this, ev->m_field, ev );
519  break;
520  case tov_WinterWheat:
521  done = m_winterwheat->Do( this, ev->m_field, ev );
522  break;
523  case tov_WWheatPControl:
524  done = m_wwheatpcontrol->Do( this, ev->m_field, ev );
525  break;
527  done = m_wwheatptoxiccontrol->Do( this, ev->m_field, ev );
528  break;
530  done = m_wwheatptreatment->Do( this, ev->m_field, ev );
531  break;
533  done = m_agrochemindustrycereal->Do( this, ev->m_field, ev );
534  break;
536  done = m_winterwheatstrigling->Do( this, ev->m_field, ev );
537  break;
539  done = m_winterwheatstriglingsingle->Do( this, ev->m_field, ev );
540  break;
542  done = m_winterwheatstriglingculm->Do( this, ev->m_field, ev );
543  break;
545  done = m_springbarleyclovergrassstrigling->Do( this, ev->m_field, ev );
546  break;
548  done = m_springbarleystrigling->Do( this, ev->m_field, ev );
549  break;
551  done = m_springbarleystriglingsingle->Do( this, ev->m_field, ev );
552  break;
554  done = m_springbarleystriglingculm->Do( this, ev->m_field, ev );
555  break;
556  case tov_MaizeStrigling:
557  done = m_maizestrigling->Do( this, ev->m_field, ev );
558  break;
559  case tov_MaizeSilage:
560  done = m_maizesilage->Do( this, ev->m_field, ev );
561  break;
562  case tov_OMaizeSilage:
563  done = m_omaizesilage->Do( this, ev->m_field, ev );
564  break;
566  done = m_winterrapestrigling->Do( this, ev->m_field, ev );
567  break;
569  done = m_winterryestrigling->Do( this, ev->m_field, ev );
570  break;
572  done = m_winterbarleystrigling->Do( this, ev->m_field, ev );
573  break;
575  done = m_fieldpeasstrigling->Do( this, ev->m_field, ev );
576  break;
578  done = m_springbarleypeaclovergrassstrigling->Do( this, ev->m_field, ev );
579  break;
580  case tov_YoungForest:
581  done = m_youngforest->Do( this, ev->m_field, ev );
582  break;
583  /* case tov_OFirstYearDanger: done = m_ofirstyeardanger->Do( this, ev->m_field, ev ); break; */
584  default:
585  char veg_type[ 20 ];
586  sprintf( veg_type, "%d", ev->m_event );
587  g_msg->Warn( WARN_FILE, "Farm::LeSwitch(): ""Unknown crop type: ", veg_type );
588  exit( 1 );
589 
590  }
591  return done;
592 }
PermanentGrassGrazed * m_permgrassgrazed
Definition: farm.h:909
PotatoesIndustry * m_potatoesindustry
Definition: farm.h:914
OGrazingPigs * m_ograzingpigs
Definition: farm.h:889
OTriticale * m_otriticale
Definition: farm.h:901
FieldPeasStrigling * m_fieldpeasstrigling
Definition: farm.h:946
SpringBarleySpr * m_springbarleyspr
Definition: farm.h:919
OPotatoes * m_opotatoes
Definition: farm.h:894
OCloverGrassGrazed1 * m_OCGG1
Definition: farm.h:883
SetAside * m_setaside
Definition: farm.h:917
long m_run
Definition: farm.h:396
Triticale * m_triticale
Definition: farm.h:926
OWinterWheatUndersown * m_owinterwheatundersown
Definition: farm.h:906
OWinterBarley * m_owinterbarley
Definition: farm.h:902
OOats * m_ooats
Definition: farm.h:892
SpringRape * m_springrape
Definition: farm.h:925
SeedGrass2 * m_seedgrass2
Definition: farm.h:916
OWinterWheat * m_owinterwheat
Definition: farm.h:907
SpringBarley * m_springbarley
Definition: farm.h:918
SpringBarleySeed * m_springbarleyseed
Definition: farm.h:923
OMaizeSilage * m_omaizesilage
Definition: farm.h:880
AgroChemIndustryCereal * m_agrochemindustrycereal
Definition: farm.h:934
OCarrots * m_ocarrots
Definition: farm.h:882
OWinterRape * m_owinterrape
Definition: farm.h:904
Sugarbeet * m_sugarbeet
Definition: farm.h:876
CloverGrassGrazed1 * m_CGG1
Definition: farm.h:871
FodderGrass * m_foddergrass
Definition: farm.h:870
OFodderbeet * m_ofodderbeet
Definition: farm.h:877
CloverGrassGrazed2 * m_CGG2
Definition: farm.h:872
WinterRapeStrigling * m_winterrapestrigling
Definition: farm.h:943
TTypesOfVegetation m_event
Definition: farm.h:398
WinterRye * m_winterrye
Definition: farm.h:929
WinterRape * m_winterrape
Definition: farm.h:928
MaizeStrigling * m_maizestrigling
Definition: farm.h:942
OWinterWheatUndersownExt * m_owinterwheatundersownext
Definition: farm.h:908
OSeedGrass2 * m_oseedgrass2
Definition: farm.h:896
SpringBarleyStriglingCulm * m_springbarleystriglingculm
Definition: farm.h:940
WinterBarleyStrigling * m_winterbarleystrigling
Definition: farm.h:945
PermanentSetAside * m_permanentsetaside
Definition: farm.h:912
LE * m_field
Definition: farm.h:400
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
SpringBarleyCloverGrassStrigling * m_springbarleyclovergrassstrigling
Definition: farm.h:938
Maize * m_maize
Definition: farm.h:878
WinterWheatStriglingCulm * m_winterwheatstriglingculm
Definition: farm.h:936
OSpringBarley * m_ospringbarley
Definition: farm.h:897
SpringBarleySKManagement * m_springbarleyskmanagement
Definition: farm.h:920
WinterRyeStrigling * m_winterryestrigling
Definition: farm.h:944
Fodderbeet * m_fodderbeet
Definition: farm.h:875
FieldPeasSilage * m_fieldpeassilage
Definition: farm.h:874
Oats * m_oats
Definition: farm.h:891
PermanentGrassTussocky * m_permgrasstussocky
Definition: farm.h:911
WinterBarley * m_winterbarley
Definition: farm.h:927
WinterWheatStriglingSingle * m_winterwheatstriglingsingle
Definition: farm.h:937
SpringBarleySilage * m_springbarleysilage
Definition: farm.h:924
OCloverGrassGrazed2 * m_OCGG2
Definition: farm.h:884
int m_tried_to_do
Definition: elements.h:85
OFieldPeas * m_ofieldpeas
Definition: farm.h:886
OSeedGrass1 * m_oseedgrass1
Definition: farm.h:895
OPermanentGrassGrazed * m_opermgrassgrazed
Definition: farm.h:893
WWheatPControl * m_wwheatpcontrol
Definition: farm.h:931
SpringBarleyStriglingSingle * m_springbarleystriglingsingle
Definition: farm.h:941
SeedGrass1 * m_seedgrass1
Definition: farm.h:915
WWheatPTreatment * m_wwheatptreatment
Definition: farm.h:933
MaizeSilage * m_maizesilage
Definition: farm.h:879
OWinterRye * m_owinterrye
Definition: farm.h:905
OSpringBarleyPigs * m_ospringbarleypigs
Definition: farm.h:899
SpringBarleyCloverGrass * m_sbarleyclovergrass
Definition: farm.h:922
OWinterBarleyExt * m_owinterbarleyext
Definition: farm.h:903
OSBarleySilage * m_osbarleysilage
Definition: farm.h:900
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
OBarleyPeaCloverGrass * m_OBarleyPCG
Definition: farm.h:881
YoungForestCrop * m_youngforest
Definition: farm.h:948
SpringBarleyPTreatment * m_springbarleyptreatment
Definition: farm.h:921
Potatoes * m_potatoes
Definition: farm.h:913
SpringBarleyPeaCloverGrassStrigling * m_springbarleypeaclovergrassstrigling
Definition: farm.h:947
WWheatPToxicControl * m_wwheatptoxiccontrol
Definition: farm.h:932
BroadBeans * m_broadbeans
Definition: farm.h:869
int m_todo
Definition: farm.h:397
OFieldPeasSilage * m_ofieldpeassilage
Definition: farm.h:887
long GetRunNum(void)
Definition: elements.h:117
SpringBarleyStrigling * m_springbarleystrigling
Definition: farm.h:939
Carrots * m_carrots
Definition: farm.h:868
PermanentGrassLowYield * m_permgrasslowyield
Definition: farm.h:910
FieldPeas * m_fieldpeas
Definition: farm.h:873
WinterWheat * m_winterwheat
Definition: farm.h:930
WinterWheatStrigling * m_winterwheatstrigling
Definition: farm.h:935
OCloverGrassSilage1 * m_OCGS1
Definition: farm.h:885
OrchardCrop * m_orchardcrop
Definition: farm.h:890
OSpringBarleyExt * m_ospringbarleyext
Definition: farm.h:898
polylist * Farm::ListOpenFields ( int  a_openness)

Returns a list of fields with openness above a_openness.

Returns the list of fields more open than a_openness.

Definition at line 8922 of file farm.cpp.

References m_fields.

8923 {
8924  polylist* p_list = new polylist;
8925  int nf = (int) m_fields.size();
8926  for ( int i = 0; i < nf; i++ )
8927  {
8928  if ( m_fields[ i ]->GetOpenness() >= a_openness )
8929  {
8930  p_list->push_back( m_fields[i]->GetPoly());
8931  }
8932  }
8933  return p_list;
8934 }
vector< LE * > m_fields
Definition: farm.h:839
vector< unsigned > polylist
Definition: farm.h:162
virtual void Farm::MakeStockFarmer ( void  )
inlinevirtual

Reimplemented in PesticideTrialTreatment, PesticideTrialToxicControl, PesticideTrialControl, OrganicPlant, and ConventionalPlant.

Definition at line 808 of file farm.h.

808 { m_stockfarmer = true; }
bool m_stockfarmer
Definition: farm.h:845
void Farm::Management ( void  )
virtual

Starts the main management loop for the farm and performs some error checking.

Definition at line 306 of file farm.cpp.

References g_msg, MapErrorMsg::Warn(), and WARN_BUG.

306  {
307  HandleEvents();
308  for ( unsigned int i = 0; i < m_fields.size(); i++ ) {
309  // Check for infinite loop in management plan.
310  int count = m_fields[ i ]->GetVegStore();
311  if ( count >= 0 )
312  m_fields[ i ]->SetVegStore( ++count );
313  if ( count > 800 ) {
314  // More than two years where nothing happened.
315  // Raise 'Merry Christmas'!
316  char error_num[ 20 ];
317  sprintf( error_num, "%d", m_fields[ i ]->GetVegType() );
318  g_msg->Warn( WARN_BUG, "I the Farm Manager caught infinite loop in tov type:", error_num );
319  sprintf( error_num, "%d", m_fields[ i ]->m_tried_to_do );
320  g_msg->Warn( WARN_BUG, "It was last seen trying to perform action # ""(or thereabouts):", error_num );
321  exit( 1 );
322  }
323  }
324 }
vector< LE * > m_fields
Definition: farm.h:839
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
virtual void HandleEvents(void)
If there are events to carry out do this, and perhaps start a new crop.
Definition: farm.cpp:684
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
bool Farm::Molluscicide ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply molluscidie to a_field.

Definition at line 1167 of file farmfuncs.cpp.

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, g_weather, LE::GetSignal(), Weather::GetWind(), LE_SIG_NO_MOLLUSC, molluscicide, Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), and LE::Trace().

1168 {
1169 
1170  if (0 >= a_days) {
1171  if ( (!g_weather->Raining()) && (g_weather->GetWind()<4.5) &&
1172  (! (a_field->GetSignal() & LE_SIG_NO_MOLLUSC ))) {
1173  a_field->Trace( molluscicide );
1174  a_field->SetLastTreatment( molluscicide );
1176  }
1177  return true;
1178  }
1179  else if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
1180  if ( ! (a_field->GetSignal() & LE_SIG_NO_MOLLUSC) ) {
1181  a_field->Trace( molluscicide );
1182  a_field->SetLastTreatment( molluscicide );
1184  }
1185  return true;
1186  }
1187  return false;
1188 }
#define LE_SIG_NO_MOLLUSC
Definition: elements.h:44
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
double GetWind(long a_date)
Definition: weather.h:425
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
class Weather * g_weather
Definition: weather.cpp:41
bool Raining(void)
Definition: weather.h:432
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
LE_Signal GetSignal(void)
Definition: elements.h:107
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::PigsAreOut ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Start a pig grazing event on a_field today or soon.

Definition at line 1740 of file farmfuncs.cpp.

References LE::GetUnsprayedMarginPolyRef(), Landscape::SupplyLEPointer(), and LE::TogglePigGrazing().

1741 {
1742 
1743  if ( (0 >= a_days)|| DoIt(50/a_days)) {
1744  a_field->TogglePigGrazing();
1745  int pref=a_field->GetUnsprayedMarginPolyRef();
1746  if (pref!=-1){
1747  // Must have an unsprayed margin so need to pass the information on to it
1748  LE* um=g_landscape_p->SupplyLEPointer(pref);
1749  um->TogglePigGrazing();
1750  }
1751  return true;
1752  }
1753  return false;
1754 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
virtual void TogglePigGrazing(void)
Definition: elements.h:162
Definition: elements.h:81
Landscape * g_landscape_p
Definition: Landscape.cpp:238
bool Farm::PigsAreOutForced ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Start a pig grazing event on a_field today - no exceptions.

Definition at line 1718 of file farmfuncs.cpp.

References LE::GetUnsprayedMarginPolyRef(), l_farm_pig_veg_reduce, pigs_out, LE::ReduceVeg_Extended(), LE::SetLastTreatment(), Landscape::SupplyLEPointer(), LE::Trace(), and CfgFloat::value().

1719 {
1720  a_field->SetLastTreatment( pigs_out );
1721  a_field->Trace( pigs_out );
1722  // Reduce the vegetation because of grazing
1724  // make this a function of grazing pressure
1725  //and field size - perhaps in a later life
1726  int pref=a_field->GetUnsprayedMarginPolyRef();
1727  if (pref!=-1){
1728  // Must have an unsprayed margin so need to pass the information on to it
1729  LE* um=g_landscape_p->SupplyLEPointer(pref);
1730  um->SetLastTreatment( pigs_out );
1732  }
1733  return false;
1734 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
double value(void)
Definition: configurator.h:107
Definition: elements.h:81
virtual void ReduceVeg_Extended(double)
Definition: elements.h:176
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
static CfgFloat l_farm_pig_veg_reduce("FARM_PIG_VEG_REDUCE", CFG_CUSTOM, 0.98)
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::PigsOut ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Generate a 'pigs_out' event for every day the cattle are on a_field.

Definition at line 1690 of file farmfuncs.cpp.

References DO_IT_PROB, LE::GetUnsprayedMarginPolyRef(), l_farm_pig_veg_reduce, pigs_out, LE::ReduceVeg_Extended(), LE::SetLastTreatment(), Landscape::SupplyLEPointer(), LE::TogglePigGrazing(), LE::Trace(), and CfgFloat::value().

1691 {
1692 
1693  if ( (0 >= a_days)|| DoIt(DO_IT_PROB))
1694  {
1695  a_field->TogglePigGrazing();
1696  a_field->Trace( pigs_out );
1697  a_field->SetLastTreatment( pigs_out );
1698  // Reduce the vegetation because of grazing
1700  // make this a function of grazing pressure
1701  //and field size - perhaps in a later life
1702  int pref=a_field->GetUnsprayedMarginPolyRef();
1703  if (pref!=-1){
1704  // Must have an unsprayed margin so need to pass the information on to it
1705  LE* um=g_landscape_p->SupplyLEPointer(pref);
1706  um->SetLastTreatment( pigs_out );
1708  }
1709  return true;
1710  }
1711  return false;
1712 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
virtual void TogglePigGrazing(void)
Definition: elements.h:162
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
double value(void)
Definition: configurator.h:107
Definition: elements.h:81
virtual void ReduceVeg_Extended(double)
Definition: elements.h:176
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
static CfgFloat l_farm_pig_veg_reduce("FARM_PIG_VEG_REDUCE", CFG_CUSTOM, 0.98)
void Trace(int a_value)
Definition: elements.cpp:459
virtual double Farm::Prob_multiplier ( )
inlinevirtual

Reimplemented in OptimisingFarm.

Definition at line 702 of file farm.h.

702 {return 1;};
bool Farm::ProductApplication0 ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply test pesticide to a_field.

Definition at line 1099 of file farmfuncs.cpp.

References Pesticide::DailyQueueAdd(), EL_TRAMLINE_DECAYTIME, g_pest, g_weather, Weather::GetWind(), LE::Insecticide(), l_farm_insecticide_kills, product_treat, Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), LE::Trace(), CfgFloat::value(), and CfgBool::value().

1100 {
1101 
1102  // NOTE Differs from normal pesticide in that it will be done on the last
1103  // day if not managed before
1104  if (0 >= a_days) {
1105  a_field->Trace( product_treat );
1106  a_field->SetLastTreatment( product_treat );
1108  a_field->Insecticide( 0.2 ); }
1110  double p=l_pest_product_0_amount.value();
1111  g_pest->DailyQueueAdd( a_field,p );
1112  return true;
1113  } else {
1114  if ( (!g_weather->Raining()) && (g_weather->GetWind()<4.5)) {
1115  a_field->Trace( product_treat );
1116  a_field->SetLastTreatment( product_treat );
1118  a_field->Insecticide( 0.2 ); }
1120  double p=l_pest_product_0_amount.value();
1121  g_pest->DailyQueueAdd( a_field,p );
1122  return true;
1123  }
1124  }
1125  return false;
1126 }
CfgFloat l_pest_product_0_amount
class Pesticide * g_pest
Definition: pesticide.cpp:70
static CfgBool l_farm_insecticide_kills("FARM_INSECTICIDE_KILLS", CFG_CUSTOM, true)
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
double GetWind(long a_date)
Definition: weather.h:425
void DailyQueueAdd(LE *a_element_sprayed, double a_amount)
Definition: pesticide.cpp:105
double value(void)
Definition: configurator.h:107
class Weather * g_weather
Definition: weather.cpp:41
bool value(void)
Definition: configurator.h:123
bool Raining(void)
Definition: weather.h:432
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
virtual void Insecticide(double)
Definition: elements.h:158
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::ProductApplication1 ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply test pesticide to a_field.

Definition at line 1132 of file farmfuncs.cpp.

References Pesticide::DailyQueueAdd(), EL_TRAMLINE_DECAYTIME, g_pest, g_weather, Weather::GetWind(), LE::Insecticide(), l_farm_insecticide_kills, product_treat, Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), LE::Trace(), CfgFloat::value(), and CfgBool::value().

1133 {
1134 
1135  // NOTE Differs from normal pesticide in that it will be done on the last
1136  // day if not managed before
1137  if (0 >= a_days) {
1138  a_field->Trace( product_treat );
1139  a_field->SetLastTreatment( product_treat );
1141  {
1142  a_field->Insecticide( 0.2 );
1143  }
1145  double p=l_pest_product_1_amount.value();
1146  g_pest->DailyQueueAdd( a_field,p );
1147  return true;
1148  } else {
1149  if ( (!g_weather->Raining()) && (g_weather->GetWind()<4.5)) {
1150  a_field->Trace( product_treat );
1151  a_field->SetLastTreatment( product_treat );
1153  a_field->Insecticide( 0.2 ); }
1155  double p=l_pest_product_1_amount.value();
1156  g_pest->DailyQueueAdd( a_field,p );
1157  return true;
1158  }
1159  }
1160  return false;
1161 }
class Pesticide * g_pest
Definition: pesticide.cpp:70
static CfgBool l_farm_insecticide_kills("FARM_INSECTICIDE_KILLS", CFG_CUSTOM, true)
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
double GetWind(long a_date)
Definition: weather.h:425
void DailyQueueAdd(LE *a_element_sprayed, double a_amount)
Definition: pesticide.cpp:105
double value(void)
Definition: configurator.h:107
CfgFloat l_pest_product_1_amount
class Weather * g_weather
Definition: weather.cpp:41
bool value(void)
Definition: configurator.h:123
bool Raining(void)
Definition: weather.h:432
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
virtual void Insecticide(double)
Definition: elements.h:158
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
void Farm::ReadRotation ( std::string  fname)
protected

Reads a rotation file into the rotation.

Definition at line 618 of file farm.cpp.

References g_msg, FarmManager::TranslateCropCodes(), and MapErrorMsg::Warn().

Referenced by OrganicCattle::OrganicCattle(), OrganicPig::OrganicPig(), OrganicPlant::OrganicPlant(), PesticideTrialTreatment::PesticideTrialTreatment(), UserDefinedFarm1::UserDefinedFarm1(), UserDefinedFarm10::UserDefinedFarm10(), UserDefinedFarm11::UserDefinedFarm11(), UserDefinedFarm12::UserDefinedFarm12(), UserDefinedFarm13::UserDefinedFarm13(), UserDefinedFarm14::UserDefinedFarm14(), UserDefinedFarm15::UserDefinedFarm15(), UserDefinedFarm16::UserDefinedFarm16(), UserDefinedFarm17::UserDefinedFarm17(), UserDefinedFarm2::UserDefinedFarm2(), UserDefinedFarm3::UserDefinedFarm3(), UserDefinedFarm4::UserDefinedFarm4(), UserDefinedFarm5::UserDefinedFarm5(), UserDefinedFarm6::UserDefinedFarm6(), UserDefinedFarm7::UserDefinedFarm7(), UserDefinedFarm8::UserDefinedFarm8(), and UserDefinedFarm9::UserDefinedFarm9().

619 {
620  ifstream ifile;
621  ifile.open(str.c_str(),ios::in);
622  if ( !ifile.is_open() ) {
623  g_msg->Warn( "Cannot open file: ", str.c_str() );
624  exit( 1 );
625  }
626  int nocrops;
627  ifile >> nocrops;
628  m_rotation.resize( nocrops );
629  std::string cropref;
630  for ( int i = 0; i < nocrops; i++ ) {
631  ifile >> cropref;
633  m_rotation[ i ] = tov;
634  }
635  ifile.close();
636 }
TTypesOfVegetation
vector< TTypesOfVegetation > m_rotation
Definition: farm.h:840
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
FarmManager * g_farmmanager
Definition: farm.cpp:238
TTypesOfVegetation TranslateCropCodes(std::string &str)
Definition: farm.cpp:1435
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
void Farm::RemoveField ( LE a_field)

Removes a field from a farm.

Definition at line 1186 of file farm.cpp.

References g_msg, MapErrorMsg::Warn(), and WARN_BUG.

1186  {
1187  int nf = (int) m_fields.size();
1188  for ( int i = 0; i < nf; i++ ) {
1189  if ( m_fields[ i ] == a_field ) {
1190  m_fields.erase( m_fields.begin() + i );
1191  return;
1192  }
1193  }
1194  // If we reach here there is something wrong because the field is not a
1195  // member of this farm
1196  g_msg->Warn( WARN_BUG, "Farm::RemoveField(LE* a_field): ""Unknown field! ", "" );
1197  exit( 1 );
1198 }
vector< LE * > m_fields
Definition: farm.h:839
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
bool Farm::RemoveHunter ( Hunter *  a_hunter)
inline

Definition at line 827 of file farm.h.

827  {
828  for (int h = 0; h < m_HuntersList.size(); h++) {
829  if (m_HuntersList[ h ] == a_hunter) {
830  m_HuntersList.erase( m_HuntersList.begin() + h );
831  }
832  }
833  }
HunterList m_HuntersList
A list of hunters allocated to this farm.
Definition: farm.h:844
bool Farm::RowCultivation ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out a harrowing between crop rows on a_field.

Definition at line 1194 of file farmfuncs.cpp.

References Calendar::Date(), DO_IT_PROB, EL_TRAMLINE_DECAYTIME, g_date, g_weather, Weather::GetRainPeriod(), LE::GetUnsprayedMarginPolyRef(), LE::InsectMortality(), LE::ReduceWeedBiomass(), row_cultivation, LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

1195 {
1196 
1197  if ( (0 >= a_days) && (g_weather->GetRainPeriod(g_date->Date(),3)<0.1) )
1198  {
1199  // Too much rain, just give up and claim we did it.
1200  return true;
1201  }
1202 
1203  if ( (0 >= a_days) ||
1204  ((g_weather->GetRainPeriod(g_date->Date(),3)<0.1) && DoIt(DO_IT_PROB))
1205  ) {
1206  a_field->Trace( row_cultivation );
1207  a_field->SetLastTreatment( row_cultivation );
1208  a_field->ReduceWeedBiomass( 0.5 );
1209  a_field->InsectMortality( 0.25 );
1211  int pref=a_field->GetUnsprayedMarginPolyRef();
1212  if (pref!=-1){
1213  // Must have an unsprayed margin so need to pass the information on to it
1214  LE* um=g_landscape_p->SupplyLEPointer(pref);
1216  um->InsectMortality( 0.25 );
1217  um->ReduceWeedBiomass( 0.5 );
1219  }
1220  return true;
1221  }
1222  return false;
1223 }
long Date(void)
Definition: calendar.h:57
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
virtual void InsectMortality(double)
Definition: elements.h:159
class Calendar * g_date
Definition: calendar.cpp:38
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
double GetRainPeriod(long a_date, unsigned int a_period)
Definition: weather.cpp:278
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
virtual void ReduceWeedBiomass(double)
Definition: elements.h:160
void Trace(int a_value)
Definition: elements.cpp:459
void Farm::SetFarmNumber ( int  a_farm_num)
inline

Definition at line 697 of file farm.h.

697 { m_farm_num = a_farm_num; }
int m_farm_num
Definition: farm.h:846
bool Farm::SleepAllDay ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Nothing to to today on a_field.

Definition at line 136 of file farmfuncs.cpp.

References LE::GetUnsprayedMarginPolyRef(), LE::SetLastTreatment(), sleep_all_day, Landscape::SupplyLEPointer(), and LE::Trace().

137 {
138 
139  a_field->Trace( sleep_all_day );
140  a_field->SetLastTreatment( sleep_all_day );
141  int pref=a_field->GetUnsprayedMarginPolyRef();
142  if (pref!=-1){
143  // Must have an unsprayed margin so need to pass the information on to it
144  LE* um=g_landscape_p->SupplyLEPointer(pref);
146  }
147  return true;
148 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
Definition: elements.h:81
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
void Trace(int a_value)
Definition: elements.cpp:459
virtual bool Farm::Spraying_fungins ( TTypesOfVegetation  )
inlinevirtual

Reimplemented in OptimisingFarm.

Definition at line 701 of file farm.h.

701 {return true; };
virtual bool Farm::Spraying_herbicides ( TTypesOfVegetation  )
inlinevirtual

Reimplemented in OptimisingFarm.

Definition at line 700 of file farm.h.

700 {return true; };
bool Farm::SpringHarrow ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out a harrow event in the spring on a_field.

Definition at line 311 of file farmfuncs.cpp.

References DO_IT_PROB, g_weather, LE::GetUnsprayedMarginPolyRef(), LE::InsectMortality(), Weather::Raining(), LE::SetLastTreatment(), spring_harrow, Landscape::SupplyLEPointer(), LE::Trace(), and LE::ZeroVeg().

312 {
313 
314  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
315  a_field->Trace( spring_harrow );
316  a_field->SetLastTreatment( spring_harrow );
317  // 30% insect mortality
318  a_field->InsectMortality( 0.7 );
319  // remove all vegetation
320  a_field->ZeroVeg();
321  int pref=a_field->GetUnsprayedMarginPolyRef();
322  if (pref!=-1){
323  // Must have an unsprayed margin so need to pass the information on to it
324  LE* um=g_landscape_p->SupplyLEPointer(pref);
326  um->InsectMortality( 0.7 );
327  um->ZeroVeg();
328  }
329  return true;
330  }
331  return false;
332 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
bool Raining(void)
Definition: weather.h:432
virtual void InsectMortality(double)
Definition: elements.h:159
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
virtual void ZeroVeg(void)
Definition: elements.h:174
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::SpringPlough ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out a ploughing event in the spring on a_field.

Definition at line 284 of file farmfuncs.cpp.

References DO_IT_PROB, g_weather, LE::GetUnsprayedMarginPolyRef(), LE::InsectMortality(), Weather::Raining(), LE::SetLastTreatment(), spring_plough, Landscape::SupplyLEPointer(), LE::Trace(), and LE::ZeroVeg().

285 {
286 
287  if ((a_days <= 0) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
288  a_field->Trace( spring_plough );
289  a_field->SetLastTreatment( spring_plough );
290  // Apply 90% mortality to the insects
291  a_field->InsectMortality( 0.1 );
292  // Reduce the vegetation to zero
293  a_field->ZeroVeg();
294  int pref=a_field->GetUnsprayedMarginPolyRef();
295  if (pref!=-1){
296  // Must have an unsprayed margin so need to pass the information on to it
297  LE* um=g_landscape_p->SupplyLEPointer(pref);
299  um->InsectMortality( 0.1);
300  um->ZeroVeg();
301  }
302  return true;
303  }
304  return false;
305 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
bool Raining(void)
Definition: weather.h:432
virtual void InsectMortality(double)
Definition: elements.h:159
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
virtual void ZeroVeg(void)
Definition: elements.h:174
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::SpringRoll ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out a roll event in the spring on a_field.

Definition at line 338 of file farmfuncs.cpp.

References DO_IT_PROB, g_weather, LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), spring_roll, Landscape::SupplyLEPointer(), and LE::Trace().

339 {
340 
341  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
342  a_field->Trace( spring_roll );
343  a_field->SetLastTreatment( spring_roll );
344  int pref=a_field->GetUnsprayedMarginPolyRef();
345  if (pref!=-1){
346  // Must have an unsprayed margin so need to pass the information on to it
347  LE* um=g_landscape_p->SupplyLEPointer(pref);
349  }
350  return true;
351  }
352  return false;
353 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
bool Raining(void)
Definition: weather.h:432
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::SpringSow ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out a sowing event in the spring on a_field.

Definition at line 359 of file farmfuncs.cpp.

References DO_IT_PROB, g_weather, LE::GetUnsprayedMarginPolyRef(), LE::GetVegType(), Weather::Raining(), LE::SetGrowthPhase(), LE::SetLastSownVeg(), LE::SetLastTreatment(), sow, spring_sow, Landscape::SupplyLEPointer(), LE::Trace(), and LE::ZeroVeg().

360 {
361 
362  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
363  a_field->Trace( spring_sow );
364  a_field->SetLastTreatment( spring_sow );
365  a_field->SetGrowthPhase( sow );
366  a_field->SetLastSownVeg(a_field->GetVegType());
367  // Reduce the vegetation to zero - should not strictly be necessary, but prevents any false starts in the crop growth.
368  a_field->ZeroVeg();
369  int pref=a_field->GetUnsprayedMarginPolyRef();
370  if (pref!=-1){
371  // Must have an unsprayed margin so need to pass the information on to it
372  LE* um=g_landscape_p->SupplyLEPointer(pref);
374  um->SetGrowthPhase( sow );
375  um->ZeroVeg();
376  um->SetLastSownVeg(um->GetVegType());
377  }
378  return true;
379  }
380  return false;
381 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
void SetLastSownVeg(TTypesOfVegetation a_tov)
Records the last vegetation type to be sown.
Definition: elements.h:287
class Weather * g_weather
Definition: weather.cpp:41
virtual TTypesOfVegetation GetVegType(void)
Definition: elements.h:125
bool Raining(void)
Definition: weather.h:432
Definition: plants.h:51
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
virtual void SetGrowthPhase(int)
Definition: elements.h:170
virtual void ZeroVeg(void)
Definition: elements.h:174
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::StrawChopping ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out straw chopping on a_field.

Definition at line 1760 of file farmfuncs.cpp.

References Calendar::Date(), DO_IT_PROB, EL_TRAMLINE_DECAYTIME, g_date, g_weather, Weather::GetRainPeriod(), LE::GetUnsprayedMarginPolyRef(), LE::InsectMortality(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), straw_chopping, Landscape::SupplyLEPointer(), and LE::Trace().

1761 {
1762 
1763  if ( (0 >= a_days) ||
1764  ((g_weather->GetRainPeriod(g_date->Date(),5)<0.1) && DoIt(DO_IT_PROB))
1765  ) {
1766  a_field->Trace( straw_chopping );
1767  a_field->SetLastTreatment( straw_chopping );
1768  a_field->InsectMortality( 0.4 );
1770  int pref=a_field->GetUnsprayedMarginPolyRef();
1771  if (pref!=-1){
1772  // Must have an unsprayed margin so need to pass the information on to it
1773  LE* um=g_landscape_p->SupplyLEPointer(pref);
1775  um->InsectMortality( 0.4 );
1777  }
1778  return true;
1779  }
1780  return false;
1781 }
long Date(void)
Definition: calendar.h:57
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
virtual void InsectMortality(double)
Definition: elements.h:159
class Calendar * g_date
Definition: calendar.cpp:38
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
double GetRainPeriod(long a_date, unsigned int a_period)
Definition: weather.cpp:278
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::Strigling ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out a mechanical weeding on a_field.

Definition at line 1229 of file farmfuncs.cpp.

References Calendar::Date(), DO_IT_PROB, EL_STRIGLING_DELAYTIME, EL_TRAMLINE_DECAYTIME, g_date, g_weather, Weather::GetRainPeriod(), LE::GetUnsprayedMarginPolyRef(), LE::InsectMortality(), LE::ReduceWeedBiomass(), LE::SetHerbicideDelay(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), strigling, Landscape::SupplyLEPointer(), and LE::Trace().

1230 {
1231 
1232  // Force strigling if it has not been done already!!! This happens regardless of weather as of 26/10/2005
1233  if ( (0 >= a_days) )// && (g_weather->GetRainPeriod(g_date->Date(),3)>0.1) )
1234  {
1235  a_field->Trace( strigling );
1236  a_field->SetLastTreatment( strigling );
1237  a_field->ReduceWeedBiomass( 0.05 );
1238  a_field->InsectMortality( 0.7 );
1241  int pref=a_field->GetUnsprayedMarginPolyRef();
1242  if (pref!=-1){
1243  // Must have an unsprayed margin so need to pass the information on to it
1244  LE* um=g_landscape_p->SupplyLEPointer(pref);
1245  um->SetLastTreatment( strigling );
1246  um->ReduceWeedBiomass( 0.05 );
1247  um->InsectMortality( 0.7 );
1250  return true;
1251  }
1252  }
1253  if ( (0 >= a_days) ||
1254  ((g_weather->GetRainPeriod(g_date->Date(),3)<0.1) && DoIt(DO_IT_PROB))
1255  ) {
1256  a_field->Trace( strigling );
1257  a_field->SetLastTreatment( strigling );
1258  a_field->ReduceWeedBiomass( 0.05 );
1259  a_field->InsectMortality( 0.7 );
1262  int pref=a_field->GetUnsprayedMarginPolyRef();
1263  if (pref!=-1){
1264  // Must have an unsprayed margin so need to pass the information on to it
1265  LE* um=g_landscape_p->SupplyLEPointer(pref);
1266  um->SetLastTreatment( strigling );
1267  um->ReduceWeedBiomass( 0.05 );
1268  um->InsectMortality( 0.7 );
1271  }
1272  return true;
1273  }
1274  return false;
1275 }
#define EL_STRIGLING_DELAYTIME
Definition: elements.h:59
long Date(void)
Definition: calendar.h:57
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
virtual void InsectMortality(double)
Definition: elements.h:159
class Calendar * g_date
Definition: calendar.cpp:38
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
double GetRainPeriod(long a_date, unsigned int a_period)
Definition: weather.cpp:278
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void SetHerbicideDelay(int a_decaytime_days)
Definition: elements.h:306
virtual void ReduceWeedBiomass(double)
Definition: elements.h:160
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::StriglingSow ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out a mechanical weeding followed by sowing on a_field.

Definition at line 1281 of file farmfuncs.cpp.

References Calendar::Date(), DO_IT_PROB, EL_STRIGLING_DELAYTIME, EL_TRAMLINE_DECAYTIME, g_date, g_weather, Weather::GetRainPeriod(), LE::GetUnsprayedMarginPolyRef(), LE::InsectMortality(), LE::ReduceWeedBiomass(), LE::SetHerbicideDelay(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), strigling_sow, Landscape::SupplyLEPointer(), and LE::Trace().

1282 {
1283 
1284  //2 days good weather afterwards
1285  if ( (0 >= a_days) && (g_weather->GetRainPeriod(g_date->Date(),3)<0.1) )
1286  {
1287  return true;
1288  }
1289 
1290  if ( (0 >= a_days) ||
1291  ((g_weather->GetRainPeriod(g_date->Date(),3)<0.1) && DoIt(DO_IT_PROB))
1292  ) {
1293  a_field->Trace( strigling_sow );
1294  a_field->SetLastTreatment( strigling_sow );
1295  a_field->ReduceWeedBiomass( 0.05 );
1296  a_field->InsectMortality( 0.7 );
1299  int pref=a_field->GetUnsprayedMarginPolyRef();
1300  if (pref!=-1){
1301  // Must have an unsprayed margin so need to pass the information on to it
1302  LE* um=g_landscape_p->SupplyLEPointer(pref);
1304  um->ReduceWeedBiomass( 0.05 );
1305  um->InsectMortality( 0.7 );
1308  }
1309  return true;
1310  }
1311  return false;
1312 }
#define EL_STRIGLING_DELAYTIME
Definition: elements.h:59
long Date(void)
Definition: calendar.h:57
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
virtual void InsectMortality(double)
Definition: elements.h:159
class Calendar * g_date
Definition: calendar.cpp:38
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
double GetRainPeriod(long a_date, unsigned int a_period)
Definition: weather.cpp:278
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void SetHerbicideDelay(int a_decaytime_days)
Definition: elements.h:306
virtual void ReduceWeedBiomass(double)
Definition: elements.h:160
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::StubbleHarrowing ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out stubble harrowing on a_field.

Definition at line 1837 of file farmfuncs.cpp.

References Calendar::Date(), DO_IT_PROB, g_date, g_weather, Weather::GetRainPeriod(), LE::GetUnsprayedMarginPolyRef(), LE::InsectMortality(), LE::SetLastTreatment(), stubble_harrowing, Landscape::SupplyLEPointer(), LE::Trace(), and LE::ZeroVeg().

1838 {
1839 
1840  if ( (0 >= a_days) ||
1841  ((g_weather->GetRainPeriod(g_date->Date(),3)<0.1) && DoIt(DO_IT_PROB))
1842  ) {
1843  a_field->Trace( stubble_harrowing );
1844  a_field->SetLastTreatment( stubble_harrowing );
1845  a_field->InsectMortality( 0.25 );
1846  a_field->ZeroVeg();
1847  int pref=a_field->GetUnsprayedMarginPolyRef();
1848  if (pref!=-1){
1849  // Must have an unsprayed margin so need to pass the information on to it
1850  LE* um=g_landscape_p->SupplyLEPointer(pref);
1852  um->ZeroVeg();
1853  um->InsectMortality( 0.25 );
1854  }
1855  return true;
1856  }
1857  return false;
1858 }
long Date(void)
Definition: calendar.h:57
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
virtual void InsectMortality(double)
Definition: elements.h:159
class Calendar * g_date
Definition: calendar.cpp:38
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
double GetRainPeriod(long a_date, unsigned int a_period)
Definition: weather.cpp:278
virtual void ZeroVeg(void)
Definition: elements.h:174
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::Swathing ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Cut the crop on a_field and leave it lying (probably rape)

Definition at line 1372 of file farmfuncs.cpp.

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, g_weather, LE::GetUnsprayedMarginPolyRef(), LE::InsectMortality(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), swathing, and LE::Trace().

1373 {
1374 
1375  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
1376  a_field->Trace( swathing );
1377  a_field->SetLastTreatment( swathing );
1378  a_field->InsectMortality( 0.5 );
1380  int pref=a_field->GetUnsprayedMarginPolyRef();
1381  if (pref!=-1){
1382  // Must have an unsprayed margin so need to pass the information on to it
1383  LE* um=g_landscape_p->SupplyLEPointer(pref);
1384  um->SetLastTreatment( swathing );
1385  um->InsectMortality( 0.5 );
1387  }
1388  return true;
1389  }
1390  return false;
1391 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
bool Raining(void)
Definition: weather.h:432
virtual void InsectMortality(double)
Definition: elements.h:159
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::SynInsecticideTreat ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply special insecticide to a_field.

Definition at line 1061 of file farmfuncs.cpp.

References EL_TRAMLINE_DECAYTIME, g_weather, LE::GetSignal(), Weather::GetWind(), LE::Insecticide(), l_farm_insecticide_kills, LE_SIG_NO_SYNG_INSECT, Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), syninsecticide_treat, LE::Trace(), and CfgBool::value().

1062 {
1063 
1064  // NOTE Differs from normal insecticide in that it will be done on the last
1065  // day if not managed before
1066  if (0 >= a_days) {
1067  if ( ! (a_field->GetSignal() & LE_SIG_NO_SYNG_INSECT )) {
1068  a_field->Trace( syninsecticide_treat );
1071  a_field->Insecticide( 0.2 );
1072  }
1074  }
1075 // double p=l_pest_insecticide_amount.value();
1076 // g_pest->DailyQueueAdd( a_field,p );
1077  return true;
1078  } else {
1079  if ( (!g_weather->Raining()) && (g_weather->GetWind()<4.5)) {
1080  if ( ! (a_field->GetSignal() & LE_SIG_NO_SYNG_INSECT ) ) {
1081  a_field->Trace( syninsecticide_treat );
1084  a_field->Insecticide( 0.2 );
1085  }
1087  }
1088 // g_pest->DailyQueueAdd( a_field, l_pest_insecticide_amount.value());
1089  return true;
1090  }
1091  }
1092  return false;
1093 }
static CfgBool l_farm_insecticide_kills("FARM_INSECTICIDE_KILLS", CFG_CUSTOM, true)
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
double GetWind(long a_date)
Definition: weather.h:425
class Weather * g_weather
Definition: weather.cpp:41
bool value(void)
Definition: configurator.h:123
bool Raining(void)
Definition: weather.h:432
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
#define LE_SIG_NO_SYNG_INSECT
Definition: elements.h:42
LE_Signal GetSignal(void)
Definition: elements.h:107
virtual void Insecticide(double)
Definition: elements.h:158
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::Trial_Control ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Special pesticide trial functionality.

Definition at line 2093 of file farmfuncs.cpp.

References EL_TRAMLINE_DECAYTIME, LE::SetLastTreatment(), LE::SetTramlinesDecay(), LE::Trace(), and trial_control.

2094 {
2095  // Will always do this at the first chance
2096  a_field->Trace( trial_control );
2097  a_field->SetLastTreatment( trial_control );
2099  return true;
2100 }
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::Trial_PesticideTreat ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Special pesticide trial functionality.

Any testing for year or date limitations must be done by calling methods, otherwise use Trial_PesticideTreat_DateLimited()

Definition at line 2044 of file farmfuncs.cpp.

References EL_TRAMLINE_DECAYTIME, LE::InsectMortality(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), LE::Trace(), and trial_insecticidetreat.

2045 {
2047  a_field->Trace( trial_insecticidetreat );
2049  a_field->InsectMortality( 0.1 ); // Change this manually if it is really a herbicide
2051  return true;
2052 }
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
virtual void InsectMortality(double)
Definition: elements.h:159
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::Trial_PesticideTreat_DateLimited ( LE a_field,
double  ,
int   
)
virtual

Special pesticide trial functionality.

This methods tests for date limitations

Definition at line 2022 of file farmfuncs.cpp.

References Pesticide::DailyQueueAdd(), EL_TRAMLINE_DECAYTIME, g_pest, LE::InsectMortality(), LE::SetLastTreatment(), LE::SetSprayedToday(), LE::SetTramlinesDecay(), Landscape::SupplyYearNumber(), LE::Trace(), trial_insecticidetreat, CfgInt::value(), and CfgFloat::value().

2023 {
2025  int year = g_landscape_p->SupplyYearNumber();
2026  if (year < cfg_productapplicstartyear.value()) return false;
2027  if (year > cfg_productapplicendyear.value()) return false;
2028  a_field->Trace(trial_insecticidetreat); // Debug function only
2030  a_field->InsectMortality(0.36); // Change this manually if it is really a herbicide
2032  a_field->SetSprayedToday(true);
2034  return true;
2035 }
class Pesticide * g_pest
Definition: pesticide.cpp:70
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
void DailyQueueAdd(LE *a_element_sprayed, double a_amount)
Definition: pesticide.cpp:105
double value(void)
Definition: configurator.h:107
void SetSprayedToday(bool a_didit)
Definition: elements.h:297
int SupplyYearNumber(void)
Definition: landscape.h:1542
CfgInt cfg_productapplicendyear
CfgFloat l_pest_insecticide_amount
virtual void InsectMortality(double)
Definition: elements.h:159
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
CfgInt cfg_productapplicstartyear
Landscape * g_landscape_p
Definition: Landscape.cpp:238
int value(void)
Definition: configurator.h:92
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::Trial_PesticideTreat_GS ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Special pesticide trial functionality.

Definition at line 2059 of file farmfuncs.cpp.

References EL_HERBICIDE_DELAYTIME, EL_TRAMLINE_DECAYTIME, LE::GetVegHeight(), LE::ReduceWeedBiomass(), LE::SetHerbicideDelay(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), LE::Trace(), and trial_insecticidetreat.

2060 {
2061  // Can spray between two certain heights only, but we have to hope that we get called in time for the first so
2062  // right now we only care if we are above a certain height (timing is also important, so must not call this until
2063  // after a ploughing and sowing event
2064  if (a_field->GetVegHeight() < 3.0) return false;
2065  // All OK so here goes:
2066  a_field->Trace( trial_insecticidetreat );
2068  //a_field->InsectMortality( 0.1 ); // Change this manually if it is really a herbicide
2069  a_field->ReduceWeedBiomass( 0.05 );
2072  return true;
2073 }
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
virtual double GetVegHeight(void)
Definition: elements.h:135
#define EL_HERBICIDE_DELAYTIME
Definition: elements.h:58
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void SetHerbicideDelay(int a_decaytime_days)
Definition: elements.h:306
virtual void ReduceWeedBiomass(double)
Definition: elements.h:160
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::Trial_ToxicControl ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Special pesticide trial functionality.

Definition at line 2079 of file farmfuncs.cpp.

References EL_TRAMLINE_DECAYTIME, LE::InsectMortality(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), LE::Trace(), and trial_toxiccontrol.

2080 {
2081  a_field->Trace( trial_toxiccontrol );
2083  a_field->InsectMortality( 0.001 );
2085  return true;
2086 }
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:304
virtual void InsectMortality(double)
Definition: elements.h:159
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:55
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::Water ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out a watering on a_field.

Definition at line 1345 of file farmfuncs.cpp.

References DO_IT_PROB, g_weather, LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), Landscape::SupplyLEPointer(), LE::Trace(), and water.

1346 {
1347 
1348 
1349  /* Turn on this code to avoid watering on heavy soils
1350  int soiltype = a_field->GetSoilType();
1351  if ( soiltype < 1 || soiltype > 4 )
1352  return true;
1353 */
1354  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
1355  a_field->Trace( water );
1356  a_field->SetLastTreatment( water );
1357  int pref=a_field->GetUnsprayedMarginPolyRef();
1358  if (pref!=-1){
1359  // Must have an unsprayed margin so need to pass the information on to it
1360  LE* um=g_landscape_p->SupplyLEPointer(pref);
1361  um->SetLastTreatment( water );
1362  }
1363  return true;
1364  }
1365  return false;
1366 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
bool Raining(void)
Definition: weather.h:432
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
void Trace(int a_value)
Definition: elements.cpp:459
bool Farm::WinterPlough ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out a ploughing event in the winter on a_field.

Definition at line 232 of file farmfuncs.cpp.

References DO_IT_PROB, g_weather, LE::GetUnsprayedMarginPolyRef(), LE::InsectMortality(), Weather::Raining(), LE::SetLastTreatment(), Landscape::SupplyLEPointer(), LE::Trace(), winter_plough, and LE::ZeroVeg().

233 {
234 
235  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
236  a_field->Trace( winter_plough );
237  a_field->SetLastTreatment( winter_plough );
238  a_field->InsectMortality( 0.1 );
239  a_field->ZeroVeg();
240  int pref=a_field->GetUnsprayedMarginPolyRef();
241  if (pref!=-1){
242  // Must have an unsprayed margin so need to pass the information on to it
243  LE* um=g_landscape_p->SupplyLEPointer(pref);
245  um->InsectMortality( 0.1 );
246  um->ZeroVeg();
247  }
248  return true;
249  }
250  return false;
251 }
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
bool DoIt(int a_probability)
Return chance out of 100.
Definition: farm.cpp:610
#define DO_IT_PROB
Definition: farmfuncs.cpp:58
Definition: elements.h:81
class Weather * g_weather
Definition: weather.cpp:41
bool Raining(void)
Definition: weather.h:432
virtual void InsectMortality(double)
Definition: elements.h:159
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
Landscape * g_landscape_p
Definition: Landscape.cpp:238
virtual void ZeroVeg(void)
Definition: elements.h:174
void Trace(int a_value)
Definition: elements.cpp:459

Member Data Documentation

AgroChemIndustryCereal* Farm::m_agrochemindustrycereal
protected

Definition at line 934 of file farm.h.

BroadBeans* Farm::m_broadbeans
protected

Definition at line 869 of file farm.h.

Carrots* Farm::m_carrots
protected

Definition at line 868 of file farm.h.

CloverGrassGrazed1* Farm::m_CGG1
protected

Definition at line 871 of file farm.h.

CloverGrassGrazed2* Farm::m_CGG2
protected

Definition at line 872 of file farm.h.

int Farm::m_farm_centroidx
protected

Farm's centroid, value x. Equal to the average of the x centroid values of all farm's fields.

Definition at line 861 of file farm.h.

Referenced by Centroids().

int Farm::m_farm_centroidy
protected

Farm's centroid, value y. Equal to the average of the y centroid values of all farm's fields.

Definition at line 863 of file farm.h.

Referenced by Centroids().

int Farm::m_farm_num
protected

Definition at line 846 of file farm.h.

TTypesOfFarm Farm::m_farmtype
protected

Definition at line 842 of file farm.h.

Referenced by AgroChemIndustryCerealFarm1::AgroChemIndustryCerealFarm1(), AgroChemIndustryCerealFarm2::AgroChemIndustryCerealFarm2(), AgroChemIndustryCerealFarm3::AgroChemIndustryCerealFarm3(), ConventionalCattle::ConventionalCattle(), ConventionalPig::ConventionalPig(), ConventionalPlant::ConventionalPlant(), ConvMarginalJord::ConvMarginalJord(), NoPesticideBaseFarm::NoPesticideBaseFarm(), NoPesticideNoPFarm::NoPesticideNoPFarm(), OptimisingFarm::OptimisingFarm(), OrganicCattle::OrganicCattle(), OrganicPig::OrganicPig(), OrganicPlant::OrganicPlant(), PesticideTrialControl::PesticideTrialControl(), PesticideTrialToxicControl::PesticideTrialToxicControl(), PesticideTrialTreatment::PesticideTrialTreatment(), UserDefinedFarm1::UserDefinedFarm1(), UserDefinedFarm10::UserDefinedFarm10(), UserDefinedFarm11::UserDefinedFarm11(), UserDefinedFarm12::UserDefinedFarm12(), UserDefinedFarm13::UserDefinedFarm13(), UserDefinedFarm14::UserDefinedFarm14(), UserDefinedFarm15::UserDefinedFarm15(), UserDefinedFarm16::UserDefinedFarm16(), UserDefinedFarm17::UserDefinedFarm17(), UserDefinedFarm18::UserDefinedFarm18(), UserDefinedFarm19::UserDefinedFarm19(), UserDefinedFarm2::UserDefinedFarm2(), UserDefinedFarm20::UserDefinedFarm20(), UserDefinedFarm21::UserDefinedFarm21(), UserDefinedFarm22::UserDefinedFarm22(), UserDefinedFarm23::UserDefinedFarm23(), UserDefinedFarm24::UserDefinedFarm24(), UserDefinedFarm25::UserDefinedFarm25(), UserDefinedFarm26::UserDefinedFarm26(), UserDefinedFarm27::UserDefinedFarm27(), UserDefinedFarm28::UserDefinedFarm28(), UserDefinedFarm29::UserDefinedFarm29(), UserDefinedFarm3::UserDefinedFarm3(), UserDefinedFarm30::UserDefinedFarm30(), UserDefinedFarm31::UserDefinedFarm31(), UserDefinedFarm32::UserDefinedFarm32(), UserDefinedFarm33::UserDefinedFarm33(), UserDefinedFarm34::UserDefinedFarm34(), UserDefinedFarm35::UserDefinedFarm35(), UserDefinedFarm4::UserDefinedFarm4(), UserDefinedFarm5::UserDefinedFarm5(), UserDefinedFarm6::UserDefinedFarm6(), UserDefinedFarm7::UserDefinedFarm7(), UserDefinedFarm8::UserDefinedFarm8(), and UserDefinedFarm9::UserDefinedFarm9().

FieldPeas* Farm::m_fieldpeas
protected

Definition at line 873 of file farm.h.

FieldPeasSilage* Farm::m_fieldpeassilage
protected

Definition at line 874 of file farm.h.

FieldPeasStrigling* Farm::m_fieldpeasstrigling
protected

Definition at line 946 of file farm.h.

vector< LE* > Farm::m_fields
protected
Fodderbeet* Farm::m_fodderbeet
protected

Definition at line 875 of file farm.h.

FodderGrass* Farm::m_foddergrass
protected

Definition at line 870 of file farm.h.

HunterList Farm::m_HuntersList
protected

A list of hunters allocated to this farm.

Definition at line 844 of file farm.h.

int Farm::m_intensity
protected

Definition at line 848 of file farm.h.

Maize* Farm::m_maize
protected

Definition at line 878 of file farm.h.

MaizeSilage* Farm::m_maizesilage
protected

Definition at line 879 of file farm.h.

MaizeStrigling* Farm::m_maizestrigling
protected

Definition at line 942 of file farm.h.

Oats* Farm::m_oats
protected

Definition at line 891 of file farm.h.

OBarleyPeaCloverGrass* Farm::m_OBarleyPCG
protected

Definition at line 881 of file farm.h.

OCarrots* Farm::m_ocarrots
protected

Definition at line 882 of file farm.h.

OCloverGrassGrazed1* Farm::m_OCGG1
protected

Definition at line 883 of file farm.h.

OCloverGrassGrazed2* Farm::m_OCGG2
protected

Definition at line 884 of file farm.h.

OCloverGrassSilage1* Farm::m_OCGS1
protected

Definition at line 885 of file farm.h.

OFieldPeas* Farm::m_ofieldpeas
protected

Definition at line 886 of file farm.h.

OFieldPeasSilage* Farm::m_ofieldpeassilage
protected

Definition at line 887 of file farm.h.

OFirstYearDanger* Farm::m_ofirstyeardanger
protected

Definition at line 888 of file farm.h.

OFodderbeet* Farm::m_ofodderbeet
protected

Definition at line 877 of file farm.h.

OGrazingPigs* Farm::m_ograzingpigs
protected

Definition at line 889 of file farm.h.

OMaizeSilage* Farm::m_omaizesilage
protected

Definition at line 880 of file farm.h.

OOats* Farm::m_ooats
protected

Definition at line 892 of file farm.h.

OPermanentGrassGrazed* Farm::m_opermgrassgrazed
protected

Definition at line 893 of file farm.h.

OPotatoes* Farm::m_opotatoes
protected

Definition at line 894 of file farm.h.

OrchardCrop* Farm::m_orchardcrop
protected

Definition at line 890 of file farm.h.

OSBarleySilage* Farm::m_osbarleysilage
protected

Definition at line 900 of file farm.h.

OSeedGrass1* Farm::m_oseedgrass1
protected

Definition at line 895 of file farm.h.

OSeedGrass2* Farm::m_oseedgrass2
protected

Definition at line 896 of file farm.h.

OSpringBarley* Farm::m_ospringbarley
protected

Definition at line 897 of file farm.h.

OSpringBarleyExt* Farm::m_ospringbarleyext
protected

Definition at line 898 of file farm.h.

OSpringBarleyPigs* Farm::m_ospringbarleypigs
protected

Definition at line 899 of file farm.h.

OTriticale* Farm::m_otriticale
protected

Definition at line 901 of file farm.h.

FarmManager* Farm::m_OurManager
protected
OWinterBarley* Farm::m_owinterbarley
protected

Definition at line 902 of file farm.h.

OWinterBarleyExt* Farm::m_owinterbarleyext
protected

Definition at line 903 of file farm.h.

OWinterRape* Farm::m_owinterrape
protected

Definition at line 904 of file farm.h.

OWinterRye* Farm::m_owinterrye
protected

Definition at line 905 of file farm.h.

OWinterWheat* Farm::m_owinterwheat
protected

Definition at line 907 of file farm.h.

OWinterWheatUndersown* Farm::m_owinterwheatundersown
protected

Definition at line 906 of file farm.h.

OWinterWheatUndersownExt* Farm::m_owinterwheatundersownext
protected

Definition at line 908 of file farm.h.

PermanentSetAside* Farm::m_permanentsetaside
protected

Definition at line 912 of file farm.h.

vector<PermCropData> Farm::m_PermCrops
protected
PermanentGrassGrazed* Farm::m_permgrassgrazed
protected

Definition at line 909 of file farm.h.

PermanentGrassLowYield* Farm::m_permgrasslowyield
protected

Definition at line 910 of file farm.h.

PermanentGrassTussocky* Farm::m_permgrasstussocky
protected

Definition at line 911 of file farm.h.

Potatoes* Farm::m_potatoes
protected

Definition at line 913 of file farm.h.

PotatoesIndustry* Farm::m_potatoesindustry
protected

Definition at line 914 of file farm.h.

LowPriority< FarmEvent* > Farm::m_queue
protected

Definition at line 838 of file farm.h.

vector<TTypesOfVegetation> Farm::m_rotation
protected
int Farm::m_rotation_sync_index
protected

Definition at line 847 of file farm.h.

SpringBarleyCloverGrass* Farm::m_sbarleyclovergrass
protected

Definition at line 922 of file farm.h.

SeedGrass1* Farm::m_seedgrass1
protected

Definition at line 915 of file farm.h.

SeedGrass2* Farm::m_seedgrass2
protected

Definition at line 916 of file farm.h.

SetAside* Farm::m_setaside
protected

Definition at line 917 of file farm.h.

SpringBarley* Farm::m_springbarley
protected

Definition at line 918 of file farm.h.

SpringBarleyCloverGrassStrigling* Farm::m_springbarleyclovergrassstrigling
protected

Definition at line 938 of file farm.h.

SpringBarleyPeaCloverGrassStrigling* Farm::m_springbarleypeaclovergrassstrigling
protected

Definition at line 947 of file farm.h.

SpringBarleyPTreatment* Farm::m_springbarleyptreatment
protected

Definition at line 921 of file farm.h.

SpringBarleySeed* Farm::m_springbarleyseed
protected

Definition at line 923 of file farm.h.

SpringBarleySilage* Farm::m_springbarleysilage
protected

Definition at line 924 of file farm.h.

SpringBarleySKManagement* Farm::m_springbarleyskmanagement
protected

Definition at line 920 of file farm.h.

SpringBarleySpr* Farm::m_springbarleyspr
protected

Definition at line 919 of file farm.h.

SpringBarleyStrigling* Farm::m_springbarleystrigling
protected

Definition at line 939 of file farm.h.

SpringBarleyStriglingCulm* Farm::m_springbarleystriglingculm
protected

Definition at line 940 of file farm.h.

SpringBarleyStriglingSingle* Farm::m_springbarleystriglingsingle
protected

Definition at line 941 of file farm.h.

SpringRape* Farm::m_springrape
protected

Definition at line 925 of file farm.h.

bool Farm::m_stockfarmer
protected
Sugarbeet* Farm::m_sugarbeet
protected

Definition at line 876 of file farm.h.

Triticale* Farm::m_triticale
protected

Definition at line 926 of file farm.h.

WinterBarley* Farm::m_winterbarley
protected

Definition at line 927 of file farm.h.

WinterBarleyStrigling* Farm::m_winterbarleystrigling
protected

Definition at line 945 of file farm.h.

WinterRape* Farm::m_winterrape
protected

Definition at line 928 of file farm.h.

WinterRapeStrigling* Farm::m_winterrapestrigling
protected

Definition at line 943 of file farm.h.

WinterRye* Farm::m_winterrye
protected

Definition at line 929 of file farm.h.

WinterRyeStrigling* Farm::m_winterryestrigling
protected

Definition at line 944 of file farm.h.

WinterWheat* Farm::m_winterwheat
protected

Definition at line 930 of file farm.h.

WinterWheatStrigling* Farm::m_winterwheatstrigling
protected

Definition at line 935 of file farm.h.

WinterWheatStriglingCulm* Farm::m_winterwheatstriglingculm
protected

Definition at line 936 of file farm.h.

WinterWheatStriglingSingle* Farm::m_winterwheatstriglingsingle
protected

Definition at line 937 of file farm.h.

WWheatPControl* Farm::m_wwheatpcontrol
protected

Definition at line 931 of file farm.h.

WWheatPToxicControl* Farm::m_wwheatptoxiccontrol
protected

Definition at line 932 of file farm.h.

WWheatPTreatment* Farm::m_wwheatptreatment
protected

Definition at line 933 of file farm.h.

YoungForestCrop* Farm::m_youngforest
protected

Definition at line 948 of file farm.h.


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