ALMaSS Rabbit ODdox  1.1
The rabbit model description following ODdox protocol
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 StubblePlough (LE *a_field, double a_user, int a_days)
 Carry out a stubble ploughing event on a_field. This is similar to normal plough but shallow (normally 6-8cm, is special cases up to 12-15cm). Done as a part of after-harvest treatments (instead of stubble cultivation) More...
 
virtual bool StubbleCultivatorHeavy (LE *a_field, double a_user, int a_days)
 Carry out a stubble cultivation event on a_field. This is non-inversion type of cultivation which can be done instead of autumn plough (on a depth up to 40 cm even, if necessary) 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 PreseedingCultivator (LE *a_field, double a_user, int a_days)
 Carry out preseeding cultivation on a_field (tilling set including cultivator and string roller to compact soil) More...
 
virtual bool PreseedingCultivatorSow (LE *a_field, double a_user, int a_days)
 Carry out preseeding cultivation together with sow on a_field (tilling and sowing set including cultivator and string roller to compact soil) 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 SpringSowWithFerti (LE *a_field, double a_user, int a_days)
 Carry out a sowing event with start fertilizer 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 ProductApplication (LE *a_field, double a_user, int a_days, double a_applicationrate, PlantProtectionProducts a_ppp)
 Apply test pesticide to a_field. More...
 
virtual bool ProductApplication_DateLimited (LE *a_field, double, int, double a_applicationrate, PlantProtectionProducts a_ppp)
 Special pesticide trial functionality. 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 StriglingHill (LE *a_field, double a_user, int a_days)
 Carry out a mechanical weeding on a_field followed by hilling up (probably on potatoes) 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_AmmoniumSulphate (LE *a_field, double a_user, int a_days)
 Apply Ammonium 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 FP_RSM (LE *a_field, double a_user, int a_days)
 RSM (ammonium nitrate solution) applied on a_field owned by an arable farmer. More...
 
virtual bool FP_Calcium (LE *a_field, double a_user, int a_days)
 Calcium applied on a_field owned by an arable farmer. More...
 
virtual bool FA_NPKS (LE *a_field, double a_user, int a_days)
 Apply NPKS fertilizer, on a_field owned by a stock 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_ManganeseSulphate (LE *a_field, double a_user, int a_days)
 Apply manganese sulphate to a_field owned by an stock farmer. More...
 
virtual bool FA_AmmoniumSulphate (LE *a_field, double a_user, int a_days)
 Apply ammonium sulphate 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 FA_RSM (LE *a_field, double a_user, int a_days)
 RSM (ammonium nitrate solution) applied on a_field owned by a stock farmer. More...
 
virtual bool FA_Calcium (LE *a_field, double a_user, int a_days)
 Calcium applied on a_field owned by a stock farmer. More...
 
virtual bool Biocide (LE *a_field, double a_user, int a_days)
 Biocide applied on a_field. More...
 
virtual bool BedForming (LE *a_field, double a_user, int a_days)
 Do bed forming up on a_field, probably of carrots. More...
 
virtual bool ShallowHarrow (LE *a_field, double a_user, int a_days)
 Carry out a shallow harrow event on a_field, e.g., after grass cutting event. More...
 
virtual bool HeavyCultivatorAggregate (LE *a_field, double a_user, int a_days)
 Carry out a heavy cultivation event on a_field. This is non-inversion type of cultivation which can be done after fertilizers application on spring for a spring crop. More...
 
virtual bool FlowerCutting (LE *a_field, double a_user, int a_days)
 Flower cutting applied on a_field. More...
 
virtual bool BulbHarvest (LE *a_field, double a_user, int a_days)
 Carry out a bulb harvest on a_field. More...
 
virtual bool StrawCovering (LE *a_field, double a_user, int a_days)
 Straw covering applied on a_field. More...
 
virtual bool StrawRemoval (LE *a_field, double a_user, int a_days)
 Straw covering applied on a_field. More...
 
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 (double a_probability)
 Return chance out of 0 to 100. More...
 
bool DoIt_prob (double a_probability)
 Return chance out of 0 to 1. 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)
 
void 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
 
NorwegianPotatoes * m_norwegianpotatoes
 
NorwegianOats * m_norwegianoats
 
NorwegianSpringBarley * m_norwegianspringbarley
 
PLWinterWheat * m_plwinterwheat
 
PLWinterRape * m_plwinterrape
 
PLWinterBarley * m_plwinterbarley
 
PLWinterTriticale * m_plwintertriticale
 
PLWinterRye * m_plwinterrye
 
PLSpringWheat * m_plspringwheat
 
PLSpringBarley * m_plspringbarley
 
PLMaize * m_plmaize
 
PLMaizeSilage * m_plmaizesilage
 
PLPotatoes * m_plpotatoes
 
PLBeet * m_plbeet
 
PLFodderLucerne1 * m_plfodderlucerne1
 
PLFodderLucerne2 * m_plfodderlucerne2
 
PLCarrots * m_plcarrots
 
PLSpringBarleySpr * m_plspringbarleyspr
 
PLWinterWheatLate * m_plwinterwheatlate
 
PLBeetSpr * m_plbeetspr
 
PLBeans * m_plbeans
 
NLBeet * m_nlbeet
 
NLCarrots * m_nlcarrots
 
NLMaize * m_nlmaize
 
NLPotatoes * m_nlpotatoes
 
NLSpringBarley * m_nlspringbarley
 
NLWinterWheat * m_nlwinterwheat
 
NLCabbage * m_nlcabbage
 
NLTulips * m_nltulips
 
NLGrassGrazed1 * m_nlgrassgrazed1
 
NLGrassGrazed1Spring * m_nlgrassgrazed1spring
 
NLGrassGrazed2 * m_nlgrassgrazed2
 
NLGrassGrazedLast * m_nlgrassgrazedlast
 
NLPermanentGrassGrazed * m_nlpermanentgrassgrazed
 
NLBeetSpring * m_nlbeetspring
 
NLCarrotsSpring * m_nlcarrotsspring
 
NLMaizeSpring * m_nlmaizespring
 
NLPotatoesSpring * m_nlpotatoesspring
 
NLSpringBarleySpring * m_nlspringbarleyspring
 
NLCabbageSpring * m_nlcabbagespring
 
NLCatchPeaCrop * m_nlcatchpeacrop
 
DummyCropPestTesting * m_dummycroppesttesting
 

Detailed Description

The base class for all farm types.

Definition at line 767 of file farm.h.

Constructor & Destructor Documentation

◆ Farm()

Farm::Farm ( FarmManager a_manager)

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

Definition at line 1058 of file farm.cpp.

1059 {
1060  m_OurManager = a_manager;
1061  m_carrots = new Carrots;
1062  m_broadbeans = new BroadBeans;
1063  m_CGG1 = new CloverGrassGrazed1;
1064  m_CGG2 = new CloverGrassGrazed2;
1065  m_fieldpeas = new FieldPeas;
1066  m_fieldpeassilage = new FieldPeasSilage;
1067  m_fodderbeet = new Fodderbeet;
1068  m_sugarbeet = new Sugarbeet;
1069  m_ofodderbeet = new OFodderbeet;
1070  m_foddergrass = new FodderGrass;
1071  m_maize = new Maize;
1072  m_maizesilage = new MaizeSilage;
1073  m_omaizesilage = new OMaizeSilage;
1074  m_OBarleyPCG = new OBarleyPeaCloverGrass;
1075  m_ocarrots = new OCarrots;
1076  m_OCGG1 = new OCloverGrassGrazed1;
1077  m_OCGG2 = new OCloverGrassGrazed2;
1078  m_OCGS1 = new OCloverGrassSilage1;
1079  m_ofieldpeas = new OFieldPeas;
1080  m_ofieldpeassilage = new OFieldPeasSilage;
1081  m_ofirstyeardanger = new OFirstYearDanger;
1082  m_ograzingpigs = new OGrazingPigs;
1083  m_orchardcrop = new OrchardCrop;
1084  m_oats = new Oats;
1085  m_ooats = new OOats;
1086  m_opermgrassgrazed = new OPermanentGrassGrazed;
1087  m_opotatoes = new OPotatoes;
1088  m_oseedgrass1 = new OSeedGrass1;
1089  m_oseedgrass2 = new OSeedGrass2;
1090  m_ospringbarley = new OSpringBarley;
1091  m_osbarleysilage = new OSBarleySilage;
1092  m_ospringbarleyext = new OSpringBarleyExt;
1093  m_ospringbarleypigs = new OSpringBarleyPigs;
1094  m_owinterbarley = new OWinterBarley;
1095  m_owinterbarleyext = new OWinterBarleyExt;
1096  m_owinterrape = new OWinterRape;
1097  m_owinterrye = new OWinterRye;
1098  m_owinterwheat = new OWinterWheat;
1099  m_owinterwheatundersown = new OWinterWheatUndersown;
1100  m_owinterwheatundersownext = new OWinterWheatUndersownExt;
1101  m_permanentsetaside = new PermanentSetAside;
1102  m_permgrassgrazed = new PermanentGrassGrazed;
1103  m_permgrasslowyield = new PermanentGrassLowYield;
1104  m_permgrasstussocky = new PermanentGrassTussocky;
1105  m_potatoes = new Potatoes;
1106  m_potatoesindustry = new PotatoesIndustry;
1107  m_sbarleyclovergrass = new SpringBarleyCloverGrass;
1108  m_seedgrass1 = new SeedGrass1;
1109  m_seedgrass2 = new SeedGrass2;
1110  m_setaside = new SetAside;
1111  m_springbarley = new SpringBarley;
1112  m_springbarleyspr = new SpringBarleySpr;
1113  m_springbarleyptreatment = new SpringBarleyPTreatment;
1114  m_springbarleyskmanagement = new SpringBarleySKManagement;
1115  m_springbarleyseed = new SpringBarleySeed;
1116  m_springbarleysilage = new SpringBarleySilage;
1117  m_springrape = new SpringRape;
1118  m_triticale = new Triticale;
1119  m_otriticale = new OTriticale;
1120  m_winterbarley = new WinterBarley;
1121  m_winterrape = new WinterRape;
1122  m_winterrye = new WinterRye;
1123  m_winterwheat = new WinterWheat;
1124  m_wwheatpcontrol = new WWheatPControl;
1125  m_wwheatptoxiccontrol = new WWheatPToxicControl;
1126  m_wwheatptreatment = new WWheatPTreatment;
1127  m_agrochemindustrycereal = new AgroChemIndustryCereal;
1128  m_winterwheatstrigling = new WinterWheatStrigling;
1129  m_winterwheatstriglingsingle = new WinterWheatStriglingSingle;
1130  m_winterwheatstriglingculm = new WinterWheatStriglingCulm;
1131  m_springbarleyclovergrassstrigling = new SpringBarleyCloverGrassStrigling;
1132  m_springbarleystrigling = new SpringBarleyStrigling;
1133  m_springbarleystriglingsingle = new SpringBarleyStriglingSingle;
1134  m_springbarleystriglingculm = new SpringBarleyStriglingCulm;
1135  m_maizestrigling = new MaizeStrigling;
1136  m_winterrapestrigling = new WinterRapeStrigling;
1137  m_winterryestrigling = new WinterRyeStrigling;
1138  m_winterbarleystrigling = new WinterBarleyStrigling;
1139  m_fieldpeasstrigling = new FieldPeasStrigling;
1140  m_springbarleypeaclovergrassstrigling = new SpringBarleyPeaCloverGrassStrigling;
1141  m_youngforest = new YoungForestCrop;
1142  m_norwegianpotatoes = new NorwegianPotatoes;
1143  m_norwegianoats = new NorwegianOats;
1144  m_norwegianspringbarley = new NorwegianSpringBarley;
1145  m_plwinterwheat = new PLWinterWheat;
1146  m_plwinterrape = new PLWinterRape;
1147  m_plwinterbarley = new PLWinterBarley;
1148  m_plwintertriticale = new PLWinterTriticale;
1149  m_plwinterrye = new PLWinterRye;
1150  m_plspringwheat = new PLSpringWheat;
1151  m_plspringbarley = new PLSpringBarley;
1152  m_plmaize = new PLMaize;
1153  m_plmaizesilage = new PLMaizeSilage;
1154  m_plpotatoes = new PLPotatoes;
1155  m_plbeet = new PLBeet;
1156  m_plfodderlucerne1 = new PLFodderLucerne1;
1157  m_plfodderlucerne2 = new PLFodderLucerne2;
1158  m_plcarrots = new PLCarrots;
1159  m_plspringbarleyspr = new PLSpringBarleySpr;
1160  m_plwinterwheatlate = new PLWinterWheatLate;
1161  m_plbeetspr = new PLBeetSpr;
1162  m_plbeans = new PLBeans;
1163 
1164  m_nlbeet = new NLBeet;
1165  m_nlcarrots = new NLCarrots;
1166  m_nlmaize = new NLMaize;
1167  m_nlpotatoes = new NLPotatoes;
1168  m_nlspringbarley = new NLSpringBarley;
1169  m_nlwinterwheat = new NLWinterWheat;
1170  m_nlcabbage = new NLCabbage;
1171  m_nltulips = new NLTulips;
1172  m_nlgrassgrazed1 = new NLGrassGrazed1;
1173  m_nlgrassgrazed1spring = new NLGrassGrazed1Spring;
1174  m_nlgrassgrazed2 = new NLGrassGrazed2;
1175  m_nlgrassgrazedlast = new NLGrassGrazedLast;
1176  m_nlpermanentgrassgrazed = new NLPermanentGrassGrazed;
1177  m_nlbeetspring = new NLBeetSpring;
1178  m_nlcarrotsspring = new NLCarrotsSpring;
1179  m_nlmaizespring = new NLMaizeSpring;
1180  m_nlpotatoesspring = new NLPotatoesSpring;
1181  m_nlspringbarleyspring = new NLSpringBarleySpring;
1182  m_nlcabbagespring = new NLCabbageSpring;
1183  m_nlcatchpeacrop = new NLCatchPeaCrop;
1184 
1185  m_dummycroppesttesting = new DummyCropPestTesting;
1186 
1187  m_rotation_sync_index = -1;
1188  // Defaults that need to be overridden when necessary
1189  m_stockfarmer = false;
1190  m_intensity = 0;
1191  m_HuntersList.resize(0); // Set the number of hunters to zero at the start.
1192 }

◆ ~Farm()

Farm::~Farm ( void  )
virtual

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

Definition at line 1199 of file farm.cpp.

1199  {
1200  delete m_carrots;
1201  delete m_broadbeans;
1202  delete m_CGG2;
1203  delete m_CGG1;
1204  delete m_fieldpeas;
1205  delete m_fieldpeassilage;
1206  delete m_fodderbeet;
1207  delete m_sugarbeet;
1208  delete m_ofodderbeet;
1209  delete m_foddergrass;
1210  delete m_maizesilage;
1211  delete m_omaizesilage;
1212  delete m_maize;
1213  delete m_ocarrots;
1214  delete m_OCGG1;
1215  delete m_OCGG2;
1216  delete m_OCGS1;
1217  delete m_ofieldpeas;
1218  delete m_ofieldpeassilage;
1219  delete m_ofirstyeardanger;
1220  delete m_ograzingpigs;
1221  delete m_orchardcrop;
1222  delete m_ooats;
1223  delete m_oats;
1224  delete m_opermgrassgrazed;
1225  delete m_opotatoes;
1226  delete m_ospringbarley;
1227  delete m_ospringbarleyext;
1228  delete m_osbarleysilage;
1229  delete m_ospringbarleypigs;
1230  delete m_owinterbarley;
1231  delete m_owinterbarleyext;
1232  delete m_owinterrape;
1233  delete m_owinterrye;
1234  delete m_owinterwheatundersown;
1236  delete m_OBarleyPCG;
1237  delete m_permanentsetaside;
1238  delete m_permgrassgrazed;
1239  delete m_permgrasstussocky;
1240  delete m_permgrasslowyield;
1241  delete m_potatoes;
1242  delete m_potatoesindustry;
1243  delete m_sbarleyclovergrass;
1244  delete m_seedgrass2;
1245  delete m_seedgrass1;
1246  delete m_setaside;
1247  delete m_springbarley;
1248  delete m_springbarleyptreatment;
1250  delete m_springbarleyseed;
1251  delete m_springrape;
1252  delete m_springbarleysilage;
1253  delete m_agrochemindustrycereal;
1254  delete m_triticale;
1255  delete m_winterbarley;
1256  delete m_winterrape;
1257  delete m_winterrye;
1258  delete m_winterwheat;
1259  delete m_wwheatpcontrol;
1260  delete m_wwheatptoxiccontrol;
1261  delete m_wwheatptreatment;
1262  delete m_winterwheatstrigling;
1266  delete m_springbarleystrigling;
1269  delete m_maizestrigling;
1270  delete m_winterrapestrigling;
1271  delete m_winterryestrigling;
1272  delete m_winterbarleystrigling;
1273  delete m_fieldpeasstrigling;
1275  delete m_youngforest;
1276  delete m_norwegianoats;
1277  delete m_norwegianspringbarley;
1278 
1279  delete m_plwinterwheat;
1280  delete m_plwinterrape;
1281  delete m_plwinterbarley;
1282  delete m_plwintertriticale;
1283  delete m_plwinterrye;
1284  delete m_plspringwheat;
1285  delete m_plspringbarley;
1286  delete m_plmaize;
1287  delete m_plmaizesilage;
1288  delete m_plpotatoes;
1289  delete m_plbeet;
1290  delete m_plfodderlucerne1;
1291  delete m_plfodderlucerne2;
1292  delete m_plcarrots;
1293  delete m_plspringbarleyspr;
1294  delete m_plwinterwheatlate;
1295  delete m_plbeetspr;
1296  delete m_plbeans;
1297 
1298  delete m_nlbeet;
1299  delete m_nlcarrots;
1300  delete m_nlmaize;
1301  delete m_nlpotatoes;
1302  delete m_nlspringbarley;
1303  delete m_nlwinterwheat;
1304  delete m_nlcabbage;
1305  delete m_nltulips;
1306  delete m_nlgrassgrazed1;
1307  delete m_nlgrassgrazed1spring;
1308  delete m_nlgrassgrazed2;
1309  delete m_nlgrassgrazedlast;
1310  delete m_nlpermanentgrassgrazed;
1311  delete m_nlbeetspring;
1312  delete m_nlcarrotsspring;
1313  delete m_nlmaizespring;
1314  delete m_nlpotatoesspring;
1315  delete m_nlspringbarleyspring;
1316  delete m_nlcabbagespring;
1317  delete m_nlcatchpeacrop;
1318 
1319  delete m_dummycroppesttesting;
1320 
1322 
1323  while (!m_queue.Empty()) {
1324  pair = m_queue.Bottom();
1325  m_queue.Pop();
1326  delete pair.m_element;
1327  }
1328 }

