Update Broker
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user