예제 #1
0
    IEnumerator RunSwitchWWW()
    {
        if (m_bGettingSwitchData == true)
        {
            yield break;
        }

        using (UnityWebRequest www = UnityWebRequest.Get(switchUrl))
        {
            yield return(www.SendWebRequest());

            m_bGettingSwitchData = true;

            string json = "";
            if (www.isNetworkError)
            {
                bioText.text         = "NETWORK ERROR Not connected to server :(\n";
                bioText.text        += www.error;
                m_bGettingSwitchData = false;
            }
            else if (www.isHttpError)
            {
                bioText.text         = "HTTP ERROR Not connected to server :( :( :(";
                bioText.text        += www.error;
                m_bGettingSwitchData = false;
            }
            else
            {
                // We are connected to the server

                // Use line below only if the JSON comes in with brackets around it
                //json = RemoveBrackets(www.downloadHandler.text);
                json = www.downloadHandler.text;
            }

            json = json.Substring(1, json.Length - 2);

            //Debug.Log(json);
            SuitDataSwitch jsonObject = JsonUtility.FromJson <SuitDataSwitch>(json);

            CheckSuitSwitches(jsonObject);
            //UpdateSwitchUI(jsonObject);
            m_bGettingSwitchData = false;
        }
    }
예제 #2
0
    private void UpdateSwitchUI(SuitDataSwitch switchData)
    {
        if (switchData == null)
        {
            return;
        }

        /*
         * m_SuitDataUIElements[15].SetData("Battery Amp High", switchData.battery_amp_high.ToString());
         * m_SuitDataUIElements[16].SetData("Battery VDC Low", switchData.battery_vdc_low.ToString());
         * m_SuitDataUIElements[17].SetData("Suit Pressure Low", switchData.p_suit_low.ToString());
         * m_SuitDataUIElements[18].SetData("SOP On", switchData.sop_on.ToString());
         * m_SuitDataUIElements[19].SetData("Suit Pressure Emergency", switchData.p_suit_emergency.ToString());
         * m_SuitDataUIElements[20].SetData("Suit Pressure High", switchData.p_suit_high.ToString());
         * m_SuitDataUIElements[21].SetData("O2 Use High", switchData.o2_use_high.ToString());
         * m_SuitDataUIElements[22].SetData("SOP Pressure Low", switchData.p_suit_low.ToString());
         * m_SuitDataUIElements[23].SetData("Fan Failure", switchData.fan_error.ToString());
         * m_SuitDataUIElements[24].SetData("CO2 High", switchData.co2_high.ToString());
         * m_SuitDataUIElements[25].SetData("Vehicle Power Present", switchData.vehicle_power.ToString());
         * m_SuitDataUIElements[26].SetData("H20 Is Off", switchData.h2o_off.ToString());
         * m_SuitDataUIElements[27].SetData("O2 is Off", switchData.o2_off.ToString());*/
    }
예제 #3
0
    private void CheckSuitSwitches(SuitDataSwitch ndts)
    {
        if (m_OutputErrorData == null)
        {
            m_OutputErrorData = FindObjectOfType <OutputErrorData>();
        }

        Debug.Log("Output Error Data" + m_OutputErrorData.gameObject.transform);

        m_OutputErrorData.ClearText();

        if (ndts == null)
        {
            //m_OutputErrorData.OutputErrorText("No Connection to Server");
            return;
        }

        if (ndts.h2o_off == "true")
        {
            m_OutputErrorData.OutputErrorText("H2O IS OFF");
        }
        if (ndts.sspe == "true")
        {
            m_OutputErrorData.OutputErrorText("SUIT P EMERG");
        }
        if (ndts.fan_error == "true")
        {
            m_OutputErrorData.OutputErrorText("FAN SW OFF");
        }
        if (ndts.vent_error == "true")
        {
            m_OutputErrorData.OutputErrorText("NO VENT FLOW");                            // Add vent rpms
        }
        if (ndts.vehicle_power == "true")
        {
            m_OutputErrorData.OutputErrorText("VEHICLE POWER AVAIL");
        }
        if (ndts.o2_off == "true")
        {
            m_OutputErrorData.OutputErrorText("O2 IS OFF");
        }
        if (ndts.sop_on == "true")
        {
            m_OutputErrorData.OutputErrorText("SECONDARY OXYGEN TANK ON");
        }

        if (m_SwitchUIElements.Length <= 0)
        {
            return;
        }

        //Debug.Log(ndts.sop_on);

        m_SwitchUIElements[0].SetActive(GetSwitchState(ndts.h2o_off));
        m_SwitchUIElements[1].SetActive(GetSwitchState(ndts.sspe));
        m_SwitchUIElements[2].SetActive(GetSwitchState(ndts.fan_error));
        m_SwitchUIElements[3].SetActive(GetSwitchState(ndts.vent_error));
        m_SwitchUIElements[4].SetActive(GetSwitchState(ndts.vehicle_power));
        m_SwitchUIElements[5].SetActive(GetSwitchState(ndts.o2_off));
        m_SwitchUIElements[6].SetActive(GetSwitchState(ndts.sop_on));
        m_SwitchUIElements[7].SetActive(GetSwitchState(ndts.battery_amp_high));
        m_SwitchUIElements[8].SetActive(GetSwitchState(ndts.battery_vdc_low));
        m_SwitchUIElements[9].SetActive(GetSwitchState(ndts.suit_pressure_low));
        m_SwitchUIElements[10].SetActive(GetSwitchState(ndts.suit_pressure_high));
        m_SwitchUIElements[11].SetActive(GetSwitchState(ndts.o2_use_high));
        m_SwitchUIElements[12].SetActive(GetSwitchState(ndts.sop_pressure_low));
        m_SwitchUIElements[13].SetActive(GetSwitchState(ndts.co2_high));
    }