当前位置: 首页>>代码示例>>Java>>正文


Java Message.setReceiver方法代码示例

本文整理汇总了Java中jason.asSemantics.Message.setReceiver方法的典型用法代码示例。如果您正苦于以下问题:Java Message.setReceiver方法的具体用法?Java Message.setReceiver怎么用?Java Message.setReceiver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jason.asSemantics.Message的用法示例。


在下文中一共展示了Message.setReceiver方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: broadcast

import jason.asSemantics.Message; //导入方法依赖的package包/类
/** change broadcast to send messages to only my team mates */
@Override
public void broadcast(Message m) throws Exception {
	//String basename = getAgName().substring(0,getAgName().length()-1);
    if (model == null) return;
	for (int i=1; i <= model.getAgsByTeam() ; i++) {
	    String oname = teamId+i;
		if (!getAgName().equals(oname)) {
			Message msg = new Message(m);
			msg.setReceiver(oname);
			for (int t=0; t<6; t++) {
 			try {
 			    sendMsg(msg);
 			    break; // the for
 			} catch (ReceiverNotFoundException e) {
 			    logger.info("Receiver "+oname+" not found: wait and try later, "+t);
 				// wait and try again
 				Thread.sleep(500);
 			}
			}
		}
	}
}
 
开发者ID:jason-lang,项目名称:apps,代码行数:24,代码来源:CowboyArch.java

示例2: broadcast

import jason.asSemantics.Message; //导入方法依赖的package包/类
/** change broadcast to send messages to only my team mates */
@Override
public void broadcast(Message m) throws Exception {
	//String basename = getAgName().substring(0,getAgName().length()-1);
    if (model == null) return;
	for (int i=1; i <= model.getAgsByTeam() ; i++) {
	    String oname = teamId+i;
		if (!getAgName().equals(oname)) {
			Message msg = new Message(m);
			msg.setReceiver(oname);
			for (int t=0; t<6; t++) {
 			try {
 			    sendMsg(msg);
 			    //logger.info("mmmm sent  "+msg.toString());
 			    break; // the for
 			} catch (ReceiverNotFoundException e) {
 			    logger.info("Receiver "+oname+" not found: wait and try later, "+t);
 				// wait and try again
 				Thread.sleep(500);
 			}
			}
		}
	}
}
 
开发者ID:jason-lang,项目名称:apps,代码行数:25,代码来源:CowboyArch.java

示例3: broadcast

import jason.asSemantics.Message; //导入方法依赖的package包/类
/** change broadcast to send messages to only my team mates */
@Override
public void broadcast(Message m) throws Exception {
	String basename = getAgName().substring(0,getAgName().length()-1);
	for (int i=1; i <= model.getAgsByTeam() ; i++) {
	    String oname = basename+i;
		if (!getAgName().equals(oname)) {
			Message msg = new Message(m);
			msg.setReceiver(oname);
			for (int t=0; t<6; t++) {
 			try {
 			    sendMsg(msg);
 			    break; // the for
 			} catch (ReceiverNotFoundException e) {
 				// wait and try again
 				Thread.sleep(500);
 			}
			}
		}
	}
}
 
开发者ID:jason-lang,项目名称:apps,代码行数:22,代码来源:CowboyArch.java

示例4: delegateSendToArch

