Ejemplo n.º 1
0
        public void PostSensor([FromBody] Sensor sensor)
        {
            string status = "Normal";

            if (Convert.ToDecimal(sensor.temperature) > CRIT_TEMP || Convert.ToDecimal(sensor.pressure) > CRIT_PRESSURE)
            {
                string message = "Critical readings LSD " + sensor.LSD + "\n" +
                                 "Temperature: " + sensor.temperature + "\n" +
                                 "Pressure: " + sensor.pressure;

                SparkBot.NotifyText(message);
                SparkBot.PostMessage(message);
                status = "Alert";
            }
            sensor.status = status;
            DBAccess.InsertSensor(sensor);
        }
Ejemplo n.º 2
0
        private static void CheckSensor()
        {
            HttpClient getClient  = new HttpClient();
            string     getAddress = "https://api.relayr.io/devices/e84e2eb1-80bf-48e8-a5c1-c710c5310281/readings";

            getClient.BaseAddress = new Uri(getAddress);
            getClient.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));

            getClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "RNClQ25HqmxEtFquKuGRAv4b8OAnFbzvh5MpFgNtyqpJOOcngIQEGwf0Xw0vgF4n");

            HttpResponseMessage response = getClient.GetAsync("").Result;
            var readingWrapper           = response.Content.ReadAsAsync <ReadingWrapper>().Result;

            decimal temperature = Convert.ToDecimal(readingWrapper.readings[0].value);

            Sensor sensor = new Sensor();
            string status = "Normal";

            string message = "";

            if (temperature > 30)
            {
                message = "Critical readings at: " + "\n" +
                          "LSD: 66-27-75-05W4 \n" +
                          "Temperature: " + temperature;

                SparkBot.NotifyText(message);
                status = "Alert";
            }
            else
            {
                message = "LSD: 66-27-75-05W4 \n" +
                          "Temperature: " + temperature;
            }
            SparkBot.PostMessage(message);

            sensor.LSD         = "66-27-75-05W4";
            sensor.temperature = temperature.ToString();
            sensor.status      = status;

            DBAccess.InsertSensor(sensor);
        }
Ejemplo n.º 3
0
        public void PostTropo([FromBody] Emergency emergency)
        {
            string message    = emergency.result.transcription;
            string identifier = emergency.result.identifier;

            string[] result = identifier.Split(',');

            EmergencyCall call = new EmergencyCall();

            call.transcription = message;
            call.identifier    = result[0];
            call.latitude      = Convert.ToDecimal(result[1]);
            call.longitude     = Convert.ToDecimal(result[2]);

            string mapsLink = "https://www.google.ca/maps?q=" + call.latitude + "," + call.longitude;

            SparkBot.NotifyText(message + "\n" + mapsLink);

            SparkBot.PostMessage("Emergency notification: " + message + "\n" + "Emergency location: " + mapsLink);

            DBAccess.InsertEmergencyCall(call);
        }