Package jade.lang.acl

Examples of jade.lang.acl.ACLMessage


  //all the agents registered with that ams.
  public void refreshRemoteAgent(APDescription platform,AID ams){
    try{
      // FIXME. Move all this block into the constructor for better performance
      // because it is invariant to the method parameters
      ACLMessage request; // variable that keeps the request search message
      Action act;  // variable that keeps the search action
      request = new ACLMessage(ACLMessage.REQUEST);
      request.setProtocol(FIPANames.InteractionProtocol.FIPA_REQUEST);
      request.setLanguage(FIPANames.ContentLanguage.FIPA_SL0);
      request.setOntology(FIPAManagementOntology.NAME);
      AMSAgentDescription amsd = new AMSAgentDescription();
      SearchConstraints constraints = new SearchConstraints();
      constraints.setMaxResults(new Long(-1)); // all results back
      // Build a AMS action object for the request
      Search s = new Search();
      s.setDescription(amsd);
      s.setConstraints(constraints);
      act = new Action();
      act.setAction(s);
     
      // request has been already initialized in the constructor
      request.clearAllReceiver();
      request.addReceiver(ams);   
      act.setActor(ams); // set the actor of this search action
      getContentManager().fillContent(request, act);
     
      addBehaviour(new handleRefreshRemoteAgentBehaviour ("search",request,platform));
     
View Full Code Here


   agent and closing down the platform administration <em>GUI</em>.
   */
  public void toolTakeDown() {
    // Stop debugging all the agents
    if(!windowMap.isEmpty()) {
      ACLMessage msg = getRequest();
      msg.setOntology(JADEManagementOntology.NAME);
      DebugOff dbgOff = new DebugOff();
      dbgOff.setDebugger(getAID());
      Iterator it = windowMap.keySet().iterator();
      while(it.hasNext()) {
        AID id = (AID)it.next();
View Full Code Here

 
  private void proceed(AID id) {
    String pendingReplyWith = (String) pendingReplies.remove(id);
    AID tn = (AID) notifiers.get(id);
    if (pendingReplyWith != null && tn != null) {
      ACLMessage msg = new ACLMessage(ACLMessage.INFORM);
      msg.addReceiver(tn);
      msg.setInReplyTo(pendingReplyWith);
      send(msg);
    }
  }
View Full Code Here


  /**
   */
  public static final String stringify(GenericMessage m) {
    ACLMessage msg = m.getACLMessage();
    if (msg != null) {
      StringBuffer sb = new StringBuffer("(");
      sb.append(ACLMessage.getPerformative(msg.getPerformative()));
      sb.append(" sender: ");
      sb.append(msg.getSender().getName());
      if (msg.getOntology() != null) {
        sb.append(" ontology: ");
        sb.append(msg.getOntology());
      }
      if (msg.getConversationId() != null) {
        sb.append(" conversation-id: ");
        sb.append(msg.getConversationId());
      }
      sb.append(')');
      return sb.toString();
    }
    else {
View Full Code Here

       
        stepByStepAgents.remove(amsId);
        slowAgents.remove(amsId);
        proceed(amsId);
       
        ACLMessage msg = getRequest();
        msg.setOntology(JADEManagementOntology.NAME);
        DebugOff dbgOff = new DebugOff();
        dbgOff.setDebugger(getAID());
        dbgOff.addDebuggedAgents(amsId);
        Action a = new Action();
        a.setActor(getAMS());
View Full Code Here

    try{
      Action a = new Action();
      a.setActor(getAMS());
      a.setAction(register_act);
     
      ACLMessage requestMsg = getRequest();
      requestMsg.setOntology(FIPAManagementOntology.NAME);
      getContentManager().fillContent(requestMsg, a);
     
      addBehaviour(new AMSClientBehaviour("Register", requestMsg));
     
    }catch(Exception e){e.printStackTrace();}
View Full Code Here

     
    }
   
    public void action() {
     
      ACLMessage message = receive(template);
      if(message != null) {
        AID name = message.getSender();
        try{
          Occurred o = (Occurred)getContentManager().extractContent(message);
          EventRecord er = o.getWhat();
          Event ev = er.getWhat();
          // DEBUG
          if(logger.isLoggable(Logger.FINEST))
            logger.log(Logger.FINEST,"Received event "+ev);
          if (message.getReplyWith() != null) {
            // A reply is expected --> put relevant information into the
            // pendingReplies Map
            ChangedBehaviourState cs = (ChangedBehaviourState)ev;
            pendingReplies.put(cs.getAgent(), message.getReplyWith());
          }
          String eventName = ev.getName();
          EventHandler h = (EventHandler)handlers.get(eventName);
          if(h != null)
            h.handle(ev);
View Full Code Here

          MessageTemplate.MatchOntology(IntrospectionOntology.NAME),
          MessageTemplate.MatchConversationId(getName() + "-control"));
    }
   
    public void action() {
      ACLMessage message = receive(template);
      if(message != null) {
        try{
          Done d = (Done)getContentManager().extractContent(message);
          Action a = (Action)d.getAction();
          AID tn = a.getActor();
View Full Code Here

    private boolean handleNotifyFailure(VerticalCommand cmd) throws IMTPException, ServiceException {
      Object[] params = cmd.getParams();
      GenericMessage msg = (GenericMessage)params[0];//FIXME: check object type
      AID receiver = (AID)params[1];
      ACLMessage acl = msg.getACLMessage();

      if(myLogger.isLoggable(Logger.FINE))
        myLogger.log(Logger.FINE,"Processing failed message "+MessageManager.stringify(msg)+" for agent "+receiver.getName());


      // FIXME: We should check if the failure is due to a "not found receiver"

      // Ask all slices whether the failed message should be stored
      Service.Slice[] slices = getAllSlices();
      for(int i = 0; i < slices.length; i++) {
        PersistentDeliverySlice slice = (PersistentDeliverySlice)slices[i];
        try {
          boolean firstTime = (acl.getUserDefinedParameter(ACL_USERDEF_DUE_DATE) == null);
          boolean accepted = false;
          try {
            accepted = slice.storeMessage(null, msg, receiver);
          }
          catch(IMTPException imtpe) {
View Full Code Here

      // We serve REQUEST messages refering to the JADE Management Ontology
      super(Introspector.this, MessageTemplate.and(MessageTemplate.MatchPerformative(ACLMessage.REQUEST),MessageTemplate.MatchOntology(JADEManagementOntology.NAME)));
    }
   
    protected ACLMessage prepareResponse (ACLMessage request) {
      ACLMessage response = request.createReply();
      try {     
        requestAction = (Action) getContentManager().extractContent(request);
        aa = (AgentAction) requestAction.getAction();
        if (aa instanceof DebugOn || aa instanceof DebugOff) {
          if (getAID().equals(requestAction.getActor())) {
            response.setPerformative(ACLMessage.AGREE);
            response.setContent(request.getContent());
          }
          else {
            response.setPerformative(ACLMessage.REFUSE);
            response.setContent("((unrecognised-parameter-value actor "+requestAction.getActor()+"))");
          }
        }
        else {
          response.setPerformative(ACLMessage.REFUSE)
          response.setContent("((unsupported-act "+aa.getClass().getName()+"))");
        }
      }
      catch (Exception e) {
        e.printStackTrace();
        response.setPerformative(ACLMessage.NOT_UNDERSTOOD)
      }
      return response;                            
    }
View Full Code Here

TOP

Related Classes of jade.lang.acl.ACLMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.