public static CallProcedureBehaviorExecution startProcedureSwitchAgent(string procedure, Agent agentToSwitch, Agent newAgent) { string orgEntity = null; List <OrganisationalStructure> structs = VRApplication.Instance.AgentPlateform.Structures; foreach (OrganisationalStructure s in structs) { List <Procedure> procs = s.Procedures; foreach (Procedure p in procs) { if (p.name == procedure) { orgEntity = s.Entities[0].name; } } } PrintSingleton.Instance.log("RUNNING : " + procedure + " / " + orgEntity); List <Entity> entities = MascaretApplication.Instance.getEnvironment().getEntities(); Entity entity = entities[0]; Mascaret.Action action2 = null; action2 = new CallProcedureAction(); ((CallProcedureAction)(action2)).Procedure = procedure; ((CallProcedureAction)(action2)).OrganisationalEntity = orgEntity; #region switching agent if (agentToSwitch != null && newAgent != null) { List <OrganisationalEntity> orgs = MascaretApplication.Instance.AgentPlateform.Organisations; for (int iOrg = 0; iOrg < orgs.Count; iOrg++) { if (orgs[iOrg].name == ((CallProcedureAction)(action2)).OrganisationalEntity) { orgs[iOrg].changeRoleAssignement(agentToSwitch.name, newAgent); } } } #endregion PrintSingleton.Instance.log("-- -- -- -- -- -- SWITCH -- -- -- -- -- -- SWITCH -- -- -- -- -- --"); PrintSingleton.Instance.log("NEW PROCEDURE : " + procedure); PrintSingleton.Instance.log("AGENT SWITCH : " + agentToSwitch.name + " -->" + newAgent.name); PrintSingleton.Instance.log("-- -- -- -- -- -- ƧMIꓕCH -- -- -- -- -- -- ƧMIꓕCH -- -- -- -- -- --"); return((CallProcedureBehaviorExecution)BehaviorScheduler.Instance.executeBehavior(action2, entity, new Dictionary <string, ValueSpecification>(), false)); }
public static CallProcedureBehaviorExecution startProcedure(string procedure) { string orgEntity = null; List <OrganisationalStructure> structs = VRApplication.Instance.AgentPlateform.Structures; foreach (OrganisationalStructure s in structs) { List <Procedure> procs = s.Procedures; foreach (Procedure p in procs) { if (p.name == procedure) { orgEntity = s.Entities[0].name; } } } if (orgEntity == null) { PrintSingleton.Instance.log("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); PrintSingleton.Instance.log("PROCEDURE NOT FOUND : " + procedure); PrintSingleton.Instance.log("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); return(null); } PrintSingleton.Instance.log("RUNNING : " + procedure + " / " + orgEntity); List <Entity> entities = MascaretApplication.Instance.getEnvironment().getEntities(); Entity entity = entities[0]; Mascaret.Action action2 = null; action2 = new CallProcedureAction(); ((CallProcedureAction)(action2)).Procedure = procedure; ((CallProcedureAction)(action2)).OrganisationalEntity = orgEntity; PrintSingleton.Instance.log("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --"); PrintSingleton.Instance.log("NEW PROCEDURE STARTED : " + procedure); PrintSingleton.Instance.log("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --"); CallProcedureBehaviorExecution cpbe = (CallProcedureBehaviorExecution)BehaviorScheduler.Instance.executeBehavior(action2, entity, new Dictionary <string, ValueSpecification>(), false); return(cpbe); }