using PlantBox.Shared.Extensions; using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; namespace PlantBox.Shared.Communication.Commands { public class CaptorsResponse : CommandSerializable { public override Command Command => Command.Captors; public CaptorValue Humidity { get; set; } public CaptorValue Luminosity { get; set; } public CaptorValue Temperature { get; set; } public CaptorsResponse() { } public CaptorsResponse(CaptorValue humidity, CaptorValue luminosity, CaptorValue temperature) { Humidity = humidity; Luminosity = luminosity; Temperature = temperature; } public override CaptorsResponse Deserialize(string[] arguments) { if (arguments == null) { throw new ArgumentNullException(nameof(arguments)); } if (arguments.Length < 3) { throw new ArgumentException($"Excepted 3 arguments, got {arguments.Length}"); } Humidity = new CaptorValue(arguments[0]); Luminosity = new CaptorValue(arguments[1]); Temperature = new CaptorValue(arguments[2]); return this; } public override string[] Serialize() { return new[] { Humidity.ToArgument(), Luminosity.ToArgument(), Temperature.ToArgument() }; } } }