Update commands accorded to doc
Update Captors and Info commands
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace PlantBox.Shared.Communication.Commands
|
||||
@@ -13,18 +14,29 @@ namespace PlantBox.Shared.Communication.Commands
|
||||
public string Name { get; set; }
|
||||
public PlantType Type { get; set; }
|
||||
public PlantState State { get; set; }
|
||||
public double Water { get; set; }
|
||||
public double HumidityMin { get; set; }
|
||||
public double HumidityMax { get; set; }
|
||||
public double LuminosityMin { get; set; }
|
||||
public double LuminosityMax { get; set; }
|
||||
public double TemperatureMin { get; set; }
|
||||
public double TemperatureMax { get; set; }
|
||||
|
||||
public InfoResponse()
|
||||
{
|
||||
|
||||
}
|
||||
public InfoResponse(string name, PlantType type, PlantState state, double water)
|
||||
|
||||
public InfoResponse(string name, PlantType type, PlantState state, double humidityMin, double humidityMax, double luminosityMin, double luminosityMax, double temperatureMin, double temperatureMax)
|
||||
{
|
||||
Name = name;
|
||||
Type = type;
|
||||
State = state;
|
||||
Water = water;
|
||||
HumidityMin = humidityMin;
|
||||
HumidityMax = humidityMax;
|
||||
LuminosityMin = luminosityMin;
|
||||
LuminosityMax = luminosityMax;
|
||||
TemperatureMin = temperatureMin;
|
||||
TemperatureMax = temperatureMax;
|
||||
}
|
||||
|
||||
public override InfoResponse Deserialize(string[] arguments)
|
||||
@@ -33,15 +45,17 @@ namespace PlantBox.Shared.Communication.Commands
|
||||
{
|
||||
throw new ArgumentNullException(nameof(arguments));
|
||||
}
|
||||
if (arguments.Length < 4)
|
||||
if (arguments.Length < 6)
|
||||
{
|
||||
throw new ArgumentException($"Excepted 4 arguments, got {arguments.Length}");
|
||||
throw new ArgumentException($"Excepted 6 arguments, got {arguments.Length}");
|
||||
}
|
||||
|
||||
Name = arguments[0];
|
||||
Type = arguments[1].ToEnumValue<PlantType>();
|
||||
State = arguments[2].ToEnumValue<PlantState>();
|
||||
Water = arguments[3].ToDouble();
|
||||
(HumidityMin, HumidityMax) = arguments[3].Split('/').Select(x => x.ToDouble()).ToArray().ToTuple();
|
||||
(LuminosityMin, LuminosityMax) = arguments[4].Split('/').Select(x => x.ToDouble()).ToArray().ToTuple();
|
||||
(TemperatureMin, TemperatureMax) = arguments[5].Split('/').Select(x => x.ToDouble()).ToArray().ToTuple();
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -53,7 +67,9 @@ namespace PlantBox.Shared.Communication.Commands
|
||||
Name,
|
||||
Type.ToString(),
|
||||
State.ToString(),
|
||||
Water.ToArgument()
|
||||
$"{HumidityMin}/{HumidityMax}",
|
||||
$"{LuminosityMin}/{LuminosityMax}",
|
||||
$"{TemperatureMin}/{TemperatureMax}"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user