示例#1
0
    public UnityShapeSpecification(string name, string url, bool movable, bool recursive, string shader) : base(name, url, movable, recursive, shader)

    {
        //PrintSingleton.Instance.log(" Looking for : " + url);

        entityGO = GameObject.Find(url);

        if (entityGO != null)
        {
            EntityGo ego = (EntityGo)entityGO.GetComponent("EntityGo");
            if (ego == null)
            {
                entityGO.AddComponent <EntityGo>();
                ego = (EntityGo)entityGO.GetComponent("EntityGo");
            }
            //else PrintSingleton.Instance.log(" Already has EntityGO Component");

            Dictionary <string, Agent> agents = VRApplication.Instance.AgentPlateform.Agents;
            string agentName = url + "@localhost:8080";

            if (agents.ContainsKey(agentName))
            {
                Mascaret.Agent agt = agents[agentName];
            }
        }
        //else PrintSingleton.Instance.log("GAME OBJECT NOT FOUND : " + url);

        //GameObject go = GameObject.Find("MascaretApplication");
        //UnityMascaretApplication uma = go.GetComponent<UnityMascaretApplication>();
    }
 public ConversationalDialogueManager(Agent agt)
 {
     host = agt;
     _incomingUtteranceMessageBox = new UtteranceMessageBox();
     _outgoingUtteranceMessageBox = new UtteranceMessageBox();
     planLib = new PlanLibrary ();
 }
    public UnityShapeSpecification(string name, string url, bool movable, bool recursive, string shader) : base(name, url, movable, recursive, shader)

    {
        Debug.Log(" Looking for : " + url);

        entityGO = GameObject.Find(url);

        if (entityGO != null)
        {
            EntityGo ego = (EntityGo)entityGO.GetComponent("EntityGo");
            if (ego == null)
            {
                entityGO.AddComponent <EntityGo>();
                ego = (EntityGo)entityGO.GetComponent("EntityGo");
            }
            else
            {
                Debug.Log(" Already has EntityGO Component");
            }

            Dictionary <string, Agent> agents = VRApplication.Instance.AgentPlateform.Agents;
            string agentName = url + "@localhost:8080";

            if (agents.ContainsKey(agentName))
            {
                Mascaret.Agent agt = agents [agentName];

                UnityBehaviorRealizer bmlRealizer = new UnityBehaviorRealizer(this);
                agt.behaviorRealizer = bmlRealizer;
            }
        }
        else
        {
            Debug.Log("Game object : " + url + " non trouvé");
        }
    }
示例#4
0
 public void addAgent(Agent agent)
 {
     if (!agents.ContainsKey(agent.Aid.toString()))
         agents.Add(agent.Aid.toString(), agent);
 }
示例#5
0
 public BehaviorPlanner(Agent agent)
 {
     this.agent = agent;
 }
