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)); } }
//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)); } }