void HandleValueChanged(object sender, ValueChangedEventArgs args) { if (args.DatabaseError != null) { Debug.LogError(args.DatabaseError.Message); return; } //Debug.Log(args.Snapshot.Key); // Do something with the data in args.Snapshot foreach (var t in args.Snapshot.Children) { if (Regex.IsMatch(t.Key, "_" + num + "$")) { var c = t.Value; if (Regex.IsMatch(t.Key, "^hi")) { HIText.SetActive(true); HIText.GetComponent <Text>().text = "Heat Index:" + c.ToString(); } if (Regex.IsMatch(t.Key, "^ir")) { IRText.SetActive(true); IRText.GetComponent <Text>().text = "IR:" + c.ToString(); } if (Regex.IsMatch(t.Key, "^gs")) { GasText.SetActive(true); GasText.GetComponent <Text>().text = "Gas Sensor:" + c.ToString(); } if (Regex.IsMatch(t.Key, "^hu")) { HumidText.SetActive(true); HumidText.GetComponent <Text>().text = "Humidity:" + c.ToString(); } if (Regex.IsMatch(t.Key, "^te")) { TempText.SetActive(true); TempText.GetComponent <Text>().text = "Temperature:" + c.ToString(); } if (Regex.IsMatch(t.Key, "^ld")) { LDRText.SetActive(true); LDRText.GetComponent <Text>().text = "LDR:" + c.ToString(); } } } }
void HandleValueChanged(object sender, ValueChangedEventArgs args) { if (args.DatabaseError != null) { Debug.LogError(args.DatabaseError.Message); return; } //Debug.Log(args.Snapshot.Key); // Do something with the data in args.Snapshot foreach (var t in args.Snapshot.Children) { if (Regex.IsMatch(t.Key, "_" + num + "$")) { var c = t.Value; Debug.Log(c); if (Regex.IsMatch(t.Key, "^hi")) { t1 = DateTime.Now; HIText.SetActive(true); HIText.GetComponent <Text>().text = "Heat Index:" + c.ToString() + "\nUpdated " + t1.ToLongTimeString(); } if (Regex.IsMatch(t.Key, "^ir")) { t2 = DateTime.Now; IRText.SetActive(true); IRText.GetComponent <Text>().text = "IR:" + c.ToString() + "\nUpdated " + t2.ToLongTimeString(); } if (Regex.IsMatch(t.Key, "^gs")) { t3 = DateTime.Now; GasText.SetActive(true); var comp = GasText.GetComponent <Text>(); comp.text = "Gas Sensor:" + c.ToString() + "\nUpdated " + t3.ToLongTimeString(); //comp.color = new Color(255, 0, 0); if (float.Parse(c.ToString()) > 500f) { Debug.Log("HIGH"); comp.color = new Color(255, 0, 0); } else { Debug.Log("LOW"); comp.color = new Color(0, 0, 0); } } if (Regex.IsMatch(t.Key, "^hu")) { var comp = HumidText.GetComponent <Text>(); if (float.Parse(c.ToString()) > 100f) { comp.color = new Color(255, 0, 0); } else { comp.color = new Color(0, 0, 0); } t4 = DateTime.Now; HumidText.SetActive(true); comp.text = "Humidity:" + c.ToString() + "\nUpdated " + t4.ToLongTimeString(); } if (Regex.IsMatch(t.Key, "^te")) { var comp = TempText.GetComponent <Text>(); if (float.Parse(c.ToString()) > 35f) { comp.color = new Color(255, 0, 0); } else { comp.color = new Color(0, 0, 0); } t5 = DateTime.Now; TempText.SetActive(true); comp.text = "Temperature:" + c.ToString() + "\nUpdated " + t5.ToLongTimeString(); } if (Regex.IsMatch(t.Key, "^ld")) { var comp = LDRText.GetComponent <Text>(); if (float.Parse(c.ToString()) > 350f) { comp.color = new Color(255, 0, 0); } else { comp.color = new Color(0, 0, 0); } t6 = DateTime.Now; LDRText.SetActive(true); comp.text = "LDR:" + c.ToString() + "\nUpdated " + t6.ToLongTimeString(); } } } }