private void DisplayIAU(IAU iau)
    {
        foreach (Transform trans in panel_top.GetComponentsInChildren <Transform>())
        {
            if (trans.tag.Equals("iau_content"))
            {
                Destroy(trans.gameObject);
            }
        }

        iauContent = Instantiate(iauContentPrefab);

        iauContent.name = "IAU Content";
        iauContent.tag  = "iau_content";
        iauContent.transform.SetParent(panel_top);
        iauContent.transform.localPosition = new Vector3(0, 0, 0);
        iauContent.transform.localRotation = Quaternion.identity;

        string textToDisplay = "Step " + iau.iau_step + "." + iau.iau_sub_step + ": " + iau.iau_high_level_action + "\n"
                               + iau.iau_task_of_action;

        if (iau.iau_caution != null && !iau.iau_caution.Trim().Equals(""))
        {
            textToDisplay += "\n" + iau.iau_caution;
        }
        Text textComponent = iauContent.transform.GetComponentInChildren <Text>();

        textComponent.text = textToDisplay;
    }
예제 #2
0
    private void DisplayIAU(IAU iau)
    {
        foreach (Transform trans in panel_top.GetComponentsInChildren <Transform>())
        {
            if (trans.tag.Equals("iau_content"))
            {
                Destroy(trans.gameObject);
            }
        }

        iauContent = Instantiate(iauContentPrefab);

        iauContent.name = "IAU Content";
        iauContent.tag  = "iau_content";
        iauContent.transform.SetParent(panel_top);
        iauContent.transform.localPosition = new Vector3(0, 0, 0);
        iauContent.transform.localRotation = Quaternion.identity;

        string textToDisplay = "Step " + iau.iau_step + "." + iau.iau_sub_step + ": " + iau.iau_high_level_action + "\n"
                               + iau.iau_task_of_action;

        if (iau.iau_caution != null && !iau.iau_caution.Trim().Equals(""))
        {
            textToDisplay += "\n" + iau.iau_caution;
        }
        Text[] textComponents = iauContent.transform.GetComponentsInChildren <Text>();
        textComponents[0].text = textToDisplay;
        textComponents[1].text = "Progress: " + iau.iau_step + "/" + TotalStepCount;

        GameObject TotalProgressVisual   = iauContent.transform.Find("TotalProgress").gameObject;
        GameObject CurrentProgressVisual = TotalProgressVisual.transform.Find("CurrentProgress").gameObject;

        CurrentProgressVisual.transform.localScale = new Vector3((float)Int32.Parse(iau.iau_step) / (float)Int32.Parse(TotalStepCount), 1, 1);
    }
    private IEnumerator UpdateIauLocked(IAU iau)
    {
        string hostName = ConnectionController.HOST_NAME;
        string url      = "http://" + hostName + "/NasaSuits/api/eva/iau/UpdateIAU.php?iau_id=" + iau.iau_id + "&locked=" + iau.iau_locked;
        WWW    response = new WWW(url);

        yield return(response);

        Debug.Log("Update locked for " + iau.iau_step + "." + iau.iau_sub_step + ": " + iau.iau_high_level_action + ", set locked=" + iau.iau_locked + ". " + response.text);
    }
    private IEnumerator GetIAUById(string iauId)
    {
        RemoveAllIAUContent();

        string hostName = ConnectionController.HOST_NAME;
        string url      = "http://" + hostName + "/NasaSuits/api/eva/iau/GetIAU.php?iau_id=" + iauId;
        WWW    response = new WWW(url);

        yield return(response);

        IAU iau = null;

        try
        {
            iau = JsonConvert.DeserializeObject <IAU>(response.text);
        }
        catch (Exception e)
        {
            Debug.Log("Exception while parsing Json object " + response.text);
            Debug.Log(e);
        }

        // If this Iau is not released, display the warning scene
        if (iau != null && !iau.iau_preemption_level.Equals("3"))
        {
            DisplayLoadingScene("This IAU " + iau.iau_step + "." + iau.iau_sub_step + " " + iau.iau_high_level_action + " is not released");
        }

        // while the preemption is not 3, wait until this Iau is released
        WaitForSeconds waitTime = new WaitForSeconds(1);

        while (iau != null && !iau.iau_preemption_level.Equals("3"))
        {
            Debug.Log("IAU is not released");

            response = new WWW(url);
            yield return(response);

            try
            {
                iau = JsonConvert.DeserializeObject <IAU>(response.text);
            }
            catch (Exception e)
            {
                Debug.Log("Exception while parsiong Json object " + response.text);
                Debug.Log(e);
            }
            yield return(waitTime);
        }

        // after the Iau is released
        if (iau != null)
        {
            // When Iau is released, remove the loading scene and show the Iau
            RemoveLoadingScene();
            currentIau = iau;
            DisplayIAU(iau);
            DisplayIUs(iau);

            // load the flow from Flow table related to this Iau
            StartCoroutine(GetFlowTableByEvaId(iau.iau_eva_id));

            // play sound effect to notice the update of IAU view
            PlaySoundEffect(TelemetryController.SOUND_EFFECT_COMPLETE, false);
        }
    }
    private IEnumerator WaitForCompletionAndGoForward(int iauId)
    {
        if (!currentIau.iau_confirm_level.Equals("3"))
        {
            string hostName = ConnectionController.HOST_NAME;
            string url      = "http://" + hostName + "/NasaSuits/api/eva/iau/GetIAU.php?iau_id=" + iauId;
            WWW    response = new WWW(url);
            yield return(response);

            IAU iau = null;
            try
            {
                iau = JsonConvert.DeserializeObject <IAU>(response.text);
            }
            catch (Exception e)
            {
                Debug.Log("Exception while parsiong Json object " + response.text);
                Debug.Log(e);
            }

            if (iau != null && !iau.iau_completed.Equals("1"))
            {
                RemoveAllIAUContent();
                DisplayLoadingScene("IAU " + currentIau.iau_step + "." + currentIau.iau_sub_step + ": " + currentIau.iau_high_level_action + " is checking by Flight Crews and Groung Crews.\nWaiting for Completion status");
            }

            // wait until the IAU is marked completed by Flight Crews or Ground Crews
            WaitForSeconds waitTime = new WaitForSeconds(1);
            while (iau != null && !iau.iau_completed.Equals("1"))
            {
                Debug.Log("IAU is waiting for Completion");
                response = new WWW(url);
                yield return(response);

                try
                {
                    iau = JsonConvert.DeserializeObject <IAU>(response.text);
                }
                catch (Exception e)
                {
                    Debug.Log("Exception while parsiong Json object " + response.text);
                    Debug.Log(e);
                }
                yield return(waitTime);
            }

            // When the IAU is marked completed
            // Remove the loading scene
            RemoveLoadingScene();
        }

        // release the lock of the current IAU
        currentIau.iau_locked = "0";
        StartCoroutine(UpdateIauLocked(currentIau));

        // Go to the next IAU base on the flow table
        for (int i = 0; i < flowEntries.Count; i++)
        {
            FlowEntry flow = flowEntries[i];
            if (flow.current_iau_id.Equals(currentIau.iau_id))
            {
                if (flow.future_iau_id != null)
                {
                    StartCoroutine(GetIAUById(flow.future_iau_id));
                    // lock the future Iau
                    StartCoroutine(UpdateIauLocked(flow.future_iau_id, "1"));

                    // play sound effect noticing the Astronaut of the update
                    PlaySoundEffect(TelemetryController.SOUND_EFFECT_COMPLETE, false);
                }
                else
                {
                    GameObject btn = GameObject.FindGameObjectWithTag("confirm_button");
                    if (btn != null)
                    {
                        btn.GetComponent <Button>().interactable = false;
                        btn.GetComponentInChildren <Text>().text = "End";
                    }
                }
                break;
            }
        }
    }
    private void DisplayIUs(IAU iau)
    {
        //destroy current ARControllers
        foreach (Transform trans in panel_top.GetComponentsInChildren <Transform>())
        {
            if (trans.tag.Equals("arc"))
            {
                Destroy(trans.gameObject);
            }
        }
        foreach (Transform trans in panel_bottom.GetComponentsInChildren <Transform>())
        {
            if (trans.tag.Equals("arc"))
            {
                Destroy(trans.gameObject);
            }
        }

        //create new arcontrollers with new Content
        GameObject obj = null;

        for (int i = 0; i < iau.iau_ius.Count; ++i)
        {
            IU iu = iau.iau_ius[i];
            switch (iu.iu_type)
            {
            case "image":
                PictureARC pictureARC = new PictureARC();
                pictureARC.SetLink(iu.iu_link);
                pictureARC.SetPos(iu.GetPosition());
                pictureARC.SetScale(iu.GetScale());
                pictureARC.SetRotation(iu.GetRotation());
                obj = CreateARC.CreateIU(pictureARC, panel_top, imagePrefab);

                break;

            case "text":
                TextARC textARC = new TextARC();
                textARC.SetLink(iu.iu_link);
                textARC.SetPos(iu.GetPosition());
                textARC.SetScale(iu.GetScale());
                textARC.SetRotation(iu.GetRotation());
                obj = CreateARC.CreateIU(textARC, panel_top, textPrefab);

                break;

            case "video":
                VideoARC videoARC = new VideoARC();
                videoARC.SetLink(iu.iu_link);
                videoARC.SetPos(iu.GetPosition());
                videoARC.SetScale(iu.GetScale());
                videoARC.SetRotation(iu.GetRotation());
                obj = CreateARC.CreateIU(videoARC, panel_top, videoPrefab);

                break;

            case "audio":
                AudioARC audioARC = new AudioARC();
                audioARC.SetLink(iu.iu_link);
                audioARC.SetPos(iu.GetPosition());
                audioARC.SetScale(iu.GetScale());
                audioARC.SetRotation(iu.GetRotation());
                obj = CreateARC.CreateIU(audioARC, panel_top, audioPrefab);

                break;

            case "3d":
                Model3dARC model3dARC = new Model3dARC();
                model3dARC.SetLink(iu.iu_link);
                model3dARC.SetPos(iu.GetPosition());
                model3dARC.SetScale(iu.GetScale());
                model3dARC.SetRotation(iu.GetRotation());

                switch (model3dARC.GetModel())
                {
                case "fusebox":
                    obj = CreateARC.CreateIU(model3dARC, panel_bottom, fuseboxPrefab);
                    break;

                case "battery pack":
                    obj = CreateARC.CreateIU(model3dARC, panel_bottom, batteryPackPrefab);
                    break;

                case "buss bars":
                    obj = CreateARC.CreateIU(model3dARC, panel_bottom, bussBarsPrefab);
                    break;

                case "estop button key":
                    obj = CreateARC.CreateIU(model3dARC, panel_bottom, eStopButtonKeyPrefab);
                    break;

                case "estop button push":
                    obj = CreateARC.CreateIU(model3dARC, panel_bottom, eStopButtonPushPrefab);
                    break;

                case "conveyor belt":
                    obj = CreateARC.CreateIU(model3dARC, panel_bottom, conveyorPrefab);
                    break;

                default:
                    Debug.Log("Could not find 3d model by name '" + model3dARC.GetModel() + "'");
                    break;
                }
                obj.AddComponent <BoxCollider>().size = new Vector3(50, 15, 30);

                break;

            default:
                Debug.Log("Something went wrong with iu type");
                break;
            }
        }
    }
