本文整理汇总了Java中jade.lang.acl.ACLMessage.setContentObject方法的典型用法代码示例。如果您正苦于以下问题:Java ACLMessage.setContentObject方法的具体用法?Java ACLMessage.setContentObject怎么用?Java ACLMessage.setContentObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jade.lang.acl.ACLMessage
的用法示例。
在下文中一共展示了ACLMessage.setContentObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processExecutionControlOntologyMsg
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
boolean processExecutionControlOntologyMsg() {
ACLMessage m = receive(ts);
if (m != null) {
// send the agent state
ACLMessage r = m.createReply();
r.setPerformative(ACLMessage.INFORM);
try {
Document agStateDoc = jasonBridgeAgArch.getTS().getAg().getAgState();
r.setContentObject((Serializable)agStateDoc);
send(r);
} catch (Exception e) {
logger.log(Level.SEVERE, "Error sending message " + r, e);
}
}
m = receive(tc);
if (m != null) {
int cycle = Integer.parseInt(m.getUserDefinedParameter("cycle"));
logger.fine("new cycle: "+cycle);
jasonBridgeAgArch.setCycleNumber(cycle);
return true;
}
return false;
}
示例2: action
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
public void action() {
ResultsAgent a = (ResultsAgent)myAgent;
// Send result before closing down
ACLMessage msg = new ACLMessage(ACLMessage.INFORM);
msg.setSender(a.getAID());
msg.addReceiver(new AID(SendTo, false));
try {
Object[] oMsg=new Object[3];
oMsg[0] = ID;
oMsg[1] = bText1;
oMsg[2] = bText2;
msg.setContentObject(oMsg);
} catch (IOException ex) {
System.err.println("Cannot add result to message. Sending empty message.");
ex.printStackTrace(System.err);
}
a.send(msg);
}
示例3: action
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
/** Actually sends the result to the dispatching agent.
*/
public void action() {
synchronized (myAgent) {
NGramDocumentComparatorAgent a = (NGramDocumentComparatorAgent)myAgent;
// Send result before closing down
ACLMessage msg = new ACLMessage(ACLMessage.INFORM);
msg.setSender(a.getAID());
msg.addReceiver(a.ResultConsumer);
try {
msg.setContentObject(Result);
} catch (IOException ex) {
System.err.println("Cannot add result to message. Sending empty message.");
ex.printStackTrace(System.err);
}
a.send(msg);
}
}
示例4: processExecutionControlOntologyMsg
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
boolean processExecutionControlOntologyMsg() {
ACLMessage m = receive(ts);
if (m != null) {
// send the agent state
ACLMessage r = m.createReply();
r.setPerformative(ACLMessage.INFORM);
try {
Document agStateDoc = jasonBridgeAgArch.getTS().getAg().getAgState();
r.setContentObject((Serializable)agStateDoc);
send(r);
} catch (Exception e) {
logger.log(Level.SEVERE, "Error sending message " + r, e);
}
}
m = receive(tc);
if (m != null) {
int cycle = Integer.parseInt(m.getUserDefinedParameter("cycle"));
logger.fine("new cycle: "+cycle);
jasonBridgeAgArch.setCycleNumber(cycle);
return true;
}
return false;
}
示例5: action
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public void action() {
ACLMessage reply=msg.createReply();
reply.setPerformative(ACLMessage.INFORM);
reply.setConversationId(Constance.GROUP_CREATED);
try {
reply.setContentObject(myAgent.getDict());
System.out.println("set defautlistmodele of reply\n");
myAgent.send(reply);
System.out.println("multiAgent sent reply\n");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例6: answer
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
public void answer(){
ACLMessage reply=msg.createReply();
reply.setPerformative(ACLMessage.INFORM);
//String listString="";
/*for(String s:myAgent.getDict()){
listString+=s+",";
}*/
try {
reply.setContentObject(myAgent.getDict());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
myAgent.send(reply);
}
示例7: sendMsgAvailableMachinesRequest
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
/**
* Forwards a request for available machines to the server.cliebnt.
*/
private void sendMsgAvailableMachinesRequest() {
// --- Get the local Address of JADE ------------------------
String myPlatformAddress = myContainer.getPlatformID();
// --- Define the AgentAction -------------------------------
ClientAvailableMachinesRequest request = new ClientAvailableMachinesRequest();
Action act = new Action();
act.setActor(myContainer.getAMS());
act.setAction(request);
// --- Define receiver of the Message -----------------------
AID agentGUIAgent = new AID("server.client" + "@" + myPlatformAddress, AID.ISGUID );
//mainPlatformAgent.addAddresses(mainPlatform.getHttp4mtp());
// --- Build Message ----------------------------------------
ACLMessage msg = new ACLMessage(ACLMessage.INFORM);
msg.setSender(myContainer.getAMS());
msg.addReceiver(agentGUIAgent);
msg.setLanguage(new SLCodec().getName());
msg.setOntology(AgentGUI_DistributionOntology.getInstance().getName());
try {
msg.setContentObject(act);
} catch (IOException errCont) {
errCont.printStackTrace();
}
// --- Send message -----------------------------------------
myContainer.postMessageToLocalAgent(msg, agentGUIAgent);
}
示例8: sendMsgRemoteContainerRequest
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
/**
* This method configures and send a ACLMessage to start a new remote-Container.
*
* @param remConf the RemoteContainerConfig
* @param preventUsageOfAlreadyUsedComputers the boolean prevent usage of already used computers
* @return the name of the container
*/
private String sendMsgRemoteContainerRequest(RemoteContainerConfig remConf) {
// --- If the remote-configuration is null configure it now -
if (remConf==null) {
remConf = this.getRemoteContainerConfigAuto();
}
// --- Define the AgentAction -------------------------------
ClientRemoteContainerRequest req = new ClientRemoteContainerRequest();
req.setRemoteConfig(remConf);
Action act = new Action();
act.setActor(myContainer.getAMS());
act.setAction(req);
// --- Define receiver of the Message -----------------------
AID agentGUIAgent = new AID(Platform.BackgroundSystemAgentApplication + "@" + this.myContainer.getPlatformID(), AID.ISGUID);
// --- Build Message ----------------------------------------
ACLMessage msg = new ACLMessage(ACLMessage.INFORM);
msg.setSender(myContainer.getAMS());
msg.addReceiver(agentGUIAgent);
msg.setLanguage(new SLCodec().getName());
msg.setOntology(AgentGUI_DistributionOntology.getInstance().getName());
try {
msg.setContentObject(act);
} catch (IOException errCont) {
errCont.printStackTrace();
}
// --- Send message -----------------------------------------
myContainer.postMessageToLocalAgent(msg, agentGUIAgent);
// --- Remind, that we're waiting for this container --------
loadInfo.setNewContainer2Wait4(remConf.getJadeContainerName());
// --- Return -----------------------------------------------
return remConf.getJadeContainerName();
}
示例9: jasonToACL
import jade.lang.acl.ACLMessage; //导入方法依赖的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;
}
示例10: jasonToACL
import jade.lang.acl.ACLMessage; //导入方法依赖的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;
}
示例11: giveBlock
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
private void giveBlock(AID receiver, Block block) {
ACLMessage messageToSourcePalette = new ACLMessage(ACLMessage.REQUEST);
messageToSourcePalette.addReceiver(receiver);
messageToSourcePalette.setProtocol(this.currProtocol);
try {
messageToSourcePalette.setContentObject(block);
} catch (IOException e) {
e.printStackTrace();
}
robotAgent.send(messageToSourcePalette);
}
示例12: addBlockToMessage
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
private static ACLMessage addBlockToMessage(ACLMessage message, Block block) {
if (block == null) {
message.setPerformative(ACLMessage.FAILURE);
return message;
}
try {
message.setContentObject(block);
} catch (IOException e) {
e.printStackTrace();
message.setPerformative(ACLMessage.FAILURE);
return message;
}
return message;
}
示例13: updateTrack
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public ACLMessage updateTrack() {
ACLMessage messageToTrackAgent = new ACLMessage(ACLMessage.INFORM);
messageToTrackAgent.setProtocol(ProtocolTemplates.TrackProtocolTemplate.TRACK_FLOOR_PROTOCOL);
try {
messageToTrackAgent.setContentObject(this.floor);
} catch (IOException e) {
e.printStackTrace();
}
messageToTrackAgent.addReceiver(new AID("TrackAgent", AID.ISLOCALNAME));
return messageToTrackAgent;
}
示例14: updateTrack
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public ACLMessage updateTrack() {
ACLMessage messageToTrackAgent = new ACLMessage(ACLMessage.INFORM);
messageToTrackAgent.setProtocol(ProtocolTemplates.TrackProtocolTemplate.TRACK_PALETTE_PROTOCOL);
try {
messageToTrackAgent.setContentObject(this.goalPalette);
} catch (IOException e) {
e.printStackTrace();
}
messageToTrackAgent.addReceiver(new AID("TrackAgent", AID.ISLOCALNAME));
return messageToTrackAgent;
}
示例15: updateTrack
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public ACLMessage updateTrack() {
ACLMessage messageToTrackAgent = new ACLMessage(ACLMessage.INFORM);
messageToTrackAgent.setProtocol(ProtocolTemplates.TrackProtocolTemplate.TRACK_PALETTE_PROTOCOL);
try {
messageToTrackAgent.setContentObject(this.sourcePalette);
} catch (IOException e) {
e.printStackTrace();
}
messageToTrackAgent.addReceiver(new AID("TrackAgent", AID.ISLOCALNAME));
return messageToTrackAgent;
}