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 Details

  • 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 IllegalArgumentException
      Main constructor that allows setting of all values.
      Parameters:
      links - Known link(s) to add. All must have unique sourceLinkDirection(s).
      nAvailableMulticastEntries - The number of entries available in the routing table.
      Throws:
      IllegalArgumentException - Indicates that there are two Links with the same sourceLinkDirection.
    • Router

      public Router​(Stream<Link> links, int nAvailableMulticastEntries) throws IllegalArgumentException
      Main constructor that allows setting of all values.
      Parameters:
      links - Known link(s) to add. All must have unique sourceLinkDirection(s).
      nAvailableMulticastEntries - The number of entries available in the routing table.
      Throws:
      IllegalArgumentException - Indicates that there are two Links with the same sourceLinkDirection.
    • Router

      public Router​(Iterable<Link> links) throws IllegalArgumentException
      Pass-through constructor that uses default values.
      Parameters:
      links - Known link(s) to add. All must have unique sourceLinkDirection(s).
      Throws:
      IllegalArgumentException - Indicates that there are two Links with the same sourceLinkDirection.
    • Router

      public Router​(Stream<Link> links) throws IllegalArgumentException
      Pass-through constructor that uses default values.
      Parameters:
      links - Known Link(s) to add. All must have unique sourceLinkDirection(s).
      Throws:
      IllegalArgumentException - Indicates that there are two Links with the same sourceLinkDirection.
    • 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 from
      nAvailableMulticastEntries - 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

      public void addLink​(Link link) throws IllegalArgumentException
      Adds a link with a unique sourceLinkDirection to this router.
      Parameters:
      link - Link to add, which must have a sourceLinkDirection not yet used.
      Throws:
      IllegalArgumentException - Indicates another Link with this sourceLinkDirection has already been added.
    • hasLink

      public boolean hasLink​(Direction direction)
      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

      public Link getLink​(Direction direction)
      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

      public Collection<Link> 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

      public Stream<ChipLocation> 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

      public MappableIterable<ChipLocation> 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

      public List<ChipLocation> neighbouringChipsCoords()
      List of the destination for all links.

      This function returns an unmodifiable list.

      Returns:
      The destination locations
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • iterator

      public Iterator<Link> iterator()
      Specified by:
      iterator in interface Iterable<Link>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals​(Object obj)
      Overrides:
      equals in class Object