Package jade.util

Examples of jade.util.Event


       if(logger.isLoggable(Logger.INFO))
          logger.log(Logger.INFO,"wait agent: Not yet implemented");
    }
        break;
      case 8://Step
        introspectorSensor.post(new Event(Introspector.STEP_EVENT, mainWnd));
        break;
      case 9://Break
        introspectorSensor.post(new Event(Introspector.BREAK_EVENT, mainWnd));
        break;
      case 10://Slow
        introspectorSensor.post(new Event(Introspector.SLOW_EVENT, mainWnd));
        break;
      case 11://Go
        introspectorSensor.post(new Event(Introspector.GO_EVENT, mainWnd));
        break;
    }
  }
View Full Code Here


      myManager.restart();
    }
  } 
 
  public synchronized Event get() {
    Event ev = null;
    if (eventQueue.size() > 0) {
      ev = (Event) eventQueue.elementAt(0);
      eventQueue.removeElementAt(0);
    }
    return ev;
View Full Code Here

    mySensor = s;
    s.setManager(this);
  }
 
  public void action() {
    Event ev = mySensor.get();
    if (ev != null) {
      onEvent(ev);
    }
    else {
      block();
View Full Code Here

   * executing this method is interrupted.
   * @throws StaleProxyException if the method was not able to execute the Command
   * @see jade.wrapper.AgentController#putO2AObject(Object, boolean)
   **/
  public final void execute(Object command, long timeout) throws StaleProxyException,ControllerException,InterruptedException {
    Event e = null;
    synchronized (this) {
      checkJADE();
      // incapsulate the command into an Event
      e = new Event(-1, command);
      try {
        if (myLogger.isLoggable(Logger.INFO))
          myLogger.log(Logger.INFO, "Requesting execution of command "+command);
        myAgent.putO2AObject(e, AgentController.ASYNC);
      } catch (StaleProxyException exc) {
        exc.printStackTrace();
        // in case an exception was thrown, restart JADE
        // and then reexecute the command
        restartJADE();
        myAgent.putO2AObject(e, AgentController.ASYNC);
      }
    }
    // wait until the answer is ready
    e.waitUntilProcessed(timeout);
  }
View Full Code Here

  private final HashMap commandQueue = new HashMap(2);

  private final Logger myLogger = Logger.getMyLogger(this.getClass().getName());

  public void action() {
    Event e = (Event) myAgent.getO2AObject();
    if (e == null) {
      block();
      return;
    }
    // put the event into the command Queue
    commandQueue.put(e.getSource(), e);
    if (myLogger.isLoggable(Logger.INFO)) {
      myLogger.log(Logger.INFO, myAgent.getLocalName() + " started execution of command " + e.getSource());
    }
    // call the processCommand method such as the command is executed
    processCommand(e.getSource());
  }
View Full Code Here

   * notify that the command has been processed and remove the command from the queue
   * @param command is the same object that was passed in the processCommand method
   **/
  final public void releaseCommand(Object command) {
    // remove the command from the queue
    Event e = (Event) commandQueue.remove(command);
    // notify that the command has been processed such as the JADEGateway is waken-up
    if (e != null) {
      if (myLogger.isLoggable(Logger.INFO)) {
        myLogger.log(Logger.INFO, myAgent.getLocalName() + " terminated execution of command " + command);
      }
      e.notifyProcessed(null);
    }
  }
View Full Code Here

TOP

Related Classes of jade.util.Event

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.