public static void GetSensors(m_garden garden) { List <sensor> sensors = new List <sensor>(); HTTPRequest request_getSensor1 = new HTTPRequest(new Uri(data.IP + "/getTemperatureSensorByGardenId?gardenId=" + garden.getId()), HTTPMethods.Get, (req_sensor1, res_sensor1) => { Debug.Log(res_sensor1.DataAsText); JArray array = JArray.Parse(res_sensor1.DataAsText); foreach (var e in array) { sensor temp = new sensor(); temp.setId((long)e["id"]); temp.setName((string)e["name"]); temp.setX((int)e["x"] * data.width / garden.getLength()); temp.setY((int)e["y"] * data.length / garden.getWidth()); temp.setType(true); sensors.Add(temp); } garden.addSensor(sensors); }).Send(); HTTPRequest request_getSensor2 = new HTTPRequest(new Uri(data.IP + "/getWetnessSensorByGardenId?gardenId=" + garden.getId()), HTTPMethods.Get, (req_sensor2, res_sensor2) => { Debug.Log(res_sensor2.DataAsText); JArray array = JArray.Parse(res_sensor2.DataAsText); foreach (var e in array) { sensor temp = new sensor(); temp.setId((long)e["id"]); temp.setName((string)e["name"]); temp.setX((int)e["x"] * data.width / garden.getLength()); temp.setY((int)e["y"] * data.length / garden.getWidth()); temp.setType(false); sensors.Add(temp); } garden.addSensor(sensors); }).Send(); HTTPRequest request_getSensorData1 = new HTTPRequest(new Uri(data.IP + "/getLatestTemperatureByGardenId?gardenId=" + garden.getId()), HTTPMethods.Get, (req_data1, res_data1) => { Debug.Log(res_data1.DataAsText); JArray array = JArray.Parse(res_data1.DataAsText); foreach (var e in array) { foreach (sensor n in garden.getSensors()) { if (n.getId() == (long)e["id"] && n.getType()) { n.setData((float)e["temperature"]); } } } foreach (sensor e in garden.getSensors()) { if (e.getType() && e.getData() != 0) { MapBG.drawOne(e.getId(), e.getName(), e.getX(), e.getY(), MapBG.SensorControllerType.Temperature, true, e.getData(), garden.getIdealTemperature() * (float)1.2, garden.getIdealTemperature() * (float)0.8); } else if (e.getType() && e.getData() == 0) { MapBG.drawOne(e.getId(), e.getName(), e.getX(), e.getY(), MapBG.SensorControllerType.Temperature, false, garden.getIdealTemperature(), garden.getIdealTemperature() * (float)1.2, garden.getIdealTemperature() * (float)0.8); } } }).Send(); HTTPRequest request_getSensorData2 = new HTTPRequest(new Uri(data.IP + "/getLatestWetnessByGardenId?gardenId=" + garden.getId()), HTTPMethods.Get, (req_data2, res_data2) => { Debug.Log(res_data2.DataAsText); JArray array = JArray.Parse(res_data2.DataAsText); foreach (var e in array) { foreach (sensor n in garden.getSensors()) { if (n.getId() == (long)e["id"] && !n.getType()) { n.setData((float)e["wetness"]); } } } foreach (sensor e in garden.getSensors()) { if (!e.getType() && e.getData() != 0) { MapBG.drawOne(e.getId(), e.getName(), e.getX(), e.getY(), MapBG.SensorControllerType.Humidity, true, e.getData(), garden.getIdealHumidity() * (float)1.2, garden.getIdealHumidity() * (float)0.8); } else if (!e.getType() && e.getData() == 0) { MapBG.drawOne(e.getId(), e.getName(), e.getX(), e.getY(), MapBG.SensorControllerType.Humidity, false, garden.getIdealHumidity(), garden.getIdealHumidity() * (float)1.2, garden.getIdealHumidity() * (float)0.8); } } }).Send(); return; }