Files
PlantBox/PlantBox.Shared/Communication/Commands/CaptorsResponse.cs
2019-03-24 12:14:28 +01:00

58 lines
1.5 KiB
C#

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<CaptorsResponse>
{
public override Command Command => Command.Captors;
public double Humidity { get; set; }
public double Luminosity { get; set; }
public double Temperature { get; set; }
public CaptorsResponse()
{
}
public CaptorsResponse(double humidity, double luminosity, double 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 = arguments[0].ToDouble();
Luminosity = arguments[1].ToDouble();
Temperature = arguments[2].ToDouble();
return this;
}
public override string[] Serialize()
{
return new[]
{
Humidity.ToArgument(),
Luminosity.ToArgument(),
Temperature.ToArgument()
};
}
}
}