public void SetSensorInformation(SensorInformationEntity entity) { double ShowTemperatureScore = (double)Math.Round(entity.temperature, 2, MidpointRounding.AwayFromZero); double ShowHumidityScore = (double)Math.Round(entity.humidity, 2, MidpointRounding.AwayFromZero); TemperatureScoreLabel.text = ShowTemperatureScore.ToString(); HumidityScoreLabel.text = ShowHumidityScore.ToString(); if (ShowTemperatureScore > TemperatureThreshold) { TemperatureArarmLabel.text = "温度は閾値を超過しました。"; TemperatureArarmLabel.color = Color.red; } else { TemperatureArarmLabel.text = "温度は正常です"; TemperatureArarmLabel.color = Color.green; } if (ShowHumidityScore > HumidityThreshold) { HumidityArarmLabel.text = "湿度は閾値を超過しました。"; HumidityArarmLabel.color = Color.red; } else { HumidityArarmLabel.text = "湿度は正常です"; HumidityArarmLabel.color = Color.green; } }
/// <summary> /// AzureFunctionの処理を呼び出す /// </summary> public IEnumerator CallAzureFunction() { Debug.Log("センサー情報取得処理開始"); SensorInformationEntity sensorinformationentity = null; using (UnityWebRequest www = UnityWebRequest.Get(azureFunctionEndpoint)) { // 受信したデータを格納するハンドラの初期化 www.downloadHandler = new DownloadHandlerBuffer(); //Debug.Log("++++++++++++++++++++1"); // 送受信を開始し、完了するまで待つ yield return(www.SendWebRequest()); //Debug.Log("++++++++++++++++++++2"); // ダウンロードした内容を文字列として取得 string jsonResponse = www.downloadHandler.text; //Debug.Log("++++++++++++++++++++3"); // 取得したJSON文字列を逆シリアライズ化 sensorinformationentity = JsonConvert.DeserializeObject <SensorInformationEntity>(jsonResponse); //Debug.Log("++++++++++++++++++++4"); } SensorInformationManager.Instance.SetSensorInformation(sensorinformationentity); //Debug.Log("++++++++++++++++++++5"); Debug.Log("センサー情報取得及び分析処理完了"); }