using PlantBox.Shared.Communication.Commands; using System; using System.Collections.Generic; using System.Text; namespace PlantBox.Broker { class PlantBox { // General Info public ulong ID { get; set; } public string Name { get; set; } public PlantType Type { get; set; } public PlantState State { get; set; } // Captors public DateTime LastMeasureDate { get; set; } public double TankLevel { get; set; } public CaptorValue Humidity { get; set; } public CaptorValue Luminosity { get; set; } public CaptorValue Temperature { get; set; } // 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; } } } }