Ejemplo n.º 1
0
        //TODO - Refactor to support list of service names
        public static List <AID> Find(string serviceName, Agent myAgent)
        {
            var providers = new List <AID>();
            var found     = false;

            while (!found)
            {
                var template = new DFAgentDescription();
                var sd       = new ServiceDescription();
                sd.setType(serviceName);
                template.addServices(sd);

                DFAgentDescription[] result = DFService.search(myAgent, template);

                if (result == null || result.Length <= 0)
                {
                    continue;
                }

                foreach (var t in result)
                {
                    providers.Add(t.getName());
                    found = true;
                }
            }

            return(providers);
        }
Ejemplo n.º 2
0
        public static void Register(string serviceName, Agent myAgent)
        {
            var dfd = new DFAgentDescription();

            dfd.setName(myAgent.getAID());
            var sd = new ServiceDescription();

            sd.setType(serviceName);
            sd.setName(serviceName);
            dfd.addServices(sd);
            DFService.register(myAgent, dfd);
        }
Ejemplo n.º 3
0
        // -----------------------

        private void registerChaseService()
        {
            DFAgentDescription dfAgentDescription = new DFAgentDescription();

            dfAgentDescription.AgentId = AId;
            DFServiceDescription serviceDescription = new DFServiceDescription();

            serviceDescription.Type = ChaseVocabulary.CHASE_TYPE;
            serviceDescription.Name = ChaseVocabulary.CHASE_SERVICE;
            dfAgentDescription.AddService(serviceDescription);
            DFService.RegisterService(this, dfAgentDescription);
        }
    protected override void Action()
    {
        DFAgentDescription dfAgentDescription = new DFAgentDescription();

        dfAgentDescription.AgentId = Agent.AId;
        DFServiceDescription collectWoodServiceDescription = new DFServiceDescription();

        collectWoodServiceDescription.Type = WorkVocabulary.WORK;
        collectWoodServiceDescription.Name = WorkVocabulary.COLLECT_WOOD_SERVICE;
        DFServiceDescription collectStoneServiceDescription = new DFServiceDescription();

        collectStoneServiceDescription.Type = WorkVocabulary.WORK;
        collectStoneServiceDescription.Name = WorkVocabulary.COLLECT_STONE_SERVICE;
        dfAgentDescription.AddService(collectStoneServiceDescription);
        dfAgentDescription.AddService(collectWoodServiceDescription);
        DFService.RegisterService(Agent, dfAgentDescription);
    }
Ejemplo n.º 5
0
    override protected void Action()
    {
        DFAgentDescription   dfAgentDescription = new DFAgentDescription();
        DFServiceDescription serviceDescription = new DFServiceDescription();

        serviceDescription.Type = WorkVocabulary.WORK;
        serviceDescription.Name = WorkVocabulary.COLLECT_STONE_SERVICE;
        dfAgentDescription.AddService(serviceDescription);
        Action <AgentDescriptionListConcept> action = delegate(AgentDescriptionListConcept concept) {
            List <DFAgentDescription> agents = concept.AgentDescriptions.FindAll(agentDescription => canAgentBeRequested(agentDescription));

            if (agents.Count != 0)
            {
                requestCollectingStone(agents.First().AgentId);
            }
        };

        DFService.RequestSearch(coordinatorAgent, dfAgentDescription, action);
    }
Ejemplo n.º 6
0
        override protected void Action()
        {
            DFAgentDescription   dfAgentDescription = new DFAgentDescription();
            DFServiceDescription serviceDescription = new DFServiceDescription();

            serviceDescription.Type = ChaseVocabulary.CHASE_TYPE;
            serviceDescription.Name = ChaseVocabulary.CHASE_SERVICE;
            dfAgentDescription.AddService(serviceDescription);
            Action <AgentDescriptionListConcept> action = delegate(AgentDescriptionListConcept concept) {
                foreach (DFAgentDescription agentDescription in concept.AgentDescriptions)
                {
                    AgentMessage message = new AgentMessage(AgentMessage.PerformativeType.INFORM);
                    message.Receiver = agentDescription.AgentId;
                    message.Ontology = ChaseVocabulary.CHASE_ONTOLOGY;
                    message.Content  = new PlayerPositionConcept(position);
                    Agent.Send(message);
                }
            };

            DFService.RequestSearch(Agent, dfAgentDescription, action);
        }
Ejemplo n.º 7
0
 public static void Deregister(Agent myAgent)
 {
     DFService.deregister(myAgent);
 }