protected string getSlot(List <string> p) { string entityName = p[2]; string slotName = p[1]; MascaretApplication.Instance.VRComponentFactory.Log(entityName + "." + slotName); string value = ""; KnowledgeBase kb = ((Agent)(this.Host)).KnowledgeBase; Mascaret.Environment envKB = kb.Environment; List <Entity> entities = envKB.getEntities(); foreach (Entity entity in entities) { if (entity.name == entityName) { MascaretApplication.Instance.VRComponentFactory.Log("ENTITY ..."); foreach (KeyValuePair <string, Slot> s in entity.Slots) { if (s.Value.name == slotName) { value = s.Value.getValue().getStringFromValue(); } } } } return(value); }
protected void manageInform(ACLMessage msg) { Agent agt = (Agent)(this.Host); string content = msg.Content; FIPASLParserResult result = parseFipaSLExpression(content); if (result.isAction) { if (result.success) { AgentBehaviorExecution be = agt.getBehaviorExecutingByName("ProceduralBehavior"); if (be != null) { ProceduralBehavior pbe = (ProceduralBehavior)(be); AID aid = new AID(result.action.performer, agt.Aid.PlateformName, agt.Aid.PlateformPort); if (result.isDone) { aid = new AID(result.action.performer, agt.Aid.PlateformName, agt.Aid.PlateformPort); pbe.onActionDone(aid, result.action.actionName); } else { pbe.onActionRunning(aid, result.action.actionName); } } } } else if (result.isEqual) { string entityName = result.iota.paramName[2]; string slotName = result.iota.paramName[0]; string value = result.iota.value; MascaretApplication.Instance.VRComponentFactory.Log(entityName + "." + slotName + "=" + value); KnowledgeBase kb = ((Agent)(this.Host)).KnowledgeBase; Mascaret.Environment envKB = kb.Environment; List <Entity> entities = envKB.getEntities(); foreach (Entity entity in entities) { if (entity.name == entityName) { MascaretApplication.Instance.VRComponentFactory.Log("ENTITY ..."); foreach (KeyValuePair <string, Slot> s in entity.Slots) { if (s.Value.name == slotName) { s.Value.addValueFromString(value); } } } } } }