Exemplo n.º 1
0
  @Override
  public void addInterfaces(MainScreen parent, Node node) {

    String[] choices = {
      "5 Ethernet-TX ports simple switch.",
      "8 Ethernet-TX ports switch.",
      "12 Ethernet-TX ports switch.",
      "24 Ethernet-TX ports switch.",
      "12 Ethernet-TX ports with 2 Ethernet-FX switch.",
      "24 Ethernet-TX ports with 2 Ethernet-FX switch.",
      "12 Ethernet-FX ports with 2 Ethernet-TX switch.",
      "24 Ethernet-FX ports with 2 Ethernet-TX switch."
    };

    String choice =
        parent.getDeviceTypeDialog("Create new switch", "Please choose switch type", choices);

    int tx = 0, fx = 0;

    if (choice.contains(choices[0])) {
      tx = 5;
      fx = 0;
    } else if (choice.contains(choices[1])) {
      tx = 8;
      fx = 0;
    } else if (choice.contains(choices[2])) {
      tx = 12;
      fx = 0;
    } else if (choice.contains(choices[3])) {
      tx = 24;
      fx = 0;
    } else if (choice.contains(choices[4])) {
      tx = 12;
      fx = 2;
    } else if (choice.contains(choices[5])) {
      tx = 24;
      fx = 2;
    } else if (choice.contains(choices[6])) {
      tx = 2;
      fx = 12;
    } else if (choice.contains(choices[7])) {
      tx = 2;
      fx = 24;
    }

    for (int i = 0; i < tx; i++) {
      node.addNetworkInterface(
          core.NetworkInterface.getIntName(core.NetworkInterface.Ethernet10T) + String.valueOf(i),
          core.NetworkInterface.Ethernet10T,
          false);
    }

    for (int i = 0; i < fx; i++) {
      node.addNetworkInterface(
          core.NetworkInterface.getIntName(core.NetworkInterface.Ethernet100FX) + String.valueOf(i),
          core.NetworkInterface.Ethernet100FX,
          false);
    }
  }
Exemplo n.º 2
0
  public void expand() {

    Node[] possibles = new Node[4];
    int possCount = 0;
    for (Node n : gameState.getPacman().current.adj) {
      if (!n.equals(prev)) {
        possibles[possCount++] = n;
      }
    }

    int nActions = possCount;
    children = new TreeNode[nActions];
    for (int i = 0; i < nActions; i++) {
      Node target = possibles[i];
      GameStateInterface nextGs = gameState.copy();
      nextGs.next(
          Utilities.getWrappedDirection(gameState.getPacman().current, target, gameState.getMaze()),
          ghosts.getActions(gameState));
      children[i] = new TreeNode(nextGs, gameState.getPacman().current);
    }
  }
  /**
   * Instantiate and populate a node object from the next item in the result set of a node query.
   *
   * @param query string
   * @return Node
   */
  protected Node nodeFromQueryRS(String query) throws DatabaseException {
    Node node = null;

    if (dbr.psRSNext(query)) {
      // String columns = org.apache.commons.lang.StringUtils.join(dbr.psRSColumnNames(query), ",
      // ");
      // System.out.println("columns: [" + columns + "]");

      node = new Node();

      Long id = dbr.psRSGetBigInt(query, "ID");
      String name = dbr.psRSGetVarChar(query, "NAME");
      String type = dbr.psRSGetVarChar(query, "TYPE");
      Double longitude = dbr.psRSGetDouble(query, "X");
      Double latitude = dbr.psRSGetDouble(query, "Y");

      node.setId(id);
      node.setName(name);
      node.setType(type);
      node.setLongitude(longitude);
      node.setLatitude(latitude);
    }

    return node;
  }