Esempio n. 1
0
    public void UpdateJointsDynamicList(string robot_id, string arm_id)
    {
        try {
            //string robotId = SceneManager.Instance.RobotNameToId(JointsRobotsList.GetValue().ToString());

            foreach (RectTransform o in JointsDynamicList.GetComponentsInChildren <RectTransform>())
            {
                if (o.gameObject.tag != "Persistent")
                {
                    Destroy(o.gameObject);
                }
            }

            System.Collections.Generic.List <ProjectRobotJoints> joints;
            if (string.IsNullOrEmpty(arm_id))
            {
                joints = CurrentActionPoint.GetAllJoints(true, robot_id).Values.ToList();
            }
            else
            {
                joints = CurrentActionPoint.GetJointsOfArm(robot_id, arm_id, true).Values.ToList();
            }
            foreach (IO.Swagger.Model.ProjectRobotJoints joint in joints)
            {
                CreateJointsButton(JointsDynamicList.transform, joint.Id, joint.Name, () => OpenDetailMenu(joint), joint.IsValid);
            }
        } catch (ItemNotFoundException ex) {
            Debug.LogError(ex);
            Notifications.Instance.ShowNotification("Failed to get robot's ID", "");
            return;
        }
    }
    public void UpdateJointsDynamicList(string robotName)
    {
        if (robotName == null)
        {
            return;
        }

        try {
            string robotId = SceneManager.Instance.RobotNameToId(robotName);

            foreach (RectTransform o in JointsDynamicList.GetComponentsInChildren <RectTransform>())
            {
                if (o.gameObject.tag != "Persistent")
                {
                    Destroy(o.gameObject);
                }
            }

            System.Collections.Generic.List <ProjectRobotJoints> joints = CurrentActionPoint.GetAllJoints(true, robotId).Values.ToList();
            foreach (IO.Swagger.Model.ProjectRobotJoints joint in joints)
            {
                CreateJointsButton(JointsDynamicList.transform, joint.Id, joint.Name, () => OpenDetailMenu(joint)).State = joint.IsValid;
            }
        } catch (ItemNotFoundException ex) {
            Debug.LogError(ex);
            Notifications.Instance.ShowNotification("Failed to get robot's ID", "");
            return;
        }
    }
    public async void UpdateMenu()
    {
        ActionPointName.text = CurrentActionPoint.Data.Name;

        CustomDropdown positionRobotsListDropdown = PositionRobotsList.Dropdown;

        positionRobotsListDropdown.dropdownItems.Clear();
        await PositionRobotsList.gameObject.GetComponent <DropdownRobots>().Init(OnRobotChanged, true);

        if (!SceneManager.Instance.SceneStarted || positionRobotsListDropdown.dropdownItems.Count == 0)
        {
            PositionRobotsList.gameObject.SetActive(false);
            PositionEndEffectorList.gameObject.SetActive(false);
            UpdatePositionUsingRobotBtn.interactable    = false;
            AddOrientationUsingRobotButton.interactable = false;
        }
        else
        {
            PositionRobotsList.gameObject.SetActive(true);
            PositionEndEffectorList.gameObject.SetActive(true);
            UpdatePositionUsingRobotBtn.interactable    = true;
            AddOrientationUsingRobotButton.interactable = true;
            OnRobotChanged((string)PositionRobotsList.GetValue());
        }

        PositionExpertModeBlock.SetActive(GameManager.Instance.ExpertMode);
        PositionManualEdit.SetPosition(CurrentActionPoint.Data.Position);


        JointsRobotsList.Dropdown.dropdownItems.Clear();
        await JointsRobotsList.gameObject.GetComponent <DropdownRobots>().Init(UpdateJointsDynamicList, false);

        if (JointsRobotsList.Dropdown.dropdownItems.Count > 0)
        {
            JointsRobotsList.gameObject.SetActive(true);
            JointsDynamicList.SetActive(true);
            UpdateJointsDynamicList((string)JointsRobotsList.GetValue());
        }
        else
        {
            JointsRobotsList.gameObject.SetActive(false);
            JointsDynamicList.SetActive(false);
        }
        if (SceneManager.Instance.SceneStarted)
        {
            AddJointsButton.interactable = true;
        }
        else
        {
            AddJointsButton.interactable = false;
        }

        UpdateOrientationsDynamicList();
        UpdateTooltips();
    }
