Exemplo n.º 1
0
        public void RegisterZoneAtm(ZoneAtmInfo zoneAtm)
        {
            var zoneAtmDataInfo = new AtmData
            {
                CO     = zoneAtm.Co,
                CO2    = zoneAtm.Co2,
                Date   = zoneAtm.date,
                HC     = zoneAtm.Hc,
                MP     = zoneAtm.MP,
                NOx    = zoneAtm.NOx,
                Rcho   = zoneAtm.Rcho,
                Sensor = _datagetter.QuerySensor(zoneAtm.Sensor),
                SOx    = zoneAtm.SOx
            };

            _zoneAtmReg.registerZoneAtm(zoneAtmDataInfo);
        }
Exemplo n.º 2
0
        public ActionResult RegisterGasReading(
            long zone,
            long sensor,
            [FromUri] double co2,
            [FromUri] double co,
            [FromUri] double hc,
            [FromUri] double rcho,
            [FromUri] double nox,
            [FromUri] double sox,
            [FromUri] double mp)
        {
            if (zone < 0)
            {
                return(BadRequest("zone id must be positive and not null"));
            }
            if (sensor < 0)
            {
                return(BadRequest("sensor id must be positive and not null"));
            }

            if (co2 < 0)
            {
                return(BadRequest("co2 must be positive"));
            }
            if (co < 0)
            {
                return(BadRequest("co must be positive"));
            }
            if (hc < 0)
            {
                return(BadRequest("hc must be positive"));
            }
            if (rcho < 0)
            {
                return(BadRequest("rcho must be positive"));
            }
            if (nox < 0)
            {
                return(BadRequest("nox must be positive"));
            }
            if (sox < 0)
            {
                return(BadRequest("sox must be positive"));
            }
            if (mp < 0)
            {
                return(BadRequest("mp must be positive"));
            }

            Console.WriteLine($"Recieved atmosphere register, entering zone {zone} from sensor {sensor}");

            var zoneAtm = new ZoneAtmInfo
            {
                Zone   = zone,
                Sensor = sensor,
                Co2    = co2,
                Co     = co,
                Hc     = hc,
                Rcho   = rcho,
                NOx    = nox,
                SOx    = sox,
                MP     = mp
            };

            try
            {
                _zoneHandler.RegisterZoneAtm(zoneAtm);
            }
            catch (Exception)
            {
                Console.WriteLine("Problem detected when registering Gas Reading");
                return(StatusCode(500));
            }

            return(Ok());
        }