References LowPriPair< ELEMTYPE >::m_element.

Member Function Documentation

◆ AddField()

void Farm::AddField ( LE a_newfield)

Adds a field to a farm.

Definition at line 1447 of file farm.cpp.

1447  {
1448  int i = (int) m_fields.size();
1449 
1450  m_fields.resize( i + 1 );
1451  m_fields[ i ] = a_newfield;
1452  // Must set the rot index to something other than -1, but identify it as not usefully set as yet.
1453  TTypesOfLandscapeElement ele = a_newfield->GetElementType();
1454  switch (ele) {
1456  case tole_YoungForest:
1457  case tole_PermPasture:
1460  case tole_Orchard:
1461  case tole_PlantNursery:
1462  m_fields[i]->SetRotIndex(-2);
1463  break;
1464  default:
1465  m_fields[ i ]->SetRotIndex(-1);
1466  }
1467 }

References tole_Orchard, tole_PermanentSetaside, tole_PermPasture, tole_PermPastureLowYield, tole_PermPastureTussocky, tole_PlantNursery, and tole_YoungForest.

◆ AddHunter()

void Farm::AddHunter ( Hunter *  a_hunter)
inline

Definition at line 922 of file farm.h.

922  {
923  m_HuntersList.push_back( a_hunter );
924  }

References m_HuntersList.

◆ AddNewEvent()

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 789 of file farm.cpp.

790  {
791  FarmEvent * ev = new FarmEvent( a_event, a_field, a_todo, a_run, a_lock, a_start, a_first_year, a_crop );
792  m_queue.Push( ev, a_date );
793 }

Referenced by Crop::SimpleEvent_().

◆ Assign_rotation()

void Farm::Assign_rotation ( vector< TTypesOfVegetation a_new_rotation)

Definition at line 1488 of file farm.cpp.

1488  {
1489 
1490  m_rotation.clear();
1491  m_rotation = a_new_rotation;
1492 
1493 }

Referenced by FarmManager::Switch_rotation().

◆ AssignPermanentCrop()

void Farm::AssignPermanentCrop ( TTypesOfVegetation  tov,
int  pct 
)
protected

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

Definition at line 2401 of file farm.cpp.

2401  {
2402  // Assumes that m_fields has all the fields already in it, and those that are occupied by permanent tole types
2403  // are denoted by -2 or -4 in rotindex, -1 is unassigned - can't use enum because positive values have other meanings
2404 
2405  // Here we can save some time if we have to allocate all the fields to one permanent crop
2406  if (a_pct == 100)
2407  {
2408  for (auto cfi = m_fields.begin(); cfi != m_fields.end(); ++cfi)
2409  {
2410  // Set the field as non-rotating
2411  (*cfi)->SetRotIndex(-4);
2412  // Assign the crop, and weeds are assumed to be undefined
2413  (*cfi)->SetVegType(a_tov, tov_Undefined);
2414  }
2415  return;
2416  }
2417 
2418  tpct a_tpct;
2419  // create a copy of the field vector and call it fields_cpy
2420  vector<LE*> fields_cpy;
2421  fields_cpy.resize(m_fields.size());
2422  copy(m_fields.begin(), m_fields.end(), fields_cpy.begin());
2423  vector<tpct> pcts;
2424  double area = 0.0;
2425 
2426 
2427  // First get the areas of all fields and then convert these to percentages
2428  int sz = (int) fields_cpy.size();
2429  // loop through the fields vector and remove any fields already assigned to permanent crops
2430  for (int i = sz - 1; i >= 0; i--) {
2431  if (fields_cpy[i]->GetRotIndex() < -1) {
2432  fields_cpy.erase(fields_cpy.begin() + i);
2433  }
2434  }
2435  // sum up the area
2436  for (auto cfi = fields_cpy.begin(); cfi != fields_cpy.end(); ++cfi) area += (*cfi)->GetArea();
2437 
2438  // Here we can take action if we only have a single field
2439  int fnos = (int) fields_cpy.size();
2440  if (fnos<1) return; // No fields to allocate, jump out
2441  else if (fnos==1) {
2442  // Use the pct as the chance that our single field is assigned
2443  if (random(100)>=a_pct) return;
2444  else {
2445  // Add field by default
2446  fields_cpy[0]->SetRotIndex(-4);
2447  // Assign the crop
2448  fields_cpy[0]->SetVegType(a_tov, tov_Undefined);
2449  return;
2450  }
2451  }
2452  // By here we have more than one field to potentially allocate to
2453  for (int i=0; i<fnos; i++) {
2454  a_tpct.pct = (int) floor(0.5+((fields_cpy[i]->GetArea()/area)*100));
2455  a_tpct.index = i;
2456  pcts.push_back(a_tpct);
2457  }
2458  // We need to look for combinations of fields that are close to our target.
2459  // First we can sort the array and ignore any that are greater than pct
2460  sort (pcts.begin(), pcts.end(), CompPcts); // results in ordering on increasing pct
2461  // now remove all those with pct>target+10% to save loads of time in the inverse integer partition
2462  int index=-1;
2463  int ind=0;
2464  int apct=a_pct+10; // Lets assume we have a tolerance of 10%
2465  while ((index==-1) && (ind< (int)pcts.size())) {
2466  if (pcts[ind++].pct>apct) index=ind;
2467  }
2468  if (index!=-1) pcts.erase(pcts.begin()+index,pcts.end());
2469  // Now find the best combination of fields to get close to our target & set them
2470  int bits = InvIntPartition(&pcts,a_pct);
2471  int mask=1;
2472  ind = 0;
2473  int used=0;
2474  //double pctused = 0.0;
2475  double check = 0.0;
2476  for (int h=0; h< (int)pcts.size(); h++) check+=fields_cpy[pcts[h].index]->GetArea();
2477  while (bits>0) {
2478  if ((bits & mask) > 0) {
2479  // Set the field as non-rotating
2480  fields_cpy[pcts[ind].index]->SetRotIndex(-4);
2481  // Assign the crop
2482  fields_cpy[pcts[ind].index]->SetVegType(a_tov, tov_Undefined);
2483  used += (int) fields_cpy[pcts[ind].index]->GetArea();
2484  //pctused = used/area;
2485  bits -= mask;
2486  }
2487  mask = mask << 1;
2488  ind++;
2489  }
2490 }

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

Referenced by OptimisingFarm::InitiateManagement().

◆ AutumnHarrow()

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 261 of file farmfuncs.cpp.

262 {
263 
264  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
265  a_field->Trace( autumn_harrow );
266  a_field->SetLastTreatment( autumn_harrow );
267  // Apply 90% mortality to the insects
268  a_field->InsectMortality( 0.1 );
269  // Reduce the vegetation to zero
270  a_field->ZeroVeg();
271  int pref=a_field->GetUnsprayedMarginPolyRef();
272  if (pref!=-1){
273  // Must have an unsprayed margin so need to pass the information on to it
274  LE* um=g_landscape_p->SupplyLEPointer(pref);
276  um->InsectMortality( 0.1 );
277  um->ZeroVeg();
278  }
279  return true;
280  }
281  return false;
282 }

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

◆ AutumnPlough()

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 132 of file farmfuncs.cpp.

133 {
134 
135  // LE is a pointer to the field element
136  // a_user is a pointer to the farm
137  // a_days is the end of the operation time - today
138  // if a_days <0 then the time to do it is passed
139  // the line below reads 'plough if last day possible OR if not raining and pass a probability test
140  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
141  // this bit sets up the events to occur when ploughing occurs
142  // The trace below is for debugging checks
143  a_field->Trace( autumn_plough );
144  // Record the event for this field, so other objects can find out it has happened
145  a_field->SetLastTreatment( autumn_plough );
146  // 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.
147  a_field->InsectMortality( 0.1 );
148  // Reduce the vegetation, in this case to zero
149  a_field->ZeroVeg();
150  // 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.
151  int pref=a_field->GetUnsprayedMarginPolyRef();
152  if (pref!=-1){
153  // Must have an unsprayed margin so need to pass the information on to it
154  LE* um=g_landscape_p->SupplyLEPointer(pref);
156  um->InsectMortality( 0.1 );
157  um->ZeroVeg();
158  }
159  return true; // completed
160  }
161  return false; // not completed
162 }

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

◆ AutumnRoll()

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 288 of file farmfuncs.cpp.

289 {
290 
291  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
292  a_field->Trace( autumn_roll );
293  a_field->SetLastTreatment( autumn_roll );
294  a_field->ZeroVeg();
295  int pref=a_field->GetUnsprayedMarginPolyRef();
296  if (pref!=-1){
297  // Must have an unsprayed margin so need to pass the information on to it
298  LE* um=g_landscape_p->SupplyLEPointer(pref);
300  um->ZeroVeg();
301  }
302  return true;
303  }
304  return false;
305 }

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

◆ AutumnSow()

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 364 of file farmfuncs.cpp.

365 {
366 
367  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
368  a_field->Trace( autumn_sow );
369  a_field->SetLastTreatment( autumn_sow );
370  a_field->SetGrowthPhase( sow );
371  a_field->SetLastSownVeg(a_field->GetVegType());
372  // Reduce the vegetation to zero
373  a_field->ZeroVeg();
374  int pref=a_field->GetUnsprayedMarginPolyRef();
375  if (pref!=-1){
376  // Must have an unsprayed margin so need to pass the information on to it
377  LE* um=g_landscape_p->SupplyLEPointer(pref);
379  um->SetGrowthPhase( sow );
380  um->ZeroVeg();
381  um->SetLastSownVeg(um->GetVegType());
382  }
383  return true;
384  }
385  return false;
386 }

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

◆ BedForming()

bool Farm::BedForming ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Do bed forming up on a_field, probably of carrots.

Definition at line 1690 of file farmfuncs.cpp.

