File failed to load: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/extensions/ams.js
ALMaSS  1.2 (after EcoStack, March 2024)
The Animal, Landscape and Man Simulation System
All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Calendar.h
Go to the documentation of this file.
1 /*
2 *******************************************************************************************************
3 Copyright (c) 2011, Christopher John Topping, Aarhus University
4 All rights reserved.
5 
6 Redistribution and use in source and binary forms, with or without modification, are permitted provided
7 that the following conditions are met:
8 
9 Redistributions of source code must retain the above copyright notice, this list of conditions and the
10 following disclaimer.
11 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
12 the following disclaimer in the documentation and/or other materials provided with the distribution.
13 
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
15 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
17 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
18 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
19 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
21 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 ********************************************************************************************************
23 */
24 
25 
26 #ifndef CALENDAR_H
27 #define CALENDAR_H
28 
29 extern class Calendar *g_date;
30 
31 struct aDate
32 {
33  int year;
34  int month;
35  int day;
36 };
37 
38 class Calendar
39 {
40 public:
41  // Reset to default values, January 1st, 0000.
42  void Reset(void);
43  void Reset2(void);
44 
49  bool TickMinute(void);
50  bool TickMinute10(void);
51  // Resets minute counter to zero.
52  bool TickHour(void);
53 
54  // Advance date by one day. Resets minute and hour counters to zero.
55  void Tick(void);
56 
57  long Date(void) { return m_date; }
58  int DayInYear(void) { return m_day_in_year; }
59  // long DaysInOldYears( void ) { return m_olddays; }
60  long OldDays(void) { return m_olddays; }
61  long GlobalDate(int a_day, int a_month, int a_year);
62 
63  int DayLength(void) { return m_todayslength; }
64  int SunRiseTime(void) { return m_todayssunrise; }
65  int SunSetTime(void) { return m_todayssunset; }
66  int DayLength(int a_day_in_year);
67  int SunRiseTime(int a_day_in_year);
68  int SunSetTime(int a_day_in_year);
69  int GetFirstYear(void) { return m_firstyear; }
70  int GetLastYear(void) { return m_lastyear; }
71  int GetYear(void) { return m_year; }
72  int GetYearNumber(void) { return m_simulationyear; }
73  int GetMonth(void) { return m_month + 1; }
74  int GetMonthRaw(void) { return m_month; }
75  int GetMinute(void) { return m_minutes; }
76  int GetHour(void) { return m_hours; }
77  int GetDayInMonth(void) { return m_day_in_month; }
79  bool JanFirst( void ) { return m_janfirst; }
80  bool MarchFirst( void ) { return m_marchfirst; }
81  void SetFirstYear( int a_year ) { m_firstyear = a_year; }
82  void SetLastYear( int a_year ) { m_lastyear = a_year; }
83  bool ValidDate( int a_day, int a_month );
84  // Check the date with ValidDate() before using DayInYear()
85  // (or suffer the consequences).
86  int DayInYear( int a_day, int a_month );
87 
88  Calendar( void );
89  void CreateDaylength(double latitude, double longitude, int timezone, int year=2021);
90 
91  private:
92  long m_date;
93  long m_olddays;
94  int m_firstyear; // Used for resetting the date.
98  int m_month;
99  int m_year;
104  int m_dawn;
105  int m_dusk;
108  int m_hours;
111 
112  int m_daylength[365];
113  int m_sunrise[365];
114  int m_sunset[365];
115 }; // class Calendar
116 
117 
119 
120 #endif // CALENDAR_H
Calendar::Reset2
void Reset2(void)
Definition: Calendar.cpp:54
Population_Manager_Base::SupplySimHH
int SupplySimHH() const
Returns half the landscape height in m.
Definition: PopulationManager.h:573
toc_None
Definition: LandscapeFarmingEnums.h:925
Calendar::m_marchfirst
bool m_marchfirst
Definition: Calendar.h:110
Calendar::m_hours
int m_hours
Definition: Calendar.h:108
THare_Population_Manager::SetPolyFood
void SetPolyFood(int a_poly, double a_value)
Set polygon food quality.
Definition: Hare_All.h:725
THare::m_vegPalatability
static double * m_vegPalatability
Will hold and array of palatability for hare for each tov type. Most are 1, but unpalatable vegetatio...
Definition: Hare_All.h:318
sunset.h
Calendar::m_daylightproportion
double m_daylightproportion
Definition: Calendar.h:106
Calendar::GetYear
int GetYear(void)
Definition: Calendar.h:71
aDate::month
int month
Definition: Calendar.h:34
aDate::year
int year
Definition: Calendar.h:33
Calendar::TickHour
bool TickHour(void)
Definition: Calendar.cpp:178
Calendar::m_sunrise
int m_sunrise[365]
Definition: Calendar.h:113
THare::GetPegDirection
int GetPegDirection()
Get direction of peg.
Definition: HareForagenPeg.cpp:467
Population_Manager_Base::SupplySimH
int SupplySimH() const
Returns landscape height in m.
Definition: PopulationManager.h:569
THare::m_pesticidedegradationrate
double m_pesticidedegradationrate
State variable used to hold the daily degredation rate of the pesticide in the body.
Definition: Hare_All.h:306
Calendar::SetFirstYear
void SetFirstYear(int a_year)
Definition: Calendar.h:81
Calendar::GetYearNumber
int GetYearNumber(void)
Definition: Calendar.h:72
Calendar::GetHour
int GetHour(void)
Definition: Calendar.h:76
Calendar::CreateDaylength
void CreateDaylength(double latitude, double longitude, int timezone, int year=2021)
Definition: Calendar.cpp:66
THare::m_EnergyMax
double m_EnergyMax
State variable - the amount of energy it is possible to eat as a multiplyer or RMR.
Definition: Hare_All.h:223
g_date
class Calendar * g_date
Definition: Calendar.cpp:37
Calendar::GetMonthRaw
int GetMonthRaw(void)
Definition: Calendar.h:74
SunSet::calcSunrise
double calcSunrise() const
Definition: sunset.cpp:455
Calendar
Definition: Calendar.h:38
Calendar::ValidDate
bool ValidDate(int a_day, int a_month)
Definition: Calendar.cpp:129
__SQRS
#define __SQRS
CreateCalendar
Calendar * CreateCalendar()
Definition: Calendar.cpp:230
CfgFloat::value
double value() const
Definition: Configurator.h:142
cfg_hare_ExtEff
CfgFloat cfg_hare_ExtEff
THare::InternalPesticideHandlingAndResponse
virtual void InternalPesticideHandlingAndResponse()
Handles internal effects of pesticide exposure. If any effects are needed this method must be re-impl...
Definition: HareForagenPeg.cpp:559
Calendar::GetMonth
int GetMonth(void)
Definition: Calendar.h:73
SunSet::setCurrentDate
double setCurrentDate(int, int, int)
Definition: sunset.cpp:508
Calendar::GetDayInMonth
int GetDayInMonth(void)
Definition: Calendar.h:77
Calendar::m_firstyear
int m_firstyear
Definition: Calendar.h:94
Calendar::DayLength
int DayLength(void)
Definition: Calendar.h:63
THare::ForageSquare
double ForageSquare(int a_x, int a_y)
Forage from an area.
Definition: HareForagenPeg.cpp:320
THare::m_OurPopulationManager
THare_Population_Manager * m_OurPopulationManager
Pointer to the hare population manager.
Definition: Hare_All.h:194
SunSet::setPosition
void setPosition(double, double, int)
Definition: sunset.cpp:93
Calendar::m_day_in_year
int m_day_in_year
Definition: Calendar.h:97
Population_Manager_Base::SupplySimWH
int SupplySimWH() const
Returns half the landscape width in m.
Definition: PopulationManager.h:571
Calendar::SetLastYear
void SetLastYear(int a_year)
Definition: Calendar.h:82
THare::Forage
double Forage(int &time)
Foraging.
Definition: HareForagenPeg.cpp:52
THare::GetPegDistance
int GetPegDistance()
Get peg distance.
Definition: HareForagenPeg.cpp:442
Calendar::Tick
void Tick(void)
Definition: Calendar.cpp:191
cfg_hare_pesticide_ingestion_exposure_rate
CfgFloat cfg_hare_pesticide_ingestion_exposure_rate("HARE_PESTICIDE_INGESTION_RATE", CFG_CUSTOM, 0.0)
SunSet::calcSunset
double calcSunset() const
Definition: sunset.cpp:466
Calendar::m_minutes
int m_minutes
Definition: Calendar.h:107
Calendar::GetDaylightProportion
double GetDaylightProportion(void)
Definition: Calendar.h:78
__FSQRS
#define __FSQRS
Definition: HareForagenPeg.cpp:46
g_date
class Calendar * g_date
Definition: Calendar.cpp:37
aDate
Definition: Calendar.h:31
Calendar::m_dawn
int m_dawn
Definition: Calendar.h:104
Calendar::Calendar
Calendar(void)
Definition: Calendar.cpp:61
CreateCalendar
Calendar * CreateCalendar()
Definition: Calendar.cpp:230
Landscape::SupplySimAreaHeight
int SupplySimAreaHeight(void)
Gets the simulation landscape height.
Definition: Landscape.h:2302
Calendar::Date
long Date(void)
Definition: Calendar.h:57
Calendar::Reset
void Reset(void)
Definition: Calendar.cpp:39
Landscape::SupplySimAreaWidth
int SupplySimAreaWidth(void)
Gets the simulation landscape width.
Definition: Landscape.h:2297
TAnimal::m_Location_y
int m_Location_y
The objects ALMaSS y coordinate.
Definition: PopulationManager.h:366
TAnimal::m_OurLandscape
static Landscape * m_OurLandscape
A pointer to the landscape object shared with all TAnimal objects.
Definition: PopulationManager.h:342
THare::Walking
void Walking(int a_dist, int a_direction)
Walking.
Definition: Hare_THare.cpp:176
Calendar::m_todayslength
int m_todayslength
Definition: Calendar.h:101
Calendar::m_olddays
long m_olddays
Definition: Calendar.h:93
activity_Foraging
Definition: Hare_All.h:92
Calendar::GetFirstYear
int GetFirstYear(void)
Definition: Calendar.h:69
Calendar::m_day_in_month
int m_day_in_month
Definition: Calendar.h:96
THare::MovePeg
void MovePeg()
Move the peg according to attraction forces.
Definition: HareForagenPeg.cpp:535
Calendar::OldDays
long OldDays(void)
Definition: Calendar.h:60
cfg_hare_pesticide_contact_exposure_rate
CfgFloat cfg_hare_pesticide_contact_exposure_rate("HARE_PESTICIDE_CONTACT_RATE", CFG_CUSTOM, 0.0)
g_FarmIntensiveness
double g_FarmIntensiveness
Definition: Hare_All.cpp:300
Calendar::GetLastYear
int GetLastYear(void)
Definition: Calendar.h:70
MapErrorMsg::Warn
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: MapErrorMsg.cpp:69
Calendar::SunSetTime
int SunSetTime(void)
Definition: Calendar.h:65
THare::EnergyBalance
void EnergyBalance(TTypeOfActivity a_activity, int dist)
Adjust energy balance for an activity.
Definition: Hare_THare.cpp:261
SunSet
Definition: sunset.h:66
CfgInt::value
int value() const
Definition: Configurator.h:116
Calendar::SunRiseTime
int SunRiseTime(void)
Definition: Calendar.h:64
TTypesOfCrops
TTypesOfCrops
Definition: LandscapeFarmingEnums.h:781
THare::ForageSquareP
double ForageSquareP(int a_x, int a_y, double *a_pestexposure)
Forage from an area and resturn pesticide exposure as well as food.
Definition: HareForagenPeg.cpp:375
THare::m_pesticide_burden
double m_pesticide_burden
State variable used to hold the current body-burden of pesticide.
Definition: Hare_All.h:301
Landscape::SupplyPesticideP
double SupplyPesticideP(int a_x, int a_y, PlantProtectionProducts a_ppp)
Gets plant pesticide for a location.
Definition: Landscape.cpp:1420
THare::ForageP
double ForageP(int &time)
Foraging but also incorporating pesticide exposure.
Definition: HareForagenPeg.cpp:179
MapErrorMsg.h
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
CfgInt
Integer configurator entry class.
Definition: Configurator.h:102
Calendar::m_month
int m_month
Definition: Calendar.h:98
THare_Population_Manager::GetPolyFood
double GetPolyFood(int a_poly)
Get stored polygon food quality.
Definition: Hare_All.h:720
aDate::day
int day
Definition: Calendar.h:35
CfgFloat
Double configurator entry class.
Definition: Configurator.h:126
Population_Manager_Base::SupplySimW
int SupplySimW() const
Returns landscape width in m.
Definition: PopulationManager.h:567
Calendar::m_dusk
int m_dusk
Definition: Calendar.h:105
Calendar::m_sunset
int m_sunset[365]
Definition: Calendar.h:114
Calendar::m_simulationyear
int m_simulationyear
Definition: Calendar.h:100
THare::GetPegPull
int GetPegPull()
Get attractive force of peg.
Definition: HareForagenPeg.cpp:458
CFG_CUSTOM
Definition: Configurator.h:70
g_random_fnc
int g_random_fnc(const int a_range)
Definition: ALMaSS_Random.cpp:74
Calendar::m_lastyear
int m_lastyear
Definition: Calendar.h:95
THare::m_peg_y
int m_peg_y
peg y-coordinate
Definition: Hare_All.h:260
Calendar::DayInYear
int DayInYear(void)
Definition: Calendar.h:58
Calendar::TickMinute
bool TickMinute(void)
Definition: Calendar.cpp:156
Calendar.h
Calendar::m_todayssunrise
int m_todayssunrise
Definition: Calendar.h:102
Calendar::TickMinute10
bool TickMinute10(void)
Definition: Calendar.cpp:167
Calendar::MarchFirst
bool MarchFirst(void)
Definition: Calendar.h:80
Calendar::m_date
long m_date
Definition: Calendar.h:92
Calendar::m_janfirst
bool m_janfirst
Definition: Calendar.h:109
Calendar::m_daylength
int m_daylength[365]
Definition: Calendar.h:112
Calendar::JanFirst
bool JanFirst(void)
Definition: Calendar.h:79
Landscape::SupplyCropType
TTypesOfCrops SupplyCropType(int a_x, int a_y)
Returns the crop type of the polygon using the polygon reference number a_polyref or coordinates a_x,...
Definition: Landscape.h:1931
TAnimal::m_Location_x
int m_Location_x
The objects ALMaSS x coordinate.
Definition: PopulationManager.h:362
Landscape::SupplyPolyRef
int SupplyPolyRef(int a_x, int a_y)
Get the in map polygon reference number from the x, y location.
Definition: Landscape.h:2157
Calendar::GlobalDate
long GlobalDate(int a_day, int a_month, int a_year)
Definition: Calendar.cpp:92
WARN_BUG
Definition: MapErrorMsg.h:34
ppp_1
Definition: LandscapeFarmingEnums.h:1079
THare::m_peg_x
int m_peg_x
peg x-coordinate
Definition: Hare_All.h:256
Calendar::m_year
int m_year
Definition: Calendar.h:99
g_hare_peg_inertia
double g_hare_peg_inertia
Definition: Hare_All.cpp:48
cfg_hare_pegmoveto_chance
CfgInt cfg_hare_pegmoveto_chance("HARE_PEGMOVETOCHANCE", CFG_CUSTOM, 5000)
Calendar::m_todayssunset
int m_todayssunset
Definition: Calendar.h:103
Landscape::GetHareFoodQuality
double GetHareFoodQuality(int a_polygon)
Returns the hare food quality of polygons LKM.
Definition: Landscape.cpp:5472
Calendar::GetMinute
int GetMinute(void)
Definition: Calendar.h:75