IEnumerator GetNumerical() { while (true) { //old server: https://gemini-program.herokuapp.com/api/suit/recent UnityWebRequest www = UnityWebRequest.Get("http://192.70.120.211:3000/api/simulation/state"); //New server from Test Week 2019 yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { string jsonString = www.downloadHandler.text; jsonString = jsonString.Replace('[', ' ').Replace(']', ' '); numericalData = JsonUtility.FromJson <NumericalTelemetry>(jsonString); int numComponents = 10; //Number of components SuitDataPoints[] suitDataPoints = new SuitDataPoints[numComponents]; setSuitData(numericalData, suitDataPoints); } yield return(new WaitForSeconds(10)); } }
IEnumerator GetNumerical() { while (true) { //UnityWebRequest www = UnityWebRequest.Get("https://nasa-bhitt.c9users.io/api/suit/recent"); UnityWebRequest www = UnityWebRequest.Get("https://gemini-program.herokuapp.com/api/suit/recent"); yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { //Debug.Log(www.downloadHandler.text); string jsonString = www.downloadHandler.text; jsonString = jsonString.Replace('[', ' ').Replace(']', ' '); //NumericalTelemetry numericalData = JsonUtility.FromJson<NumericalTelemetry>(jsonString); numericalData = JsonUtility.FromJson <NumericalTelemetry>(jsonString); //if time life battery is erroneous when received from server if (numericalData.t_battery[0] == '-') { numericalData.t_battery = "00:00:00"; } //check for negative time value if (numericalData.t_battery[0] == '-') { numericalData.t_battery = "00:00:00"; } int numComponents = 15; DataPoints [] dataPoints = new DataPoints[numComponents]; setDataPoints(numericalData, dataPoints); for (int i = 0; i < dataPoints.Length; i++) { Debug.Log(dataPoints[1].name + " : " + dataPoints[1].value + " " + dataPoints[1].unit); if (dataPoints[i].status == 3) { //NotificationService.Issue(dataPoints[i].name, "has failed", 0); } } //makeNumericalDataUI(dataPoints); } //make a request every 10 seconds yield return(new WaitForSeconds(10)); } }
//Sets Suit Telemetry public void setSuitData(NumericalTelemetry data, SuitDataPoints[] dataPoints) { dataPoints[0] = new SuitDataPoints("Sub Pressure", data.p_sub, "psia", 2.0f, 4.0f); dataPoints[1] = new SuitDataPoints("Sub Temperature", data.t_sub, "\u00B0F", 4f, 6f); dataPoints[2] = new SuitDataPoints("Fan Tachometer", data.v_fan, "RPM", 10000f, 40000f); dataPoints[3] = new SuitDataPoints("EVA Time", data.t_eva, "hh:mm:ss", 0, 36000); dataPoints[4] = new SuitDataPoints("Oxygen Pressure", data.p_o2, "psia", 750f, 950f); dataPoints[5] = new SuitDataPoints("Battery Capacity", data.cap_battery, "amp-hr", 0f, 30f); dataPoints[6] = new SuitDataPoints("H2O Gas Pressure", data.p_h2o_g, "psia", 14f, 16f); dataPoints[7] = new SuitDataPoints("H2O Liquid Pressure", data.p_h2o_l, "psia", 14f, 16f); dataPoints[8] = new SuitDataPoints("Secondary Oxygen Pack Pressure", data.p_sop, "psia", 750f, 950f); dataPoints[9] = new SuitDataPoints("Secondary Oxygen Pack Flow Rate", data.rate_sop, "psi/min", 0.5f, 1.0f); }
//Sets Suit Telemetry public void setSuitData(NumericalTelemetry data, SuitDataPoints[] dataPoints) { dataPoints[0] = new SuitDataPoints("Heart Beats Per Minute", data.heart_bpm, "bpm", 85f, 90f); dataPoints[1] = new SuitDataPoints("Sub Pressure", data.p_sub, "psia", 2.0f, 4.0f); dataPoints[2] = new SuitDataPoints("Internal Suit Pressure", data.p_suit, "psid", 2.0f, 4.0f); dataPoints[3] = new SuitDataPoints("Sub Temperature", data.t_sub, "\u00B0F", 4f, 6f); dataPoints[4] = new SuitDataPoints("Fan Tachometer", data.v_fan, "RPM", 10000f, 40000f); dataPoints[5] = new SuitDataPoints("Oxygen Pressure", data.p_o2, "psia", 750f, 950f); dataPoints[6] = new SuitDataPoints("Oxygen Rate", data.rate_o2, "psi/min", 0.5f, 1.0f); dataPoints[7] = new SuitDataPoints("Battery Capacity", data.cap_battery, "amp-hr", 0f, 30f); dataPoints[8] = new SuitDataPoints("H2O Gas Pressure", data.p_h2o_g, "psia", 14f, 16f); dataPoints[9] = new SuitDataPoints("H2O Liquid Pressure", data.p_h2o_l, "psia", 14f, 16f); dataPoints[10] = new SuitDataPoints("Secondary Oxygen Pack Pressure", data.p_sop, "psia", 750f, 950f); dataPoints[11] = new SuitDataPoints("Secondary Oxygen Pack Flow Rate", data.rate_sop, "psi/min", 0.5f, 1.0f); }
IEnumerator GetNumerical() { while (true) { UnityWebRequest www = UnityWebRequest.Get("https://skylab-program.herokuapp.com/api/suit/recent"); yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { string jsonString = www.downloadHandler.text; jsonString = jsonString.Replace('[', ' ').Replace(']', ' '); numericalData = JsonUtility.FromJson <NumericalTelemetry>(jsonString); if (numericalData.t_battery[0] == '-') { numericalData.t_battery = "00:00:00"; } if (numericalData.t_oxygen[0] == '-') { numericalData.t_oxygen = "00:00:00"; } if (numericalData.t_water[0] == '-') { numericalData.t_water = "00:00:00"; } int numAr = 12; //Number of components SuitDataPoints[] suitDataPoints = new SuitDataPoints[numAr]; setSuitData(numericalData, suitDataPoints); tDataS.Add(numericalData); stdDev(tDataS, numAr); } yield return(new WaitForSeconds(10)); } }
public void setDataPoints(NumericalTelemetry data, DataPoints [] dataPoints) { dataPoints[0] = new DataPoints("Heart Rate", data.heart_bpm, "bpm", 85f, 90f); dataPoints[1] = new DataPoints("Internal Suit Pressure", data.p_suit, "psid", 2.0f, 4.0f); dataPoints[2] = new DataPoints("Sub Pressure", data.p_sub, "psia", 2.0f, 4.0f); dataPoints[3] = new DataPoints("Sub Temperature", data.t_sub, "\u00B0F", 4f, 6f); dataPoints[4] = new DataPoints("Fan Tachometer", data.v_fan, "RPM", 10000f, 40000f); dataPoints[5] = new DataPoints("Oxygen Pressure", data.p_o2, "psia", 750f, 950f); dataPoints[6] = new DataPoints("Oxygen Rate", data.rate_o2, "psi/min", 0.5f, 1.0f); dataPoints[7] = new DataPoints("Battery Capacity", data.cap_battery, "amp-hr", 0f, 30f); dataPoints[8] = new DataPoints("H2O Gas Pressure", data.p_h2o_g, "psia", 14f, 16f); dataPoints[9] = new DataPoints("H2O Liquid Pressure", data.p_h2o_l, "psia", 14f, 16f); dataPoints[10] = new DataPoints("Secondary Oxygen Pack Pressure", data.p_sop, "psia", 750f, 950f); dataPoints[11] = new DataPoints("Secondary Oxygen Pack Flow Rate", data.rate_sop, "psi/min", 0.5f, 1.0f); dataPoints[12] = new DataPoints("Time Life Battery", data.t_battery, "hh:mm:ss", 0, 36000); dataPoints[13] = new DataPoints("Time Life Oxygen", data.t_oxygen, "hh:mm:ss", 0, 36000); dataPoints[14] = new DataPoints("Time Life Water", data.t_water, "hh:mm:ss", 0, 36000); //dataPoints[15] = new DataPoints("Last Update", data.create_date, "find out", 1, 1); }