1691 {
1692 
1693  if ((0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
1694  a_field->Trace(bed_forming);
1695  a_field->SetLastTreatment(bed_forming);
1696  a_field->InsectMortality(0.75);
1697  a_field->ZeroVeg();
1699  int pref = a_field->GetUnsprayedMarginPolyRef();
1700  if (pref != -1) {
1701  // Must have an unsprayed margin so need to pass the information on to it
1702  LE* um = g_landscape_p->SupplyLEPointer(pref);
1704  um->ZeroVeg();
1705  um->InsectMortality(0.75);
1707  }
1708  return true;
1709  }
1710  return false;
1711 }

References bed_forming, DO_IT_PROB, EL_TRAMLINE_DECAYTIME, g_landscape_p, g_weather, LE::GetUnsprayedMarginPolyRef(), LE::InsectMortality(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::ZeroVeg().

◆ Biocide()

bool Farm::Biocide ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Biocide applied on a_field.

Definition at line 2415 of file farmfuncs.cpp.

2416 {
2417  if ((0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
2418  a_field->Trace(biocide);
2419  a_field->SetLastTreatment(biocide);
2421  int pref = a_field->GetUnsprayedMarginPolyRef();
2422  if (pref != -1) {
2423  // Must have an unsprayed margin so need to pass the information on to it
2424  LE* um = g_landscape_p->SupplyLEPointer(pref);
2427  }
2428  return true;
2429  }
2430  return false;
2431 }

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

◆ BulbHarvest()

bool Farm::BulbHarvest ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out a bulb harvest on a_field.

Definition at line 2465 of file farmfuncs.cpp.

2466 {
2467  //5 days good weather before
2468  if ((0 >= a_days) || ((g_weather->GetRainPeriod(g_date->Date(), 5) < 0.1) && DoIt(DO_IT_PROB))) {
2469  a_field->Trace(bulb_harvest);
2470  a_field->SetLastTreatment(bulb_harvest);
2471  a_field->SetGrowthPhase(harvest1);
2472  // Here we have to do a little skip to avoid too low insect populations after harvest, but a correct veg biomass
2473  a_field->InsectMortality(0.3);
2474  // remove all vegetation
2475  a_field->ZeroVeg();
2476  double insects = a_field->GetInsectPop();
2477  a_field->ResetDigestability();
2478  a_field->RecalculateBugsNStuff();
2479  a_field->SetInsectPop(insects);
2481  int pref = a_field->GetUnsprayedMarginPolyRef();
2482  if (pref != -1) {
2483  // Must have an unsprayed margin so need to pass the information on to it
2484  LE* um = g_landscape_p->SupplyLEPointer(pref);
2486  um->SetGrowthPhase(harvest1);
2487  um->InsectMortality(0.3);
2488  um->ZeroVeg();
2490  um->ResetDigestability();
2491  um->RecalculateBugsNStuff();
2492  }
2493  return true;
2494  }
2495  return false;
2496 }

References bulb_harvest, Calendar::Date(), DO_IT_PROB, EL_TRAMLINE_DECAYTIME, g_date, g_landscape_p, g_weather, LE::GetInsectPop(), Weather::GetRainPeriod(), LE::GetUnsprayedMarginPolyRef(), harvest1, LE::InsectMortality(), LE::ResetDigestability(), LE::SetGrowthPhase(), LE::SetInsectPop(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::ZeroVeg().

◆ BurnStrawStubble()

bool Farm::BurnStrawStubble ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Burn stubble on a_field.

Definition at line 2236 of file farmfuncs.cpp.

2237 {
2238 
2239  if ( (0 >= a_days) && (g_weather->GetRainPeriod(g_date->Date(),3)>0.1))
2240  {
2241  return true;
2242  }
2243  if ( (0 >= a_days) || ((g_weather->GetRainPeriod(g_date->Date(),3)<0.1)
2244  && DoIt(DO_IT_PROB)))
2245  {
2246  a_field->Trace( burn_straw_stubble );
2248  a_field->InsectMortality( 0.4 );
2249  a_field->ReduceVeg( 0.2 );
2251  int pref=a_field->GetUnsprayedMarginPolyRef();
2252  if (pref!=-1){
2253  // Must have an unsprayed margin so need to pass the information on to it
2254  LE* um=g_landscape_p->SupplyLEPointer(pref);
2256  um->ReduceVeg( 0.2 );
2257  um->InsectMortality( 0.4 );
2259  }
2260  return true;
2261  }
2262  return false;
2263 }

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

◆ CattleIsOut()

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 1974 of file farmfuncs.cpp.

1975 {
1979  double biomass = a_field->GetVegBiomass();
1980  if (biomass > 100.0)
1981  {
1982  a_field->SetLastTreatment(cattle_out);
1983  a_field->Trace(cattle_out);
1984  // Reduce the vegetation because of grazing
1985  //double h=a_field->GetVegHeight();
1986  //double reduc = 1-(l_farm_cattle_veg_reduce.value()*((h-15)/15));
1987  //a_field->ReduceVeg_Extended( reduc );
1988  a_field->GrazeVegetation( l_farm_cattle_veg_reduce.value( ), false );
1989  int pref = a_field->GetUnsprayedMarginPolyRef();
1990  if (pref != -1)
1991  {
1992  // Must have an unsprayed margin so need to pass the information on to it
1993  LE* um = g_landscape_p->SupplyLEPointer(pref);
1996  }
1997  }
1998  int d1 = g_date->DayInYear(10, 9);
1999  if (d1 > a_max) d1 = a_max;
2000  if ((((g_date->DayInYear() > d1) && (10 >= a_days)) && DoIt(10)) || (0 >= a_days))
2001  {
2002  a_field->ToggleCattleGrazing();
2003  int pref = a_field->GetUnsprayedMarginPolyRef();
2004  if (pref != -1){
2005  // Must have an unsprayed margin so need to pass the information on to it
2006  LE* um = g_landscape_p->SupplyLEPointer(pref);
2007  um->ToggleCattleGrazing();
2008  }
2009  return true;
2010  }
2011  return false;
2012 }

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

◆ CattleIsOutLow()

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 2018 of file farmfuncs.cpp.

2019 {
2020 
2021  // Generate a 'cattle_in_out' event for every day the cattle is on the
2022  // field.
2023  double biomass = a_field->GetVegBiomass();
2024  if (biomass > 100.0)
2025  {
2026  a_field->SetLastTreatment(cattle_out_low);
2027  a_field->Trace(cattle_out_low);
2028  // Reduce the vegetation because of grazing
2029  //double h=a_field->GetVegHeight();
2030  //double reduc = 1-(l_farm_cattle_veg_reduce2.value()*((h-15)/15));
2031  //a_field->ReduceVeg_Extended( reduc );
2032  a_field->GrazeVegetation( l_farm_cattle_veg_reduce2.value( ), false );
2033  int pref = a_field->GetUnsprayedMarginPolyRef();
2034  if (pref != -1)
2035  {
2036  // Must have an unsprayed margin so need to pass the information on to it
2037  LE* um = g_landscape_p->SupplyLEPointer(pref);
2040  }
2041  }
2042  int d1 = g_date->DayInYear(10, 9);
2043  if (d1 > a_max) d1 = a_max;
2044  if ((((g_date->DayInYear() > d1) && (10 >= a_days)) && DoIt(10)) || (0 >= a_days))
2045  {
2046  a_field->ToggleCattleGrazing();
2047  int pref = a_field->GetUnsprayedMarginPolyRef();
2048  if (pref != -1){
2049  // Must have an unsprayed margin so need to pass the information on to it
2050  LE* um = g_landscape_p->SupplyLEPointer(pref);
2051  um->ToggleCattleGrazing();
2052  }
2053  return true;
2054  }
2055  return false;
2056 }

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

◆ CattleOut()

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 1910 of file farmfuncs.cpp.

1911 {
1915  if ((0 >= a_days) || DoIt( DO_IT_PROB ))
1916  {
1917  a_field->ToggleCattleGrazing();
1918  a_field->Trace( cattle_out );
1919  a_field->SetLastTreatment( cattle_out );
1920  // Reduce the vegetation because of grazing
1921  //double h=a_field->GetVegHeight();
1922  //double reduc = 1-(l_farm_cattle_veg_reduce.value()*((h-15)/15));
1923  //a_field->ReduceVeg_Extended( reduc );
1924  a_field->GrazeVegetation( l_farm_cattle_veg_reduce.value(), false );
1925  int pref = a_field->GetUnsprayedMarginPolyRef();
1926  if (pref != -1)
1927  {
1928  // Must have an unsprayed margin so need to pass the information on to it
1929  // This happens if all arable fields are given unsprayed margins - they have no effect on grass unless it is sprayed with pesticides
1930  LE* um = g_landscape_p->SupplyLEPointer( pref );
1931  um->ToggleCattleGrazing();
1934  }
1935  return true;
1936  }
1937  return false;
1938 }

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

◆ CattleOutLowGrazing()

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 1944 of file farmfuncs.cpp.

1945 {
1946 
1947  if ( (0 >= a_days)|| DoIt(DO_IT_PROB)) {
1948  a_field->ToggleCattleGrazing();
1949  a_field->Trace( cattle_out_low );
1950  a_field->SetLastTreatment( cattle_out_low );
1951  // Reduce the vegetation because of grazing
1952  //double h=a_field->GetVegHeight();
1953  //double reduc = 1-(l_farm_cattle_veg_reduce.value()*((h-15)/15));
1954  //a_field->ReduceVeg_Extended( reduc );
1955  a_field->GrazeVegetation( l_farm_cattle_veg_reduce2.value( ), false );
1956  int pref=a_field->GetUnsprayedMarginPolyRef();
1957  if (pref!=-1){
1958  // Must have an unsprayed margin so need to pass the information on to it
1959  // This happens if all arable fields are given unsprayed margins - they have no effect on grass unless it is sprayed with pesticides
1960  LE* um=g_landscape_p->SupplyLEPointer(pref);
1961  um->ToggleCattleGrazing();
1964  }
1965  return true;
1966  }
1967  return false;
1968 }

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

◆ Centroids()

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 5334 of file farm.cpp.

5334  {
5337  int sum_centroidx = 0;
5338  int sum_centroidy = 0;
5339  int no_fields = (int)m_fields.size();
5340  for (int i=0; i<no_fields; i++){
5341  sum_centroidx += m_fields[i]->GetCentroidX();
5342  sum_centroidy += m_fields[i]->GetCentroidY();
5343  }
5344  m_farm_centroidx = sum_centroidx/no_fields;
5345  m_farm_centroidy = sum_centroidy/no_fields;
5346 }

References m_farm_centroidx, m_farm_centroidy, and m_fields.

Referenced by FarmManager::FindNeighbours().

◆ CheckRotationManagementLoop()

void Farm::CheckRotationManagementLoop ( FarmEvent ev)
protected

Rotation error check function

Definition at line 839 of file farm.cpp.

839  {
840  if ( ev->m_field->GetMgtLoopDetectDate() == g_date->Date() ) {
841  // The last crop managment plan stopped on the same day as
842  // it was started.
843 
844  // Bump loop counter.
845  ev->m_field->SetMgtLoopDetectCount( ev->m_field->GetMgtLoopDetectCount() + 1 );
846 
847  if ( ev->m_field->GetMgtLoopDetectCount() > ( long )( m_rotation.size() + 2 ) ) {
848  // We have a loop.
849  char errornum[ 20 ];
850  sprintf( errornum, "%d", m_farmtype );
851  g_msg->Warn( WARN_BUG, "Rotation management loop detected in farmtype ", errornum );
852  exit( 1 );
853  }
854  } else {
855  ev->m_field->SetMgtLoopDetectCount( 0 );
856  }
857 }

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

◆ CutOrch()

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 2362 of file farmfuncs.cpp.

2363 {
2364 
2365  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
2366  a_field->Trace( mow ); //? tried to do=mow...
2367  a_field->SetLastTreatment( mow );
2368  a_field->SetMownDecay( 12 ); // 12 days of not suitable
2369  //ReduceVeg_Extended( 0.2 );
2370  //a_field->InsectMortality( 0.4 );
2371  a_field->SetGrowthPhase( harvest1 );
2372  //m_DateCut = a_today; ?? what to substitute it with?
2373 
2374  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
2375 
2376  int pref=a_field->GetUnsprayedMarginPolyRef();
2377  if (pref!=-1){
2378  // Must have an unsprayed margin so need to pass the information on to it
2379  LE* um=g_landscape_p->SupplyLEPointer(pref);
2380  um->SetLastTreatment( mow );
2381  um->ReduceVeg_Extended( 0.2 ); //are these values ok?
2382  um->InsectMortality( 0.4 );
2384  }
2385  return true;
2386  }
2387  return false;
2388 }

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

◆ CutToHay()

bool Farm::CutToHay ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out hay cutting on a_field.

Definition at line 2269 of file farmfuncs.cpp.

2270 {
2271 
2272  if ( (0 >= a_days) || ((g_weather->GetRainPeriod(g_date->Date(),5)<0.1)
2273  && DoIt(DO_IT_PROB)))
2274  {
2275  a_field->Trace( cut_to_hay );
2276  a_field->SetLastTreatment( cut_to_hay );
2277  a_field->SetGrowthPhase(harvest1);
2278  a_field->InsectMortality(0.4);
2279  a_field->ReduceVeg_Extended( 0.2 );
2280  a_field->SetVegHeight(10);
2281  //a_field->ResetDigestability();
2283  int pref=a_field->GetUnsprayedMarginPolyRef();
2284  if (pref!=-1){
2285  // Must have an unsprayed margin so need to pass the information on to it
2286  LE* um=g_landscape_p->SupplyLEPointer(pref);
2288  um->SetGrowthPhase(harvest1);
2289  um->InsectMortality(0.4);
2290  um->ReduceVeg_Extended( 0.2 );
2291  um->SetVegHeight( 10);
2293  }
2294  return true;
2295  }
2296  return false;
2297 }

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

◆ CutToSilage()

bool Farm::CutToSilage ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Cut vegetation for silage on a_field.

Definition at line 2329 of file farmfuncs.cpp.

2330 {
2331 
2332  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
2333  a_field->Trace( cut_to_silage );
2334  a_field->SetLastTreatment( cut_to_silage );
2335  a_field->ReduceVeg_Extended( 0.2 );
2336  a_field->InsectMortality( 0.4 );
2337  a_field->SetVegHeight( 10 );
2339  a_field->SetGrowthPhase(harvest1);
2340  //a_field->ResetDigestability();
2341  int pref=a_field->GetUnsprayedMarginPolyRef();
2342  if (pref!=-1){
2343  // Must have an unsprayed margin so need to pass the information on to it
2344  LE* um=g_landscape_p->SupplyLEPointer(pref);
2346  um->ReduceVeg_Extended( 0.2 );
2347  um->InsectMortality( 0.4 );
2348  um->SetVegHeight( 10 );
2350  um->ResetDigestability();
2351  um->SetGrowthPhase(harvest1);
2352  }
2353  return true;
2354  }
2355  return false;
2356 }

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

◆ CutWeeds()

bool Farm::CutWeeds ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out weed topping on a_field.

Definition at line 2303 of file farmfuncs.cpp.

2304 {
2305 
2306  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB)))
2307  {
2308  a_field->Trace( cut_weeds );
2309  a_field->SetLastTreatment( cut_weeds );
2310  a_field->ReduceVeg( 0.8 );
2312  int pref=a_field->GetUnsprayedMarginPolyRef();
2313  if (pref!=-1){
2314  // Must have an unsprayed margin so need to pass the information on to it
2315  LE* um=g_landscape_p->SupplyLEPointer(pref);
2316  um->SetLastTreatment( cut_weeds );
2317  um->ReduceVeg( 0.8 );
2319  }
2320  return true;
2321  }
2322  return false;
2323 }

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

◆ DeepPlough()

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 417 of file farmfuncs.cpp.

418 {
419 
420  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
421  a_field->Trace( deep_ploughing );
422  a_field->SetLastTreatment( deep_ploughing );
423  // Apply 90% mortality to the insects
424  a_field->InsectMortality( 0.1 );
425  // Reduce the vegetation to zero
426  a_field->ZeroVeg();
427  int pref=a_field->GetUnsprayedMarginPolyRef();
428  if (pref!=-1){
429  // Must have an unsprayed margin so need to pass the information on to it
430  LE* um=g_landscape_p->SupplyLEPointer(pref);
432  um->InsectMortality( 0.1 );
433  um->ZeroVeg();
434  }
435  return true;
436  }
437  return false;
438 }

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

◆ DoIt()

bool Farm::DoIt ( double  a_probability)

Return chance out of 0 to 100.

Definition at line 800 of file farm.cpp.

800  {
801  return (g_rand_uni() < (a_probability/100.0));
802 }

References g_rand_uni.

◆ DoIt_prob()

bool Farm::DoIt_prob ( double  a_probability)

Return chance out of 0 to 1.

Definition at line 808 of file farm.cpp.

808  {
809  return (g_rand_uni() < a_probability);
810 }

References g_rand_uni.

◆ FA_AmmoniumSulphate()

bool Farm::FA_AmmoniumSulphate ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply ammonium sulphate to a_field owned by an stock farmer.

Definition at line 990 of file farmfuncs.cpp.

991 {
992 
993  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
994  a_field->Trace( fa_ammoniumsulphate );
997  int pref=a_field->GetUnsprayedMarginPolyRef();
998  if (pref!=-1){
999  // Must have an unsprayed margin so need to pass the information on to it
1000  LE* um=g_landscape_p->SupplyLEPointer(pref);
1003  }
1004  return true;
1005  }
1006  return false;
1007 }

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

◆ FA_Calcium()

bool Farm::FA_Calcium ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Calcium applied on a_field owned by a stock farmer.

Definition at line 1133 of file farmfuncs.cpp.

1134 {
1135  if ((0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
1136  a_field->Trace(fa_calcium);
1137  a_field->SetLastTreatment(fa_calcium);
1139  int pref = a_field->GetUnsprayedMarginPolyRef();
1140  if (pref != -1) {
1141  // Must have an unsprayed margin so need to pass the information on to it
1142  LE* um = g_landscape_p->SupplyLEPointer(pref);
1145  }
1146  return true;
1147  }
1148  return false;
1149 }

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

◆ FA_GreenManure()

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 1062 of file farmfuncs.cpp.

1063 {
1064 
1065  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
1066  a_field->Trace( fa_greenmanure );
1067  a_field->SetLastTreatment( fa_greenmanure );
1069  int pref=a_field->GetUnsprayedMarginPolyRef();
1070  if (pref!=-1){
1071  // Must have an unsprayed margin so need to pass the information on to it
1072  LE* um=g_landscape_p->SupplyLEPointer(pref);
1075  }
1076  return true;
1077  }
1078  return false;
1079 }

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

◆ FA_ManganeseSulphate()

bool Farm::FA_ManganeseSulphate ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply manganese sulphate to a_field owned by an stock farmer.

Definition at line 1013 of file farmfuncs.cpp.

1014 {
1015  if ((0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
1016  a_field->Trace(fa_manganesesulphate);
1019  int pref = a_field->GetUnsprayedMarginPolyRef();
1020  if (pref != -1) {
1021  // Must have an unsprayed margin so need to pass the information on to it
1022  LE* um = g_landscape_p->SupplyLEPointer(pref);
1025  }
1026  return true;
1027  }
1028  return false;
1029 }

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

◆ FA_Manure()

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 1036 of file farmfuncs.cpp.

1037 {
1038 
1039  if ( (0 >= a_days) || ((g_weather->GetTemp()>0)&&
1040  !g_weather->Raining() && DoIt(DO_IT_PROB)))
1041 {
1042  a_field->Trace( fa_manure );
1043  a_field->SetLastTreatment( fa_manure );
1045  int pref=a_field->GetUnsprayedMarginPolyRef();
1046  if (pref!=-1){
1047  // Must have an unsprayed margin so need to pass the information on to it
1048  LE* um=g_landscape_p->SupplyLEPointer(pref);
1049  um->SetLastTreatment( fa_manure );
1051  }
1052  return true;
1053  }
1054  return false;
1055 }

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

◆ FA_NPK()

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 917 of file farmfuncs.cpp.

918 {
919 
920  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
921  a_field->Trace( fa_npk );
922  a_field->SetLastTreatment( fa_npk );
924  int pref=a_field->GetUnsprayedMarginPolyRef();
925  if (pref!=-1){
926  // Must have an unsprayed margin so need to pass the information on to it
927  LE* um=g_landscape_p->SupplyLEPointer(pref);
928  um->SetLastTreatment( fa_npk );
930  }
931  return true;
932  }
933  return false;
934 }

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

◆ FA_NPKS()

bool Farm::FA_NPKS ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply NPKS fertilizer, on a_field owned by a stock farmer.

Definition at line 891 of file farmfuncs.cpp.

892 {
893 
894  if ((0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
895  a_field->Trace(fa_npks);
896  a_field->SetLastTreatment(fa_npks);
898  int pref = a_field->GetUnsprayedMarginPolyRef();
899  if (pref != -1) {
900  // Must have an unsprayed margin so need to pass the information on to it
901  LE* um = g_landscape_p->SupplyLEPointer(pref);
904  um->InsectMortality(0.4);
906  }
907 
908  return true;
909  }
910  return false;
911 }

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

◆ FA_PK()

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 941 of file farmfuncs.cpp.

942 {
943 
944  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
945  a_field->Trace( fa_pk );
946  a_field->SetLastTreatment( fa_pk );
948  int pref=a_field->GetUnsprayedMarginPolyRef();
949  if (pref!=-1){
950  // Must have an unsprayed margin so need to pass the information on to it
951  LE* um=g_landscape_p->SupplyLEPointer(pref);
952  um->SetLastTreatment( fa_pk );
954  }
955  return true;
956  }
957  return false;
958 }

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

◆ FA_RSM()

bool Farm::FA_RSM ( LE a_field,
double  a_user,
int  a_days 
)
virtual

RSM (ammonium nitrate solution) applied on a_field owned by a stock farmer.

Definition at line 1111 of file farmfuncs.cpp.

