diff --git a/PlantBox.Shared/Communication/Commands/CaptorsInterval.cs b/PlantBox.Shared/Communication/Commands/HistoricInterval.cs similarity index 86% rename from PlantBox.Shared/Communication/Commands/CaptorsInterval.cs rename to PlantBox.Shared/Communication/Commands/HistoricInterval.cs index 60d33bb..5bc37af 100644 --- a/PlantBox.Shared/Communication/Commands/CaptorsInterval.cs +++ b/PlantBox.Shared/Communication/Commands/HistoricInterval.cs @@ -4,7 +4,7 @@ using System.Text; namespace PlantBox.Shared.Communication.Commands { - public enum CaptorsInterval + public enum HistoricInterval { Monthly, Weekly, diff --git a/PlantBox.Shared/Communication/Commands/HistoricRequest.cs b/PlantBox.Shared/Communication/Commands/HistoricRequest.cs new file mode 100644 index 0000000..fe5219d --- /dev/null +++ b/PlantBox.Shared/Communication/Commands/HistoricRequest.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Text; + +namespace PlantBox.Shared.Communication.Commands +{ + public class HistoricRequest : CommandSerializable + { + public HistoricInterval Interval { get; set; } + public int Number { get; set; } + + public HistoricRequest() + { + + } + public HistoricRequest(HistoricInterval interval, int number) + { + Interval = interval; + Number = number; + } + + public override HistoricRequest Deserialize(string[] arguments) + { + if (arguments == null) + { + throw new ArgumentNullException(nameof(arguments)); + } + if (arguments.Length < 2) + { + throw new ArgumentException($"Excepted 2 arguments, got {arguments.Length}"); + } + + Interval = (HistoricInterval)Enum.Parse(typeof(HistoricInterval), arguments[0], true); + Number = int.Parse(arguments[0], CultureInfo.InvariantCulture); + + return this; + } + + public override string[] Serialize() + { + return new[] { Interval.ToString(), Number.ToString(CultureInfo.InvariantCulture) }; + } + } +}