import jason.asSemantics.Message; //导入方法依赖的package包/类
private void delegateSendToArch(Term to, TransitionSystem ts, Message m) throws Exception {
    if (!to.isAtom() && !to.isString()) 
        throw new JasonException("The TO parameter ('"+to+"') of the internal action 'send' is not an atom!");

    String rec = null;
    if (to.isString())
        rec = ((StringTerm)to).getString();
    else
        rec = to.toString();
    if (rec.equals("self"))
        rec = ts.getUserAgArch().getAgName();
    m.setReceiver(rec);
    ts.getUserAgArch().sendMsg(m);
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:15,代码来源:send.java

示例5: broadcast

import jason.asSemantics.Message; //导入方法依赖的package包/类
/** change broadcast to send messages to only my team mates */
@Override
public void broadcast(Message m) throws Exception {
    String basename = getAgName().substring(0,getAgName().length()-1);
    for (int i=1; i <= model.getAgsByTeam() ; i++) {
        String oname = basename+i;
        if (!getAgName().equals(oname)) {
            Message msg = new Message(m);
            msg.setReceiver(oname);
            sendMsg(msg);
        }
    }
}
 
开发者ID:jason-lang,项目名称:jason,代码行数:14,代码来源:MinerArch.java

示例6: delegateSendToArch

import jason.asSemantics.Message; //导入方法依赖的package包/类
private void delegateSendToArch(Term to, TransitionSystem ts, Message m) throws Exception {
    if (!to.isAtom() && !to.isString())
        throw new JasonException("The TO parameter ('"+to+"') of the internal action 'send' is not an atom!");

    String rec = null;
    if (to.isString())
        rec = ((StringTerm)to).getString();
    else
        rec = to.toString();
    if (rec.equals("self"))
        rec = ts.getUserAgArch().getAgName();
    m.setReceiver(rec);
    ts.getUserAgArch().sendMsg(m);
}
 
开发者ID:jason-lang,项目名称:jason,代码行数:15,代码来源:send.java

示例7: setReceiverInPath

import jason.asSemantics.Message; //导入方法依赖的package包/类
/**
 * @param msg
 * @return
 */
private Message setReceiverInPath(Message msg) {
	Link link = this.hardware.getPath2sink();
	List<Device> devices = link.getLinkedDevices();
	int t = 0;
	if (devices.get(0) == this.hardware) {
		t = 1;
	}
	Device d = devices.get(t);
	ZigBeeSensorNode node = (ZigBeeSensorNode) d;
	msg.setReceiver(node.getSoftware().getID());
	return msg;
}
 
开发者ID:gsi-upm,项目名称:shanks-wsn-module,代码行数:17,代码来源:ZigBeeSensorNodeSofware.java

示例8: sendArgument

import jason.asSemantics.Message; //导入方法依赖的package包/类
public void sendArgument(Argument arg) {
	for (ArgumentativeAgent agent : this.argumentationGroup) {
		Message m = new Message();
		m.setPropCont(arg);
		m.setReceiver(((SimpleShanksAgent) agent).getID());
		super.sendMsg(m);
	}
	this.argumentation.addArgument((Argument) arg.clone(), this);
	this.mySentArguments.put(mySentArguments.size(), arg);
}
 
开发者ID:gsi-upm,项目名称:BARMAS,代码行数:11,代码来源:BarmasClassificatorAgent.java

示例9: getCamelMessages

import jason.asSemantics.Message; //导入方法依赖的package包/类
/**
 * @param message
 * @param receiver
 * 
 * receive the messages from the camel exchange, and pass it to a particular agent or all the agents, based on the value of the receiver parameter
 */
public void getCamelMessages(Message message, String receiver)
{	
	try
	{	
		Iterator<SimpleJasonAgent> it = agentList.iterator();
           for (; it.hasNext();)
           {
           	SimpleJasonAgent a = it.next();
           	
           	//if the receiver value is "all", send the message to all the agents in the context
           	if (receiver.equals("all"))
           	{
           		Message tm = message;
           		if (!a.getAgName().equals(message.getSender())) {
					tm.setReceiver(a.getAgName());
					a.updateMsgQueue(tm);
				}
           	}
           	else if (a.getAgName().equals(receiver))
           		a.updateMsgQueue(message);
           }
	}
	catch(Exception e)
	{			
	}		
}
 
开发者ID:scranefield,项目名称:camel-agent,代码行数:33,代码来源:AgentContainer.java


注:本文中的jason.asSemantics.Message.setReceiver方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。