/** * 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!"); } } } }
public CentralisedAgArch DelAg(string agName) { CentralisedAgArch agArch = ags[agName]; ags.Remove(agName); return(agArch); }
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(); }
/** 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); } }
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); }
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()); }
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); }
/** * 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!"); } } } }
public void AddAg(CentralisedAgArch ag) { ags.Add(ag.GetAgName(), ag); }