com.speckled.specksim.imp.shells
Class PerfectRadioShell

java.lang.Object
  extended by com.speckled.specksim.imp.shells.PerfectRadioShell
All Implemented Interfaces:
Configurable, MessageShell, java.lang.Cloneable

@ConfigurableType(value="Perfect radio")
public class PerfectRadioShell
extends java.lang.Object
implements MessageShell, java.lang.Cloneable

Simulates a perfect radio. The broadcasts are perfectly spherical and reliable

Author:
ryanm

Field Summary
 float bitrate
          The bitrate of the radio, in kbps
 int channel
          The channel of the radio
 
Constructor Summary
PerfectRadioShell()
          Builds a new radio shell
PerfectRadioShell(PerfectRadioShell shell)
          Constructs a new shell, identical to the argument
 
Method Summary
 MessageShell clone()
          Override this method to return a copy of this MessageShell.
 float getBitRate()
          Gets the data transmission speed, in kilobits per second.
 Vector3d[] getBoundingBox(SpeckPosition orientation)
          Works out an axis-aligned bounding box for this message shell.
 int getChannelID()
          Gets an identifier for the channel used by this shell.
 Configurator getConfigurator()
          Gets a Configurator object that describes and can manipulate the variables of this Configurable.
 float getRange()
          Gets the range of this radio shell
 float getRangeSq()
          Gets the square of the range of this radio shell
 boolean hit(Speck sender, SpeckPosition senderOrientation, Speck target, SpeckPosition targetOrientation)
          Checks to see if the sender can reach the target.
 void setRadioRange(float r)
          Sets the range of this radio
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bitrate

@ConfigurableVariable(value="Bit rate")
@NumberRange(value={0.0f,1024.0f})
@Description(value="The bitrate of the radio, in kbps")
@Priority(value=2)
public float bitrate
The bitrate of the radio, in kbps


channel

@ConfigurableVariable(value="Channel")
@Description(value="The channel of the radio. Transmissions on different channels do not interfere with each other")
@Priority(value=3)
public int channel
The channel of the radio

Constructor Detail

PerfectRadioShell

public PerfectRadioShell()
Builds a new radio shell


PerfectRadioShell

public PerfectRadioShell(PerfectRadioShell shell)
Constructs a new shell, identical to the argument

Parameters:
shell - The shell to copy
Method Detail

hit

public boolean hit(Speck sender,
                   SpeckPosition senderOrientation,
                   Speck target,
                   SpeckPosition targetOrientation)
Description copied from interface: MessageShell
Checks to see if the sender can reach the target.

Specified by:
hit in interface MessageShell
Parameters:
sender - The sending speck
senderOrientation - The position of the sending speck at the time of transmission
target - The prospective receiving speck
targetOrientation - The position of the target speck at the time of transmission
Returns:
true if the sender can succesfully transmit to the target, false otherwise.

getBoundingBox

public Vector3d[] getBoundingBox(SpeckPosition orientation)
Description copied from interface: MessageShell
Works out an axis-aligned bounding box for this message shell. This can be used as a quick rejection test when looking for broadcast recipients.

Specified by:
getBoundingBox in interface MessageShell
Parameters:
orientation - The orientation of the sending speck at the time of transmission
Returns:
A two-element array of Vector3Ds. The first element will be the position of the corner of the bounding box that is closest to the origin. The second element will be the corner furthest from the origin.

getBitRate

public float getBitRate()
Description copied from interface: MessageShell
Gets the data transmission speed, in kilobits per second. Return 0 for an effectively infinite bandwidth

Specified by:
getBitRate in interface MessageShell
Returns:
the bit rate of the transceiver, kbps, or 0 if you'd rather not bother will all of this messy low-level stuff

getChannelID

public int getChannelID()
Description copied from interface: MessageShell
Gets an identifier for the channel used by this shell. Shells operating on different channels will not interfer with each other. Radio devices should return a different value than laser devices, for example.

Specified by:
getChannelID in interface MessageShell
Returns:
An integer identifier for this channel.

getConfigurator

public Configurator getConfigurator()
Description copied from interface: Configurable
Gets a Configurator object that describes and can manipulate the variables of this Configurable. This method must only return null if the Configurable object is Annotated such that an AnnotatedConfigurator can be built from it.

Specified by:
getConfigurator in interface Configurable
Returns:
A configurator object, or null if annotated

setRadioRange

@ConfigurableVariable(value="Range")
@NumberRange(value={0.0f,1.7999999523162842f})
@Description(value="The range of the transmission")
@Priority(value=1)
public void setRadioRange(float r)
Sets the range of this radio

Parameters:
r - The new maximum range for transmissions

getRangeSq

public float getRangeSq()
Gets the square of the range of this radio shell

Returns:
The range of the radio, squared

getRange

@ConfigurableVariable(value="Range")
public float getRange()
Gets the range of this radio shell

Returns:
The range of the radio

clone

public MessageShell clone()
Description copied from interface: MessageShell
Override this method to return a copy of this MessageShell. This is so that changes can be made to the shell without affecting ongoing broadcasts.

Specified by:
clone in interface MessageShell
Overrides:
clone in class java.lang.Object
Returns:
A copy of this MessageShell, such that the clone will hit the same set of specks as the original