1112 {
1113  if ((0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
1114  a_field->Trace(fa_rsm);
1115  a_field->SetLastTreatment(fa_rsm);
1117  int pref = a_field->GetUnsprayedMarginPolyRef();
1118  if (pref != -1) {
1119  // Must have an unsprayed margin so need to pass the information on to it
1120  LE* um = g_landscape_p->SupplyLEPointer(pref);
1121  um->SetLastTreatment(fa_rsm);
1123  }
1124  return true;
1125  }
1126  return false;
1127 }

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

◆ FA_Sludge()

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 1086 of file farmfuncs.cpp.

1087 {
1088 
1089  if ( (0 >= a_days) || ((g_weather->GetTemp()>0)&&
1090  !g_weather->Raining() && DoIt(DO_IT_PROB)))
1091 {
1092  a_field->Trace( fa_sludge );
1093  a_field->SetLastTreatment( fa_sludge );
1095  int pref=a_field->GetUnsprayedMarginPolyRef();
1096  if (pref!=-1){
1097  // Must have an unsprayed margin so need to pass the information on to it
1098  LE* um=g_landscape_p->SupplyLEPointer(pref);
1099  um->SetLastTreatment( fa_sludge );
1101  }
1102  return true;
1103  }
1104  return false;
1105 }

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

◆ FA_Slurry()

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 965 of file farmfuncs.cpp.

966 {
967 
968  if ( (0 >= a_days) || ((g_weather->GetTemp()>0)&&
969  !g_weather->Raining() && DoIt(DO_IT_PROB)))
970 {
971  a_field->Trace( fa_slurry );
972  a_field->SetLastTreatment( fa_slurry );
974  int pref=a_field->GetUnsprayedMarginPolyRef();
975  if (pref!=-1){
976  // Must have an unsprayed margin so need to pass the information on to it
977  LE* um=g_landscape_p->SupplyLEPointer(pref);
980  }
981  return true;
982  }
983  return false;
984 }

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

◆ FlowerCutting()

bool Farm::FlowerCutting ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Flower cutting applied on a_field.

Definition at line 2437 of file farmfuncs.cpp.

2438 {
2439  if ((0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
2440  a_field->Trace(flower_cutting);
2441  a_field->ReduceVeg_Extended(0.8);
2442  a_field->InsectMortality(0.9);
2443  a_field->SetVegHeight(35);
2444  a_field->SetLastTreatment(flower_cutting);
2446  int pref = a_field->GetUnsprayedMarginPolyRef();
2447  if (pref != -1) {
2448  // Must have an unsprayed margin so need to pass the information on to it
2449  LE* um = g_landscape_p->SupplyLEPointer(pref);
2450  um->ReduceVeg_Extended(0.8);
2451  um->InsectMortality(0.9);
2452  um->SetVegHeight(30);
2455  }
2456  return true;
2457  }
2458  return false;
2459 }

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

◆ FP_AmmoniumSulphate()

bool Farm::FP_AmmoniumSulphate ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply Ammonium Sulphate to a_field owned by an arable farmer.

Definition at line 750 of file farmfuncs.cpp.

751 {
752 
753  if ((0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
754  a_field->Trace(fp_ammoniumsulphate);
757  int pref = a_field->GetUnsprayedMarginPolyRef();
758  if (pref != -1) {
759  // Must have an unsprayed margin so need to pass the information on to it
760  LE* um = g_landscape_p->SupplyLEPointer(pref);
763  }
764  return true;
765  }
766  return false;
767 }

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

◆ FP_Calcium()

bool Farm::FP_Calcium ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Calcium applied on a_field owned by an arable farmer.

Definition at line 869 of file farmfuncs.cpp.

870 {
871  if ((0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
872  a_field->Trace(fp_calcium);
873  a_field->SetLastTreatment(fp_calcium);
875  int pref = a_field->GetUnsprayedMarginPolyRef();
876  if (pref != -1) {
877  // Must have an unsprayed margin so need to pass the information on to it
878  LE* um = g_landscape_p->SupplyLEPointer(pref);
881  }
882  return true;
883  }
884  return false;
885 }

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

◆ FP_GreenManure()

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 798 of file farmfuncs.cpp.

799 {
800 
801  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
802  a_field->Trace( fp_greenmanure );
803  a_field->SetLastTreatment( fp_greenmanure );
805  int pref=a_field->GetUnsprayedMarginPolyRef();
806  if (pref!=-1){
807  // Must have an unsprayed margin so need to pass the information on to it
808  LE* um=g_landscape_p->SupplyLEPointer(pref);
811  }
812  return true;
813  }
814  return false;
815 }

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

◆ FP_LiquidNH3()

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 677 of file farmfuncs.cpp.

678 {
679 
680  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
681  a_field->Trace( fp_liquidNH3 );
682  a_field->SetLastTreatment( fp_liquidNH3 );
684  int pref=a_field->GetUnsprayedMarginPolyRef();
685  if (pref!=-1){
686  // Must have an unsprayed margin so need to pass the information on to it
687  LE* um=g_landscape_p->SupplyLEPointer(pref);
690  }
691  return true;
692  }
693  return false;
694 }

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

◆ FP_ManganeseSulphate()

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 727 of file farmfuncs.cpp.

728 {
729 
730  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
731  a_field->Trace( fp_manganesesulphate );
734  int pref=a_field->GetUnsprayedMarginPolyRef();
735  if (pref!=-1){
736  // Must have an unsprayed margin so need to pass the information on to it
737  LE* um=g_landscape_p->SupplyLEPointer(pref);
740  }
741  return true;
742  }
743  return false;
744 }

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

◆ FP_Manure()

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 773 of file farmfuncs.cpp.

774 {
775 
776  if ( (0 >= a_days) || ((g_weather->GetTemp()>0)&&
777  !g_weather->Raining() && DoIt(DO_IT_PROB))) {
778  a_field->Trace( fp_manure );
779  a_field->SetLastTreatment( fp_manure );
781  int pref=a_field->GetUnsprayedMarginPolyRef();
782  if (pref!=-1){
783  // Must have an unsprayed margin so need to pass the information on to it
784  LE* um=g_landscape_p->SupplyLEPointer(pref);
787  }
788  return true;
789  }
790  return false;
791 }

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

◆ FP_NPK()

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 629 of file farmfuncs.cpp.

630 {
631 
632  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
633  a_field->Trace( fp_npk );
634  a_field->SetLastTreatment( fp_npk );
636  int pref=a_field->GetUnsprayedMarginPolyRef();
637  if (pref!=-1){
638  // Must have an unsprayed margin so need to pass the information on to it
639  LE* um=g_landscape_p->SupplyLEPointer(pref);
642  }
643  return true;
644  }
645  return false;
646 }

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

◆ FP_NPKS()

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 602 of file farmfuncs.cpp.

603 {
604 
605  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
606  a_field->Trace( fp_npks );
607  a_field->SetLastTreatment( fp_npks );
609  int pref=a_field->GetUnsprayedMarginPolyRef();
610 if (pref!=-1){
611  // Must have an unsprayed margin so need to pass the information on to it
612  LE* um=g_landscape_p->SupplyLEPointer(pref);
614  um->SetGrowthPhase( harvest1 );
615  um->InsectMortality( 0.4 );
617 }
618 
619  return true;
620  }
621  return false;
622 }

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

◆ FP_PK()

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 653 of file farmfuncs.cpp.

654 {
655 
656  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
657  a_field->Trace( fp_pk );
658  a_field->SetLastTreatment( fp_pk );
660  int pref=a_field->GetUnsprayedMarginPolyRef();
661  if (pref!=-1){
662  // Must have an unsprayed margin so need to pass the information on to it
663  LE* um=g_landscape_p->SupplyLEPointer(pref);
664  um->SetLastTreatment(fp_pk);
666  }
667  return true;
668  }
669  return false;
670 }

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

◆ FP_RSM()

bool Farm::FP_RSM ( LE a_field,
double  a_user,
int  a_days 
)
virtual

RSM (ammonium nitrate solution) applied on a_field owned by an arable farmer.

Definition at line 847 of file farmfuncs.cpp.

848 {
849  if ((0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
850  a_field->Trace(fp_rsm);
851  a_field->SetLastTreatment(fp_rsm);
853  int pref = a_field->GetUnsprayedMarginPolyRef();
854  if (pref != -1) {
855  // Must have an unsprayed margin so need to pass the information on to it
856  LE* um = g_landscape_p->SupplyLEPointer(pref);
859  }
860  return true;
861  }
862  return false;
863 }

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

◆ FP_Sludge()

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 822 of file farmfuncs.cpp.

823 {
824  //
825  if ( (0 >= a_days) || ((g_weather->GetTemp()>0)&&
826  !g_weather->Raining() && DoIt(DO_IT_PROB)))
827 {
828  a_field->Trace( fp_sludge );
829  a_field->SetLastTreatment( fp_sludge );
831  int pref=a_field->GetUnsprayedMarginPolyRef();
832  if (pref!=-1){
833  // Must have an unsprayed margin so need to pass the information on to it
834  LE* um=g_landscape_p->SupplyLEPointer(pref);
837  }
838  return true;
839  }
840  return false;
841 }

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

◆ FP_Slurry()

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 701 of file farmfuncs.cpp.

702 {
703 
704  if ( (0 >= a_days) || ((g_weather->GetTemp()>0)&&
705  !g_weather->Raining() && DoIt(DO_IT_PROB)))
706 {
707  a_field->Trace( fp_slurry );
708  a_field->SetLastTreatment( fp_slurry );
710  int pref=a_field->GetUnsprayedMarginPolyRef();
711  if (pref!=-1){
712  // Must have an unsprayed margin so need to pass the information on to it
713  LE* um=g_landscape_p->SupplyLEPointer(pref);
716  }
717  return true;
718  }
719  return false;
720 }

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

◆ FungicideTreat()

bool Farm::FungicideTreat ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply fungicide to a_field.

Reimplemented in OptimisingFarm.

Definition at line 1279 of file farmfuncs.cpp.

1280 {
1281 
1282  if (0 >= a_days)
1283  {
1284  if ( ( ! a_field->GetSignal() & LE_SIG_NO_FUNGICIDE ))
1285  {
1286  a_field->Trace( fungicide_treat );
1287  a_field->SetLastTreatment( fungicide_treat );
1290  }
1291  return true;
1292  }
1293  else if ( (g_weather->GetWind()<4.5) &&
1294  (!g_weather->Raining()) && DoIt(DO_IT_PROB)) {
1295  if ( ! (a_field->GetSignal() & LE_SIG_NO_FUNGICIDE) ) {
1296  a_field->Trace( fungicide_treat );
1297  a_field->SetLastTreatment( fungicide_treat );
1300  }
1301  return true;
1302  }
1303  return false;
1304 }

References Landscape::CheckForPesticideRecord(), DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fungicide, fungicide_treat, g_landscape_p, g_weather, Weather::GetWind(), LE_SIG_NO_FUNGICIDE, Weather::Raining(), LE::SetLastTreatment(), and LE::SetTramlinesDecay().

◆ GetArea()

int Farm::GetArea ( void  )

Returns the area of arable fields owned by that farm.

Definition at line 1331 of file farm.cpp.

1331  {
1332  int area = 0;
1333  for (unsigned int i = 0; i < m_fields.size(); i++) {
1334  if (m_fields[i]->GetElementType() == tole_Field) area += (int)m_fields[i]->GetArea();
1335  }
1336  return area;
1337 }

References tole_Field.

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

◆ GetAreaDouble()

double Farm::GetAreaDouble ( void  )

Returns the area of arable fields owned by that farm.

Definition at line 1350 of file farm.cpp.

1350  {
1351  double area = 0;
1352  for ( unsigned int i = 0; i < m_fields.size(); i++ ) {
1353  if (m_fields[i]->GetElementType()==tole_Field) area += m_fields[i]->GetArea();
1354  }
1355  return area;
1356 }

References tole_Field.

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

◆ GetAreaOpenFields()

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 1369 of file farm.cpp.

1370 {
1371  int area = 0;
1372  for (unsigned int i = 0; i < m_fields.size(); i++) {
1373  if (m_fields[i]->GetOpenness() > a_openness) area += int(m_fields[i]->GetArea());
1374  }
1375  return area;
1376 }

◆ GetCentroids()

APoint Farm::GetCentroids ( )
inline

Definition at line 908 of file farm.h.

908 { APoint pt; pt.m_x = m_farm_centroidx; pt.m_y = m_farm_centroidy; return pt; }

References m_farm_centroidx, and m_farm_centroidy.

◆ GetCrop()

TTypesOfVegetation Farm::GetCrop ( int  a_index)
inline

Definition at line 914 of file farm.h.

914  {
915  return m_rotation[a_index];
916  }

References m_rotation.

◆ GetFarmNumber()

int Farm::GetFarmNumber ( void  )
inline

Definition at line 782 of file farm.h.

782 { return m_farm_num; }

References m_farm_num.

Referenced by FarmManager::FarmManagement(), and InvIntPartition().

◆ GetFirstCropIndex()

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 1385 of file farm.cpp.

1385  {
1386  // If g_farm_fixed_rotation, then determine the first
1387  // crop number in the rotation rotation number.
1389 
1391  // We are running all the farms synchronized, so
1392  // simply set the first crop to run on all farm fields.
1393  return 0;
1394  }
1395 
1396  // Each farm runs its fields sync'ed but independently from
1397  // the other farmers.
1398 
1399  // Determine if this farm has selected its own start index
1400  // and set it if not. m_rotation_sync_index is initialized
1401  // to -1 by the Farm::Farm() constructor.
1402  if ( -1 == m_rotation_sync_index ) {
1403  m_rotation_sync_index = (int) (rand() % m_rotation.size());
1404  }
1405  // Return farm localized rotation index.
1406  return m_rotation_sync_index;
1407  }
1408 
1409  // Not synchronised, but we want to follow our rotation sequence, so check
1410  // if we have started this process, if not set the sync value.
1411  // afterwards just increment this.
1412  if ( -1 == m_rotation_sync_index ) {
1413  if (m_rotation.size() > 0) m_rotation_sync_index = (int)(rand() % m_rotation.size()); else m_rotation_sync_index = 0;
1414  }
1415  else m_rotation_sync_index = (int) ((m_rotation_sync_index+1) % m_rotation.size());
1416  return m_rotation_sync_index;
1417 }

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

◆ GetFirstDate()

int Farm::GetFirstDate ( TTypesOfVegetation  a_tov)
protected

Gets the start date for a crop type.

Definition at line 1582 of file farm.cpp.

