62 lines
1.7 KiB
C#
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()
|
|
};
|
|
}
|
|
}
|
|
}
|