Files
PlantBox/PlantBox.Shared/Communication/Commands/CaptorsResponse.cs
Eveldee 9e78307541 Update commands accorded to doc
Update Captors and Info commands
2019-04-22 16:54:16 +02:00

62 lines
1.7 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 double Tank { get; set; }
public CaptorsResponse()
{
}
public CaptorsResponse(double humidity, double luminosity, double temperature, double tank)
{
Humidity = humidity;
Luminosity = luminosity;
Temperature = temperature;
Tank = tank;
}
public override CaptorsResponse Deserialize(string[] arguments)
{
if (arguments == null)
{
throw new ArgumentNullException(nameof(arguments));
}
if (arguments.Length < 4)
{
throw new ArgumentException($"Excepted 4 arguments, got {arguments.Length}");
}
Humidity = arguments[0].ToDouble();
Luminosity = arguments[1].ToDouble();
Temperature = arguments[2].ToDouble();
Tank = arguments[3].ToDouble();
return this;
}
public override string[] Serialize()
{
return new[]
{
Humidity.ToArgument(),
Luminosity.ToArgument(),
Temperature.ToArgument(),
Tank.ToArgument()
};
}
}
}