vanetsim.scenario
Class RSU

java.lang.Object
  extended by vanetsim.scenario.RSU

public final class RSU
extends java.lang.Object

A Road-Side-Unit to send and receive WiFi signals.


Field Summary
static boolean colorCleared
          flag to clear vehicle color
static ArrayDeque<Vehicle> coloredVehicles
          saves all colored vehicles
static RSU lastSender
           
 
Constructor Summary
RSU(int x, int y, int radius, boolean isEncrypted)
          Instantiates a new RSU.
 
Method Summary
 void cleanup(int timePerStep)
          Cleanup all outdated messages
 int getBeaconCountdown()
          Gets the current beacon countdown
 int getCommunicationCountdown()
          Gets the current communication countdown
 KnownVehiclesList getKnownVehiclesList_()
           
 Region getRegion()
          Returns the region the RSU is placed in
 long getRSUID()
          Resets this rsu so that it can be reused.
 int getWifiRadius()
          Returns the wifi radius
 int getX()
          Returns the x coordinate of the RSU
 int getY()
          Returns the y coordinate of the RSU
 boolean isEncrypted_()
           
static boolean isShowEncryptedBeaconsInMix_()
           
 void receiveMessage(int sourceX, int sourceY, Message message)
          Receive a message from a vehicle.
 void sendBeacons()
          Find vehicles in neighborhood and send beacons to them.
 void sendEncryptedBeacons()
          Find vehicles in neighborhood and send beacons to them.
 void sendMessages()
          send messages to all vehicles in reach.
static void setBeaconInterval(int beaconInterval)
          Sets a new value for the beacon interval.
static void setBeaconMonitorZoneEnabled(boolean beaconMonitorEnabled)
          Sets if beacon zones should be monitored or not.
static void setBeaconsEnabled(boolean state)
          Sets if beacons are enabled or not.
static void setCommunicationEnabled(boolean state)
          Sets if communication is enabled or not.
static void setCommunicationInterval(int communicationInterval)
          Sets a new value for the communication interval.
static void setMonitoredMixZoneVariables(int beaconMonitorMinX, int beaconMonitorMaxX, int beaconMonitorMinY, int beaconMonitorMaxY)
          Sets the values for the monitored beacon zone.
 void setRegion(Region region)
          Sets the region the RSU is placed
static void setRegions(Region[][] regions)
          Sets the reference to all regions.
static void setShowEncryptedBeaconsInMix_(boolean showEncryptedBeaconsInMix_)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

coloredVehicles

public static ArrayDeque<Vehicle> coloredVehicles
saves all colored vehicles


lastSender

public static RSU lastSender

colorCleared

public static boolean colorCleared
flag to clear vehicle color

Constructor Detail

RSU

public RSU(int x,
           int y,
           int radius,
           boolean isEncrypted)
Instantiates a new RSU.

Parameters:
x - the x coordinate
y - the y coordinate
radius - the signal radius
isEncrypted - if message is encrypted
Method Detail

sendMessages

public void sendMessages()
send messages to all vehicles in reach. Uses broadcast, because vehicles cannot send beacons to the RSUs(often to far away)


sendBeacons

public void sendBeacons()
Find vehicles in neighborhood and send beacons to them. Please check the following conditions before calling this function:


sendEncryptedBeacons

public void sendEncryptedBeacons()
Find vehicles in neighborhood and send beacons to them. Please check the following conditions before calling this function:


receiveMessage

public final void receiveMessage(int sourceX,
                                 int sourceY,
                                 Message message)
Receive a message from a vehicle.

Parameters:
sourceX - the x coordinate of the other vehicle
sourceY - the y coordinate of the other vehicle
message - the message

cleanup

public void cleanup(int timePerStep)
Cleanup all outdated messages

Parameters:
timePerStep - the actual time per step

getRSUID

public long getRSUID()
Resets this rsu so that it can be reused. public void reset(){ //reset countdowns and other variables communicationCountdown_ = 0; knownVehiclesTimeoutCountdown_ = 0; beaconCountdown_ = (int)Math.round(x_)%beaconInterval_; communicationCountdown_ = (int)Math.round(x_)%communicationInterval_; //reset communication info knownVehiclesList_.clear(); knownMessages_.clear(); } /* /** Returns the Road-Side-Unit id

Returns:
the RSU id

getX

public int getX()
Returns the x coordinate of the RSU

Returns:
the x coordinate

getY

public int getY()
Returns the y coordinate of the RSU

Returns:
the y coordinate

setRegion

public void setRegion(Region region)
Sets the region the RSU is placed

Parameters:
region - the region

getRegion

public Region getRegion()
Returns the region the RSU is placed in

Returns:
the region

getWifiRadius

public int getWifiRadius()
Returns the wifi radius

Returns:
the wifi radius in cm

getBeaconCountdown

public int getBeaconCountdown()
Gets the current beacon countdown

Returns:
the beacon countdown

getCommunicationCountdown

public int getCommunicationCountdown()
Gets the current communication countdown

Returns:
the communication countdown

setRegions

public static void setRegions(Region[][] regions)
Sets the reference to all regions. Call this on map reload!

Parameters:
regions - the array with all regions

setBeaconsEnabled

public static void setBeaconsEnabled(boolean state)
Sets if beacons are enabled or not. Common to all Road-Side-Units.

Parameters:
state - true to enable beacons, else false

setCommunicationEnabled

public static void setCommunicationEnabled(boolean state)
Sets if communication is enabled or not. Common to all Road-Side-Units.

Parameters:
state - true to enable communication, else false

setCommunicationInterval

public static void setCommunicationInterval(int communicationInterval)
Sets a new value for the communication interval. Common to all Road-Side-Units.

Parameters:
communicationInterval - the new value

setBeaconInterval

public static void setBeaconInterval(int beaconInterval)
Sets a new value for the beacon interval. Common to all Road-Side-Units.

Parameters:
beaconInterval - the new value

setBeaconMonitorZoneEnabled

public static void setBeaconMonitorZoneEnabled(boolean beaconMonitorEnabled)
Sets if beacon zones should be monitored or not. Common to all RSUs.

Parameters:
beaconMonitorEnabled - true to enable monitoring mix zones, else false

setMonitoredMixZoneVariables

public static void setMonitoredMixZoneVariables(int beaconMonitorMinX,
                                                int beaconMonitorMaxX,
                                                int beaconMonitorMinY,
                                                int beaconMonitorMaxY)
Sets the values for the monitored beacon zone. A rectangular bounding box within the specified coordinates is monitored if setBeaconMonitorZoneEnabled(boolean) is set to true.

Parameters:
beaconMonitorMinX - the minimum x coordinate
beaconMonitorMaxX - the maximum x coordinate
beaconMonitorMinY - the minimum y coordinate
beaconMonitorMaxY - the maximum y coordinate

isEncrypted_

public boolean isEncrypted_()

getKnownVehiclesList_

public KnownVehiclesList getKnownVehiclesList_()

isShowEncryptedBeaconsInMix_

public static boolean isShowEncryptedBeaconsInMix_()

setShowEncryptedBeaconsInMix_

public static void setShowEncryptedBeaconsInMix_(boolean showEncryptedBeaconsInMix_)