Update Broker

This commit is contained in:
2019-04-24 23:14:10 +02:00
parent 0f91751087
commit ab85e78f4c
7 changed files with 87 additions and 7 deletions

View File

@@ -8,7 +8,7 @@ namespace PlantBox.Broker
class PlantBox
{
// General Info
public ulong ID { get; }
public ulong ID { get; set; }
public string Name { get; set; }
public PlantType Type { get; set; }
public PlantState State { get; set; }
@@ -22,5 +22,30 @@ namespace PlantBox.Broker
// Historic
public HistoricManager HistoricManager { get; set; }
// State conditions
public void UpdateState()
{
if (Humidity.Value < Humidity.Min || Humidity.Value > Humidity.Max)
{
State = PlantState.Warning;
}
if (Luminosity.Value < Luminosity.Min || Luminosity.Value > Luminosity.Max)
{
State = PlantState.Warning;
}
if (Temperature.Value < Temperature.Min || Temperature.Value > Temperature.Max)
{
State = PlantState.Warning;
}
if (TankLevel < 20)
{
State = PlantState.Warning;
}
if ((DateTime.Now - LastMeasureDate).TotalMinutes > 6)
{
State = PlantState.Bad;
}
}
}
}