1582  {
1583  switch (a_tov2) {
1584  case tov_Carrots:
1585  return m_carrots->GetFirstDate();
1586  case tov_BroadBeans:
1587  return m_broadbeans->GetFirstDate();
1588  case tov_FodderGrass:
1589  return m_foddergrass->GetFirstDate();
1591  return m_CGG1->GetFirstDate();
1593  return m_CGG2->GetFirstDate();
1594  case tov_FieldPeas:
1595  return m_fieldpeas->GetFirstDate();
1596  case tov_FieldPeasSilage:
1597  return m_fieldpeassilage->GetFirstDate();
1598  case tov_FodderBeet:
1599  return m_fodderbeet->GetFirstDate();
1600  case tov_SugarBeet:
1601  return m_sugarbeet->GetFirstDate();
1602  case tov_OFodderBeet:
1603  return m_ofodderbeet->GetFirstDate();
1604  case tov_Maize:
1605  return m_maize->GetFirstDate();
1606  case tov_OMaizeSilage:
1607  return m_omaizesilage->GetFirstDate();
1608  case tov_MaizeSilage:
1609  return m_maizesilage->GetFirstDate();
1611  return m_OBarleyPCG->GetFirstDate();
1612  case tov_OCarrots:
1613  return m_ocarrots->GetFirstDate();
1615  return m_OCGG1->GetFirstDate();
1617  return m_OCGG2->GetFirstDate();
1619  return m_OCGS1->GetFirstDate();
1620  case tov_OFieldPeas:
1621  return m_ofieldpeas->GetFirstDate();
1622  case tov_OFirstYearDanger:
1623  return m_ofirstyeardanger->GetFirstDate();
1624  case tov_OGrazingPigs:
1625  return m_ograzingpigs->GetFirstDate();
1626  case tov_OrchardCrop:
1627  return m_orchardcrop->GetFirstDate();
1628  case tov_OOats:
1629  return m_ooats->GetFirstDate();
1630  case tov_Oats:
1631  return m_oats->GetFirstDate();
1633  return m_opermgrassgrazed->GetFirstDate();
1634  case tov_OPotatoes:
1635  return m_opotatoes->GetFirstDate();
1636  case tov_OSpringBarley:
1637  return m_ospringbarley->GetFirstDate();
1638  case tov_OSBarleySilage:
1639  return m_osbarleysilage->GetFirstDate();
1640  case tov_OSpringBarleyExt:
1641  return m_ospringbarleyext->GetFirstDate();
1642  case tov_OSpringBarleyPigs:
1643  return m_ospringbarleypigs->GetFirstDate();
1644  case tov_OWinterBarley:
1645  return m_owinterbarley->GetFirstDate();
1646  case tov_OWinterBarleyExt:
1647  return m_owinterbarleyext->GetFirstDate();
1648  case tov_OWinterRape:
1649  return m_owinterrape->GetFirstDate();
1650  case tov_OWinterRye:
1651  return m_owinterrye->GetFirstDate();
1653  return m_owinterwheatundersown->GetFirstDate();
1654  case tov_OWinterWheat:
1655  return m_owinterwheat->GetFirstDate();
1657  return m_owinterwheatundersownext->GetFirstDate();
1659  return m_permgrassgrazed->GetFirstDate();
1661  return m_permgrasslowyield->GetFirstDate();
1662  case tov_PermanentGrassTussocky: // Only used for tole_PermPastureTussocky
1663  return m_permgrasstussocky->GetFirstDate();
1664  case tov_PermanentSetaside:
1665  return m_permanentsetaside->GetFirstDate();
1666  case tov_Potatoes:
1667  return m_potatoes->GetFirstDate();
1668  case tov_SeedGrass1:
1669  return m_seedgrass1->GetFirstDate();
1670  case tov_SeedGrass2:
1671  return m_seedgrass2->GetFirstDate();
1672  case tov_Setaside:
1673  return m_setaside->GetFirstDate();
1674  case tov_SpringBarley:
1675  return m_springbarley->GetFirstDate();
1676  case tov_SpringBarleySpr:
1677  return m_springbarleyspr->GetFirstDate();
1679  return m_springbarleyptreatment->GetFirstDate();
1681  return m_springbarleyskmanagement->GetFirstDate();
1683  return m_sbarleyclovergrass->GetFirstDate();
1684  case tov_SpringBarleySeed:
1685  return m_springbarleyseed->GetFirstDate();
1687  return m_springbarleysilage->GetFirstDate();
1689  return m_springbarleystrigling->GetFirstDate();
1691  return m_springbarleystriglingsingle->GetFirstDate();
1693  return m_springbarleystriglingculm->GetFirstDate();
1694  case tov_SpringRape:
1695  return m_springrape->GetFirstDate();
1696  case tov_Triticale:
1697  return m_triticale->GetFirstDate();
1698  case tov_OTriticale:
1699  return m_otriticale->GetFirstDate();
1700  case tov_WinterBarley:
1701  return m_winterbarley->GetFirstDate();
1702  case tov_WinterRape:
1703  return m_winterrape->GetFirstDate();
1704  case tov_WinterRye:
1705  return m_winterrye->GetFirstDate();
1706  case tov_WinterWheat:
1707  return m_winterwheat->GetFirstDate();
1709  return m_winterwheatstrigling->GetFirstDate();
1711  return m_winterwheatstriglingsingle->GetFirstDate();
1713  return m_winterwheatstriglingculm->GetFirstDate();
1714  case tov_WWheatPControl:
1715  return m_wwheatpcontrol->GetFirstDate();
1717  return m_wwheatptoxiccontrol->GetFirstDate();
1718  case tov_WWheatPTreatment:
1719  return m_wwheatptreatment->GetFirstDate();
1721  return m_agrochemindustrycereal->GetFirstDate();
1722  case tov_YoungForest:
1723  return m_youngforest->GetFirstDate();
1724  case tov_NorwegianPotatoes:
1725  return m_norwegianpotatoes->GetFirstDate();
1726  case tov_NorwegianOats:
1727  return m_norwegianoats->GetFirstDate();
1729  return m_norwegianspringbarley->GetFirstDate();
1730 
1731  case tov_PLWinterWheat:
1732  return m_plwinterwheat->GetFirstDate();
1733  case tov_PLWinterRape:
1734  return m_plwinterrape->GetFirstDate();
1735  case tov_PLWinterBarley:
1736  return m_plwinterbarley->GetFirstDate();
1737  case tov_PLWinterTriticale:
1738  return m_plwintertriticale->GetFirstDate();
1739  case tov_PLWinterRye:
1740  return m_plwinterrye->GetFirstDate();
1741  case tov_PLSpringWheat:
1742  return m_plspringwheat->GetFirstDate();
1743  case tov_PLSpringBarley:
1744  return m_plspringbarley->GetFirstDate();
1745  case tov_PLMaize:
1746  return m_plmaize->GetFirstDate();
1747  case tov_PLMaizeSilage:
1748  return m_plmaizesilage->GetFirstDate();
1749  case tov_PLPotatoes:
1750  return m_plpotatoes->GetFirstDate();
1751  case tov_PLBeet:
1752  return m_plbeet->GetFirstDate();
1753  case tov_PLFodderLucerne1:
1754  return m_plfodderlucerne1->GetFirstDate();
1755  case tov_PLFodderLucerne2:
1756  return m_plfodderlucerne2->GetFirstDate();
1757  case tov_PLCarrots:
1758  return m_plcarrots->GetFirstDate();
1759  case tov_PLSpringBarleySpr:
1760  return m_plspringbarleyspr->GetFirstDate();
1761  case tov_PLWinterWheatLate:
1762  return m_plwinterwheatlate->GetFirstDate();
1763  case tov_PLBeetSpr:
1764  return m_plbeetspr->GetFirstDate();
1765  case tov_PLBeans:
1766  return m_plbeans->GetFirstDate();
1767 
1768  case tov_NLBeet:
1769  return m_nlbeet->GetFirstDate();
1770  case tov_NLCarrots:
1771  return m_nlcarrots->GetFirstDate();
1772  case tov_NLMaize:
1773  return m_nlmaize->GetFirstDate();
1774  case tov_NLPotatoes:
1775  return m_nlpotatoes->GetFirstDate();
1776  case tov_NLSpringBarley:
1777  return m_nlspringbarley->GetFirstDate();
1778  case tov_NLWinterWheat:
1779  return m_nlwinterwheat->GetFirstDate();
1780  case tov_NLCabbage:
1781  return m_nlcabbage->GetFirstDate();
1782  case tov_NLTulips:
1783  return m_nltulips->GetFirstDate();
1784  case tov_NLGrassGrazed1:
1785  return m_nlgrassgrazed1->GetFirstDate();
1787  return m_nlgrassgrazed1spring->GetFirstDate();
1788  case tov_NLGrassGrazed2:
1789  return m_nlgrassgrazed2->GetFirstDate();
1790  case tov_NLGrassGrazedLast:
1791  return m_nlgrassgrazedlast->GetFirstDate();
1793  return m_nlpermanentgrassgrazed->GetFirstDate();
1794  case tov_NLBeetSpring:
1795  return m_nlbeetspring->GetFirstDate();
1796  case tov_NLCarrotsSpring:
1797  return m_nlcarrotsspring->GetFirstDate();
1798  case tov_NLMaizeSpring:
1799  return m_nlmaizespring->GetFirstDate();
1800  case tov_NLPotatoesSpring:
1801  return m_nlpotatoesspring->GetFirstDate();
1803  return m_nlspringbarleyspring->GetFirstDate();
1804  case tov_NLCabbageSpring:
1805  return m_nlcabbagespring->GetFirstDate();
1806  case tov_NLCatchPeaCrop:
1807  return m_nlcatchpeacrop->GetFirstDate();
1808 
1810  return m_dummycroppesttesting->GetFirstDate();
1811 
1812  default:
1813  return 0;
1814  }
1815 }

References tov_AgroChemIndustryCereal, tov_BroadBeans, tov_Carrots, tov_CloverGrassGrazed1, tov_CloverGrassGrazed2, tov_DummyCropPestTesting, tov_FieldPeas, tov_FieldPeasSilage, tov_FodderBeet, tov_FodderGrass, tov_Maize, tov_MaizeSilage, tov_NLBeet, tov_NLBeetSpring, tov_NLCabbage, tov_NLCabbageSpring, tov_NLCarrots, tov_NLCarrotsSpring, tov_NLCatchPeaCrop, tov_NLGrassGrazed1, tov_NLGrassGrazed1Spring, tov_NLGrassGrazed2, tov_NLGrassGrazedLast, tov_NLMaize, tov_NLMaizeSpring, tov_NLPermanentGrassGrazed, tov_NLPotatoes, tov_NLPotatoesSpring, tov_NLSpringBarley, tov_NLSpringBarleySpring, tov_NLTulips, tov_NLWinterWheat, tov_NorwegianOats, tov_NorwegianPotatoes, tov_NorwegianSpringBarley, 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_PLBeans, tov_PLBeet, tov_PLBeetSpr, tov_PLCarrots, tov_PLFodderLucerne1, tov_PLFodderLucerne2, tov_PLMaize, tov_PLMaizeSilage, tov_PLPotatoes, tov_PLSpringBarley, tov_PLSpringBarleySpr, tov_PLSpringWheat, tov_PLWinterBarley, tov_PLWinterRape, tov_PLWinterRye, tov_PLWinterTriticale, tov_PLWinterWheat, tov_PLWinterWheatLate, 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.

◆ GetIntensity()

int Farm::GetIntensity ( void  )
inline

Definition at line 907 of file farm.h.

907 { return m_intensity; }

References m_intensity.

◆ GetMaxOpenness()

int Farm::GetMaxOpenness ( )
inline

Returns the maximum openness score of the fields.

Definition at line 802 of file farm.h.

803  {
804  int op = 0;
805  for (int i = 0; i < m_fields.size(); i++)
806  {
807  int openness = m_fields[i]->GetOpenness();
808  if (openness > op) op = openness;
809  }
810  return op;
811  }

References m_fields.

◆ GetNextCrop()

TTypesOfVegetation Farm::GetNextCrop ( int  a_index)
inline

Definition at line 917 of file farm.h.

917  {
918  int ind = a_index + 1;
919  if (ind >= (int)m_rotation.size()) ind = ind - (int)m_rotation.size();
920  return m_rotation[ind];
921  }

References m_rotation.

◆ GetNextCropIndex()

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 1427 of file farm.cpp.

1427  {
1429  // Rotation not enabled.
1430  return a_rot_index;
1431  }
1432 
1433  if ( a_rot_index == -1 )
1434  return -1;
1435 
1436  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
1437  a_rot_index = 0;
1438 
1439  return a_rot_index;
1440 }

References g_farm_enable_crop_rotation, and CfgBool::value().

◆ GetNextCropStartDate()

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 864 of file farm.cpp.

864  {
865  TTypesOfVegetation l_tov2;
866 
867  if ( a_field->GetRotIndex() < 0 || g_farm_fixed_crop_enable.value() //|| g_farm_test_crop.value()
868  ) {
869  l_tov2 = a_curr_veg; // don't do it if no rotation
870  } else {
871  l_tov2 = m_rotation[ GetNextCropIndex( a_field->GetRotIndex() ) ];
872  }
873  a_curr_veg = l_tov2;
874  return GetFirstDate( l_tov2 );
875 }

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

◆ GetNoFields()

int Farm::GetNoFields ( )
inline

Returns the number of the fields owned.

Definition at line 794 of file farm.h.

794 { return (int) m_fields.size(); }

References m_fields.

◆ GetNoOpenFields()

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 1359 of file farm.cpp.

1360 {
1361  int num = 0;
1362  for (unsigned int i = 0; i < m_fields.size(); i++) {
1363  if (m_fields[i]->GetOpenness() > a_openness) num++;
1364  }
1365  return num;
1366 }

◆ GetPreviousCrop()

TTypesOfVegetation Farm::GetPreviousCrop ( int  a_index)
inline

Definition at line 909 of file farm.h.

909  {
910  int ind = a_index - 1;
911  if (ind < 0) ind = (int)m_rotation.size() - 1;
912  return m_rotation[ind];
913  }

References m_rotation.

Referenced by Field::GetPreviousCrop().

◆ GetTotalArea()

int Farm::GetTotalArea ( void  )

Returns the area of all fields owned by that farm.

Definition at line 1340 of file farm.cpp.

1340  {
1341  int area = 0;
1342  for (unsigned int i = 0; i < m_fields.size(); i++)
1343  {
1344  area += (int)m_fields[i]->GetArea();
1345  }
1346  return area;
1347 }

◆ GetType()

TTypesOfFarm Farm::GetType ( void  )
inline

Definition at line 901 of file farm.h.

901 { return m_farmtype; }

References m_farmtype.

◆ GetValidCoords()

APoint Farm::GetValidCoords ( )
inline

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

Definition at line 800 of file farm.h.

800 { APoint pt; pt.m_x = m_fields[0]->GetValidX(); pt.m_y = m_fields[0]->GetValidY(); return pt; }

References m_fields.

◆ GrowthRegulator()

bool Farm::GrowthRegulator ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply growth regulator to a_field.

Definition at line 1250 of file farmfuncs.cpp.

1251 {
1252 
1253  if (0 >= a_days)
1254  {
1255  if ( (!g_weather->Raining()) && (g_weather->GetWind()<4.5) &&
1256  (!(a_field->GetSignal() & LE_SIG_NO_GROWTH_REG) )) {
1257  a_field->Trace( growth_regulator );
1258  a_field->SetLastTreatment( growth_regulator );
1260  }
1261  return true;
1262  }
1263  else if ( (g_weather->GetWind()<4.5) &&
1264  (!g_weather->Raining()) && DoIt(DO_IT_PROB)) {
1265  if ( ! (a_field->GetSignal() & LE_SIG_NO_GROWTH_REG) ) {
1266  a_field->Trace( growth_regulator );
1267  a_field->SetLastTreatment( growth_regulator );
1269  }
1270  return true;
1271  }
1272  return false;
1273 }

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

◆ HandleEvents()

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 882 of file farm.cpp.

882  {
883  if ( m_queue.Empty() )
884  return;
885 
887  FarmEvent * ev = pair.m_element;
888  while ( pair.m_pri <= g_date->Date() ) {
889  m_queue.Pop();
891  if ( LeSwitch( ev ) ) {
892  // This crop management plan has terminated.
893 
894  // First check for an infinite loop in the rotation scheme,
895  // ie. a scenario where all crops decide not to run given
896  // the date.
898 
899  // Outdate any remaining events for this field.
900  ev->m_field->BumpRunNum();
901 
902  // Crop treatment done, select and initiate new crop if in rotation.
903  TTypesOfVegetation new_veg = ev->m_field->GetVegType();
904 
905  if ( ev->m_field->GetRotIndex() >= 0 ) {
906  int new_index = GetNextCropIndex( ev->m_field->GetRotIndex() );
907  new_veg = m_rotation[ new_index ];
908  // Running in fixed crop mode?
911  }
913  ev->m_field->SetRotIndex( new_index );
915  ev->m_field->SetVegType(new_veg, tov_Undefined);
916  }
917 
918  // Reset the event list for this field.
919  ev->m_field->ResetTrace();
920  // Reset event timeout counter.
921  ev->m_field->SetVegStore( 0 );
922 
923  // The next bit simply determines the start date of the next crop in
924  // the rotation and passes this to the start crop event.
925  // The crop is responsible for raising an error if the next crop is
926  // not possible or otherwise handling the problem
927 
928  // 19/5-2003: Note: This code was moved out into a dedicated
929  // method of the Farm class, GetNextCropStartDate(), as precisely
930  // the same piece of code needs to be run during initialization of
931  // farm management.
932  TTypesOfVegetation l_tov = new_veg;
933  int l_nextcropstartdate = GetNextCropStartDate( ev->m_field, l_tov );
934 
935  // Create 'start' event for today and put it on the queue.
936  AddNewEvent( new_veg, g_date->Date(), ev->m_field, PROG_START, ev->m_field->GetRunNum(), false, l_nextcropstartdate, false, l_tov );
937 
938  // Set starting date for rotation mgmt loop detection.
939  ev->m_field->SetMgtLoopDetectDate( g_date->Date() );
940  }
941 
942  delete ev;
943 
944  if ( m_queue.Empty() )
945  return;
946  pair = m_queue.Bottom();
947  ev = pair.m_element;
948  }
949 }

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

◆ Harvest()

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 1769 of file farmfuncs.cpp.

