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


Java OneShotBehaviour类代码示例

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


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

示例1: informAllAgsToPerformCycle

import jade.core.behaviours.OneShotBehaviour; //导入依赖的package包/类
public void informAllAgsToPerformCycle(final int cycle) {
    addBehaviour(new OneShotBehaviour() {
        public void action() {
            try {
                logger.fine("Sending performCycle "+cycle+" to all agents.");
                ACLMessage m = new ACLMessage(ACLMessage.INFORM);
                m.setOntology(controllerOntology);
                addAllAgsAsReceivers(m);
                m.setContent("performCycle");
                m.addUserDefinedParameter("cycle", String.valueOf(cycle));
                send(m);
            } catch (Exception e) {
                logger.log(Level.SEVERE, "Error in informAllAgsToPerformCycle", e);
            }
        }
    });
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:18,代码来源:JadeExecutionControl.java

示例2: setupSemanticInterpretationPrinciples

import jade.core.behaviours.OneShotBehaviour; //导入依赖的package包/类
protected SemanticInterpretationPrincipleTable setupSemanticInterpretationPrinciples() {
	// Create a default SIP table
	SemanticInterpretationPrincipleTable table = super.setupSemanticInterpretationPrinciples();

    // Create a new SIP to display the picture, using a NotificationSIPAdapter
    SemanticInterpretationPrinciple sip_view =
    new NotificationSIPAdapter(this, "(image-content ??id ??content)") {
	    protected void notify(final MatchResult applyResult, SemanticRepresentation sr) {
	    	potentiallyAddBehaviour(new OneShotBehaviour() {
				public void action() {
				    myGUI.displayPhoto(((Constant)applyResult.term("content")).byteValue());
				}
			});
	    }
	};

    // Add the created SIP into the SIP table
    table.addSemanticInterpretationPrinciple(sip_view);
    return table;
}
 
开发者ID:krevelen,项目名称:coala,代码行数:21,代码来源:Viewer.java

示例3: broadcast

import jade.core.behaviours.OneShotBehaviour; //导入依赖的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: informAgToPerformCycle

import jade.core.behaviours.OneShotBehaviour; //导入依赖的package包/类
public void informAgToPerformCycle(final String agName, final int cycle) {
    addBehaviour(new OneShotBehaviour() {
        public void action() {
            ACLMessage m = new ACLMessage(ACLMessage.INFORM);
            m.setOntology(controllerOntology);
            m.addReceiver(new AID(agName, AID.ISLOCALNAME));
            m.setContent("performCycle");
            m.addUserDefinedParameter("cycle", String.valueOf(cycle));
            send(m);
        }
    });
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:13,代码来源:JadeExecutionControl.java

示例5: getAgState

import jade.core.behaviours.OneShotBehaviour; //导入依赖的package包/类
public Document getAgState(final String agName) {
    if (agName == null) return null;

    state = null;
    addBehaviour(new OneShotBehaviour() {
        public void action() {
            try {
                ACLMessage m = new ACLMessage(ACLMessage.QUERY_REF);
                m.setOntology(controllerOntology);
                m.addReceiver(new AID(agName, AID.ISLOCALNAME));
                m.setContent("agState");
                ACLMessage r = ask(m);
                if (r == null) {
                    System.err.println("No agent state received! (possibly timeout in ask)");
                } else {
                    state = (Document) r.getContentObject();
                }
            } catch (Exception e) {
                logger.log(Level.SEVERE, "Error in getAgState", e);
            } finally {
                synchronized (syncWaitState) {
                    syncWaitState.notifyAll();
                }
            }
        }
    });
    return waitState();
}
 
开发者ID:jason-lang,项目名称:jason,代码行数:29,代码来源:JadeExecutionControl.java

示例6: setupSemanticInterpretationPrinciples

import jade.core.behaviours.OneShotBehaviour; //导入依赖的package包/类
protected SemanticInterpretationPrincipleTable setupSemanticInterpretationPrinciples() {
	SemanticInterpretationPrincipleTable res_table = super.setupSemanticInterpretationPrinciples();
	SemanticInterpretationPrinciple sip =
	new NotificationSIPAdapter(this, B_IMAGE_CONTENT_PATTERN) {
	    protected void notify(final MatchResult applyResult, SemanticRepresentation sr) {
		potentiallyAddBehaviour(new OneShotBehaviour() {
			public void action() {
			    myGUI.displayPhoto(((Constant)applyResult.term("content")).byteValue());
			}
		    });
	    }
	};
    res_table.addSemanticInterpretationPrinciple(sip);
    return res_table;
}
 
开发者ID:krevelen,项目名称:coala,代码行数:16,代码来源:Viewer.java

示例7: setupSemanticInterpretationPrinciples

import jade.core.behaviours.OneShotBehaviour; //导入依赖的package包/类
protected SemanticInterpretationPrincipleTable setupSemanticInterpretationPrinciples() {
	SemanticInterpretationPrincipleTable table = super.setupSemanticInterpretationPrinciples();
	SemanticInterpretationPrinciple sip =
	new NotificationSIPAdapter(this, B_IMAGE_CONTENT_PATTERN) {
	    protected void notify(final MatchResult applyResult, SemanticRepresentation sr) {
		potentiallyAddBehaviour(new OneShotBehaviour() {
			public void action() {
			    myGUI.displayPhoto(((Constant)applyResult.term("content")).byteValue());
			}
		    });
	    }
	};
    table.addSemanticInterpretationPrinciple(sip);
    return table;
}
 
开发者ID:krevelen,项目名称:coala,代码行数:16,代码来源:Viewer.java

示例8: updateCatalogue

import jade.core.behaviours.OneShotBehaviour; //导入依赖的package包/类
/**
    This is invoked by the GUI when the user adds a new book for sale
 */
public void updateCatalogue(final String title, final int price) {
	addBehaviour(new OneShotBehaviour() {
		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;

		public void action() {
			catalogue.put(title, new Integer(price));
			System.out.println(title + " inserted into catalogue. Price = " + price);
		}
	} );
}
 
开发者ID:bluezio,项目名称:jade-booktrading,代码行数:17,代码来源:BookSellerAgent.java

示例9: setup

import jade.core.behaviours.OneShotBehaviour; //导入依赖的package包/类
@Override
    protected void setup() {
        System.out.println("Auction Seller Agent ready for service!");

        Object[] args = getArguments();
        if (args != null && args.length > 0) {
            itemName = (String) args[0];
            itemPrice = Integer.parseInt((String) args[1]);

            System.out.println("This time I'm selling the item \"" + itemName + "\" with the starting price of " + itemPrice);
            System.out.println("Please make your bids!");


            // Add behaviour to get the buyers bids

//            addBehaviour(new TickerBehaviour(this, 30000) {
//                @Override
//                protected void onTick() {
//                    // Get all the BidderAgents
//                    DFAgentDescription template = new DFAgentDescription();
//                    ServiceDescription sd = new ServiceDescription();
//                    sd.setType("auction-bidder");
//                    template.addServices(sd);
//
//                    try {
//                        DFAgentDescription[] result = DFService.search(myAgent, template);
//
//                        bidderAgents = new AID[result.length];
//                        for (int i = 0; i < result.length; i++) {
//                            System.out.println("Found seller: " + result[i].getName());
//
//                            bidderAgents[i] = result[i].getName();
//                        }
//                    } catch (FIPAException e) {
//                        e.printStackTrace();
//                    }
//
//                    myAgent.addBehaviour(new AuctionPerformer());
//                }
//            });

            addBehaviour(new OneShotBehaviour() {
                @Override
                public void action() {
                    // Get all the BidderAgents
                    DFAgentDescription template = new DFAgentDescription();
                    ServiceDescription sd = new ServiceDescription();
                    sd.setType("auction-bidder");
                    template.addServices(sd);

                    try {
                        DFAgentDescription[] result = DFService.search(myAgent, template);

                        bidderAgents = new AID[result.length];
                        for (int i = 0; i < result.length; i++) {
                            System.out.println("Found seller: " + result[i].getName());

                            bidderAgents[i] = result[i].getName();
                        }
                    } catch (FIPAException e) {
                        e.printStackTrace();
                    }

                    myAgent.addBehaviour(new AuctionPerformer());
                }
            });
        } else {
            System.out.println("No item to be auctioned this time");
            doDelete();
        }
    }
 
开发者ID:ohvitorino,项目名称:auctions,代码行数:72,代码来源:AuctionerAgent.java

示例10: setup

import jade.core.behaviours.OneShotBehaviour; //导入依赖的package包/类
protected void setup() {
		getContentManager().registerLanguage(new SLCodec());
		getContentManager().registerOntology(MobilityOntology.getInstance());
		
		addBehaviour(new OneShotBehaviour() {
//			public boolean started = false;
			@Override
			public void action() {
				// TODO Auto-generated method stub

				// Wait a while:
				long startTime = System.currentTimeMillis();
				while(System.currentTimeMillis()-startTime<5000);
				
//				AgentMobilityService am = new AgentMobilityService();
				
				System.out.println("trying to move ...");
				Location dest = new ContainerID("android",null);
				doMove(dest);

//				try {
//					System.out.println("trying to move ...");
//					Hashtable<String, Location> locations = new Hashtable<String, Location>();
//
//					// Get available locations with AMS
//					sendRequest(new Action(getAMS(), new QueryPlatformLocationsAction()));
//
//					//Receive response from AMS
//					MessageTemplate mt = MessageTemplate.and(
//							MessageTemplate.MatchSender(getAMS()),
//							MessageTemplate.MatchPerformative(ACLMessage.INFORM));
//					ACLMessage resp = blockingReceive(mt);
//					ContentElement ce = getContentManager().extractContent(resp);
//					Result result = (Result) ce;
//					jade.util.leap.Iterator it = result.getItems().iterator();
//					while (it.hasNext()) {
//						Location loc = (Location)it.next();
//						locations.put(loc.getName(), loc);
//					}
//
//					Location dest = locations.get("android");
//					doMove(dest);
//				}
//				catch (Exception e) { e.printStackTrace(); }
			}
		});
	}
 
开发者ID:tATAmI-Project,项目名称:tATAmI-PC,代码行数:48,代码来源:SimpleMobileAgent.java


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