示例#1
0
    IEnumerator GetSwitch()
    {
        while (true)
        {
            UnityWebRequest www = UnityWebRequest.Get("https://gemini-program.herokuapp.com/api/suitswitch/recent");    //Placeholder
            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.isHttpError)
            {
                Debug.Log(www.error);
            }
            else
            {
                string jsonString = www.downloadHandler.text;
                jsonString = jsonString.Replace('[', ' ').Replace(']', ' ');

                SwitchTelemetry    switchData = JsonUtility.FromJson <SwitchTelemetry>(jsonString);
                int                numSwitch  = 14;
                SwitchDataPoints[] dataPoints = new SwitchDataPoints[numSwitch];

                setSwitchData(switchData, dataPoints);
            }
            yield return(new WaitForSeconds(10));
        }
    }
示例#2
0
    public void setSwitchData(SwitchTelemetry data, SwitchDataPoints[] dataPoints)
    {
        dataPoints[0] = new SwitchDataPoints("SOP On", data.sop_on);
        dataPoints[1] = new SwitchDataPoints("Spacesuit Pressure Emergency", data.sspe);
        dataPoints[2] = new SwitchDataPoints("Fan Failure", data.fan_error);
        dataPoints[3] = new SwitchDataPoints("No Vent Flow", data.vent_error);
        dataPoints[4] = new SwitchDataPoints("Vehicle Power Present", data.vehicle_power);
        dataPoints[5] = new SwitchDataPoints("H2O is off", data.h2o_off);
        dataPoints[6] = new SwitchDataPoints("O2 is off", data.o2_off);

        //data not coming from server
        dataPoints[7]  = new SwitchDataPoints("Battery AMP High", data.battery_amp_high);
        dataPoints[8]  = new SwitchDataPoints("Battery VDC Low", data.battery_vdc_low);
        dataPoints[9]  = new SwitchDataPoints("Suit Pressure Low", data.suit_pressure_low);
        dataPoints[10] = new SwitchDataPoints("Spacesuit Pressure High", data.spacesuit_pressure_high);
        dataPoints[11] = new SwitchDataPoints("O2 High Use", data.o2_high_use);
        dataPoints[12] = new SwitchDataPoints("SOP Pressure Low", data.sop_pressure_low);
        dataPoints[13] = new SwitchDataPoints("CO2 High", data.co2_high);
    }