Esempio n. 1
0
 public void InitAP(IO.Swagger.Model.ProjectActionPoint apData, float size, IActionPointParent parent = null)
 {
     Debug.Assert(apData != null);
     SetParent(parent);
     Data = apData;
     OrientationsVisible     = PlayerPrefsHelper.LoadBool("/AP/" + Data.Id + "/visible", true);
     ActionsCollapsed        = PlayerPrefsHelper.LoadBool("/AP/" + Data.Id + "/actionsCollapsed", false);
     transform.localPosition = GetScenePosition();
     SetSize(size);
     ActivateForGizmo((ControlBoxManager.Instance.UseGizmoMove && ProjectManager.Instance.AllowEdit && !MenuManager.Instance.IsAnyMenuOpened) ? "GizmoRuntime" : "Default");
 }
Esempio n. 2
0
        public void InitAP(IO.Swagger.Model.ProjectActionPoint apData, float size, IActionPointParent parent = null)
        {
            Debug.Assert(apData != null);
            SetParent(parent);
            Data = apData;
            transform.localPosition = GetScenePosition();
            SetSize(size);
            ActivateForGizmo((ControlBoxManager.Instance.UseGizmoMove == true) ? "GizmoRuntime" : "Default");
            // TODO: is this neccessary?

            /*if (Data.Orientations.Count == 0)
             *  Data.Orientations.Add(new IO.Swagger.Model.NamedOrientation(id: "default", orientation: new IO.Swagger.Model.Orientation()));*/
        }
Esempio n. 3
0
 public void ActionPointBaseUpdate(IO.Swagger.Model.ProjectActionPoint apData)
 {
     Data.Name     = apData.Name;
     Data.Position = apData.Position;
     // update position and rotation based on received data from swagger
     transform.localPosition = GetScenePosition();
     if (Parent != null)
     {
         ConnectionToParent.UpdateLine();
     }
     //TODO: ActionPoint has multiple rotations of end-effectors, for visualization, render end-effectors individually
     //transform.localRotation = GetSceneOrientation();
 }
Esempio n. 4
0
        public ActionPoint SpawnActionPoint(IO.Swagger.Model.ProjectActionPoint apData, IActionPointParent actionPointParent)
        {
            Debug.Assert(apData != null);
            GameObject AP;

            if (actionPointParent == null)
            {
                AP = Instantiate(ActionPointPrefab, ActionPointsOrigin.transform);
            }
            else
            {
                AP = Instantiate(ActionPointPrefab, actionPointParent.GetTransform());
            }

            AP.transform.localScale = new Vector3(1f, 1f, 1f);
            ActionPoint actionPoint = AP.GetComponent <ActionPoint>();

            actionPoint.InitAP(apData, APSize, actionPointParent);
            ActionPoints.Add(actionPoint.Data.Id, actionPoint);

            return(actionPoint);
        }
Esempio n. 5
0
        /// <summary>
        /// Updates actions of ActionPoint and ProjectActionPoint received from server.
        /// </summary>
        /// <param name="projectActionPoint"></param>
        /// <returns></returns>
        public (List <string>, Dictionary <string, string>) UpdateActionPoint(IO.Swagger.Model.ProjectActionPoint projectActionPoint)
        {
            if (Data.Parent != projectActionPoint.Parent)
            {
                ChangeParent(projectActionPoint.Parent);
            }
            Data = projectActionPoint;
            List <string> currentA = new List <string>();
            // Connections between actions (action -> output --- input <- action2)
            Dictionary <string, string> connections = new Dictionary <string, string>();

            //update actions
            foreach (IO.Swagger.Model.Action projectAction in projectActionPoint.Actions)
            {
                string          providerName = projectAction.Type.Split('/').First();
                string          actionType   = projectAction.Type.Split('/').Last();
                IActionProvider actionProvider;
                try {
                    actionProvider = Scene.Instance.GetActionObject(providerName);
                } catch (KeyNotFoundException ex) {
                    if (ActionsManager.Instance.ServicesData.TryGetValue(providerName, out Service originalService))
                    {
                        actionProvider = originalService;
                    }
                    else
                    {
                        Debug.LogError("PROVIDER NOT FOUND EXCEPTION: " + providerName + " " + actionType);
                        continue; //TODO: throw exception
                    }
                }


                // if action exist, just update it, otherwise create new
                if (!Actions.TryGetValue(projectAction.Id, out Action action))
                {
                    action = Scene.Instance.SpawnAction(projectAction.Id, projectAction.Name, actionType, this, actionProvider);
                }
                // updates name of the action
                action.ActionUpdateBaseData(projectAction);
                // updates parameters of the action
                action.ActionUpdate(projectAction);

                // Add current connection from the server, we will only map the outputs
                foreach (IO.Swagger.Model.ActionIO actionIO in projectAction.Outputs)
                {
                    //if(!connections.ContainsKey(projectAction.Id))
                    connections.Add(projectAction.Id, actionIO.Default);
                }

                // local list of all actions for current action point
                currentA.Add(projectAction.Id);
            }


            if (Parent != null)
            {
                ConnectionToParent.UpdateLine();
            }

            if (actionPointMenu != null && actionPointMenu.CurrentActionPoint == this)
            {
                actionPointMenu.UpdateMenu();
            }
            return(currentA, connections);
        }
Esempio n. 6
0
 public override (List <string>, Dictionary <string, string>) UpdateActionPoint(IO.Swagger.Model.ProjectActionPoint projectActionPoint)
 {
     (List <string>, Dictionary <string, string>)result = base.UpdateActionPoint(projectActionPoint);
     UpdateOrientationsVisuals();
     return(result);
 }