1770 {
1771  //5 days good weather before
1772  if ((0 >= a_days) || ((g_weather->GetRainPeriod(g_date->Date(), 5) < 0.1) && DoIt(DO_IT_PROB))) {
1773  a_field->Trace(harvest);
1774  a_field->SetLastTreatment(harvest);
1775  a_field->SetGrowthPhase(harvest1);
1776  // Here we have to do a little skip to avoid too low insect populations after harvest, but a correct veg biomass
1777  a_field->InsectMortality(0.4);
1778  double insects = a_field->GetInsectPop();
1779  a_field->ResetDigestability();
1780  a_field->RecalculateBugsNStuff();
1781  a_field->SetInsectPop(insects);
1783  int pref = a_field->GetUnsprayedMarginPolyRef();
1784  // Are we a cereal crop? If so we need to have some spilled grain
1785  double someseed = 0.0;
1786  double somemaize = 0.0;
1787  if (dynamic_cast<VegElement*>(a_field)->IsMatureCereal()) {
1788  someseed = m_OurManager->GetSpilledGrain();
1789  a_field->SetStubble(true);
1790  }
1791  else if (dynamic_cast<VegElement*>(a_field)->IsMaize()) {
1792  // Maize in stubble
1793  a_field->SetStubble(true);
1794  somemaize = m_OurManager->GetSpilledMaize();
1795  }
1796  a_field->SetBirdSeed( someseed );
1797  a_field->SetBirdMaize( somemaize );
1798  if (pref != -1){
1799  // Must have an unsprayed margin so need to pass the information on to it
1800  LE* um = g_landscape_p->SupplyLEPointer(pref);
1802  um->SetGrowthPhase(harvest1);
1803  um->InsectMortality(0.4);
1805  um->ResetDigestability();
1806  um->RecalculateBugsNStuff();
1807  um->SetBirdSeed( someseed );
1808  um->SetBirdMaize( somemaize );
1809  if ((somemaize > 0) || (someseed > 0)) um->SetStubble(true);
1810  }
1811  return true;
1812  }
1813  return false;
1814 }

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

◆ HarvestLong()

bool Farm::HarvestLong ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out a harvest on a_field.

Definition at line 1821 of file farmfuncs.cpp.

1822 {
1823 
1824  //5 days good weather before
1825  if ((0 >= a_days) ||
1827  ) {
1828  a_field->Trace(harvest);
1829  a_field->SetLastTreatment(harvest);
1830  a_field->SetGrowthPhase(harvest1);
1831  // Here we have to do a little skip to avoid too low insect populations after harvest, but a correct veg biomass
1832  a_field->InsectMortality(0.4);
1833  double insects = a_field->GetInsectPop();
1834  a_field->ResetDigestability();
1835  a_field->RecalculateBugsNStuff();
1836  a_field->SetInsectPop(insects);
1838  int pref = a_field->GetUnsprayedMarginPolyRef();
1839  double someseed = 0.0; //No bird seed or maize forage on sugar beet (which is currently (March 2015) the only crop using HarvestLong.
1840  a_field->SetBirdSeed( someseed );
1841  a_field->SetBirdMaize( someseed );
1842  if (pref != -1){
1843  // Must have an unsprayed margin so need to pass the information on to it
1844  LE* um = g_landscape_p->SupplyLEPointer(pref);
1846  um->SetGrowthPhase(harvest1);
1847  um->InsectMortality(0.4);
1849  um->ResetDigestability();
1850  um->RecalculateBugsNStuff();
1851  um->SetBirdSeed( someseed );
1852  um->SetBirdMaize( someseed );
1853  }
1854  return true;
1855  }
1856  return false;
1857 }

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

◆ HayBailing()

bool Farm::HayBailing ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out hay bailing on a_field.

Definition at line 2184 of file farmfuncs.cpp.

2185 {
2186 
2187  if ( (0 >= a_days) ||
2188  ((g_weather->GetRainPeriod(g_date->Date(),5)<0.1) && DoIt(DO_IT_PROB))
2189  ) {
2190  a_field->Trace( hay_bailing );
2191  a_field->SetLastTreatment( hay_bailing );
2193  int pref=a_field->GetUnsprayedMarginPolyRef();
2194  if (pref!=-1){
2195  // Must have an unsprayed margin so need to pass the information on to it
2196  LE* um=g_landscape_p->SupplyLEPointer(pref);
2199  }
2200  return true;
2201  }
2202  return false;
2203 }

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

◆ HayTurning()

bool Farm::HayTurning ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out hay turning on a_field.

Definition at line 2159 of file farmfuncs.cpp.

2160 {
2161 
2162  if ( (0 >= a_days) ||
2163  ((g_weather->GetRainPeriod(g_date->Date(),5)<0.1) && DoIt(DO_IT_PROB))
2164  ) {
2165  a_field->Trace( hay_turning );
2166  a_field->SetLastTreatment( hay_turning );
2168  int pref=a_field->GetUnsprayedMarginPolyRef();
2169  if (pref!=-1){
2170  // Must have an unsprayed margin so need to pass the information on to it
2171  LE* um=g_landscape_p->SupplyLEPointer(pref);
2174  }
2175  return true;
2176  }
2177  return false;
2178 }

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

◆ HeavyCultivatorAggregate()

bool Farm::HeavyCultivatorAggregate ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out a heavy cultivation event on a_field. This is non-inversion type of cultivation which can be done after fertilizers application on spring for a spring crop.

Definition at line 217 of file farmfuncs.cpp.

218 {
219  if ((0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
220  a_field->Trace(heavy_cultivator_aggregate);
222  a_field->InsectMortality(0.1); // The same global mortality as for normal plough
223  a_field->ZeroVeg(); // Zero veg as with stubble harrowing
224  int pref = a_field->GetUnsprayedMarginPolyRef();
225  if (pref != -1) {
226  // Must have an unsprayed margin so need to pass the information on to it
227  LE* um = g_landscape_p->SupplyLEPointer(pref);
229  um->InsectMortality(0.1);
230  um->ZeroVeg();
231  }
232  return true; // completed
233  }
234  return false; // not completed
235 }

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

◆ HerbicideTreat()

bool Farm::HerbicideTreat ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply herbicide to a_field.

Reimplemented in OptimisingFarm.

Definition at line 1156 of file farmfuncs.cpp.

1157 {
1158 
1159  if (0 >= a_days) // Must do this
1160  {
1161  if (((a_field->GetSignal() & LE_SIG_NO_HERBICIDE)==0 ))
1162  {
1163  a_field->Trace( herbicide_treat );
1164  a_field->SetLastTreatment( herbicide_treat );
1165  if ( l_farm_herbicide_kills.value())
1166  {
1167  a_field->ReduceWeedBiomass( 0.05 );
1168  }
1172 
1173  }
1174  return true;
1175  }
1176  else if ((g_weather->GetWind()<4.5) && (!g_weather->Raining()) && DoIt(DO_IT_PROB))
1177  {
1178  if ( !(a_field->GetSignal() & LE_SIG_NO_HERBICIDE) )
1179  {
1180  a_field->Trace( herbicide_treat );
1181  a_field->SetLastTreatment( herbicide_treat );
1182  if ( l_farm_herbicide_kills.value())
1183  {
1184  a_field->ReduceWeedBiomass( 0.05 );
1185  }
1189  }
1190  return true;
1191  }
1192  return false;
1193 }

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

◆ HillingUp()

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 1663 of file farmfuncs.cpp.

1664 {
1665 
1666  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
1667  a_field->Trace( hilling_up );
1668  a_field->SetLastTreatment( hilling_up );
1669  a_field->InsectMortality( 0.75 );
1670  a_field->ReduceWeedBiomass( 0.25 );
1672  int pref=a_field->GetUnsprayedMarginPolyRef();
1673  if (pref!=-1){
1674  // Must have an unsprayed margin so need to pass the information on to it
1675  LE* um=g_landscape_p->SupplyLEPointer(pref);
1677  um->ReduceWeedBiomass( 0.25 );
1678  um->InsectMortality( 0.75 );
1680  }
1681  return true;
1682  }
1683  return false;
1684 }

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

◆ InitiateManagement()

void Farm::InitiateManagement ( void  )
virtual

Kicks off the farm's management.

Reimplemented in OptimisingFarm, and UserDefinedFarm.

Definition at line 1514 of file farm.cpp.

1514  {
1515  for ( unsigned int i = 0; i < m_fields.size(); i++ ) {
1516  int rot_index = m_fields[ i ]->GetRotIndex();
1518  // If the field has been designated as non-rotating and therefore already has its veg type, then skip it.
1519  if ( rot_index < -1 ) {
1520  // Check for any type of permanent element type with management plan.
1521  TTypesOfLandscapeElement ele = m_fields[ i ]->GetElementType();
1522  switch (ele) {
1524  new_veg = tov_PermanentGrassLowYield;
1525  break;
1526  case tole_YoungForest:
1527  new_veg = tov_YoungForest;
1528  break;
1529  case tole_PermPasture:
1530  new_veg = tov_PermanentGrassGrazed;
1531  break;
1533  new_veg = tov_PermanentGrassTussocky;
1534  break;
1536  new_veg = tov_PermanentSetaside;
1537  break;
1538  case tole_Orchard:
1539  new_veg = tov_OrchardCrop;
1540  break;
1541  case tole_PlantNursery:
1542  new_veg = tov_PlantNursery;
1543  break;
1544  default:
1545  if (rot_index != -4) {
1546  // Error
1547  g_msg->Warn("Unexpected negative value in Farm::InitiateManagement","");
1548  exit(0);
1549  }
1550  else
1551  {
1552  new_veg = m_fields[i]->GetVegType();
1553  }
1554  }
1555  }
1556  else {
1557  rot_index = GetFirstCropIndex( m_fields[ i ]->GetElementType() );
1558  new_veg = m_rotation[ rot_index ];
1559  }
1560  // Running in fixed crop mode?
1561  if ( g_farm_fixed_crop_enable.value() ) {
1562  int fv = g_farm_fixed_crop_type.value();
1563  new_veg = g_letype->TranslateVegTypes( fv );
1564  }
1565  m_fields[ i ]->SetVegType( new_veg, tov_Undefined );
1566  m_fields[ i ]->SetRotIndex( rot_index );
1567  m_fields[ i ]->SetGrowthPhase( janfirst );
1568  // Reset event timeout counter. We are now 800 days from
1569  // oblivion.
1570  long prog_start_date = g_date->Date();
1571  m_fields[ i ]->SetVegStore( 0 );
1572  TTypesOfVegetation l_tov = new_veg;
1573  int l_nextcropstartdate = GetNextCropStartDate( m_fields[ i ], l_tov );
1574  AddNewEvent( new_veg, prog_start_date, m_fields[ i ], PROG_START, 0, false, l_nextcropstartdate, true, l_tov );
1575  }
1576 }

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_PlantNursery, tole_YoungForest, tov_OrchardCrop, tov_PermanentGrassGrazed, tov_PermanentGrassLowYield, tov_PermanentGrassTussocky, tov_PermanentSetaside, tov_PlantNursery, tov_Undefined, tov_YoungForest, LE_TypeClass::TranslateVegTypes(), CfgInt::value(), CfgBool::value(), and MapErrorMsg::Warn().

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

◆ InsecticideTreat()

bool Farm::InsecticideTreat ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply insecticide to a_field.

Reimplemented in OptimisingFarm.

Definition at line 1348 of file farmfuncs.cpp.

1349 {
1350 
1351  if (0 >= a_days)
1352  {
1353  if (( ! (a_field->GetSignal() & LE_SIG_NO_INSECTICIDE) ))
1354  {
1355  // **CJT** Turn this code on to use the pesticide engine with insecticides
1356  // g_pest->DailyQueueAdd( a_field, l_pest_insecticide_amount.value());
1357  //
1358  a_field->Trace( insecticide_treat );
1359  a_field->SetLastTreatment( insecticide_treat );
1361  {
1362  a_field->Insecticide( 0.36 );
1363  }
1366  }
1367  return true;
1368  }
1369  else if ( (g_weather->GetWind()<4.5) &&
1370  (!g_weather->Raining()) && DoIt(DO_IT_PROB)) {
1371  if ( ! (a_field->GetSignal() & LE_SIG_NO_INSECTICIDE )) {
1372 // **CJT** Turn this code on to use the pesticide engine with insecticides
1373 // g_pest->DailyQueueAdd( a_field, l_pest_insecticide_amount.value());
1374 //
1375  a_field->Trace( insecticide_treat );
1376  a_field->SetLastTreatment( insecticide_treat );
1378  a_field->Insecticide( 0.36 );
1379  }
1382  }
1383  return true;
1384  }
1385  return false;
1386 }

References Landscape::CheckForPesticideRecord(), DO_IT_PROB, EL_TRAMLINE_DECAYTIME, g_landscape_p, g_weather, Weather::GetWind(), insecticide, LE::Insecticide(), insecticide_treat, l_farm_insecticide_kills, LE_SIG_NO_INSECTICIDE, Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), and CfgBool::value().

◆ InvIntPartition()

int Farm::InvIntPartition ( vector< tpct > *  items,
int  target 
)
protected

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

Definition at line 2493 of file farm.cpp.

2493  {
2494  //Figure out how many bitmasks we need...
2495  //4 bits have a maximum value of 15, so we need 15 masks.
2496  //Calculated as:
2497  // (2 ^ ItemCount) - 1
2498  long long int sz = (long long int) items->size();
2499  if (sz>80) {
2500  // This is a warning that we did no consider all combinations of fields but 2^63 combinations should be enough :)
2501  g_msg->Warn("Too many potential fields in UserDefinedFarm::InvIntPartition: ",sz);
2502  g_msg->Warn("Farm Number: ",GetFarmNumber());
2503  sz = 63;
2504  }
2505  long int calcs = (1 << sz);
2506  //Spit out the corresponding calculation for each bitmask
2507  int sum;
2508  int found = 0;
2509  int diff = 100;
2510  for (long int i=1; i<calcs; i++) {
2511  //Get the items from our array that correspond to
2512  //the on bits in our mask
2513  sum = 0;
2514  int mask = 1;
2515  for (int bit=0; bit<sz; bit++) {
2516  if ((i & mask) > 0) {
2517  sum+=(*items)[bit].pct;
2518  }
2519  mask = mask << 1;
2520  }
2521 
2522  if (abs(sum-target) < diff ){
2523  found = i;
2524  diff = abs(sum-target);
2525  if (diff<1) break; //added 01.11.12 to prevent from checking all the combinations when the right one is found
2526  }
2527  }
2528  return found;
2529 }

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

Referenced by AssignPermanentCrop().

◆ IsStockFarmer()

bool Farm::IsStockFarmer ( void  )
inline

Definition at line 905 of file farm.h.

905 { return m_stockfarmer; }

References m_stockfarmer.

◆ LeSwitch()

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 386 of file farm.cpp.

