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


Java Message类代码示例

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


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

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

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

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

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


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