Package jade.lang.acl

Examples of jade.lang.acl.ACLMessage


   * exception.
   * @return the ACLMessage representing this exception
   **/
  public ACLMessage getACLMessage() {
    if (msg == null) {
      msg = new ACLMessage(ACLMessage.NOT_UNDERSTOOD);
      msg.setContent(getMessage());
    }
    return msg;
  }
View Full Code Here


    else {
      throw new UnsupportedFunction();
    }
   
    // Prepare the notification
    ACLMessage notification = request.createReply();
    notification.setPerformative(ACLMessage.INFORM);
    Predicate p = null;
    if (resultItems != null) {
      // The action produced a result
      p = new Result(slAction, resultItems);
    }
View Full Code Here

        for (int i = 0; i < size; i++) {
          System.out.println("aclModel: " + aclModel.getChild(this.aclRoot, i).getClass());
          ACLMessageNode theNode = (ACLMessageNode)aclModel.getChild(this.aclRoot, i);
          String direction = theNode.getDirection();
          String theTime = theNode.getTime();
          ACLMessage theMsg = theNode.getMessage();
          bw.newLine();
          bw.write(direction);
          bw.newLine();
          bw.write(theTime);
          bw.newLine();
          bw.write(theMsg.toString());
          bw.newLine();
        }
        bw.flush();
        bw.close();
        f.close();
View Full Code Here

        GenericMessage msg = (GenericMessage) params[0];
        AID receiver = (AID) params[1];
        InternalError ie = (InternalError) params[2];

        // If (the sender is not the AMS and the performative is not FAILURE)
        ACLMessage aclmsg = msg.getACLMessage();

        if ((aclmsg.getSender() == null) ||
                ((aclmsg.getSender().equals(myContainer.getAMS())) &&
                (aclmsg.getPerformative() == ACLMessage.FAILURE))) { // sanity check to avoid infinite loops

            return;
        }

        // Send back a failure message
        final ACLMessage failure = aclmsg.createReply();
        failure.setPerformative(ACLMessage.FAILURE);

        //System.err.println(failure.toString());
        final AID theAMS = myContainer.getAMS();
        failure.setSender(theAMS);
        failure.setLanguage(FIPANames.ContentLanguage.FIPA_SL);

        // FIXME: the content is not completely correct, but that should
        // also avoid creating wrong content
        String content = "( (action " + msg.getSender().toString();
        content = content + " (ACLMessage) ) (MTS-error " + receiver + " \"" +
            ie.getMessage() + "\") )";
        failure.setContent(content);

        try {
            GenericCommand command = new GenericCommand(MessagingSlice.SEND_MESSAGE,
                    MessagingSlice.NAME, null);
            command.addParam(theAMS);
            command.addParam(new GenericMessage(failure));
            command.addParam((AID) (failure.getAllReceiver().next()));

            // FIXME: We should set the AMS principal and credentials
            submit(command);
        } catch (ServiceException se) {
            // It should never happen
View Full Code Here

    private int cnt = 0;
   
    protected void setup() {
      addBehaviour(new CyclicBehaviour(this) {
        public void action() {
          ACLMessage msg = myAgent.receive();
          if (msg != null) {
            if (!firstReceived) {
              firstReceived = true;
              startTime = System.currentTimeMillis();
            }
View Full Code Here

   */
  public static class RTTReceiverAgent extends Agent {
    protected void setup() {
      addBehaviour(new CyclicBehaviour(this) {
        public void action() {
          ACLMessage msg = myAgent.receive();
          if (msg != null) {
            ACLMessage reply = msg.createReply();
            reply.setPerformative(ACLMessage.INFORM);
            reply.setByteSequenceContent(msg.getByteSequenceContent());
            myAgent.send(reply);
          }
          else {
            block();
          }
View Full Code Here

    SearchConstraints constraints = null;
    AbsIRE absIota = null;
   
    try {
      // Get DFD template and search constraints from the subscription message
      ACLMessage subMessage = sub.getMessage();
      if (myLogger.isLoggable(Logger.CONFIG)) {
        myLogger.log(Logger.CONFIG, "Registering subscription "+subMessage.getConversationId()+". Agent is "+subMessage.getSender().getName());
      }
     
      absIota = (AbsIRE) cm.extractAbsContent(subMessage);
      AbsPredicate absResult = absIota.getProposition();
      AbsAgentAction absAction = (AbsAgentAction) absResult.getAbsObject(BasicOntology.RESULT_ACTION);
      AbsAgentAction absSearch = (AbsAgentAction) absAction.getAbsObject(BasicOntology.ACTION_ACTION);
      Search search = (Search) FIPAManagementOntology.getInstance().toObject(absSearch);
     
      dfdTemplate = (DFAgentDescription) search.getDescription();
      constraints = search.getConstraints();
     
      // Register the Subscription
      kBase.subscribe(dfdTemplate, sub);
     
      // Update the cache
      synchronized (subscriptionsCache) {
        if (subscriptions != null) {
          subscriptionsCache.put(subMessage.getConversationId(), new SubscriptionInfo(sub, dfdTemplate, absIota));
          subscriptions = toArray(subscriptionsCache);
        }
      }
    }
    catch(Exception e) {
View Full Code Here

  }
 
 
  public boolean deregister( SubscriptionResponder.Subscription sub ) throws FailureException {
    if (myLogger.isLoggable(Logger.CONFIG)) {
      ACLMessage subMessage = sub.getMessage();
      myLogger.log(Logger.CONFIG, "Deregistering subscription "+subMessage.getConversationId()+". Agent is "+subMessage.getSender().getName());
    }
    kBase.unsubscribe(sub);
   
    // Update the cache
    synchronized (subscriptionsCache) {
View Full Code Here

      if ( DFMemKB.compare(template, dfd) || ((oldDfd!=null) && DFMemKB.compare(template, oldDfd))) {
        // This subscriber must be notified
        List results = new ArrayList();
        results.add(dfd);
        if (myLogger.isLoggable(Logger.FINE)) {
          ACLMessage subMessage = info.getSubscription().getMessage();
          myLogger.log(Logger.FINE, "Notifying subscribed agent "+subMessage.getSender().getName()+" ["+subMessage.getConversationId()+"] ");
        }
        notify(info.getSubscription(), results, info.getAbsIota());
      }
    }
  }
View Full Code Here

    return m;
  }

  private void notify(SubscriptionResponder.Subscription sub, List results, AbsIRE absIota) {
    try {
      ACLMessage notification = sub.getMessage().createReply();
      notification.addUserDefinedParameter(ACLMessage.IGNORE_FAILURE, "true");
      notification.setPerformative(ACLMessage.INFORM);
      AbsPredicate absEquals = new AbsPredicate(SLVocabulary.EQUALS);
      absEquals.set(SLVocabulary.EQUALS_LEFT, absIota);
      absEquals.set(SLVocabulary.EQUALS_RIGHT, FIPAManagementOntology.getInstance().fromObject(results));
     
      cm.fillContent(notification, absEquals);
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.