1
|
//
|
2
|
// Author: A. Konig
|
3
|
//
|
4
|
|
5
|
using System;
|
6
|
|
7
|
namespace ServerApp.Parser.OutputInfo
|
8
|
{
|
9
|
/// <summary>
|
10
|
/// Class representing the weather in a given interval at ZCU
|
11
|
/// - shortest possible interval is 1h
|
12
|
/// </summary>
|
13
|
/// <author>A. Konig</author>
|
14
|
public class WeatherInfo
|
15
|
{
|
16
|
/// <summary> Temperature in °C </summary>
|
17
|
public double temp;
|
18
|
/// <summary> Probability of rain in % </summary>
|
19
|
public int rain;
|
20
|
/// <summary> Wind in m/s </summary>
|
21
|
public double wind;
|
22
|
/// <summary> Luminance </summary>
|
23
|
public double lum;
|
24
|
/// <summary> General weather conditions </summary>
|
25
|
public WeatherConditions condition;
|
26
|
|
27
|
/// <summary> Start of interval </summary>
|
28
|
public DateTime startTime;
|
29
|
/// <summary> Length of interval in hours </summary>
|
30
|
public int intervalLength;
|
31
|
|
32
|
public WeatherInfo()
|
33
|
{
|
34
|
condition = WeatherConditions.Dark;
|
35
|
}
|
36
|
|
37
|
/// <summary>
|
38
|
/// Constructor
|
39
|
/// </summary>
|
40
|
/// <param name="startTime">Start of the interval</param>
|
41
|
/// <param name="temp">Temperature in °C</param>
|
42
|
/// <param name="rain">Probability of rain in %</param>
|
43
|
/// <param name="wind">Wind in m/w</param>
|
44
|
/// <param name="lum">Luminance in lux</param>
|
45
|
/// <param name="intervalLength">Interval length</param>
|
46
|
public WeatherInfo(DateTime startTime, double temp, int rain, double wind, double lum, int intervalLength)
|
47
|
{
|
48
|
this.startTime = startTime;
|
49
|
this.temp = temp;
|
50
|
this.rain = rain;
|
51
|
this.wind = wind;
|
52
|
this.lum = lum;
|
53
|
this.intervalLength = intervalLength;
|
54
|
|
55
|
condition = ValueToConditions.TransferLuxToConditions(lum);
|
56
|
}
|
57
|
|
58
|
/// <summary>
|
59
|
/// Constructor
|
60
|
/// </summary>
|
61
|
/// <param name="startTime">Start of the interval</param>
|
62
|
/// <param name="temp">Temperature in °C</param>
|
63
|
/// <param name="rain">Probability of rain in %</param>
|
64
|
/// <param name="wind">Wind in m/s</param>
|
65
|
/// <param name="condition">Weather conditions</param>
|
66
|
/// <param name="intervalLength">Interval length</param>
|
67
|
public WeatherInfo(DateTime startTime, double temp, int rain, double wind, WeatherConditions condition, int intervalLength)
|
68
|
{
|
69
|
this.startTime = startTime;
|
70
|
this.temp = temp;
|
71
|
this.rain = rain;
|
72
|
this.wind = wind;
|
73
|
this.condition = condition;
|
74
|
this.intervalLength = intervalLength;
|
75
|
|
76
|
lum = ValueToConditions.TransferConditionsToLux(condition);
|
77
|
}
|
78
|
|
79
|
/// <summary>
|
80
|
/// To string
|
81
|
/// </summary>
|
82
|
/// <returns>interval start temperature probability of rain wind weather condition</returns>
|
83
|
public override string ToString()
|
84
|
{
|
85
|
return $"{startTime} \t {temp}°C \t {rain}% \t {wind}m/s \t {condition.ToString()} \t {lum}";
|
86
|
}
|
87
|
|
88
|
/// <summary>
|
89
|
/// Eqquals
|
90
|
/// </summary>
|
91
|
/// <param name="obj"> Other object </param>
|
92
|
/// <returns></returns>
|
93
|
public override bool Equals(object obj)
|
94
|
{
|
95
|
WeatherInfo other = (WeatherInfo) obj;
|
96
|
|
97
|
if (startTime == other.startTime && rain == other.rain && condition == other.condition)
|
98
|
{
|
99
|
if ((int)(temp * 1000) == (int)(other.temp *1000) && (int)(wind*1000) == (int)(other.wind*1000))
|
100
|
return true;
|
101
|
}
|
102
|
|
103
|
return false;
|
104
|
}
|
105
|
}
|
106
|
}
|