-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweatherdata.cpp
More file actions
120 lines (100 loc) · 3.52 KB
/
Copy pathweatherdata.cpp
File metadata and controls
120 lines (100 loc) · 3.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#include "weatherdata.h"
#include "utils.h"
#include <math.h>
#define INVALID_HIGH_TEMP -1000.0
#define INVALID_LOW_TEMP 1000.0
#define INVALID_HIGH_HUMIDITY -1.0
#define INVALID_LOW_HUMIDITY 101.0
#define INVALID_HIGH_GUST -1.0
//*****************************************************************************
CWeatherData::CWeatherData(void)
: m_fTemp(-459.666), // Absolute zero in Fahrenheit
m_fPressure(0.0),
m_fHumidity(0.0),
m_fWindSpeed(0.0),
m_fWindGust(0.0),
m_fWindDir(0.0),
m_fRainMinute(0.0),
m_fRainHour(0.0),
m_fRainDay(0.0),
m_fRainMonth(0.0),
m_fRainSeason(0.0),
m_fTempDailyHigh(INVALID_HIGH_TEMP),
m_fTempDailyLow(INVALID_LOW_TEMP),
m_fHumidityDailyHigh(INVALID_HIGH_HUMIDITY),
m_fHumidityDailyLow(INVALID_LOW_HUMIDITY),
m_fWindGustDailyHigh(INVALID_HIGH_GUST)
{
}
//*****************************************************************************
CWeatherData::~CWeatherData(void)
{
}
//*****************************************************************************
void CWeatherData::SetTemperature(const float fTemp)
{
m_fTemp = fTemp;
if(m_fTemp > m_fTempDailyHigh)
m_fTempDailyHigh = m_fTemp;
if(m_fTemp < m_fTempDailyLow)
m_fTempDailyLow = m_fTemp;
}
//*****************************************************************************
void CWeatherData::SetHumidity(const float fHumidity)
{
m_fHumidity = fHumidity;
if(m_fHumidity > m_fHumidityDailyHigh)
m_fHumidityDailyHigh = m_fHumidity;
if(m_fHumidity < m_fHumidityDailyLow)
m_fHumidityDailyLow = m_fHumidity;
}
//*****************************************************************************
void CWeatherData::SetWindGust(const float fWindGust)
{
m_fWindGust = fWindGust;
if(m_fWindGust > m_fWindGustDailyHigh)
m_fWindGustDailyHigh = m_fWindGust;
}
//*****************************************************************************
float CWeatherData::GetDewPoint(void) const
{
float fDewPoint;
float fTempC = F2C(m_fTemp);
float fDewPointC = 243.04 * (logf(m_fHumidity / 100.0) + ((17.625 * fTempC) / (243.04 + fTempC))) / (17.625 - logf(m_fHumidity / 100.0) - ((17.625 * fTempC) / (243.04 + fTempC)));
fDewPoint = C2F(fDewPointC);
return fDewPoint;
}
//*****************************************************************************
bool CWeatherData::IsValidDailyHighTemperature(void) const
{
return (m_fTempDailyHigh != INVALID_HIGH_TEMP);
}
//*****************************************************************************
bool CWeatherData::IsValidDailyLowTemperature(void) const
{
return (m_fTempDailyLow != INVALID_LOW_TEMP);
}
//*****************************************************************************
bool CWeatherData::IsValidDailyHighHumidity(void) const
{
return (m_fHumidityDailyHigh != INVALID_HIGH_HUMIDITY);
}
//*****************************************************************************
bool CWeatherData::IsValidDailyLowHumidity(void) const
{
return (m_fHumidityDailyLow != INVALID_LOW_HUMIDITY);
}
//*****************************************************************************
bool CWeatherData::IsValidDailyHighWindGust(void) const
{
return (m_fWindGustDailyHigh != INVALID_HIGH_GUST);
}
//*****************************************************************************
void CWeatherData::ResetDailyValues(void)
{
m_fTempDailyHigh = INVALID_HIGH_TEMP;
m_fTempDailyLow = INVALID_LOW_TEMP;
m_fHumidityDailyHigh = INVALID_HIGH_HUMIDITY;
m_fHumidityDailyLow = INVALID_LOW_HUMIDITY;
m_fWindGustDailyHigh = INVALID_HIGH_GUST;
}