예제 #7
0
    private void DisplayIUs(IAU iau)
    {
        //destroy current ARControllers
        foreach (Transform trans in panel_top.GetComponentsInChildren <Transform>())
        {
            if (trans.tag.Equals("arc"))
            {
                Destroy(trans.gameObject);
            }
        }
        foreach (Transform trans in panel_bottom.GetComponentsInChildren <Transform>())
        {
            if (trans.tag.Equals("arc"))
            {
                Destroy(trans.gameObject);
            }
        }

        foreach (Transform trans in worldSpace.GetComponentsInChildren <Transform>())
        {
            if (trans.tag.Equals("arc"))
            {
                Destroy(trans.gameObject);
            }
        }

        //create new arcontrollers with new Content
        GameObject obj = null;

        for (int i = 0; i < iau.iau_ius.Count; ++i)
        {
            IU iu = iau.iau_ius[i];
            switch (iu.iu_type)
            {
            case "image":
                PictureARC pictureARC = new PictureARC();
                pictureARC.SetLink(iu.iu_link);
                pictureARC.SetPos(iu.GetPosition());
                pictureARC.SetScale(iu.GetScale());
                pictureARC.SetRotation(iu.GetRotation());
                obj = CreateARC.CreateIU(pictureARC, panel_top, imagePrefab);

                break;

            case "text":
                TextARC textARC = new TextARC();
                textARC.SetLink(iu.iu_link);
                textARC.SetPos(iu.GetPosition());
                textARC.SetScale(iu.GetScale());
                textARC.SetRotation(iu.GetRotation());
                obj = CreateARC.CreateIU(textARC, panel_top, textPrefab);

                break;

            case "video":
                VideoARC videoARC = new VideoARC();
                videoARC.SetLink(iu.iu_link);
                videoARC.SetPos(iu.GetPosition());
                videoARC.SetScale(iu.GetScale());
                videoARC.SetRotation(iu.GetRotation());
                obj = CreateARC.CreateIU(videoARC, panel_top, videoPrefab);

                break;

            case "audio":
                AudioARC audioARC = new AudioARC();
                audioARC.SetLink(iu.iu_link);
                audioARC.SetPos(iu.GetPosition());
                audioARC.SetScale(iu.GetScale());
                audioARC.SetRotation(iu.GetRotation());
                obj = CreateARC.CreateIU(audioARC, panel_top, audioPrefab);

                break;

            case "3d":
                Model3dARC model3dARC = new Model3dARC();
                model3dARC.SetLink(iu.iu_link);
                model3dARC.SetPos(iu.GetPosition());
                model3dARC.SetScale(iu.GetScale());
                model3dARC.SetRotation(iu.GetRotation());
                CreateARC.CreateIU(model3dARC, panel_bottom, model3dPrefab);

                break;

            default:
                Debug.Log("Something went wrong with iu type");
                break;
            }
        }
    }