Package com.dcaiti.eworld.visualizer.simulation.models

Examples of com.dcaiti.eworld.visualizer.simulation.models.RoadsideUnit


          break;
      }

      return;
    }
    RoadsideUnit removedRoadsideUnit = roadsideUnits.get(id);
    if (removedRoadsideUnit != null) {
      System.out.println("rsu");
      networkViewPlugin.removeVolatileModelElement(roadsideUnits.get(id));
      roadsideUnits.remove(id);
      updateCounter();
View Full Code Here


      setChanged();
      notifyObservers(ObserverNotifications.messageSent);

      return;
    }
    RoadsideUnit sendingRoadsideUnit = roadsideUnits.get(id);
    if (sendingRoadsideUnit != null) {
      sendingRoadsideUnit.sendMessage(messageID, ipSegments, destinationLatitude, destinationLongitude,
          destinationRadius);
      updateCounter();
      if (SimulationSettings.getInstance().isShowingStatusBarSteps()) {
        if (ipSegments == null)
          ipSegments = new byte[] { 0, 0, 0, 0 };
View Full Code Here

      setChanged();
      notifyObservers(ObserverNotifications.messageReceived);

      return;
    }
    RoadsideUnit receivingRoadsideUnit = roadsideUnits.get(id);
    if (receivingRoadsideUnit != null) {
      receivingRoadsideUnit.receiveMessage(messageID);
      updateCounter();
      if (SimulationSettings.getInstance().isShowingStatusBarSteps()) {
        MainStatusBar.getInstance().showMessage(
            "Roadside Unit is receiving a messsage [id: " + id + "] [message id: "
                + Integer.toString(messageID) + "]");
View Full Code Here

  private void addRoadsideUnit(final String id, final double latitude,
      final double longitude) {
    Runnable worker = new Runnable() {
      @Override
      public synchronized void run() {
        RoadsideUnit addedRoadsideUnit = new RoadsideUnit(id,
            Utilities.project(latitude, longitude));
        modelController.addRoadsideUnit(addedRoadsideUnit);

        if (simulationSettings.isBuffering()) {
          simulationBuffer.add(
              VisualizationConstants.CMD_ADDRSU,
              new RoadsideUnit(id, Utilities.project(latitude,
                  longitude)));
        }

        if (sync)
          try {
View Full Code Here

            sendingVehicle.setDestinationRadius(destinationRadius);
            simulationBuffer.add(
                VisualizationConstants.CMD_SENDV2X,
                sendingVehicle);
          } else if (modelController.getRoadsideUnit(id) != null) {
            RoadsideUnit sendingRoadsideUnit = new RoadsideUnit(
                modelController.getRoadsideUnit(id).getID(),
                modelController.getRoadsideUnit(id)
                    .getPosition());
            sendingRoadsideUnit.setSentMessageID(messageID);
            sendingRoadsideUnit.setIPSegments(ipSegments);
            sendingRoadsideUnit
                .setDestinationLatitude(destinationLatitude);
            sendingRoadsideUnit
                .setDestinationLongitude(destinationLongitude);
            sendingRoadsideUnit
                .setDestinationRadius(destinationRadius);
            simulationBuffer.add(
                VisualizationConstants.CMD_SENDV2X,
                sendingRoadsideUnit);
          } else if (modelController.getTrafficLight(id) != null) {
View Full Code Here

            receivingVehicle.setReceivedMessageID(messageID);
            simulationBuffer.add(
                VisualizationConstants.CMD_RECVV2X,
                receivingVehicle);
          } else if (modelController.getRoadsideUnit(id) != null) {
            RoadsideUnit receivingRoadsideUnit = new RoadsideUnit(
                modelController.getRoadsideUnit(id).getID(),
                modelController.getRoadsideUnit(id)
                    .getPosition());
            receivingRoadsideUnit.setReceivedMessageID(messageID);
            simulationBuffer.add(
                VisualizationConstants.CMD_RECVV2X,
                receivingRoadsideUnit);
          } else if (modelController.getTrafficLight(id) != null) {
            TrafficLight receivingTrafficLight = new TrafficLight(
View Full Code Here

        else
          addedVehicle.setHidden(false);
      }
    }
    else if (arg instanceof RoadsideUnit) {
      RoadsideUnit addedRoadsideUnit = (RoadsideUnit) arg;

      String id = addedRoadsideUnit.getID();
      String type = addedRoadsideUnit.getPrettyName();
      Double latitude = GlobalPosition.from(Point2DUtils.convertPoint(addedRoadsideUnit.getPosition()))
          .getLatitude();
      Double longitude = GlobalPosition.from(Point2DUtils.convertPoint(addedRoadsideUnit.getPosition()))
          .getLongitude();
      String speed = "N/A";
      String direction = "N/A";
      String coveredDistance = "N/A";
      String communicationCount = addedRoadsideUnit.getSentCount() + "/" + addedRoadsideUnit.getReceivedCount();

      Object[] addedData = new Object[] { id, type, latitude, longitude, speed, direction, coveredDistance,
          communicationCount };

      // Add a new model to the table
      if (!modelsToRows.containsKey(addedRoadsideUnit.getID())) {
        tableModel.addRow(addedData);
        modelsToRows.put(addedRoadsideUnit.getID(), tableModel.getRowCount() - 1);
        tableModel.setValueAt(true, modelsToRows.get(addedRoadsideUnit.getID()), columns.get("Annotation"));
        tableModel.setValueAt(true, modelsToRows.get(addedRoadsideUnit.getID()), columns.get("Radius"));
        tableModel.setValueAt(false, modelsToRows.get(addedRoadsideUnit.getID()), columns.get("Destination"));
        tableModel.setValueAt(false, modelsToRows.get(addedRoadsideUnit.getID()), columns.get("V2X-Tracing"));
        tableModel.setValueAt(false, modelsToRows.get(addedRoadsideUnit.getID()), columns.get("Hide"));
        updateGlobalSettings(modelsToRows.get(addedRoadsideUnit.getID()),
            modelsToRows.get(addedRoadsideUnit.getID()));
      }
      // Modify an existing model in the table
      else {
        tableModel.setValueAt(id, modelsToRows.get(addedRoadsideUnit.getID()), columns.get("ID"));
        tableModel.setValueAt(type, modelsToRows.get(addedRoadsideUnit.getID()), columns.get("Type"));
        tableModel.setValueAt(latitude, modelsToRows.get(addedRoadsideUnit.getID()), columns.get("Latitude"));
        tableModel.setValueAt(longitude, modelsToRows.get(addedRoadsideUnit.getID()), columns.get("Longitude"));
        tableModel.setValueAt(communicationCount, modelsToRows.get(addedRoadsideUnit.getID()),
            columns.get("# Sent/Received"));

        Boolean displayAnnotations = (Boolean) tableModel.getValueAt(
            modelsToRows.get(addedRoadsideUnit.getID()), columns.get("Annotation"));
        if (displayAnnotations)
          addedRoadsideUnit.setDisplayingAnnotations(true);
        else
          addedRoadsideUnit.setDisplayingAnnotations(false);

        Boolean displayRadius = (Boolean) tableModel.getValueAt(modelsToRows.get(addedRoadsideUnit.getID()),
            columns.get("Radius"));
        if (displayRadius)
          addedRoadsideUnit.setDisplayingRadius(true);
        else
          addedRoadsideUnit.setDisplayingRadius(false);

        Boolean displayDestination = (Boolean) tableModel.getValueAt(
            modelsToRows.get(addedRoadsideUnit.getID()),
            columns.get("Destination"));
        if (displayDestination)
          addedRoadsideUnit.setDisplayingDestination(true);
        else
          addedRoadsideUnit.setDisplayingDestination(false);

        Boolean v2xTracing = (Boolean) tableModel.getValueAt(modelsToRows.get(addedRoadsideUnit.getID()),
            columns.get("V2X-Tracing"));
        if (v2xTracing)
          addedRoadsideUnit.setV2XTracing(true);
        else
          addedRoadsideUnit.setV2XTracing(false);

        Boolean hidden = (Boolean) tableModel.getValueAt(modelsToRows.get(addedRoadsideUnit.getID()),
            columns.get("Hide"));
        if (hidden)
          addedRoadsideUnit.setHidden(true);
        else
          addedRoadsideUnit.setHidden(false);
      }
    }
    else if (arg instanceof TrafficLight) {
      TrafficLight addedTrafficLight = (TrafficLight) arg;
View Full Code Here

      // Convert speed back to meters per second (m/s)
      addedVehicle.setSpeed(addedVehicle.getSpeed() / 3.6f / 3.6f);
      buffer.add(new SimulationStep<Byte, VolatileModelElement>(command, addedVehicle));
    }
    else if (model instanceof RoadsideUnit) {
      RoadsideUnit addedRoadsideUnit = (RoadsideUnit) model;
      buffer.add(new SimulationStep<Byte, VolatileModelElement>(command, addedRoadsideUnit));
    }
    else if (model instanceof TrafficLight) {
      TrafficLight addedTrafficLight = (TrafficLight) model;
      buffer.add(new SimulationStep<Byte, VolatileModelElement>(command, addedTrafficLight));
View Full Code Here

   */
  private void addRoadsideUnit(final RoadsideUnit addedRoadsideUnit) throws IOException {
    Runnable worker = new Runnable() {
      @Override
      public synchronized void run() {
        RoadsideUnit addedRoadsideUnitClone = new RoadsideUnit(addedRoadsideUnit.getID(),
            addedRoadsideUnit.getPosition());
        modelController.addRoadsideUnit(addedRoadsideUnitClone);
      }
    };
    try {
View Full Code Here

          modelController.sendNetworkMessage(sendingVehicle.getID(), sendingVehicle.getSentMessageID(),
              sendingVehicle.getIPSegments(), sendingVehicle.getDestinationLatitude(),
              sendingVehicle.getDestinationLongitude(), sendingVehicle.getDestinationRadius());
        }
        else if (model instanceof RoadsideUnit) {
          RoadsideUnit sendingRoadsideUnit = (RoadsideUnit) model;
          modelController.sendNetworkMessage(sendingRoadsideUnit.getID(),
              sendingRoadsideUnit.getSentMessageID(), sendingRoadsideUnit.getIPSegments(),
              sendingRoadsideUnit.getDestinationLatitude(),
              sendingRoadsideUnit.getDestinationLongitude(), sendingRoadsideUnit.getDestinationRadius());
        }
        else if (model instanceof TrafficLight) {
          TrafficLight sendingTrafficLight = (TrafficLight) model;
          modelController.sendNetworkMessage(sendingTrafficLight.getID(),
              sendingTrafficLight.getSentMessageID(), sendingTrafficLight.getIPSegments(),
View Full Code Here

TOP

Related Classes of com.dcaiti.eworld.visualizer.simulation.models.RoadsideUnit

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.