本文整理汇总了Java中jade.lang.acl.ACLMessage.getContentObject方法的典型用法代码示例。如果您正苦于以下问题:Java ACLMessage.getContentObject方法的具体用法?Java ACLMessage.getContentObject怎么用?Java ACLMessage.getContentObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jade.lang.acl.ACLMessage
的用法示例。
在下文中一共展示了ACLMessage.getContentObject方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: moveAndgetBlockFromSourcePalette
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
private void moveAndgetBlockFromSourcePalette() {
// _controller.move(sourcePaletteColor);
// _agent.broadCastColor(sourcePaletteColor);
//this.sendPosition((byte) 2);
_robotToStationCommunicator.requestDirtyBlock();
ACLMessage reply = _robotToStationCommunicator.receiveReply();
if (reply.getPerformative() == ACLMessage.INFORM) {
try {
_state.block = (Block) reply.getContentObject();
_state.isCarryingBlock = true;
} catch (UnreadableException e) {
e.printStackTrace();
}
} else {
// Exception handlung
}
}
示例2: handleServiceTypeRequest
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public ACLMessage handleServiceTypeRequest(ACLMessage serviceTypeRequest) {
Block block;
try {
block = (Block) serviceTypeRequest.getContentObject();
if (block != null) {
goalPalette.giveBlock(block);
return informMessage(serviceTypeRequest);
} else {
return failureMessage(serviceTypeRequest);
}
} catch (StationException | UnreadableException e) {
e.printStackTrace();
return failureMessage(serviceTypeRequest);
}
}
示例3: takeBlockTest
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Ignore
@Test
public void takeBlockTest() {
sourcePalette = new SourcePalette(0, 10);
communicator = new SourcePaletteCommunicator(sourcePalette);
ACLMessage reply = communicator.handleServiceTypeRequest(takeBlockMessage());
assertTrue(reply.getPerformative() == ACLMessage.INFORM);
assertTrue(this.sourcePalette.getBlocks().size() == 10);
Block block = null;
try {
block = (Block) reply.getContentObject();
} catch (UnreadableException e) {
fail();
e.printStackTrace();
}
assertTrue(block.Status.equals(Block.possibleBlockStatus.DIRTY));
}
示例4: action
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public void action() {
ACLMessage msg = myAgent.receive();
if (msg!=null) {
AID sender = msg.getSender();
// ---- extract content -----------------------------
Object msgContent = null;
try {
msgContent = msg.getContentObject();
} catch (UnreadableException e) {
msgContent = null;
}
localEnvModelNew.put(sender.getLocalName(), (Integer) msgContent);
if (localEnvModelNew.size()==localEnvModel.size()) {
gui.updateGUI(localEnvModelNew);
localEnvModel = localEnvModelNew;
localEnvModelNew = new HashMap<String, Integer>();
if (gui.slider.getValue()>0) {
myAgent.doWait(gui.slider.getValue());
}
// --- Den n�chsten Schritt ausf�hren ----
myAgent.addBehaviour(new StepBehaviour());
}
}
else {
block();
}
}
示例5: waitAndGetCleanedBlock
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
private void waitAndGetCleanedBlock() {
_robotToStationCommunicator.requestCleanedBlock();
ACLMessage reply = _robotToStationCommunicator.receiveReply();
while (reply.getPerformative() == ACLMessage.FAILURE) {
myAgent.doWait(1000);
_robotToStationCommunicator.requestCleanedBlock();
reply = _robotToStationCommunicator.receiveReply();
}
try {
_state.block = (Block) reply.getContentObject();
_state.isCarryingBlock = true;
} catch (UnreadableException e) {
e.printStackTrace();
}
}
示例6: waitAndGetPaintedBlock
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
private void waitAndGetPaintedBlock() {
_robotToStationCommunicator.requestPaintedBlock();
ACLMessage reply = _robotToStationCommunicator.receiveReply();
while (reply.getPerformative() == ACLMessage.FAILURE) {
myAgent.doWait(1000);
_robotToStationCommunicator.requestCleanedBlock();
reply = _robotToStationCommunicator.receiveReply();
}
try {
_state.block = (Block) reply.getContentObject();
_state.isCarryingBlock = true;
} catch (UnreadableException e) {
e.printStackTrace();
}
}
示例7: receiveRobotState
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public RobotState receiveRobotState() {
ACLMessage robotStateMessage = this.trackAgent.blockingReceive(
MessageTemplate.MatchProtocol(ProtocolTemplates.TrackProtocolTemplate.TRACK_ROBOT_STATE_PROTOCOL));
RobotState state = null;
try {
state = (RobotState) robotStateMessage.getContentObject();
} catch (UnreadableException e) {
e.printStackTrace();
}
return state;
}
示例8: receiveFloor
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public Floor receiveFloor() {
ACLMessage floorMessage = this.trackAgent.blockingReceive(
MessageTemplate.MatchProtocol(ProtocolTemplates.TrackProtocolTemplate.TRACK_FLOOR_PROTOCOL));
Floor floorState = null;
try {
floorState = (Floor) floorMessage.getContentObject();
} catch (UnreadableException e) {
e.printStackTrace();
}
return floorState;
}
示例9: receivePalette
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public Palette receivePalette() {
ACLMessage paletteMessage = this.trackAgent.blockingReceive(
MessageTemplate.MatchProtocol(ProtocolTemplates.TrackProtocolTemplate.TRACK_PALETTE_PROTOCOL));
Palette paletteState = null;
try{
paletteState = (Palette) paletteMessage.getContentObject();
} catch (UnreadableException e){
e.printStackTrace();
}
return paletteState;
}
示例10: unwrapPayload
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
public static <T extends Serializable> T unwrapPayload(ACLMessage msg, Class<T> type) {
try {
final Serializable payload = msg.getContentObject();
if (payload == null) {
return null;
} else if (type.isAssignableFrom(payload.getClass())) {
return type.cast(payload);
}
} catch (UnreadableException e) {
LOG.error("Unwrapping message payload failed.", e);
}
return null;
}