Class Router
java.lang.Object
uk.ac.manchester.spinnaker.machine.Router
- All Implemented Interfaces:
Iterable<Link>
,MappableIterable<Link>
public final class Router extends Object implements MappableIterable<Link>
Routers are parts of SpiNNaker chips responsible for directing where
on-machine messages are delivered to.
- Author:
- Christian-B
-
Field Summary
Fields Modifier and Type Field Description int
nAvailableMulticastEntries
The number of entries available in the routing table. -
Constructor Summary
Constructors Constructor Description Router()
Default constructor allowing links to be added later.Router(int nAvailableMulticastEntries)
Default constructor allowing links to be added later.Router(Iterable<Link> links)
Pass-through constructor that uses default values.Router(Iterable<Link> links, int nAvailableMulticastEntries)
Main constructor that allows setting of all values.Router(Stream<Link> links)
Pass-through constructor that uses default values.Router(Stream<Link> links, int nAvailableMulticastEntries)
Main constructor that allows setting of all values.Router(HasChipLocation source, int nAvailableMulticastEntries, ChipDetails details, Machine machine)
Creates a new router from this source with links in all but the missing directions. -
Method Summary
Modifier and Type Method Description void
addLink(Link link)
Adds a link with a uniquesourceLinkDirection
to this router.boolean
equals(Object obj)
Link
getLink(Direction direction)
Obtains a link going in this direction.int
hashCode()
boolean
hasLink(Direction direction)
Indicates if there is a link going in this direction.Iterator<Link>
iterator()
MappableIterable<ChipLocation>
iterNeighbouringChipsCoords()
Iterable over the destinations of each link.Collection<Link>
links()
Return a view over the links.List<ChipLocation>
neighbouringChipsCoords()
List of the destination for all links.int
size()
The size of the router which is the number of link(s) it has.Stream<ChipLocation>
streamNeighbouringChipsCoords()
Stream of the destinations of each link.String
toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface uk.ac.manchester.spinnaker.utils.MappableIterable
filter, first, first, map, nth, toCollectingMap, toCollectingMap, toCollectingMap, toCollectingMap, toList, toList, toMap, toMap, toSet, toSet
-
Field Details
-
nAvailableMulticastEntries
public final int nAvailableMulticastEntriesThe number of entries available in the routing table.
-
-
Constructor Details
-
Router
public Router(int nAvailableMulticastEntries)Default constructor allowing links to be added later.- Parameters:
nAvailableMulticastEntries
- The number of entries available in the routing table.
-
Router
public Router()Default constructor allowing links to be added later. The router will be of standard size. -
Router
public Router(Iterable<Link> links, int nAvailableMulticastEntries) throws IllegalArgumentExceptionMain constructor that allows setting of all values.- Parameters:
links
- Known link(s) to add. All must have uniquesourceLinkDirection
(s).nAvailableMulticastEntries
- The number of entries available in the routing table.- Throws:
IllegalArgumentException
- Indicates that there are two Links with the samesourceLinkDirection
.
-
Router
Main constructor that allows setting of all values.- Parameters:
links
- Known link(s) to add. All must have uniquesourceLinkDirection
(s).nAvailableMulticastEntries
- The number of entries available in the routing table.- Throws:
IllegalArgumentException
- Indicates that there are two Links with the samesourceLinkDirection
.
-
Router
Pass-through constructor that uses default values.- Parameters:
links
- Known link(s) to add. All must have uniquesourceLinkDirection
(s).- Throws:
IllegalArgumentException
- Indicates that there are two Links with the samesourceLinkDirection
.
-
Router
Pass-through constructor that uses default values.- Parameters:
links
- Known Link(s) to add. All must have uniquesourceLinkDirection
(s).- Throws:
IllegalArgumentException
- Indicates that there are two Links with the samesourceLinkDirection
.
-
Router
public Router(HasChipLocation source, int nAvailableMulticastEntries, ChipDetails details, Machine machine)Creates a new router from this source with links in all but the missing directions. Used to build a router object from JSON.- Parameters:
source
- Chip which links are coming fromnAvailableMulticastEntries
- The number of entries available in the routing table.details
- The description of the chip containing this router from JSON.machine
- The Machine this chip will go on. Used for calculating wrap-arounds- Throws:
NullPointerException
- if a non-valid direction is not in ignoredLinks
-
-
Method Details
-
addLink
Adds a link with a uniquesourceLinkDirection
to this router.- Parameters:
link
- Link to add, which must have asourceLinkDirection
not yet used.- Throws:
IllegalArgumentException
- Indicates another Link with thissourceLinkDirection
has already been added.
-
hasLink
Indicates if there is a link going in this direction.- Parameters:
direction
- Direction to find link for.- Returns:
- True if and only if there is a link in this direction,
-
getLink
Obtains a link going in this direction.null
is returned if no link found.- Parameters:
direction
- Direction to find link for.- Returns:
- The Link or
null
-
links
Return a view over the links.Each link is guaranteed to differ in at least the
sourceLinkDirection
.- Returns:
- An unmodifiable collection of Link(s).
-
size
public int size()The size of the router which is the number of link(s) it has.The number of neighbouring chip coordinates will always be equal to the number of links.
- Returns:
- The number of Link(s) and therefore NeighbouringChipsCoords
-
streamNeighbouringChipsCoords
Stream of the destinations of each link.There will be exactly one destination for each link. While normally all destinations will be unique the is no guarantee.
- Returns:
- A Stream over the destination locations.
-
iterNeighbouringChipsCoords
Iterable over the destinations of each link.There will be exactly one destination for each link. While normally all destinations will be unique the is no guarantee.
- Returns:
- The destination locations.
-
neighbouringChipsCoords
List of the destination for all links.This function returns an unmodifiable list.
- Returns:
- The destination locations
-
toString
-
iterator
-
hashCode
public int hashCode() -
equals
-