Esempio n. 4
0
    public async void UpdateMenu()
    {
        if (CurrentActionPoint == null)
        {
            return;
        }
        CloseAnySubmenu();

        PositionExpertModeBlock.SetActive(GameManager.Instance.ExpertMode);
        RobotPickBlock.SetActive(!GameManager.Instance.ExpertMode);
        PositionManualEdit.SetPosition(CurrentActionPoint.Data.Position);

        if (SceneManager.Instance.SceneStarted && SceneManager.Instance.IsRobotSelected())
        {
            JointsDynamicList.SetActive(true);
            if (SceneManager.Instance.SceneStarted && SceneManager.Instance.IsRobotAndEESelected())
            {
                UpdateJointsDynamicList(SceneManager.Instance.SelectedArmId);
            }
            else
            {
                UpdateJointsDynamicList(SceneManager.Instance.SelectedRobot.GetId(), null);
            }
        }
        else
        {
            JointsDynamicList.SetActive(false);
        }


        UpdateOrientationsDynamicList();

        const string noRobot         = "There is no robot in the scene";
        const string sceneNotStarted = "To add using robot, go online";
        const string eeNotSelected   = "End effector is not selected";

        UpdatePositionUsingRobotBtn.SetInteractivity(SceneManager.Instance.SceneStarted && SceneManager.Instance.IsRobotAndEESelected());
        UpdatePositionUsingRobotBtn2.SetInteractivity(UpdatePositionUsingRobotBtn.IsInteractive());
        AddOrientationUsingRobotButton.SetInteractivity(SceneManager.Instance.SceneStarted && SceneManager.Instance.IsRobotAndEESelected());
        AddJointsButton.SetInteractivity(SceneManager.Instance.SceneStarted, "Scene not started");

        if (!SceneManager.Instance.RobotInScene())
        {
            UpdatePositionUsingRobotBtn.SetInteractivity(false, noRobot);
            UpdatePositionUsingRobotBtn2.SetInteractivity(false, noRobot);
            AddOrientationUsingRobotButton.SetInteractivity(false, noRobot);
            AddJointsButton.SetInteractivity(false, noRobot);
            JointsListLabel.text = "To show joints list, add a robot to the scene";
        }
        else if (!SceneManager.Instance.SceneStarted)
        {
            UpdatePositionUsingRobotBtn.SetInteractivity(false, "To update using robot, go online");
            UpdatePositionUsingRobotBtn2.SetInteractivity(false, "To update using robot, go online");
            AddOrientationUsingRobotButton.SetInteractivity(false, sceneNotStarted);
            AddJointsButton.SetInteractivity(false, sceneNotStarted);
            JointsListLabel.text = "List of joints:";
        }
        else if (!SceneManager.Instance.IsRobotAndEESelected())
        {
            UpdatePositionUsingRobotBtn.SetInteractivity(false, eeNotSelected);
            UpdatePositionUsingRobotBtn2.SetInteractivity(false, eeNotSelected);
            AddOrientationUsingRobotButton.SetInteractivity(false, eeNotSelected);
            AddJointsButton.SetInteractivity(SceneManager.Instance.IsRobotSelected(), "Robot is not selected");
            if (SceneManager.Instance.IsRobotSelected())
            {
                JointsListLabel.text = "List of joints:";
            }
            else
            {
                JointsListLabel.text = "To show joints list, select robot";
            }
        }
        else
        {
            UpdatePositionUsingRobotBtn.SetInteractivity(true);
            UpdatePositionUsingRobotBtn2.SetInteractivity(true);
            AddOrientationUsingRobotButton.SetInteractivity(true);
            AddJointsButton.SetInteractivity(true);
            JointsListLabel.text = "List of joints:";
        }
    }