Esempio n. 1
0
        private void timerTick(object obj)
        {
            isReadingNow = true;
            getDataFromDevice();
            isReadingNow = false;

            //Obsluga wyjscia
            //onOffDevice();

            //Zapis danych
            if (connectIsOk)
            {
                Measurement.AddMeasurement(1, id, temperature);
                //Measurement.AddMeasurement(2, id, adc[5]);

                if (!CommunicationStatus)
                {
                    CommunicationStatus = true;
                }
            }
            else
            {
                if (CommunicationStatus)
                {
                    CommunicationStatus = false;
                }
            }

            if (lastDateCheck.Hour % 2 != 0 && DateTime.Now.Hour % 2 == 0)
            {
                SendEmailWithLogs();
            }
            lastDateCheck = DateTime.Now;
        }
Esempio n. 2
0
 public IActionResult PostMeasurement([FromBody] Measurement measurement)
 {
     if (measurement.measurement_type == null || measurement.avr_device == null || measurement.value == null)
     {
         return(BadRequest());
     }
     else
     {
         Measurement newMeasurement = Measurement.AddMeasurement(measurement);
         if (newMeasurement.value.Equals(measurement.value))
         {
             return(CreatedAtRoute("GetMeasurement", new { newMeasurement.id }, newMeasurement));
         }
     }
     return(BadRequest());
 }
Esempio n. 3
0
 public void EndMeasurement(Measurement measurement)
 {
     measurement.Stopwatch.Stop();
     measurement.AddMeasurement(measurement.Stopwatch.Elapsed);
 }