def get_bag_agent_info(type_, directory_agent, sender, msgcnt): gmess = Graph() # Construimos el mensaje de registro gmess.bind('foaf', FOAF) gmess.bind('dso', DSO) ask_obj = agn[sender.name + '-Search'] gmess.add((ask_obj, RDF.type, DSO.Search)) gmess.add((ask_obj, DSO.AgentType, type_)) gr = send_message( build_message(gmess, perf=ACL.request, sender=sender.uri, receiver=directory_agent.uri, msgcnt=msgcnt, content=ask_obj), directory_agent.address) dic = get_message_properties(gr) content = dic['content'] agents = [] for (s, p, o) in gr.triples((content, None, None)): if str(p).startswith('http://www.w3.org/1999/02/22-rdf-syntax-ns#_'): address = gr.value(subject=o, predicate=DSO.Address) url = gr.value(subject=o, predicate=DSO.Uri) name = gr.value(subject=o, predicate=FOAF.name) agent = Agent(name, url, address, None) agents += [agent] return agents
def get_agent_info(type_, directory_agent, sender, msgcnt): gmess = Graph() # Construimos el mensaje de registro gmess.bind('foaf', FOAF) gmess.bind('dso', DSO) ask_obj = agn[sender.name + '-Search'] gmess.add((ask_obj, RDF.type, DSO.Search)) gmess.add((ask_obj, DSO.AgentType, type_)) gr = send_message( build_message(gmess, perf=ACL.request, sender=sender.uri, receiver=directory_agent.uri, msgcnt=msgcnt, content=ask_obj), directory_agent.address) dic = get_message_properties(gr) content = dic['content'] address = gr.value(subject=content, predicate=DSO.Address) url = gr.value(subject=content, predicate=DSO.Uri) name = gr.value(subject=content, predicate=FOAF.name) return Agent(name, url, address, None)
dport = args.dport if args.dhost is None: dhostname = socket.gethostname() else: dhostname = args.dhost agn = Namespace("http://www.agentes.org#") # Contador de mensajes messages_cnt = 0 # Datos del Agente AgenteRecomendador = Agent('AgenteRecomendador', agn.AgenteRecomendador, 'http://%s:%d/comm' % (hostname, port), 'http://%s:%d/Stop' % (hostname, port)) # Directory agent address DirectoryAgent = Agent('DirectoryAgent', agn.Directory, 'http://%s:%d/Register' % (dhostname, dport), 'http://%s:%d/Stop' % (dhostname, dport)) # Global triplestore graph dsgraph = Graph() cola1 = Queue() # Flask stuff app = Flask(__name__, template_folder='../templates')
if args.dhost is None: dhostname = socket.gethostname() else: dhostname = args.dhost hostname = socket.gethostname() port = 9050 agn = Namespace("http://www.agentes.org#") # Contador de mensajes messages_cnt = 0 # Datos del Agente AgenteDevoluciones = Agent('AgenteDevoluciones', agn.AgenteDevoluciones, 'http://%s:%d/comm' % (hostname, port), 'http://%s:%d/Stop' % (hostname, port)) # Directory agent address DirectoryAgent = Agent('DirectoryAgent', agn.Directory, 'http://%s:%d/Register' % (dhostname, dport), 'http://%s:%d/Stop' % (dhostname, dport)) # Global triplestore graph dsgraph = Graph() cola1 = Queue() # Flask stuff app = Flask(__name__, template_folder='../templates')
else: hostname = socket.gethostname() # Directory Service Graph dsgraph = Graph() # Vinculamos todos los espacios de nombre a utilizar dsgraph.bind('acl', ACL) dsgraph.bind('rdf', RDF) dsgraph.bind('rdfs', RDFS) dsgraph.bind('foaf', FOAF) dsgraph.bind('dso', DSO) agn = Namespace("http://www.agentes.org#") DirectoryAgent = Agent('DirectoryAgent', agn.Directory, 'http://%s:%d/Register' % (hostname, port), 'http://%s:%d/Stop' % (hostname, port)) app = Flask(__name__) mss_cnt = 0 cola1 = Queue() # Cola de comunicacion entre procesos @app.route("/Register") def register(): """ Entry point del agente que recibe los mensajes de registro La respuesta es enviada al retornar la funcion, no hay necesidad de enviar el mensaje explicitamente Asumimos una version simplificada del protocolo FIPA-request en la que no enviamos el mesaje Agree cuando vamos a responder
dport = args.dport if args.dhost is None: dhostname = socket.gethostname() else: dhostname = args.dhost agn = Namespace("http://www.agentes.org#") # Contador de mensajes messages_cnt = 0 # Datos del Agente AgenteNegociador = Agent('AgenteNegociador', agn.AgenteNegociador, 'http://%s:%d/comm' % (hostname, port), 'http://%s:%d/Stop' % (hostname, port)) # Directory agent address DirectoryAgent = Agent('DirectoryAgent', agn.Directory, 'http://%s:%d/Register' % (dhostname, dport), 'http://%s:%d/Stop' % (dhostname, dport)) DirectoryAgent = Agent('DirectoryAgent', agn.Directory, 'http://%s:9000/Register' % hostname, 'http://%s:9000/Stop' % hostname) # Global triplestore graph dsgraph = Graph() cola1 = Queue()