Class TxrxProcess

java.lang.Object
uk.ac.manchester.spinnaker.transceiver.TxrxProcess

public class TxrxProcess extends Object
A process for talking to SpiNNaker efficiently that uses multiple connections in communication (if appropriate).
  • Field Details

    • DEFAULT_NUM_CHANNELS

      protected static final int DEFAULT_NUM_CHANNELS
      The default for the number of parallel channels.
      See Also:
    • DEFAULT_INTERMEDIATE_CHANNEL_WAITS

      protected static final int DEFAULT_INTERMEDIATE_CHANNEL_WAITS
      The default for the number of instantaneously active channels.
      See Also:
    • DEFAULT_INTERMEDIATE_TIMEOUT_WAITS

      protected static final int DEFAULT_INTERMEDIATE_TIMEOUT_WAITS
      The default number of outstanding responses to wait for before continuing sending requests.
      See Also:
    • SCP_RETRIES

      protected static final int SCP_RETRIES
      The default number of times to resend any packet for any reason before an error is triggered.
    • RETRY_DELAY_MS

      protected static final int RETRY_DELAY_MS
      How long to wait between retries, in milliseconds.
      See Also:
    • SCP_TIMEOUT

      protected static final int SCP_TIMEOUT
      The default for the timeout (in ms).
  • Constructor Details

    • TxrxProcess

      public TxrxProcess(ConnectionSelector<Conn> connectionSelector, RetryTracker retryTracker)
      Type Parameters:
      Conn - The type of connection.
      Parameters:
      connectionSelector - How to select how to communicate.
      retryTracker - Object used to track how many retries were used in an operation. May be null if no suck tracking is required.
    • TxrxProcess

      protected TxrxProcess(ConnectionSelector<Conn> connectionSelector, int numRetries, int timeout, int numChannels, int intermediateChannelWaits, RetryTracker retryTracker)
      Type Parameters:
      Conn - The type of connection.
      Parameters:
      connectionSelector - How to select how to communicate.
      numRetries - The number of times to retry a communication.
      timeout - The timeout (in ms) for the communication.
      numChannels - The number of parallel communications to support
      intermediateChannelWaits - How many parallel communications to launch at once. (??)
      retryTracker - Object used to track how many retries were used in an operation. May be null if no suck tracking is required.
  • Method Details

    • finishBatch

      protected final void finishBatch() throws ProcessException, IOException, InterruptedException
      Wait for all outstanding requests sent by this process to receive replies or time out. Then test if an error occurred on the SpiNNaker side, and throw a process exception it if it did.
      Throws:
      IOException - If communications fail.
      ProcessException - an exception that wraps the original exception that occurred.
      InterruptedException - If the communications were interrupted.
    • sendRequest

      protected final void sendRequest(SCPRequest<EmptyResponse> request) throws IOException, InterruptedException
      Send a request. The actual payload of the response to this request is to be considered to be uninteresting provided it doesn't indicate a failure. In particular, the response is a EmptyResponse.
      Parameters:
      request - The request to send.
      Throws:
      IOException - If sending fails.
      InterruptedException - If communications are interrupted while preparing to send.
    • sendRequest

      protected final <Resp extends CheckOKResponse> void sendRequest(SCPRequest<Resp> request, Consumer<Resp> callback) throws IOException, InterruptedException
      Send a request and handle the response.
      Type Parameters:
      Resp - The type of response expected to the request.
      Parameters:
      request - The request to send.
      callback - The callback that handles the request's response.
      Throws:
      IOException - If sending fails.
      InterruptedException - If communications are interrupted.
    • sendGet

      protected final <T, R extends PayloadedResponse<T, ?>> void sendGet(SCPRequest<R> request, Consumer<T> callback) throws IOException, InterruptedException
      Send a request for a response with a payload.
      Type Parameters:
      T - The type of parsed payload expected.
      R - The type of response expected to the request.
      Parameters:
      request - The request to send.
      callback - The callback that handles the parsed payload.
      Throws:
      IOException - If sending fails.
      InterruptedException - If communications are interrupted.
    • call

      public final void call(SCPRequest<EmptyResponse> request) throws IOException, ProcessException, InterruptedException
      Do a synchronous call of an SCP operation, sending the given message and completely processing the interaction before returning its response.
      Parameters:
      request - The request to send
      Throws:
      IOException - If the communications fail
      ProcessException - If the other side responds with a failure code
      InterruptedException - If the communications were interrupted.
    • retrieve

      public final <T, R extends PayloadedResponse<T, ?>> T retrieve(SCPRequest<R> request) throws IOException, ProcessException, InterruptedException
      Do a synchronous call of an SCP operation, sending the given message and completely processing the interaction before returning its parsed payload.
      Type Parameters:
      T - The type of the payload of the response.
      R - The type of the response; implicit in the type of the request.
      Parameters:
      request - The request to send
      Returns:
      The successful response to the request
      Throws:
      IOException - If the communications fail
      ProcessException - If the other side responds with a failure code
      InterruptedException - If the communications were interrupted.
    • sendOneWayRequest

      protected final void sendOneWayRequest(SCPRequest<NoResponse> request) throws IOException, InterruptedException
      Send a one-way request. One way requests do not need to be finished.
      Parameters:
      request - The request to send. Must be a one-way request!
      Throws:
      IOException - If sending fails.
      InterruptedException - If communications are interrupted while preparing to send.