コード例 #1
0
  public void startAllAgents() {
    Enumeration<SimpleJasonAgent> e = getAgents().elements();

    while (e.hasMoreElements()) {
      SimpleJasonAgent j = e.nextElement();
      if (!j.getHasStarted()) j.run();
    }
  }
コード例 #2
0
 /**
  * @param content
  * @param receiver
  * @param annotations
  * @param updateMode
  * @param persistent receive the percepts from the camel exchange, and pass it to a particular
  *     agent or all the agents, based on the value of the receiver parameter
  */
 public void getCamelpercepts(
     String content, String receiver, String annotations, String updateMode, String persistent) {
   try {
     Iterator<SimpleJasonAgent> it = agentList.iterator();
     for (; it.hasNext(); ) {
       SimpleJasonAgent a = it.next();
       if (!receiver.equals("")) {
         if (a.getAgName().equals(receiver))
           a.updatePerceptList(content, annotations, updateMode, persistent);
       } else a.updatePerceptList(content, annotations, updateMode, persistent);
     }
   } catch (Exception e) {
   }
 }
コード例 #3
0
  /**
   * @param message
   * @param receiver
   *     <p>receive the messages from the camel exchange, and pass it to a particular agent or all
   *     the agents, based on the value of the receiver parameter
   */
  public void getCamelMessages(Message message, String receiver) {
    try {
      Iterator<SimpleJasonAgent> it = agentList.iterator();
      for (; it.hasNext(); ) {
        SimpleJasonAgent a = it.next();

        // if the receiver value is "all", send the message to all the agents in the context
        if (receiver.equals("all")) {
          Message tm = message;
          if (!a.getAgName().equals(message.getSender())) {
            tm.setReceiver(a.getAgName());
            a.updateMsgQueue(tm);
          }
        } else if (a.getAgName().equals(receiver)) a.updateMsgQueue(message);
      }
    } catch (Exception e) {
    }
  }