Пример #1
0
  public static void main(String args[]) throws Exception {
    IAFProperties.setGraphicsOn(false);

    new Thread() {
      public void run() {
        String[] args1 = new String[4];
        args1[0] = "-port";
        args1[1] = "60000";
        args1[2] = "-file-dir";
        args1[3] = "jade/";
        jade.Boot.main(args1);
      }
    }.start();

    // Get a hold on JADE runtime
    jade.core.Runtime rt = jade.core.Runtime.instance();

    // Exit the JVM when there are no more containers around
    rt.setCloseVM(true);

    // Create a default profile
    Profile p = new ProfileImpl();
    p.setParameter("preload", "a*");
    p.setParameter(Profile.MAIN_PORT, "60000");
    p.setParameter(Profile.FILE_DIR, "jade/");

    // Waits for JADE to start
    boolean notConnected = true;

    while (notConnected) {
      try {
        Socket s = new Socket("localhost", Integer.parseInt("60000"));
        notConnected = false;
      } catch (NumberFormatException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (UnknownHostException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (IOException e) {

        System.err.println("Error: " + e.getMessage());
        System.err.println("Reconnecting in one second");
        try {
          Thread.currentThread().sleep(1000);
        } catch (InterruptedException e1) {
          // TODO Auto-generated catch block
          e1.printStackTrace();
        }
      }
    }

    // Create a new non-main container, connecting to the default
    // main container (i.e. on this host, port 1099)
    final jade.wrapper.AgentContainer ac = rt.createAgentContainer(p);

    {
    }
    MainInteractionManager.getInstance().setTitle("node ");
  }
Пример #2
0
  public static void main(String args[]) throws Exception {

    // Get a hold on JADE runtime
    jade.core.Runtime rt = jade.core.Runtime.instance();

    // Exit the JVM when there are no more containers around
    rt.setCloseVM(true);

    // Create a default profile
    Profile p = new ProfileImpl();
    p.setParameter("preload", "a*");
    p.setParameter(Profile.MAIN_PORT, "60000");
    p.setParameter(Profile.FILE_DIR, "jade/");

    // Create a new non-main container, connecting to the default
    // main container (i.e. on this host, port 1099)
    final jade.wrapper.AgentContainer ac = rt.createAgentContainer(p);

    {
    }
    MainInteractionManager.getInstance().setTitle("node ");
  }
Пример #3
0
  public static void main(String args[]) throws Exception {

    // Get a hold on JADE runtime
    jade.core.Runtime rt = jade.core.Runtime.instance();

    // Exit the JVM when there are no more containers around
    rt.setCloseVM(true);

    // Create a default profile
    Profile p = new ProfileImpl();
    p.setParameter("preload", "a*");
    p.setParameter(Profile.MAIN_PORT, "60000");
    if (args.length == 2 && args[1].equalsIgnoreCase("pause")) {
      ingenias.jade.graphics.MainInteractionManager.goManual();
    }
    if (new File("target/jade").exists() && new File("target/jade").isDirectory())
      p.setParameter(Profile.FILE_DIR, "target/jade/");
    else {
      // from http://stackoverflow.com/questions/617414/create-a-temporary-directory-in-java
      final File temp;
      temp = File.createTempFile("jade", Long.toString(System.nanoTime()));

      if (!(temp.delete())) {
        throw new IOException("Could not delete temp file: " + temp.getAbsolutePath());
      }

      if (!(temp.mkdir())) {
        throw new IOException("Could not create temp directory: " + temp.getAbsolutePath());
      }
      p.setParameter(Profile.FILE_DIR, temp.getAbsolutePath() + "/");
    }

    // Create a new non-main container, connecting to the default
    // main container (i.e. on this host, port 1099)
    final jade.wrapper.AgentContainer ac = rt.createAgentContainer(p);

    {
      // Create a new agent
      final jade.wrapper.AgentController agcGUIAgent_0DeploymentUnitByType0 =
          ac.createNewAgent(
              "GUIAgent_0DeploymentUnitByType0",
              "ingenias.jade.agents.GUIAgentJADEAgent",
              new Object[0]);

      new Thread() {
        public void run() {
          try {
            System.out.println("Starting up GUIAgent_0DeploymentUnitByType0...");
            agcGUIAgent_0DeploymentUnitByType0.start();
          } catch (Exception e) {
            e.printStackTrace();
          }
        }
      }.start();

      // Create a new agent
      final jade.wrapper.AgentController agcGUIAgent_1DeploymentUnitByType0 =
          ac.createNewAgent(
              "GUIAgent_1DeploymentUnitByType0",
              "ingenias.jade.agents.GUIAgentJADEAgent",
              new Object[0]);

      new Thread() {
        public void run() {
          try {
            System.out.println("Starting up GUIAgent_1DeploymentUnitByType0...");
            agcGUIAgent_1DeploymentUnitByType0.start();
          } catch (Exception e) {
            e.printStackTrace();
          }
        }
      }.start();

      // Create a new agent
      final jade.wrapper.AgentController agcGUIAgent_2DeploymentUnitByType0 =
          ac.createNewAgent(
              "GUIAgent_2DeploymentUnitByType0",
              "ingenias.jade.agents.GUIAgentJADEAgent",
              new Object[0]);

      new Thread() {
        public void run() {
          try {
            System.out.println("Starting up GUIAgent_2DeploymentUnitByType0...");
            agcGUIAgent_2DeploymentUnitByType0.start();
          } catch (Exception e) {
            e.printStackTrace();
          }
        }
      }.start();
    }
    MainInteractionManager.getInstance().setTitle("node SampleDeployment");
  }