386  {
387  // Ignore this event if it is from the execution of
388  // a previous management plan.
389  if (ev->m_field->GetRunNum() > ev->m_run)
390  return false;
391  // Store what we are trying to do this time.
392  // ***FN*** To be cleaned up later.
393  ev->m_field->m_tried_to_do = ev->m_todo;
394  bool done;
395 
396  switch (ev->m_event) {
397  case tov_Carrots:
398  done = m_carrots->Do( this, ev->m_field, ev );
399  break;
400  case tov_BroadBeans:
401  done = m_broadbeans->Do( this, ev->m_field, ev );
402  break;
403  case tov_FodderGrass:
404  done = m_foddergrass->Do( this, ev->m_field, ev );
405  break;
407  done = m_CGG1->Do( this, ev->m_field, ev );
408  break;
410  done = m_CGG2->Do( this, ev->m_field, ev );
411  break;
412  case tov_FieldPeas:
413  done = m_fieldpeas->Do( this, ev->m_field, ev );
414  break;
415  case tov_FieldPeasSilage:
416  done = m_fieldpeassilage->Do( this, ev->m_field, ev );
417  break;
418  case tov_FodderBeet:
419  done = m_fodderbeet->Do( this, ev->m_field, ev );
420  break;
421  case tov_SugarBeet:
422  done = m_sugarbeet->Do( this, ev->m_field, ev );
423  break;
424  case tov_OFodderBeet:
425  done = m_ofodderbeet->Do( this, ev->m_field, ev );
426  break;
427  case tov_Maize:
428  done = m_maize->Do( this, ev->m_field, ev );
429  break;
431  done = m_OBarleyPCG->Do( this, ev->m_field, ev );
432  break;
433  case tov_OCarrots:
434  done = m_ocarrots->Do( this, ev->m_field, ev );
435  break;
437  done = m_OCGS1->Do( this, ev->m_field, ev );
438  break;
440  done = m_OCGG1->Do( this, ev->m_field, ev );
441  break;
443  done = m_OCGG2->Do( this, ev->m_field, ev );
444  break;
445  case tov_OFieldPeas:
446  done = m_ofieldpeas->Do( this, ev->m_field, ev );
447  break;
449  done = m_ofieldpeassilage->Do( this, ev->m_field, ev );
450  break;
451  case tov_OGrazingPigs:
452  done = m_ograzingpigs->Do( this, ev->m_field, ev );
453  break;
454  case tov_OrchardCrop:
455  done = m_orchardcrop->Do( this, ev->m_field, ev );
456  break;
457  case tov_OOats:
458  done = m_ooats->Do( this, ev->m_field, ev );
459  break;
460  case tov_Oats:
461  done = m_oats->Do( this, ev->m_field, ev );
462  break;
464  done = m_opermgrassgrazed->Do( this, ev->m_field, ev );
465  break;
466  case tov_OPotatoes:
467  done = m_opotatoes->Do( this, ev->m_field, ev );
468  break;
469  case tov_OSpringBarley:
470  done = m_ospringbarley->Do( this, ev->m_field, ev );
471  break;
472  case tov_OSBarleySilage:
473  done = m_osbarleysilage->Do( this, ev->m_field, ev );
474  break;
475  case tov_OSeedGrass1:
476  done = m_oseedgrass1->Do( this, ev->m_field, ev );
477  break;
478  case tov_OSeedGrass2:
479  done = m_oseedgrass2->Do( this, ev->m_field, ev );
480  break;
482  done = m_ospringbarleyext->Do( this, ev->m_field, ev );
483  break;
485  done = m_ospringbarleypigs->Do( this, ev->m_field, ev );
486  break;
487  case tov_OWinterBarley:
488  done = m_owinterbarley->Do( this, ev->m_field, ev );
489  break;
491  done = m_owinterbarleyext->Do( this, ev->m_field, ev );
492  break;
494  done = m_owinterwheatundersown->Do( this, ev->m_field, ev );
495  break;
496  case tov_OWinterWheat:
497  done = m_owinterwheat->Do( this, ev->m_field, ev );
498  break;
500  done = m_owinterwheatundersownext->Do( this, ev->m_field, ev );
501  break;
502  case tov_OWinterRape:
503  done = m_owinterrape->Do( this, ev->m_field, ev );
504  break;
505  case tov_OWinterRye:
506  done = m_owinterrye->Do( this, ev->m_field, ev );
507  break;
509  done = m_permgrassgrazed->Do( this, ev->m_field, ev );
510  break;
512  done = m_permgrasslowyield->Do( this, ev->m_field, ev );
513  break;
515  done = m_permgrasstussocky->Do( this, ev->m_field, ev );
516  break;
518  done = m_permanentsetaside->Do( this, ev->m_field, ev );
519  break;
520  case tov_Potatoes:
521  done = m_potatoes->Do( this, ev->m_field, ev );
522  break;
524  done = m_potatoesindustry->Do( this, ev->m_field, ev );
525  break;
526  case tov_SeedGrass1:
527  done = m_seedgrass1->Do( this, ev->m_field, ev );
528  break;
529  case tov_SeedGrass2:
530  done = m_seedgrass2->Do( this, ev->m_field, ev );
531  break;
532  case tov_Setaside:
533  done = m_setaside->Do( this, ev->m_field, ev );
534  break;
535  case tov_SpringBarley:
536  done = m_springbarley->Do( this, ev->m_field, ev );
537  break;
538  case tov_SpringBarleySpr:
539  done = m_springbarleyspr->Do( this, ev->m_field, ev );
540  break;
542  done = m_springbarleyptreatment->Do( this, ev->m_field, ev );
543  break;
545  done = m_springbarleyskmanagement->Do( this, ev->m_field, ev );
546  break;
548  done = m_sbarleyclovergrass->Do( this, ev->m_field, ev );
549  break;
551  done = m_springbarleyseed->Do( this, ev->m_field, ev );
552  break;
554  done = m_springbarleysilage->Do( this, ev->m_field, ev );
555  break;
556  case tov_SpringRape:
557  done = m_springrape->Do( this, ev->m_field, ev );
558  break;
559  case tov_Triticale:
560  done = m_triticale->Do( this, ev->m_field, ev );
561  break;
562  case tov_OTriticale:
563  done = m_otriticale->Do( this, ev->m_field, ev );
564  break;
565  case tov_WinterBarley:
566  done = m_winterbarley->Do( this, ev->m_field, ev );
567  break;
568  case tov_WinterRape:
569  done = m_winterrape->Do( this, ev->m_field, ev );
570  break;
571  case tov_WinterRye:
572  done = m_winterrye->Do( this, ev->m_field, ev );
573  break;
574  case tov_WinterWheat:
575  done = m_winterwheat->Do( this, ev->m_field, ev );
576  break;
577  case tov_WWheatPControl:
578  done = m_wwheatpcontrol->Do( this, ev->m_field, ev );
579  break;
581  done = m_wwheatptoxiccontrol->Do( this, ev->m_field, ev );
582  break;
584  done = m_wwheatptreatment->Do( this, ev->m_field, ev );
585  break;
587  done = m_agrochemindustrycereal->Do( this, ev->m_field, ev );
588  break;
590  done = m_winterwheatstrigling->Do( this, ev->m_field, ev );
591  break;
593  done = m_winterwheatstriglingsingle->Do( this, ev->m_field, ev );
594  break;
596  done = m_winterwheatstriglingculm->Do( this, ev->m_field, ev );
597  break;
599  done = m_springbarleyclovergrassstrigling->Do( this, ev->m_field, ev );
600  break;
602  done = m_springbarleystrigling->Do( this, ev->m_field, ev );
603  break;
605  done = m_springbarleystriglingsingle->Do( this, ev->m_field, ev );
606  break;
608  done = m_springbarleystriglingculm->Do( this, ev->m_field, ev );
609  break;
610  case tov_MaizeStrigling:
611  done = m_maizestrigling->Do( this, ev->m_field, ev );
612  break;
613  case tov_MaizeSilage:
614  done = m_maizesilage->Do( this, ev->m_field, ev );
615  break;
616  case tov_OMaizeSilage:
617  done = m_omaizesilage->Do( this, ev->m_field, ev );
618  break;
620  done = m_winterrapestrigling->Do( this, ev->m_field, ev );
621  break;
623  done = m_winterryestrigling->Do( this, ev->m_field, ev );
624  break;
626  done = m_winterbarleystrigling->Do( this, ev->m_field, ev );
627  break;
629  done = m_fieldpeasstrigling->Do( this, ev->m_field, ev );
630  break;
632  done = m_springbarleypeaclovergrassstrigling->Do( this, ev->m_field, ev );
633  break;
634  case tov_PlantNursery:
635  // uses youngforest management because this effectively does nothing, but stops the crop management creating looping error
636  case tov_YoungForest:
637  done = m_youngforest->Do(this, ev->m_field, ev);
638  break;
640  done = m_norwegianpotatoes->Do(this, ev->m_field, ev);
641  break;
642  case tov_NorwegianOats:
643  done = m_norwegianoats->Do(this, ev->m_field, ev);
644  break;
646  done = m_norwegianspringbarley->Do(this, ev->m_field, ev);
647  break;
648 
649  case tov_PLWinterWheat:
650  done = m_plwinterwheat->Do(this, ev->m_field, ev);
651  break;
652  case tov_PLWinterRape:
653  done = m_plwinterrape->Do(this, ev->m_field, ev);
654  break;
655  case tov_PLWinterBarley:
656  done = m_plwinterbarley->Do(this, ev->m_field, ev);
657  break;
659  done = m_plwintertriticale->Do(this, ev->m_field, ev);
660  break;
661  case tov_PLWinterRye:
662  done = m_plwinterrye->Do(this, ev->m_field, ev);
663  break;
664  case tov_PLSpringWheat:
665  done = m_plspringwheat->Do(this, ev->m_field, ev);
666  break;
667  case tov_PLSpringBarley:
668  done = m_plspringbarley->Do(this, ev->m_field, ev);
669  break;
670  case tov_PLMaize:
671  done = m_plmaize->Do(this, ev->m_field, ev);
672  break;
673  case tov_PLMaizeSilage:
674  done = m_plmaizesilage->Do(this, ev->m_field, ev);
675  break;
676  case tov_PLPotatoes:
677  done = m_plpotatoes->Do(this, ev->m_field, ev);
678  break;
679  case tov_PLBeet:
680  done = m_plbeet->Do(this, ev->m_field, ev);
681  break;
683  done = m_plfodderlucerne1->Do(this, ev->m_field, ev);
684  break;
686  done = m_plfodderlucerne2->Do(this, ev->m_field, ev);
687  break;
688  case tov_PLCarrots:
689  done = m_plcarrots->Do(this, ev->m_field, ev);
690  break;
692  done = m_plspringbarleyspr->Do(this, ev->m_field, ev);
693  break;
695  done = m_plwinterwheatlate->Do(this, ev->m_field, ev);
696  break;
697  case tov_PLBeetSpr:
698  done = m_plbeetspr->Do(this, ev->m_field, ev);
699  break;
700  case tov_PLBeans:
701  done = m_plbeans->Do(this, ev->m_field, ev);
702  break;
703 
704  case tov_NLBeet:
705  done = m_nlbeet->Do(this, ev->m_field, ev);
706  break;
707  case tov_NLCarrots:
708  done = m_nlcarrots->Do(this, ev->m_field, ev);
709  break;
710  case tov_NLMaize:
711  done = m_nlmaize->Do(this, ev->m_field, ev);
712  break;
713  case tov_NLPotatoes:
714  done = m_nlpotatoes->Do(this, ev->m_field, ev);
715  break;
716  case tov_NLSpringBarley:
717  done = m_nlspringbarley->Do(this, ev->m_field, ev);
718  break;
719  case tov_NLWinterWheat:
720  done = m_nlwinterwheat->Do(this, ev->m_field, ev);
721  break;
722  case tov_NLCabbage:
723  done = m_nlcabbage->Do(this, ev->m_field, ev);
724  break;
725  case tov_NLTulips:
726  done = m_nltulips->Do(this, ev->m_field, ev);
727  break;
728  case tov_NLGrassGrazed1:
729  done = m_nlgrassgrazed1->Do(this, ev->m_field, ev);
730  break;
732  done = m_nlgrassgrazed1spring->Do(this, ev->m_field, ev);
733  break;
734  case tov_NLGrassGrazed2:
735  done = m_nlgrassgrazed2->Do(this, ev->m_field, ev);
736  break;
738  done = m_nlgrassgrazedlast->Do(this, ev->m_field, ev);
739  break;
741  done = m_nlpermanentgrassgrazed->Do(this, ev->m_field, ev);
742  break;
743  case tov_NLBeetSpring:
744  done = m_nlbeetspring->Do(this, ev->m_field, ev);
745  break;
746  case tov_NLCarrotsSpring:
747  done = m_nlcarrotsspring->Do(this, ev->m_field, ev);
748  break;
749  case tov_NLMaizeSpring:
750  done = m_nlmaizespring->Do(this, ev->m_field, ev);
751  break;
753  done = m_nlpotatoesspring->Do(this, ev->m_field, ev);
754  break;
756  done = m_nlspringbarleyspring->Do(this, ev->m_field, ev);
757  break;
758  case tov_NLCabbageSpring:
759  done = m_nlcabbagespring->Do(this, ev->m_field, ev);
760  break;
761  case tov_NLCatchPeaCrop:
762  done = m_nlcatchpeacrop->Do(this, ev->m_field, ev);
763  break;
764 
766  done = m_dummycroppesttesting->Do(this, ev->m_field, ev);
767  break;
768 
769  case tov_Lawn:
770  // No current actions
771  done = true;
772  break;
773  /* case tov_OFirstYearDanger: done = m_ofirstyeardanger->Do( this, ev->m_field, ev ); break; */
774  default:
775  char veg_type[ 20 ];
776  sprintf( veg_type, "%d", ev->m_event );
777  g_msg->Warn( WARN_FILE, "Farm::LeSwitch(): ""Unknown crop type: ", veg_type );
778  exit( 1 );
779 
780  }
781  return done;
782 }

References g_msg, 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_DummyCropPestTesting, tov_FieldPeas, tov_FieldPeasSilage, tov_FieldPeasStrigling, tov_FodderBeet, tov_FodderGrass, tov_Lawn, tov_Maize, tov_MaizeSilage, tov_MaizeStrigling, tov_NLBeet, tov_NLBeetSpring, tov_NLCabbage, tov_NLCabbageSpring, tov_NLCarrots, tov_NLCarrotsSpring, tov_NLCatchPeaCrop, tov_NLGrassGrazed1, tov_NLGrassGrazed1Spring, tov_NLGrassGrazed2, tov_NLGrassGrazedLast, tov_NLMaize, tov_NLMaizeSpring, tov_NLPermanentGrassGrazed, tov_NLPotatoes, tov_NLPotatoesSpring, tov_NLSpringBarley, tov_NLSpringBarleySpring, tov_NLTulips, tov_NLWinterWheat, tov_NorwegianOats, tov_NorwegianPotatoes, tov_NorwegianSpringBarley, 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_PlantNursery, tov_PLBeans, tov_PLBeet, tov_PLBeetSpr, tov_PLCarrots, tov_PLFodderLucerne1, tov_PLFodderLucerne2, tov_PLMaize, tov_PLMaizeSilage, tov_PLPotatoes, tov_PLSpringBarley, tov_PLSpringBarleySpr, tov_PLSpringWheat, tov_PLWinterBarley, tov_PLWinterRape, tov_PLWinterRye, tov_PLWinterTriticale, tov_PLWinterWheat, tov_PLWinterWheatLate, 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.

◆ ListOpenFields()

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 9399 of file farm.cpp.

9400 {
9401  polylist* p_list = new polylist;
9402  int nf = (int) m_fields.size();
9403  for ( int i = 0; i < nf; i++ )
9404  {
9405  if ( m_fields[ i ]->GetOpenness() >= a_openness )
9406  {
9407  p_list->push_back( m_fields[i]->GetPoly());
9408  }
9409  }
9410  return p_list;
9411 }

References m_fields.

◆ MakeStockFarmer()

virtual void Farm::MakeStockFarmer ( void  )
inlinevirtual

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

Definition at line 906 of file farm.h.

906 { m_stockfarmer = true; }

References m_stockfarmer.

◆ Management()

void Farm::Management ( void  )
virtual

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

Definition at line 361 of file farm.cpp.

361  {
362  HandleEvents();
363  for ( unsigned int i = 0; i < m_fields.size(); i++ ) {
364  // Check for infinite loop in management plan.
365  int count = m_fields[ i ]->GetVegStore();
366  if ( count >= 0 )
367  m_fields[ i ]->SetVegStore( ++count );
368  if ( count > 800 ) {
369  // More than two years where nothing happened.
370  // Raise 'Merry Christmas'!
371  char error_num[ 20 ];
372  sprintf( error_num, "%d", m_fields[ i ]->GetVegType() );
373  g_msg->Warn( WARN_BUG, "I the Farm Manager caught infinite loop in tov type:", error_num );
374  sprintf( error_num, "%d", m_fields[ i ]->m_tried_to_do );
375  g_msg->Warn( WARN_BUG, "It was last seen trying to perform action # ""(or thereabouts):", error_num );
376  exit( 1 );
377  }
378  }
379 }

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

◆ Molluscicide()

bool Farm::Molluscicide ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply molluscidie to a_field.

Definition at line 1481 of file farmfuncs.cpp.

1482 {
1483 
1484  if (0 >= a_days) {
1485  if ( (!g_weather->Raining()) && (g_weather->GetWind()<4.5) &&
1486  (! (a_field->GetSignal() & LE_SIG_NO_MOLLUSC ))) {
1487  a_field->Trace( molluscicide );
1488  a_field->SetLastTreatment( molluscicide );
1491  }
1492  return true;
1493  }
1494  else if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
1495  if ( ! (a_field->GetSignal() & LE_SIG_NO_MOLLUSC) ) {
1496  a_field->Trace( molluscicide );
1497  a_field->SetLastTreatment( molluscicide );
1500  }
1501  return true;
1502  }
1503  return false;
1504 }

References Landscape::CheckForPesticideRecord(), DO_IT_PROB, EL_TRAMLINE_DECAYTIME, g_landscape_p, g_weather, Weather::GetWind(), insecticide, LE_SIG_NO_MOLLUSC, molluscicide, Weather::Raining(), LE::SetLastTreatment(), and LE::SetTramlinesDecay().

◆ PigsAreOut()

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 2112 of file farmfuncs.cpp.

2113 {
2114 
2115  if ( (0 >= a_days)|| DoIt(50/a_days)) {
2116  a_field->TogglePigGrazing();
2117  int pref=a_field->GetUnsprayedMarginPolyRef();
2118  if (pref!=-1){
2119  // Must have an unsprayed margin so need to pass the information on to it
2120  LE* um=g_landscape_p->SupplyLEPointer(pref);
2121  um->TogglePigGrazing();
2122  }
2123  return true;
2124  }
2125  return false;
2126 }

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

◆ PigsAreOutForced()

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 2090 of file farmfuncs.cpp.

2091 {
2092  a_field->SetLastTreatment( pigs_out );
2093  a_field->Trace( pigs_out );
2094  // Reduce the vegetation because of grazing
2096  // make this a function of grazing pressure
2097  //and field size - perhaps in a later life
2098  int pref=a_field->GetUnsprayedMarginPolyRef();
2099  if (pref!=-1){
2100  // Must have an unsprayed margin so need to pass the information on to it
2101  LE* um=g_landscape_p->SupplyLEPointer(pref);
2102  um->SetLastTreatment( pigs_out );
2104  }
2105  return false;
2106 }

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

◆ PigsOut()

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 2062 of file farmfuncs.cpp.

