Beispiel #1
0
  public void setup(Scenario scenario, SimTime time) {
    float px;
    float py;

    for (int i = 0; i < numNodes; i++) {
      // float p=2+i*1.5f;
      // float p=5+i;
      px = (float) (Math.random() * scenario.getWidth());
      py = (float) (Math.random() * scenario.getHeight());

      Node newNode =
          new EcraNode(new Point2d(px, py), nodeRadius, scenario, vMin, vMax, targetAttr);
      newNode.setAntennaRadius(antennaRadius);
      nodes.add(newNode);
    }

    // Salvo un rierimento allo scenario
    this.scenario = scenario;

    // Crea i reference point
    createRefPoints();

    // Assegna i ref point di default
    setDefaultRefPoint((int) (numRefPoint / 2));

    // Seleziona i ref point
    if (estractRefPoint) estractRefPoints();

    // Imposto per la prima volta i ruoli
    roleAssignament();
  } // Fine generateNodes
  public Result index() {
    BreadcrumbList bc = new BreadcrumbList();
    bc.addCrumb("System", routes.SystemController.index(0));
    bc.addCrumb("Logging", routes.LoggingController.index());

    Map<Node, List<InternalLogger>> loggers = Maps.newHashMap();
    Map<Node, Map<String, InternalLoggerSubsystem>> subsystems = Maps.newHashMap();
    for (Node node : serverNodes.all()) {
      loggers.put(node, node.allLoggers());
      subsystems.put(node, node.allLoggerSubsystems());
    }

    return ok(views.html.system.logging.index.render(currentUser(), bc, loggers, subsystems));
  }
  public Result setSubsystemLevel(String nodeId, String subsystem, String level) {
    try {
      Node node = nodeService.loadNode(nodeId);
      node.setSubsystemLoggerLevel(subsystem, level);

      return redirect(routes.LoggingController.index());
    } catch (IOException e) {
      return status(500, views.html.errors.error.render(ApiClient.ERROR_MSG_IO, e, request()));
    } catch (APIException e) {
      String message =
          "Could not set log level. We expected HTTP 200, but got a HTTP " + e.getHttpCode() + ".";
      return status(500, views.html.errors.error.render(message, e, request()));
    } catch (NodeService.NodeNotFoundException e) {
      return status(
          404, views.html.errors.error.render(ApiClient.ERROR_MSG_NODE_NOT_FOUND, e, request()));
    }
  }
Beispiel #4
0
 private boolean isVisible(Node node, Node targetNode) {
   float distance = Point2d.distance(node.getPosition(), targetNode.getPosition());
   if (distance <= node.getAntennaRadius()) return true;
   else return false;
 } // Fine isVisible