Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package lab5;
- import jade.content.ContentElement;
- import jade.content.ContentManager;
- import jade.content.lang.Codec;
- import jade.content.lang.sl.SLCodec;
- import jade.content.onto.OntologyException;
- import jade.content.onto.basic.Action;
- import jade.content.onto.basic.Result;
- import jade.core.Agent;
- import jade.core.Location;
- import jade.domain.JADEAgentManagement.QueryPlatformLocationsAction;
- import jade.domain.mobility.MobilityOntology;
- import jade.lang.acl.ACLMessage;
- import jade.lang.acl.MessageTemplate;
- import jade.util.leap.ArrayList;
- import jade.util.leap.List;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- /**
- *
- * @author student
- */
- public class Pinkie extends Agent {
- ArrayList lokacje ;
- int numer;
- protected void IdzStad(){
- doMove((Location) lokacje.get(numer));
- numer++;
- if(numer>=lokacje.size())
- numer=0;
- }
- protected void PobierzKontenery(){
- try {
- ContentManager cm = getContentManager();
- cm.registerLanguage(new SLCodec());
- cm.registerOntology(MobilityOntology.getInstance());
- ACLMessage request = new ACLMessage(ACLMessage.REQUEST);
- request.setLanguage(new SLCodec().getName());
- request.setOntology(MobilityOntology.getInstance().getName());
- request.addReceiver(getAMS());
- cm = getContentManager();
- QueryPlatformLocationsAction query = new QueryPlatformLocationsAction();
- Action action = new Action(getAMS(),query);
- cm.fillContent(request, action);
- send(request);
- MessageTemplate mt = MessageTemplate.MatchSender(getAMS());
- ACLMessage msg = blockingReceive(mt);
- ContentElement ce = cm.extractContent(msg);
- lokacje = (ArrayList) ((Result) ce).getItems();
- System.out.println(lokacje.toString());
- } catch (Codec.CodecException | OntologyException ex) {
- Logger.getLogger(Pinkie.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- @Override
- protected void setup(){
- super.setup();
- PobierzKontenery();
- lokacje = new ArrayList();
- numer = 0;
- addBehaviour(new Przesuniecie(this));
- }
- @Override
- protected void beforeMove(){
- super.beforeMove();
- }
- @Override
- protected void afterMove(){
- super.afterMove();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement