本文整理汇总了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);
}
}
}
}
}
示例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);
}
}
}
}
}
示例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);
}
}
}
}
}
示例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);
}
示例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);
}
}
}
示例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);
}
示例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;
}
示例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);
}
示例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)
{
}
}