protected void manageQueryRef(ACLMessage msg) { string content = msg.Content; FIPASLParserResult result = parseFipaSLExpression(content); Dictionary <string, Agent> agents = VRApplication.Instance.AgentPlateform.Agents; if (result.isIota) { FIPAIota iota = result.iota; if (iota.predicate == "slot") { string fml; string res = getSlot(iota.paramName); MascaretApplication.Instance.VRComponentFactory.Log("IOTA : " + iota.predicate + " " + iota.result + " == " + res); if (res != "") { // give the intention ACLMessage aclMsg = new ACLMessage(ACLPerformative.INFORM); aclMsg.Sender = ((Agent)Host).Aid; aclMsg.Receivers.Add(msg.Sender); aclMsg.Content = "((= (iota ?" + iota.paramName[0] + " (" + iota.predicate + " ?" + iota.paramName[1] + " ?" + iota.paramName[2] + ")) " + res + "))"; aclMsg.ConversationID = msg.ConversationID; ((Agent)Host).send(aclMsg); MascaretApplication.Instance.VRComponentFactory.Log("Inform message: " + aclMsg.Content); //bilal 19-10-15 fml = "<FML><Performative>Inform</Performative><Receivers><Receiver>" + msg.Sender + "</Receiver></Receivers><Content>" + /* "the " + iota.paramName[1] + " of " + iota.paramName[2] + "is" +*/ res + "</Content><Emotion>Neutral</Emotion><Ressources><Ressource>" + "" + "</Ressource></Ressources></FML>"; } //bilal 19-10-15 else { fml = "<FML><Performative>Inform</Performative><Receivers><Receiver>" + msg.Sender + "</Receiver></Receivers><Content>" + "I don't know" + /*" the value of the " + iota.paramName[1] + " of " + iota.paramName[2] +*/ "</Content><Emotion>Neutral</Emotion><Ressources><Ressource>" + "" + "</Ressource></Ressources></FML>"; } if (fml != null) { ((EmbodiedAgent)(Host)).addIntention(fml); } //bilal 19-10-15 } } }
protected void manageQueryRef(ACLMessage msg) { /* * Dictionary<string, Agent> agents = VRApplication.Instance.AgentPlateform.Agents; * * string agentName = msg.Sender.toString(); * //MascaretApplication.Instance.VRComponentFactory.Log("Sender : " + agentName + " - Host: "+this.Host.name); * if (agents.ContainsKey(agentName)) * { * Mascaret.Agent agt = agents[agentName]; * * ProceduralBehavior pbehavior = (ProceduralBehavior)(agt.getBehaviorExecutingByName("ProceduralBehavior")); * List<ProcedureExecution> procedures = pbehavior.runningProcedures; * //MascaretApplication.Instance.VRComponentFactory.Log("M-Procedures : " + procedures.Count); * foreach (ProcedureExecution proc in procedures) * MascaretApplication.Instance.VRComponentFactory.Log(proc.procedure.getFullName()); * * List<KeyValuePair<ProcedureExecution, ActionNode>> actionNodes = pbehavior.actionsToDo; * //MascaretApplication.Instance.VRComponentFactory.Log("M-Action Nodes Count: " + actionNodes.Count); * * for (int atd = 0; atd < actionNodes.Count; ++atd) * { * if (actionNodes[atd].Value.Action.GetType().ToString() == "Mascaret.CallOperationAction") * { * //MascaretApplication.Instance.VRComponentFactory.Log("Action Node Description: "+actionNodes[atd].Value.Description); * string fml=null; * if (msg.Content == "action") * { * fml = "<FML><Performative>Inform</Performative><Receivers><Receiver>" + agentName + "</Receiver></Receivers><Content>" + actionNodes[atd].Value.Description + "</Content><Emotion>Neutral</Emotion><Ressources><Ressource>" + "" + "</Ressource></Ressources></FML>"; * } * else if (msg.Content == "object") * { * CallOperationAction coa = (CallOperationAction)(actionNodes[atd].Value.Action); * List<InputPin> pins = coa.InputPins; * if (pins.Count >= 1) * { * InputPin ip = pins[0]; * List<ObjectNode> nObjNode = ip.getIncomingObjectNode(); * * if (nObjNode.Count >= 1) * { * ObjectNode on = nObjNode[0]; * foreach (ProcedureExecution pe in procedures) * { * Dictionary<string, InstanceSpecification> affect = pe.getAffectations(); * if (affect.ContainsKey(on.name)) * { * InstanceSpecification instance = affect[on.name]; * fml = "<FML><Performative>Point</Performative><Receivers><Receiver>" + agentName + "</Receiver></Receivers><Content>" + "" + "</Content><Emotion>Neutral</Emotion><Ressources><Ressource>" + instance.name + "</Ressource></Ressources></FML>"; * } * } * } * } * } * * if(fml != null) ((EmbodiedAgent)(Host)).addIntention(fml); * } * } * }*/ //////////////////////////////////////////////////bilal Sep2015//////////////////////////////////////////////////////////////////////////////////////////////////////////////// string content = msg.Content; FIPASLParserResult result = parseFipaSLExpression(content); Dictionary <string, Agent> agents = VRApplication.Instance.AgentPlateform.Agents; if (result.isIota) { FIPAIota iota = result.iota; if (iota.predicate == "slot") { string res = getSlot(iota.paramName); MascaretApplication.Instance.VRComponentFactory.Log("IOTA : " + iota.predicate + " " + iota.result + " == " + res); if (res != "") { // give the intention ACLMessage aclMsg = new ACLMessage(ACLPerformative.INFORM); aclMsg.Sender = ((Agent)Host).Aid; aclMsg.Receivers.Add(msg.Sender); aclMsg.Content = "((= (iota ?" + iota.paramName[0] + " (" + iota.predicate + " ?" + iota.paramName[1] + " ?" + iota.paramName[2] + ")) " + res + "))"; ((Agent)Host).send(aclMsg); MascaretApplication.Instance.VRComponentFactory.Log("Inform message: " + aclMsg.Content); } } } /*string agentName = msg.Sender.toString(); * MascaretApplication.Instance.VRComponentFactory.Log("Sender : " + agentName + " - Host: "+this.Host.name); * if (agents.ContainsKey(agentName)) * { * Mascaret.Agent agt = agents[agentName]; * KnowledgeBase kb = agt.KnowledgeBase; * Mascaret.Environment envKB = kb.Environment; * List<Entity> entitiesKB = envKB.getEntities(); * foreach (Entity entity in entitiesKB) * { * MascaretApplication.Instance.VRComponentFactory.Log(entity.getFullName()); * if (entity.Slots.Count > 0) * { * foreach (KeyValuePair<string, Slot> s in entity.Slots) * { * if (s.Value.getValue() != null) * MascaretApplication.Instance.VRComponentFactory.Log(s.Key + " = " + s.Value.getValue().getStringFromValue()); * } * } * } * * }*/ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// }