public class Node
extends java.lang.Object
Constructor and Description |
---|
Node(Position position)
Construct and initialize a sensor node
|
Modifier and Type | Method and Description |
---|---|
java.lang.Boolean |
checkBusy()
Check if node is busy
|
void |
detectEvent(Event event)
Makes the node detect an event
|
boolean |
equals(java.lang.Object o) |
Event |
getEventFromId(int id)
Get Event data
|
java.util.HashMap<java.lang.Integer,Event> |
getEvents()
Gets the hashmap of events
|
java.util.HashMap<java.lang.Integer,Route> |
getKnownRoutes()
Gets the hashmap of knownRoutes
|
java.util.List<Node> |
getNeighbours()
Returns a list of neighbours
|
Position |
getPosition()
Get node position.
|
Route |
getRouteFromId(int id)
Get route from routing list
|
void |
insertNeighbour(Node neighbour)
Insert a neighbor that messages can be sent to
|
boolean |
receiveMessage(Message message)
Takes a message into the nodes job queue
|
void |
setNotBusy() |
void |
setNotBusyIfEmpty()
Sets not busy if the node has no messages
|
void |
setSyncedRoutes(java.util.HashMap<java.lang.Integer,Route> syncedRoutes)
Set a HashMap of syncedRoutes
|
void |
spawnAgent(int maxsteps)
Create an agent to spread the list of events
|
void |
spawnQuery(int queryId,
int maxsteps)
Create a querie to find an event
|
void |
update()
Updates the node one timestep
|
public Node(Position position) throws java.lang.IllegalArgumentException
position
- The nodes positionjava.lang.IllegalArgumentException
public void detectEvent(Event event) throws java.lang.IllegalArgumentException
event
- Event to detect.java.lang.IllegalArgumentException
public void spawnAgent(int maxsteps) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public void spawnQuery(int queryId, int maxsteps) throws java.lang.IllegalArgumentException
queryId
- The id for the event to findmaxsteps
- max timesteps query is allowed to livejava.lang.IllegalArgumentException
public void update()
public void insertNeighbour(Node neighbour) throws java.lang.IllegalArgumentException
neighbour
- the neighbor to be insertedjava.lang.IllegalArgumentException
public Event getEventFromId(int id) throws java.lang.IllegalArgumentException
id
- the event idjava.lang.IllegalArgumentException
public Route getRouteFromId(int id) throws java.lang.IllegalArgumentException
id
- id of routejava.lang.IllegalArgumentException
public Position getPosition()
public boolean receiveMessage(Message message) throws java.lang.IllegalArgumentException
message
- the message to be receivejava.lang.IllegalArgumentException
public void setNotBusyIfEmpty()
public void setNotBusy()
public java.lang.Boolean checkBusy()
public java.util.HashMap<java.lang.Integer,Event> getEvents()
public java.util.HashMap<java.lang.Integer,Route> getKnownRoutes()
public void setSyncedRoutes(java.util.HashMap<java.lang.Integer,Route> syncedRoutes) throws java.lang.IllegalArgumentException
syncedRoutes
- the synced routejava.lang.IllegalArgumentException
public java.util.List<Node> getNeighbours()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object