• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Message类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: sendMsg

import jason.asSemantics.Message; //导入依赖的package包/类
public void sendMsg(Message m) throws ReceiverNotFoundException {
    // actually send the message
    if (m.getSender() == null)  m.setSender(getAgName());
    
    CentralisedAgArch rec = masRunner.getAg(m.getReceiver());
        
    if (rec == null) {
        if (isRunning())
            throw new ReceiverNotFoundException("Receiver '" + m.getReceiver() + "' does not exist! Could not send " + m);
        else
            return;
    }
    rec.receiveMsg(m.clone()); // send a cloned message

    // notify listeners
    if (msgListeners != null) 
        for (MsgListener l: msgListeners) 
            l.msgSent(m);
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:20,代码来源:CentralisedAgArch.java


示例2: broadcast

import jason.asSemantics.Message; //导入依赖的package包/类
public void broadcast(final Message m) {
    addBehaviour(new OneShotBehaviour() {
        private static final long serialVersionUID = 1L;
        public void action() {
            try {
                ACLMessage acl = jasonToACL(m);
                addAllAgsAsReceivers(acl);
                send(acl);
            } catch (Exception e) {
                logger.log(Level.SEVERE, "Error in broadcast of "+m, e);
            }
        }
    });
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:15,代码来源:JadeAg.java


示例3: checkMail

import jason.asSemantics.Message; //导入依赖的package包/类
/** overridden to ignore bid messages */
public void checkMail() {
	List mbox = (List) fEnv.getAgMbox(getName());
	synchronized (mbox) {
		Iterator i = mbox.iterator();
		while (i.hasNext()) {
			Message im = (Message) i.next();
			if (!im.getPropCont().startsWith("bid")) {
				fTS.getC().getMB().add(im);
				if (fTS.getSettings().verbose() >= 1) {
					System.out.println("Agent " + getName() + " received message: " + im);
				}
			}
			i.remove();
		}
	}
}
 
开发者ID:jason-lang,项目名称:apps,代码行数:18,代码来源:CPHAgArch.java


示例4: fencePerceived

import jason.asSemantics.Message; //导入依赖的package包/类
public void fencePerceived(int x, int y, boolean open) {
    int obj;
    Atom s;
    if (open) {
        obj = WorldModel.OPEN_FENCE;
        s   = aOPEN;
    } else {
        obj = WorldModel.CLOSED_FENCE;
        s   = aCLOSED;
    }       
    if (!model.hasObject(obj, x, y)) {
        model.add(obj, x, y);
        //if (acView != null) acView.addObject(obj, x, y);
        Message m = new Message("tell", null, null, createCellPerception(x, y, ASSyntax.createStructure(aFENCE.toString(), s)));
        try { broadcast(m); } catch (Exception e) { e.printStackTrace(); }
    }
}
 
开发者ID:jason-lang,项目名称:apps,代码行数:18,代码来源:CowboyArch.java


示例5: locationPerceived

import jason.asSemantics.Message; //导入依赖的package包/类
/** update the model with the agent location and share this information with team mates */
void locationPerceived(final int x, final int y) {
    if (model == null) {
        logger.info("***** No model created yet! I cannot set my location");
        return;
    }
	oldLoc = model.getAgPos(getMyId());
       if (oldLoc != null) {
           model.clearAgView(oldLoc); // clear golds and  enemies
       }
	if (oldLoc == null || !oldLoc.equals(new Location(x,y))) {
		try {
			model.setAgPos(getMyId(), x, y);
			//if (acView != null) acView.getModel().setAgPos(getMyId(), x, y);
			model.incVisited(x, y);
		
			Message m = new Message("tell", null, null, "my_status("+x+","+y+")");
			broadcast(m);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	myAddQueue(lastLocations, new Location(x, y));
	checkRestart();
}
 
开发者ID:jason-lang,项目名称:apps,代码行数:27,代码来源:CowboyArch.java


示例6: 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


示例7: obstaclePerceived

import jason.asSemantics.Message; //导入依赖的package包/类
/** update the model with obstacle and share them with the team mates */
public void obstaclePerceived(int x, int y) {
    //getTS().getLogger().info("perceived obstacle bbbb "+x+","+y+"   "+model.hasObject(WorldModel.OBSTACLE, x, y));
	if (! model.hasObject(WorldModel.OBSTACLE, x, y)) {
		model.add(WorldModel.OBSTACLE, x, y);
		//if (acView != null) acView.addObject(WorldModel.OBSTACLE, x, y);
		Message m = new Message("tell", null, null, createCellPerception(x, y, aOBSTACLE));
           try { broadcast(m); } catch (Exception e) { e.printStackTrace(); }
	} else {
	    Location l = new Location(x, y);
	    if (ephemeralObstacle.remove(l))
           logger.info("uuuuu ephemeral location "+l+" perceived! so, it is no more ephemeral.");
	}
	if(clModel == null) 
		clModel = ClusterModelFactory.getModel(teamId+myId);
	clModel.insertTree(x, y);
}
 
开发者ID:jason-lang,项目名称:apps,代码行数:18,代码来源:CowboyArch.java


示例8: 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


示例9: 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


示例10: sendMsg

import jason.asSemantics.Message; //导入依赖的package包/类
public void sendMsg(Message m) throws ReceiverNotFoundException {
    // actually send the message
    if (m.getSender() == null)  m.setSender(getAgName());

    CentralisedAgArch rec = masRunner.getAg(m.getReceiver());

    if (rec == null) {
        if (isRunning())
            throw new ReceiverNotFoundException("Receiver '" + m.getReceiver() + "' does not exist! Could not send " + m);
        else
            return;
    }
    rec.receiveMsg(m.clone()); // send a cloned message

    // notify listeners
    if (msgListeners != null)
        for (MsgListener l: msgListeners)
            l.msgSent(m);
}
 
开发者ID:jason-lang,项目名称:jason,代码行数:20,代码来源:CentralisedAgArch.java


示例11: ZigBeeSensorNodeSofware

import jason.asSemantics.Message; //导入依赖的package包/类
/**
 * Constructor
 * 
 * @param id
 * @param logger
 * @param stepTime
 * @param random
 */
public ZigBeeSensorNodeSofware(String id, Logger logger, ZigBeeSensorNode hardware, double perceptionRange,
		double stepTime, double maxNoise, double minNoise, MersenneTwisterFast random, ShanksSimulation sim) {
	super(id, logger);
	this.hardware = hardware;
	this.hardware.setSoftware(this);
	this.perceptionRange = perceptionRange;
	this.stepTime = stepTime;
	this.msgsReadyToProcess = new ArrayList<Message>();
	this.consumedTimeInStep = 0.0;
	this.maxNoise = maxNoise;
	this.minNoise = minNoise;
	this.random = random;
	this.msgCounter = 0;
	this.sim = sim;
}
 
开发者ID:gsi-upm,项目名称:shanks-wsn-module,代码行数:24,代码来源:ZigBeeSensorNodeSofware.java


示例12: getMessageProcessingTime

import jason.asSemantics.Message; //导入依赖的package包/类
/**
 * @param msg
 * @return
 */
private double getMessageProcessingTime(Message msg) {
	Object content = msg.getPropCont();
	String s = content.toString() + msg.getInReplyTo();
	byte[] asciiBytes = new byte[0];
	try {
		asciiBytes = s.getBytes("ASCII");
	} catch (UnsupportedEncodingException e) {
		this.getLogger().warning("Impossible to get package size in bytes: " + e.getMessage());
	}
	int bytes = asciiBytes.length;
	double bits = bytes * 8;
	// 108kbps = 108bpms
	// time in ms
	double time = bits / 108;
	return time;
}
 
开发者ID:gsi-upm,项目名称:shanks-wsn-module,代码行数:21,代码来源:ZigBeeSensorNodeSofware.java


示例13: checkMail

import jason.asSemantics.Message; //导入依赖的package包/类
@Override
public void checkMail() {
	ACLMessage acl;
	while ((acl = agent.getNextMessage()) != null) {
		String ilForce = JasonMessage.getIlForce(acl);
		String sender = acl.sender.toString();
		String replyWith = acl.replyWith;
		String inReplyTo = acl.inReplyTo;
		Serializable content = JasonMessage.getJasonContent(acl);
		if (content != null) {
			Message jmsg = new Message(ilForce, sender, agent.getAid().toString(), content, replyWith);
			if (inReplyTo != null)
				jmsg.setInReplyTo(inReplyTo);
			getTS().getC().getMailBox().add(jmsg);
		}
	}
}
 
开发者ID:gcvt,项目名称:siebog,代码行数:18,代码来源:JasonEEAgArch.java


示例14: toAclMessage

import jason.asSemantics.Message; //导入依赖的package包/类
public static ACLMessage toAclMessage(Message jmsg) {
	ACLMessage acl = createForIlForce(jmsg.getIlForce());
	acl.sender = new AID(jmsg.getSender());
	final String jmsgReceiver = jmsg.getReceiver();
	if (jmsgReceiver != null)
		acl.receivers.add(new AID(jmsgReceiver));
	if (jmsg.getPropCont() instanceof Term || jmsg.getPropCont() instanceof String) {
		acl.content = jmsg.getPropCont().toString();
	} else {
		acl.contentObj = (Serializable) jmsg.getPropCont();
	}
	acl.replyWith = jmsg.getMsgId();
	acl.language = "AgentSpeak";
	if (jmsg.getInReplyTo() != null)
		acl.inReplyTo = jmsg.getInReplyTo();
	return acl;
}
 
开发者ID:gcvt,项目名称:siebog,代码行数:18,代码来源:JasonMessage.java


示例15: checkMail

import jason.asSemantics.Message; //导入依赖的package包/类
public void checkMail() {
	// Check incoming new argumentation
	List<Message> inbox = this.getInbox();
	if (inbox.size() > 0) {

		this.pendingArguments = new ArrayList<Argument>();
		for (Message msg : inbox) {
			Argument arg = (Argument) msg.getPropCont();
			this.pendingArguments.add(arg);
		}
	} else {
		// If no message is received, the argumentation finish
	}

	inbox.clear();
}
 
开发者ID:gsi-upm,项目名称:BARMAS,代码行数:17,代码来源:BarmasManagerAgent.java


示例16: SimpleJasonAgent

import jason.asSemantics.Message; //导入依赖的package包/类
public SimpleJasonAgent(AgentContainer container, String filePathOrURL, String name) {
    this.container = container;
    this.name = name;
    hasStarted = false;
	localMsgQueue = new ConcurrentLinkedQueue<Message>();
	pers_percepts = new ConcurrentLinkedQueue<Literal>();
	temp_percepts = new ConcurrentLinkedQueue<Literal>();
	myConsumers = new Vector<AgentConsumer>();
    
    try {
        ag = new Agent();
        new TransitionSystem(ag, new Circumstance(), new Settings(), this);  
        //Initialise agent from the .asl file
        ag.initAg(filePathOrURL);
    } catch (Exception e) {
        logger.log(Level.SEVERE, "Init error", e);
    }
}
 
开发者ID:scranefield,项目名称:camel-agent,代码行数:19,代码来源:SimpleJasonAgent.java


示例17: broadcast

import jason.asSemantics.Message; //导入依赖的package包/类
public void broadcast(jason.asSemantics.Message m) throws Exception {
    for (String agName: masRunner.getAgs().keySet()) {
        if (!agName.equals(this.getAgName())) {
            m.setReceiver(agName);
            sendMsg(m);
        }
    }
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:9,代码来源:CentralisedAgArch.java


示例18: checkMail

import jason.asSemantics.Message; //导入依赖的package包/类
public void checkMail() {
    Circumstance C = getTS().getC();
    Message im = mbox.poll();
    while (im != null) {
        C.addMsg(im);
        if (logger.isLoggable(Level.FINE)) logger.fine("received message: " + im);
        im = mbox.poll();
    }
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:10,代码来源:CentralisedAgArch.java


示例19: sendMsg

import jason.asSemantics.Message; //导入依赖的package包/类
public void sendMsg(Message m) throws Exception {
    ACLMessage acl = jasonToACL(m);
    acl.addReceiver(new AID(m.getReceiver(), AID.ISLOCALNAME));
    if (m.getInReplyTo() != null) {
        String convid = conversationIds.get(m.getInReplyTo());
        if (convid != null) {
            acl.setConversationId(convid);
        }
    }
    if (logger.isLoggable(Level.FINE)) logger.fine("Sending message: " + acl);
    send(acl);
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:13,代码来源:JadeAg.java


示例20: jasonToACL

import jason.asSemantics.Message; //导入依赖的package包/类
protected ACLMessage jasonToACL(Message m) throws IOException {
    ACLMessage acl = kqmlToACL(m.getIlForce());
    // send content as string if it is a Term/String (it is better for interoperability)
    if (m.getPropCont() instanceof Term || m.getPropCont() instanceof String) {
        acl.setContent(m.getPropCont().toString());         
    } else {
        acl.setContentObject((Serializable)m.getPropCont());
    }
    acl.setReplyWith(m.getMsgId());
    acl.setLanguage("AgentSpeak");
    if (m.getInReplyTo() != null) {
        acl.setInReplyTo(m.getInReplyTo());
    }
    return acl;
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:16,代码来源:JadeAg.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AxisDescription类代码示例发布时间:2022-05-22
下一篇:
Java RefreshQueuesResponse类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap