-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
303 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
sample/DavisVantage.WeatherReader.Sample/Properties/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/DavisVantage.WeatherReader/Extensions/PrintExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
using System.Text; | ||
|
||
namespace DavisVantage.WeatherReader.Extensions | ||
{ | ||
public static class PrintExtensions | ||
{ | ||
public static string PrintAllProperties<T>(this T data) where T: class | ||
{ | ||
var stringBuilder = new StringBuilder(); | ||
foreach (var property in typeof(T).GetRuntimeProperties()) | ||
{ | ||
if (property.PropertyType == typeof(List<decimal>)) | ||
{ | ||
var extraValues = (List<decimal>)property.GetValue(data); | ||
PrintValues(property, ref stringBuilder, extraValues); | ||
} | ||
else if (property.PropertyType == typeof(List<int>)) | ||
{ | ||
var extraValues = (List<int>)property.GetValue(data); | ||
PrintValues(property, ref stringBuilder, extraValues); | ||
} | ||
else | ||
{ | ||
stringBuilder.Append($"\n{property.Name}: {property.GetValue(data)}"); | ||
} | ||
} | ||
return stringBuilder.ToString(); | ||
} | ||
|
||
private static void PrintValues<T>(PropertyInfo propertyInfo, ref StringBuilder stringBuilder, List<T> extraValues) | ||
{ | ||
for (var i = 0; i < extraValues.Count; i++) | ||
{ | ||
stringBuilder.Append($"\n{propertyInfo.Name}[{i}]: {extraValues[i]}"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using DavisVantage.WeatherReader.Models; | ||
using DavisVantage.WeatherReader.Models.Extremes; | ||
|
||
namespace DavisVantage.WeatherReader | ||
{ | ||
public interface IByteReader | ||
{ | ||
CurrentWeather ReadCurrentWeatherFromByteArray(byte[] byteArray, bool valuesInMetric); | ||
WeatherExtremes ReadWeatherExtremesFromByteArray(byte[] byteArray, bool valuesInMetric); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 31 additions & 1 deletion
32
src/DavisVantage.WeatherReader/Models/Extremes/WeatherDayExtremes.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,36 @@ | ||
namespace DavisVantage.WeatherReader.Models.Extremes | ||
using System; | ||
using DavisVantage.WeatherReader.Extensions; | ||
|
||
namespace DavisVantage.WeatherReader.Models.Extremes | ||
{ | ||
public class WeatherDayExtremes | ||
{ | ||
public int BarometerMax { get; set; } | ||
public int BarometerMin { get; set; } | ||
public DateTime BarometerMaxTime { get; set; } | ||
public DateTime BarometerMinTime { get; set; } | ||
public int MaxWindSpeed { get; set; } | ||
public DateTime MaxWindSpeedTime { get; set; } | ||
public decimal TempInsideMax { get; set; } | ||
public DateTime TempInsideMaxTime { get; set; } | ||
public decimal TempInsideMin { get; set; } | ||
public DateTime TempInsideMinTime { get; set; } | ||
public int HumidityInsideMax { get; set; } | ||
public DateTime HumidityInsideMaxTime { get; set; } | ||
public int HumidityInsideMin { get; set; } | ||
public DateTime HumidityInsideMinTime { get; set; } | ||
public decimal TempOutsideMax { get; set; } | ||
public decimal TempOutsideMin { get; set; } | ||
public DateTime TempOutsideMaxTime { get; set; } | ||
public DateTime TempOutsideMinTime { get; set; } | ||
public decimal WindChillMin { get; set; } | ||
public DateTime WindChillMinTime { get; set; } | ||
public decimal ThswMax { get; set; } | ||
public DateTime ThswMaxTime { get; set; } | ||
|
||
public override string ToString() | ||
{ | ||
return this.PrintAllProperties(); | ||
} | ||
} | ||
} |
8 changes: 7 additions & 1 deletion
8
src/DavisVantage.WeatherReader/Models/Extremes/WeatherExtremes.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
namespace DavisVantage.WeatherReader.Models.Extremes | ||
using DavisVantage.WeatherReader.Extensions; | ||
|
||
namespace DavisVantage.WeatherReader.Models.Extremes | ||
{ | ||
public class WeatherExtremes | ||
{ | ||
public WeatherDayExtremes WeatherDayExtremes { get; set; } | ||
public WeatherMonthExtremes WeatherMonthExtremes { get; set; } | ||
public WeatherYearExtremes WeatherYearExtremes { get; set; } | ||
public override string ToString() | ||
{ | ||
return this.PrintAllProperties(); | ||
} | ||
} | ||
} |
9 changes: 5 additions & 4 deletions
9
src/DavisVantage.WeatherReader/Models/Extremes/WeatherMonthExtremes.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using DavisVantage.WeatherReader.Extensions; | ||
|
||
namespace DavisVantage.WeatherReader.Models.Extremes | ||
{ | ||
public class WeatherMonthExtremes | ||
{ | ||
public override string ToString() | ||
{ | ||
return this.PrintAllProperties(); | ||
} | ||
} | ||
} |
9 changes: 5 additions & 4 deletions
9
src/DavisVantage.WeatherReader/Models/Extremes/WeatherYearExtremes.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using DavisVantage.WeatherReader.Extensions; | ||
|
||
namespace DavisVantage.WeatherReader.Models.Extremes | ||
{ | ||
public class WeatherYearExtremes | ||
{ | ||
public override string ToString() | ||
{ | ||
return this.PrintAllProperties(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.