示例#6
0
        public ProcedureExecution(Procedure procedure, OrganisationalEntity organisation, Agent agent)
        {
            this.procedure = procedure;
            this.organisation = organisation;
            this.agent = agent;

            agentToPartition = new Dictionary<string, ActivityPartition>();
            partitionToAgent = new Dictionary<ActivityPartition, AID>();
            activeTokens = new List<ActivityExecutionToken>();
            affectations = new Dictionary<string, InstanceSpecification>();
            activityParams = new Dictionary<string, ValueSpecification>();
            actionsRunning = new List<KeyValuePair<string, ActionNode>>();
            actionsDone = new List<ActionNode>();
            allActionsDone = new Dictionary<string, List<ActionNode>>(); // key: AID
            allActionsDoneTimestamps = new Dictionary<string, List<TimeExpression>>();

            for (int i = 0; i < procedure.Activity.Partitions.Count; i++)
            {
                ActivityPartition partition = procedure.Activity.Partitions[i];
                List<RoleAssignement> assignements = organisation.RoleAssignement;
                for (int j = 0; j < assignements.Count; j++)
                {
                    if (partition.name == assignements[j].Role.name)
                    {
                        agentToPartition.Add(assignements[j].Agent.toString(), partition);
                        partitionToAgent.Add(partition, assignements[j].Agent);
                        Agent agt = MascaretApplication.Instance.AgentPlateform.Agents[assignements[j].Agent.toString()];
                        if (agt == null) MascaretApplication.Instance.VRComponentFactory.Log("CA VA TRANCHER");
                        affectations.Add(partition.name, agt);
                    }
                }
            }

            ActivityExecutionToken initialToken = new ActivityExecutionToken();
            initialToken.currentLocation = procedure.Activity.Initial;

            if (initialToken.currentLocation == null)
            {
                System.Console.WriteLine("ERROR: no initial node found, not allowed");
                System.Console.WriteLine("Procedure will not start.");
                return;
            }

            List<ActivityEdge> controlFlows = procedure.Activity.Initial.getOutgoingControlFlowEdges();

            if (controlFlows.Count == 1)
            {
                initialToken.outgoingEdge = controlFlows[0];
                activeTokens.Add(initialToken);

                ActionNode dummyActionVariable = null;
                tryToAdvanceToken(initialToken, dummyActionVariable,true); //first advancement
            }
            else
            {
                if (controlFlows.Count == 0)
                {
                    System.Console.WriteLine("WARNING: initial node has no outgoing edges");
                }
                else
                {
                    System.Console.WriteLine("ERROR: multiple outgoing edges for the initial node, not allowed");
                }
                System.Console.WriteLine("Procedure will not start.");
            }
        }
        void CallProceduralBehaviourExecution(ActionNode action)
        {
            MascaretApplication.Instance.VRComponentFactory.Log(Host.name + "+++++++++++++++++++++++++++########################################### CallProceduralBehaviourExecution  " + action.name);

            MascaretApplication appli = MascaretApplication.Instance;
            //bool found = false;
            OrganisationalEntity askedOrg = null;
            Procedure askedProc = null;
            Role askedRole = null;

            List<OrganisationalEntity> orgs = appli.AgentPlateform.Organisations;

            appli.VRComponentFactory.Log("ProceduralBehaviourExecution");

            for (int iOrg = 0; iOrg < orgs.Count; iOrg++)
            {
                appli.VRComponentFactory.Log("------ Org " + orgs[iOrg].name + " ?");
                if (orgs[iOrg].name == parameters["orgEntity"].getStringFromValue())
                {
                    appli.VRComponentFactory.Log("----------Org : " + orgs[iOrg].name + " found");
                    OrganisationalStructure os = orgs[iOrg].Structure;
                    List<Procedure> procs = os.Procedures;
                    askedOrg = orgs[iOrg];

                    for (int iP = 0; iP < procs.Count; iP++)
                    {
                        if (procs[iP].name == action.Action.name)
                        {
                            appli.VRComponentFactory.Log("Procedure " + procs[iP].name + " found");
                            askedProc = procs[iP];
                            List<RoleAssignement> assigns = orgs[iOrg].RoleAssignement;

                            appli.VRComponentFactory.Log("Assigns : " + assigns.Count);
                            for (int iAss = 0; iAss < assigns.Count; iAss++)
                            {
                                agt = appli.AgentPlateform.Agents[assigns[iAss].Agent.toString()];
                                askedRole = assigns[iAss].Role;
                                if (agt.name == Host.name)
                                {
                                    appli.VRComponentFactory.Log("Role : " + assigns[iAss].Role.name + " == " + agt.name);

                                    AgentBehaviorExecution pbehavior = agt.getBehaviorExecutingByName("ProceduralBehavior");

                                    if (pbehavior != null)
                                    {
                                        appli.VRComponentFactory.Log("Procedure " + askedProc.name + " launched for " + agt.name);
                                        ProceduralBehavior procBehave = (ProceduralBehavior)(pbehavior);

                                        Dictionary<string, ValueSpecification> procParams = new Dictionary<string, ValueSpecification>();

                                        procBehave.pushProcedureToDo(askedProc, askedOrg, askedRole, procParams);

                                    }
                                }
                            }
                        }

                    }
                }
            }
        }
示例#8
0
        public virtual void parse(XElement root, bool loadAll)
        {
            XElement appliNode = root.Element("ApplicationParameters");
            XElement actnode = root.Element("Actors");
            XElement orgNode = root.Element("Organisations");

            {
                if (agentPlateform == null)
                {
                    this.VRComponentFactory.Log("Agent Plateform");
                    // Parametres par defaut de l'applie ....
                    string ressourceDir = "HTTPServerBaseDir";
                    agentPlateform = new AgentPlateform("localhost", 8080, ressourceDir, false);
                    agent = new Agent(agentPlateform, "HTTPManager", null, "");
                    agent.addBehavior("SimpleCommunicationBehavior", 0.2, true);
                    agentPlateform.addAgent(agent);
                }

            }

            foreach (XElement child in root.Elements())
            {

                if (child.Name.LocalName == "Environment")
                {
                    string envUrl = child.Attribute("url").Value;
                    Environment env = parseEnvironment(envUrl, actnode, orgNode, loadAll);
                }
            }
        }