namespace Thread_Centraline
{
    internal class Rilevazione
    {
        public string IdCentralina { get; private init; }

        public DateTime Timestamp { get; private init; }

        public double PM10 { get; private init; }
        public double PM25 { get; private init; }
        public double CO2 { get; private init; }
        public double NO2 { get; private init; }
        public double Rumore { get; private init; }

        public Rilevazione(string idCentralina, DateTime timestamp, double pM10, double pM25, double cO2, double nO2, double rumore)
        {
            IdCentralina = idCentralina;
            Timestamp = timestamp;
            PM10 = pM10;
            PM25 = pM25;
            CO2 = cO2;
            NO2 = nO2;
            Rumore = rumore;
        }

        public Rilevazione(string idCentralina)
        {
            IdCentralina = idCentralina;

            Random r = new Random();
            if (r.Next(10) >= 1)
                PM10 = r.NextDouble() * 50;                
            else
                PM10 = r.NextDouble() * 30 + 50;

            if (r.Next(10) >= 1)
                PM25 = r.NextDouble() * 25;
            else
                PM25 = r.NextDouble() * 15 + 25;

            if (r.Next(10) >= 1)
                CO2 = r.NextDouble() * 600 + 400;
            else 
                CO2 = r.NextDouble() * 200 + 1000;

            if (r.Next(10) >= 1)
                NO2 = r.NextDouble() * 40;
            else
                NO2 = r.NextDouble() * 20 + 40;

            if (r.Next(10) >= 1)
                Rumore = r.NextDouble() * 30 + 40;
            else
                Rumore = r.NextDouble() * 30 + 70;
        }
    }
}
