Ejemplo n.º 1
0
 /**
  * Sends a message to the given agents notifying them that the environment has changed
  * (called by the user environment). If no agent is informed, the notification is sent
  * to all agents.
  */
 public void InformAgsEnvironmentChanged(params string[] agents)
 {
     if (agents.Length == 0)
     {
         foreach (CentralisedAgArch ag in masRunner.GetAgs().Values)
         {
             ag.GetReasoner().GetUserAgArch().WakeUpSense();
         }
     }
     else
     {
         foreach (string agName in agents)
         {
             CentralisedAgArch ag = masRunner.GetAg(agName);
             if (ag != null)
             {
                 ag.WakeUpSense();
             }
             else
             {
                 Debug.Log("Error sending message notification: agent " + agName + " does not exist!");
             }
         }
     }
 }
Ejemplo n.º 2
0
    public CentralisedAgArch DelAg(string agName)
    {
        CentralisedAgArch agArch = ags[agName];

        ags.Remove(agName);
        return(agArch);
    }
Ejemplo n.º 3
0
    public void StartAgent(string agName)
    {
        // create the agent thread
        CentralisedAgArch agArch = masRunner.GetAg(agName);

        //Thread agThread = new Thread(agArch); //Yo quitaria los threads
        agArch.ReasoningCycleStarting();
    }
Ejemplo n.º 4
0
        /** called by the user implementation of the environment when the action was executed */
        public void ActionExecuted(string agName, Structure actTerm, bool success, object infraData)
        {
            ExecuteAction action = (ExecuteAction)infraData;

            action.SetResult(success);
            CentralisedAgArch ag = masRunner.GetAg(agName);

            if (ag != null) // the agent may was killed
            {
                ag.ActionExecuted(action);
            }
        }
Ejemplo n.º 5
0
    public bool KillAgent(string agName, string byAg)
    {
        Debug.Log("Killing centralised agent " + agName);
        CentralisedAgArch ag = masRunner.GetAg(agName);

        if (ag != null && ag.GetReasoner().GetAgent().KillAcc(byAg))
        {
            ag.StopAg();
            masRunner.DelAg(agName);
            return(true);
        }
        return(false);
    }
Ejemplo n.º 6
0
    public AgentArchitecture Clone(Agent source, List <string> archClasses, string agName)
    {
        // create a new infra arch
        CentralisedAgArch agArch = NewAgInstance();

        agArch.SetAgName(agName);
        agArch.SetEnvInfraTier(masRunner.GetEnvironmentInfraTier());
        agArch.SetControlInfraTier(masRunner.GetControllerInfraTier());
        masRunner.AddAg(agArch);

        agArch.CreateArchs(archClasses, source, masRunner);

        StartAgent(agName);
        return(agArch.GetUserAgArch());
    }
Ejemplo n.º 7
0
    public string CreateAgent(string agName, string agSource, string agClass, List <string> archClasses, Settings stts, Agent father)
    {
        Debug.Log("Creating centralised agent " + agName + " from source " + agSource + " (agClass=" + agClass + ", archClass=" + archClasses + ", settings=" + stts);

        if (stts == null)
        {
            stts = new Settings();
        }

        string prefix = null;

        if (father != null && father.GetASLSrc().StartsWith(SourcePath.CRPrefix))
        {
            prefix = SourcePath.CRPrefix + "/";
        }
        //agSource = masRunner.GetProject().GetSourcePaths().FixPath(agSource, prefix); //el proyect creo que es algo con unity. Sep, esto es unity

        string nb = "";
        int    n  = 1;

        while (masRunner.GetAg(agName + nb) != null)
        {
            nb = "_" + (n++);
        }
        agName = agName + nb;

        CentralisedAgArch agArch = NewAgInstance();

        agArch.SetAgName(agName);
        //agArch.CreateArchs(ap.GetAgArchClasses(), ap.agClass.GetClassName(), ap.getBBClass(), agSource, stts, masRunner); //esto creo que no hace falta porque no tenemos cosas personalizadas
        agArch.SetEnvInfraTier(masRunner.GetEnvironmentInfraTier());
        agArch.SetControlInfraTier(masRunner.GetControllerInfraTier());     //Esto esta comentado en masrunner

        // if debug mode is active, set up new agent to be synchronous and visible for ExecutionControlGUI
        if (masRunner.IsDebug())
        {
            stts.SetVerbose(2);
            stts.SetSync(true);
            //agArch.GetLogger().SetLevel(Level.FINE);
            //agArch.GetTS().GetLogger().SetLevel(Level.FINE);
            //agArch.GetTS().GetAg().GetLogger().SetLevel(Level.FINE);
        }

        masRunner.AddAg(agArch);

        Debug.Log("Agent " + agName + " created!");
        return(agName);
    }
Ejemplo n.º 8
0
 /**
  * Sends a message to a set of agents notifying them that the environment has changed.
  * The collection has the agents' names.
  * (called by the user environment).
  *
  * @deprecated use the informAgsEnvironmentChanged with string... parameter
  */
 public void InformAgsEnvironmentChanged(List <string> agents)
 {
     if (agents == null)
     {
         InformAgsEnvironmentChanged();
     }
     else
     {
         foreach (string agName in agents)
         {
             CentralisedAgArch ag = masRunner.GetAg(agName);
             if (ag != null)
             {
                 ag.GetReasoner().GetUserAgArch().WakeUpSense();
             }
             else
             {
                 Debug.Log("Error sending message notification: agent " + agName + " does not exist!");
             }
         }
     }
 }
Ejemplo n.º 9
0
 public void AddAg(CentralisedAgArch ag)
 {
     ags.Add(ag.GetAgName(), ag);
 }