2063 {
2064 
2065  if ( (0 >= a_days)|| DoIt(DO_IT_PROB))
2066  {
2067  a_field->TogglePigGrazing();
2068  a_field->Trace( pigs_out );
2069  a_field->SetLastTreatment( pigs_out );
2070  // Reduce the vegetation because of grazing
2072  // make this a function of grazing pressure
2073  //and field size - perhaps in a later life
2074  int pref=a_field->GetUnsprayedMarginPolyRef();
2075  if (pref!=-1){
2076  // Must have an unsprayed margin so need to pass the information on to it
2077  LE* um=g_landscape_p->SupplyLEPointer(pref);
2078  um->SetLastTreatment( pigs_out );
2080  }
2081  return true;
2082  }
2083  return false;
2084 }

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

◆ PreseedingCultivator()

bool Farm::PreseedingCultivator ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out preseeding cultivation on a_field (tilling set including cultivator and string roller to compact soil)

Definition at line 311 of file farmfuncs.cpp.

312 {
313  if ((0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
314  a_field->Trace(preseeding_cultivator);
316  // Apply 90% mortality to the insects as for harrowing
317  a_field->InsectMortality(0.1);
318  // Reduce the vegetation to zero as for harrowing
319  a_field->ZeroVeg();
320  int pref = a_field->GetUnsprayedMarginPolyRef();
321  if (pref != -1) {
322  // Must have an unsprayed margin so need to pass the information on to it
323  LE* um = g_landscape_p->SupplyLEPointer(pref);
325  um->InsectMortality(0.1);
326  um->ZeroVeg();
327  }
328  return true;
329  }
330  return false;
331 }

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

◆ PreseedingCultivatorSow()

bool Farm::PreseedingCultivatorSow ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out preseeding cultivation together with sow on a_field (tilling and sowing set including cultivator and string roller to compact soil)

Definition at line 337 of file farmfuncs.cpp.

338 {
339  if ((0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
340  a_field->Trace(preseeding_cultivator_sow);
342  a_field->SetGrowthPhase(sow); // as with AutumnSow treatment
343  a_field->SetLastSownVeg(a_field->GetVegType()); // as with AutumnSow treatment
344  // Reduce the vegetation to zero
345  a_field->ZeroVeg();
346  int pref = a_field->GetUnsprayedMarginPolyRef();
347  if (pref != -1) {
348  // Must have an unsprayed margin so need to pass the information on to it
349  LE* um = g_landscape_p->SupplyLEPointer(pref);
351  um->SetGrowthPhase(sow);
352  um->ZeroVeg();
353  um->SetLastSownVeg(um->GetVegType());
354  }
355  return true;
356  }
357  return false;
358 }

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

◆ Prob_multiplier()

virtual double Farm::Prob_multiplier ( )
inlinevirtual

Reimplemented in OptimisingFarm.

Definition at line 786 of file farm.h.

786 {return 1;};

◆ ProductApplication()

bool Farm::ProductApplication ( LE a_field,
double  a_user,
int  a_days,
double  a_applicationrate,
PlantProtectionProducts  a_ppp 
)
virtual

Apply test pesticide to a_field.

Definition at line 1445 of file farmfuncs.cpp.

1446 {
1447  // NOTE Differs from normal pesticide in that it will be done on the last
1448  // day if not managed before
1449  if (0 >= a_days) {
1450  a_field->Trace(product_treat);
1451  a_field->SetLastTreatment(product_treat);
1453  {
1455  }
1458  g_pest->DailyQueueAdd(a_field, a_applicationrate, a_ppp);
1459  return true;
1460  }
1461  else {
1462  if ((!g_weather->Raining()) && (g_weather->GetWind() < 4.5)) {
1463  a_field->Trace(product_treat);
1464  a_field->SetLastTreatment(product_treat);
1467  }
1470  g_pest->DailyQueueAdd(a_field, a_applicationrate, a_ppp);
1471  return true;
1472  }
1473  }
1474  return false;
1475 }

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

◆ ProductApplication_DateLimited()

bool Farm::ProductApplication_DateLimited ( LE a_field,
double  ,
int  ,
double  a_applicationrate,
PlantProtectionProducts  a_ppp 
)
virtual

Special pesticide trial functionality.

This methods tests for date limitations

Definition at line 2396 of file farmfuncs.cpp.

2397 {
2399  int year = g_landscape_p->SupplyYearNumber();
2400  if (year < cfg_productapplicstartyear.value()) return false;
2401  if (year > cfg_productapplicendyear.value()) return false;
2402  a_field->Trace(trial_insecticidetreat); // Debug function only
2404  a_field->InsectMortality(cfg_CustomInsecticideKillProp.value()); // Change this manually if it is really a herbicide
2406  a_field->SetSprayedToday(true);
2407  g_pest->DailyQueueAdd(a_field, a_applicationrate, a_ppp);
2408  return true;
2409 }

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

◆ ReadRotation()

void Farm::ReadRotation ( std::string  fname)
protected

◆ RemoveField()

void Farm::RemoveField ( LE a_field)

Removes a field from a farm.

Definition at line 1473 of file farm.cpp.

1473  {
1474  int nf = (int) m_fields.size();
1475  for ( int i = 0; i < nf; i++ ) {
1476  if ( m_fields[ i ] == a_field ) {
1477  m_fields.erase( m_fields.begin() + i );
1478  return;
1479  }
1480  }
1481  // If we reach here there is something wrong because the field is not a
1482  // member of this farm
1483  g_msg->Warn( WARN_BUG, "Farm::RemoveField(LE* a_field): ""Unknown field! ", "" );
1484  exit( 1 );
1485 }

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

◆ RemoveHunter()

void Farm::RemoveHunter ( Hunter *  a_hunter)
inline

Definition at line 925 of file farm.h.

925  {
926  for (int h = 0; h < m_HuntersList.size(); h++) {
927  if (m_HuntersList[ h ] == a_hunter) {
928  m_HuntersList.erase( m_HuntersList.begin() + h );
929  }
930  }
931  }

References m_HuntersList.

◆ RowCultivation()

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 1510 of file farmfuncs.cpp.

1511 {
1512 
1513  if ( (0 >= a_days) && (g_weather->GetRainPeriod(g_date->Date(),3)<0.1) )
1514  {
1515  // Too much rain, just give up and claim we did it.
1516  return true;
1517  }
1518 
1519  if ( (0 >= a_days) ||
1520  ((g_weather->GetRainPeriod(g_date->Date(),3)<0.1) && DoIt(DO_IT_PROB))
1521  ) {
1522  a_field->Trace( row_cultivation );
1523  a_field->SetLastTreatment( row_cultivation );
1524  a_field->ReduceWeedBiomass( 0.5 );
1525  a_field->InsectMortality( 0.25 );
1527  int pref=a_field->GetUnsprayedMarginPolyRef();
1528  if (pref!=-1){
1529  // Must have an unsprayed margin so need to pass the information on to it
1530  LE* um=g_landscape_p->SupplyLEPointer(pref);
1532  um->InsectMortality( 0.25 );
1533  um->ReduceWeedBiomass( 0.5 );
1535  }
1536  return true;
1537  }
1538  return false;
1539 }

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

◆ SetFarmNumber()

void Farm::SetFarmNumber ( int  a_farm_num)
inline

Definition at line 781 of file farm.h.

781 { m_farm_num = a_farm_num; }

References m_farm_num.

◆ ShallowHarrow()

bool Farm::ShallowHarrow ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out a shallow harrow event on a_field, e.g., after grass cutting event.

Definition at line 498 of file farmfuncs.cpp.

499 {
500 
501  if ((0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
502  a_field->Trace(shallow_harrow);
504  // 30% insect mortality
505  a_field->InsectMortality(0.7);
506  // remove vegetation partly
507  a_field->ReduceVeg(0.8);
508  int pref = a_field->GetUnsprayedMarginPolyRef();
509  if (pref != -1) {
510  // Must have an unsprayed margin so need to pass the information on to it
511  LE* um = g_landscape_p->SupplyLEPointer(pref);
513  um->InsectMortality(0.7);
514  um->ReduceVeg(0.8);
515  }
516  return true;
517  }
518  return false;
519 }

References DO_IT_PROB, g_landscape_p, g_weather, LE::GetUnsprayedMarginPolyRef(), LE::InsectMortality(), Weather::Raining(), LE::ReduceVeg(), LE::SetLastTreatment(), shallow_harrow, and Landscape::SupplyLEPointer().

◆ SleepAllDay()

bool Farm::SleepAllDay ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Nothing to to today on a_field.

Definition at line 241 of file farmfuncs.cpp.

242 {
243  if (0 >= a_days) {
244  a_field->Trace(sleep_all_day);
246  int pref = a_field->GetUnsprayedMarginPolyRef();
247  if (pref != -1) {
248  // Must have an unsprayed margin so need to pass the information on to it
249  LE* um = g_landscape_p->SupplyLEPointer(pref);
251  }
252  return true;
253  }
254  return false;
255 }

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

◆ Spraying_fungins()

virtual bool Farm::Spraying_fungins ( TTypesOfVegetation  )
inlinevirtual

Reimplemented in OptimisingFarm.

Definition at line 785 of file farm.h.

785 {return true; };

◆ Spraying_herbicides()

virtual bool Farm::Spraying_herbicides ( TTypesOfVegetation  )
inlinevirtual

Reimplemented in OptimisingFarm.

Definition at line 784 of file farm.h.

784 {return true; };

◆ SpringHarrow()

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 471 of file farmfuncs.cpp.

472 {
473 
474  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
475  a_field->Trace( spring_harrow );
476  a_field->SetLastTreatment( spring_harrow );
477  // 30% insect mortality
478  a_field->InsectMortality( 0.7 );
479  // remove all vegetation
480  a_field->ZeroVeg();
481  int pref=a_field->GetUnsprayedMarginPolyRef();
482  if (pref!=-1){
483  // Must have an unsprayed margin so need to pass the information on to it
484  LE* um=g_landscape_p->SupplyLEPointer(pref);
486  um->InsectMortality( 0.7 );
487  um->ZeroVeg();
488  }
489  return true;
490  }
491  return false;
492 }

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

◆ SpringPlough()

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 444 of file farmfuncs.cpp.

445 {
446 
447  if ((a_days <= 0) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
448  a_field->Trace( spring_plough );
449  a_field->SetLastTreatment( spring_plough );
450  // Apply 90% mortality to the insects
451  a_field->InsectMortality( 0.1 );
452  // Reduce the vegetation to zero
453  a_field->ZeroVeg();
454  int pref=a_field->GetUnsprayedMarginPolyRef();
455  if (pref!=-1){
456  // Must have an unsprayed margin so need to pass the information on to it
457  LE* um=g_landscape_p->SupplyLEPointer(pref);
459  um->InsectMortality( 0.1);
460  um->ZeroVeg();
461  }
462  return true;
463  }
464  return false;
465 }

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

◆ SpringRoll()

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 525 of file farmfuncs.cpp.

526 {
527 
528  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
529  a_field->Trace( spring_roll );
530  a_field->SetLastTreatment( spring_roll );
531  int pref=a_field->GetUnsprayedMarginPolyRef();
532  if (pref!=-1){
533  // Must have an unsprayed margin so need to pass the information on to it
534  LE* um=g_landscape_p->SupplyLEPointer(pref);
536  }
537  return true;
538  }
539  return false;
540 }

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

◆ SpringSow()

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 546 of file farmfuncs.cpp.

547 {
548 
549  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
550  a_field->Trace( spring_sow );
551  a_field->SetLastTreatment( spring_sow );
552  a_field->SetGrowthPhase( sow );
553  a_field->SetLastSownVeg(a_field->GetVegType());
554  // Reduce the vegetation to zero - should not strictly be necessary, but prevents any false starts in the crop growth.
555  a_field->ZeroVeg();
556  int pref=a_field->GetUnsprayedMarginPolyRef();
557  if (pref!=-1){
558  // Must have an unsprayed margin so need to pass the information on to it
559  LE* um=g_landscape_p->SupplyLEPointer(pref);
561  um->SetGrowthPhase( sow );
562  um->ZeroVeg();
563  um->SetLastSownVeg(um->GetVegType());
564  }
565  return true;
566  }
567  return false;
568 }

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

◆ SpringSowWithFerti()

bool Farm::SpringSowWithFerti ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out a sowing event with start fertilizer in the spring on a_field.

Definition at line 574 of file farmfuncs.cpp.

575 {
576 
577  if ((0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
578  a_field->Trace(spring_sow_with_ferti);
580  a_field->SetGrowthPhase(sow);
581  a_field->SetLastSownVeg(a_field->GetVegType());
582  // Reduce the vegetation to zero - should not strictly be necessary, but prevents any false starts in the crop growth.
583  a_field->ZeroVeg();
584  int pref = a_field->GetUnsprayedMarginPolyRef();
585  if (pref != -1) {
586  // Must have an unsprayed margin so need to pass the information on to it
587  LE* um = g_landscape_p->SupplyLEPointer(pref);
589  um->SetGrowthPhase(sow);
590  um->ZeroVeg();
591  um->SetLastSownVeg(um->GetVegType());
592  }
593  return true;
594  }
595  return false;
596 }

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

◆ StrawChopping()

bool Farm::StrawChopping ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out straw chopping on a_field.

Definition at line 2132 of file farmfuncs.cpp.

2133 {
2134 
2135  if ( (0 >= a_days) ||
2136  ((g_weather->GetRainPeriod(g_date->Date(),5)<0.1) && DoIt(DO_IT_PROB))
2137  ) {
2138  a_field->Trace( straw_chopping );
2139  a_field->SetLastTreatment( straw_chopping );
2140  a_field->InsectMortality( 0.4 );
2142  int pref=a_field->GetUnsprayedMarginPolyRef();
2143  if (pref!=-1){
2144  // Must have an unsprayed margin so need to pass the information on to it
2145  LE* um=g_landscape_p->SupplyLEPointer(pref);
2147  um->InsectMortality( 0.4 );
2149  }
2150  return true;
2151  }
2152  return false;
2153 }

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

◆ StrawCovering()

bool Farm::StrawCovering ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Straw covering applied on a_field.

Definition at line 2502 of file farmfuncs.cpp.

2503 {
2504  if ((0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
2505  a_field->Trace(straw_covering);
2506  a_field->SetLastTreatment(straw_covering);
2508  int pref = a_field->GetUnsprayedMarginPolyRef();
2509  if (pref != -1) {
2510  // Must have an unsprayed margin so need to pass the information on to it
2511  LE* um = g_landscape_p->SupplyLEPointer(pref);
2514  }
2515  return true;
2516  }
2517  return false;
2518 }

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

◆ StrawRemoval()

bool Farm::StrawRemoval ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Straw covering applied on a_field.

Definition at line 2524 of file farmfuncs.cpp.

2525 {
2526  if ((0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
2527  a_field->Trace(straw_removal);
2528  a_field->SetLastTreatment(straw_removal);
2530  int pref = a_field->GetUnsprayedMarginPolyRef();
2531  if (pref != -1) {
2532  // Must have an unsprayed margin so need to pass the information on to it
2533  LE* um = g_landscape_p->SupplyLEPointer(pref);
2536  }
2537  return true;
2538  }
2539  return false;
2540 }

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

◆ Strigling()

bool Farm::Strigling ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out a mechanical weeding on a_field.

Definition at line 1545 of file farmfuncs.cpp.

1546 {
1547 
1548  // Force strigling if it has not been done already!!! This happens regardless of weather as of 26/10/2005
1549  if ( (0 >= a_days) )// && (g_weather->GetRainPeriod(g_date->Date(),3)>0.1) )
1550  {
1551  a_field->Trace( strigling );
1552  a_field->SetLastTreatment( strigling );
1553  a_field->ReduceWeedBiomass( 0.05 );
1554  a_field->InsectMortality( 0.7 );
1557  int pref=a_field->GetUnsprayedMarginPolyRef();
1558  if (pref!=-1){
1559  // Must have an unsprayed margin so need to pass the information on to it
1560  LE* um=g_landscape_p->SupplyLEPointer(pref);
1561  um->SetLastTreatment( strigling );
1562  um->ReduceWeedBiomass( 0.05 );
1563  um->InsectMortality( 0.7 );
1566  return true;
1567  }
1568  }
1569  if ( (0 >= a_days) ||
1570  ((g_weather->GetRainPeriod(g_date->Date(),3)<0.1) && DoIt(DO_IT_PROB))
1571  ) {
1572  a_field->Trace( strigling );
1573  a_field->SetLastTreatment( strigling );
1574  a_field->ReduceWeedBiomass( 0.05 );
1575  a_field->InsectMortality( 0.7 );
1578  int pref=a_field->GetUnsprayedMarginPolyRef();
1579  if (pref!=-1){
1580  // Must have an unsprayed margin so need to pass the information on to it
1581  LE* um=g_landscape_p->SupplyLEPointer(pref);
1582  um->SetLastTreatment( strigling );
1583  um->ReduceWeedBiomass( 0.05 );
1584  um->InsectMortality( 0.7 );