Exemplo n.º 1
0
 internal TemperatureSensor(IGrovePi device, Pin pin, TemperatureSensorModel model)
 {
     if (device == null) throw new ArgumentNullException(nameof(device));
     _device = device;
     _pin = pin;
     _model = model;
 }
Exemplo n.º 2
0
 internal TemperatureSensor(IGrovePi device, Pin pin, TemperatureSensorModel model)
 {
     if (device == null)
     {
         throw new ArgumentNullException(nameof(device));
     }
     _device = device;
     _pin    = pin;
     _model  = model;
 }
Exemplo n.º 3
0
        //This method takes the temperature of the box you ask for and return it as a string
        //this is used before the post request the the API and this is called for every box
        public string GetTemperature(int boxNo)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://192.168.1." + (150 + boxNo));

            request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;

            using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                using (Stream stream = response.GetResponseStream())
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        string json = reader.ReadToEnd();
                        TemperatureSensorModel temp = JsonConvert.DeserializeObject <TemperatureSensorModel>(json);
                        return(temp.Temperature.ToString());
                    }
        }
 public void SaveSensorData(TemperatureSensorModel temp)
 {
     _sql.SaveData("dbo.spTemperatureSensor_UploadData", temp, "WeatherStationDB");
 }
Exemplo n.º 5
0
 public ITemperatureSensor TemperatureSensor(Pin pin, TemperatureSensorModel model)
 {
     return(DoBuild(x => new TemperatureSensor(x, pin, model)));
 }