Class PthalesReceiver

  • All Implemented Interfaces:
    Receiver

    public class PthalesReceiver
    extends SDFReceiver
    A receiver for the Pthales model of computation.
    Since:
    Ptolemy II 10.0
    Version:
    $Id$
    Author:
    Rémi Barrère
    Pt.AcceptedRating:
    Red (cxh)
    Pt.ProposedRating:
    Red (cxh)
    • Constructor Summary

      Constructors 
      Constructor Description
      PthalesReceiver()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void checkArray​(java.util.LinkedHashMap<java.lang.String,​java.lang.Integer[]> baseSpec, java.util.LinkedHashMap<java.lang.String,​java.lang.Integer[]> patternSpec, java.util.LinkedHashMap<java.lang.String,​java.lang.Integer[]> tilingSpec, java.util.List<java.lang.String> dimensions)
      Check whether the array is correct or not.
      void clear()
      Do nothing.
      java.util.List<Token> elementList()
      Return a list with tokens that are currently in the receiver available for get() or getArray().
      void fillParameters​(Actor actor, IOPort port)
      Update parameters of this receiver according to the actor and port.
      Token get()
      Get a token from this receiver.
      Token[] getArray​(int numberOfTokens)
      Get an array of tokens from this receiver.
      boolean hasRoom()
      Return true if the buffer can contain one more token.
      boolean hasRoom​(int numberOfTokens)
      Return true if the buffer can contain n more token.
      boolean hasToken()
      Return if the buffer contains 1 more token to be read.
      boolean hasToken​(int numberOfTokens)
      Return if the buffer contains n more token to be read.
      boolean isDynamic()
      Return true if the receiver is dynamic.
      boolean isKnown()
      Return true.
      void put​(Token token)
      Put the specified token into the next appropriate array position, given the FIXME.
      void putArray​(Token[] tokenArray, int numberOfTokens)
      Put a portion of the specified token array into this receiver.
      void putArrayToAll​(Token[] tokens, int numberOfTokens, Receiver[] receivers)
      Put a sequence of tokens to all receivers in the specified array.
      void putToAll​(Token token, Receiver[] receivers)
      Put a single token to all receivers in the specified array.
      void reset()
      Reset this receiver to its initial state, which is typically either empty (same as calling clear()) or unknown.
      void setDynamic​(boolean dynamic)
      Set whether this receiver is dynamic.
      void setExternalBuffer​(Actor actor, IOPort port, Token[] buffer)
      Specify a buffer to use for storing the array.
      void setInputArray​(IOPort port, Actor actor)
      Specifies the input array that will read the buffer allocated as output.
      void setOutputArray​(IOPort port, Actor actor)
      Specifies the output array that will be read by the receiver.
      void setReadParameters​(java.lang.Integer[] repetitions)
      Set repetitions of the actor containing the port that contains the receiver.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • _buffer

        protected Token[] _buffer
        Buffer memory.
      • _sizes

        protected java.util.LinkedHashMap<java.lang.String,​java.lang.Integer> _sizes
        array size by dimension.
    • Constructor Detail

      • PthalesReceiver

        public PthalesReceiver()
    • Method Detail

      • checkArray

        public void checkArray​(java.util.LinkedHashMap<java.lang.String,​java.lang.Integer[]> baseSpec,
                               java.util.LinkedHashMap<java.lang.String,​java.lang.Integer[]> patternSpec,
                               java.util.LinkedHashMap<java.lang.String,​java.lang.Integer[]> tilingSpec,
                               java.util.List<java.lang.String> dimensions)
                        throws IllegalActionException
        Check whether the array is correct or not. FIXME: What does it mean to be correct?
        Parameters:
        baseSpec - The origin.
        patternSpec - Fitting of the array.
        tilingSpec - Paving of the array.
        dimensions - Dimensions contained in the array.
        Throws:
        IllegalActionException - FIXME: If what?
      • elementList

        public java.util.List<Token> elementList()
        Return a list with tokens that are currently in the receiver available for get() or getArray(). The oldest token (the one that was put first) should be listed first in any implementation of this method.
        Specified by:
        elementList in interface Receiver
        Overrides:
        elementList in class SDFReceiver
        Returns:
        A list of instances of Token.
      • fillParameters

        public void fillParameters​(Actor actor,
                                   IOPort port)
        Update parameters of this receiver according to the actor and port.
        Parameters:
        actor - The actor.
        port - The port.
      • getArray

        public Token[] getArray​(int numberOfTokens)
                         throws NoTokenException
        Get an array of tokens from this receiver. The numberOfTokens argument specifies the number of tokens to get. In an implementation, the length of the returned array must be equal to numberOfTokens.
        Specified by:
        getArray in interface Receiver
        Overrides:
        getArray in class SDFReceiver
        Parameters:
        numberOfTokens - The number of tokens to get in the returned array.
        Returns:
        An array of tokens read from the receiver.
        Throws:
        NoTokenException - If there are not numberOfTokens tokens.
      • hasRoom

        public boolean hasRoom()
        Return true if the buffer can contain one more token.
        Specified by:
        hasRoom in interface Receiver
        Overrides:
        hasRoom in class SDFReceiver
        Returns:
        true or false.
      • hasRoom

        public boolean hasRoom​(int numberOfTokens)
        Return true if the buffer can contain n more token.
        Specified by:
        hasRoom in interface Receiver
        Overrides:
        hasRoom in class SDFReceiver
        Parameters:
        numberOfTokens - the number of needed places to put tokens
        Returns:
        true or false.
      • hasToken

        public boolean hasToken()
        Return if the buffer contains 1 more token to be read.
        Specified by:
        hasToken in interface Receiver
        Overrides:
        hasToken in class SDFReceiver
        Returns:
        True.
      • hasToken

        public boolean hasToken​(int numberOfTokens)
        Return if the buffer contains n more token to be read.
        Specified by:
        hasToken in interface Receiver
        Overrides:
        hasToken in class SDFReceiver
        Parameters:
        numberOfTokens - the number of needed tokens
        Returns:
        True.
      • isDynamic

        public boolean isDynamic()
        Return true if the receiver is dynamic. A dynamic receiver's get() method returns data from the current control position, which is is adjusted each time get() is called. A non-dynamic receiver's get() method merely increments the positionIn pointer each time get() is called.
        Returns:
        true if this receiver is dynamic.
        See Also:
        setDynamic(boolean)
      • put

        public void put​(Token token)
        Put the specified token into the next appropriate array position, given the FIXME. If the specified token is null, this method inserts a null into the array.
        Specified by:
        put in interface Receiver
        Overrides:
        put in class SDFReceiver
        Parameters:
        token - The token to put into the receiver.
        Throws:
        NoRoomException - If there is no room in the receiver.
      • putArray

        public void putArray​(Token[] tokenArray,
                             int numberOfTokens)
                      throws NoRoomException,
                             IllegalActionException
        Put a portion of the specified token array into this receiver. The first numberOfTokens elements of the token array are put into this receiver. The ability to specify a longer array than needed allows certain domains to have more efficient implementations.
        Specified by:
        putArray in interface Receiver
        Overrides:
        putArray in class AbstractReceiver
        Parameters:
        tokenArray - The array containing tokens to put into this receiver.
        numberOfTokens - The number of elements of the token array to put into this receiver.
        Throws:
        NoRoomException - If the token array cannot be put.
        IllegalActionException - If the token is not acceptable to one of the ports (e.g., wrong type).
      • putArrayToAll

        public void putArrayToAll​(Token[] tokens,
                                  int numberOfTokens,
                                  Receiver[] receivers)
                           throws NoRoomException,
                                  IllegalActionException
        Put a sequence of tokens to all receivers in the specified array. Implementers will assume that all such receivers are of the same class.
        Specified by:
        putArrayToAll in interface Receiver
        Overrides:
        putArrayToAll in class AbstractReceiver
        Parameters:
        tokens - The sequence of token to put.
        numberOfTokens - The number of tokens to put (the array might be longer).
        receivers - The receivers.
        Throws:
        NoRoomException - If there is no room for the token.
        IllegalActionException - If the token is not acceptable to one of the ports (e.g., wrong type).
      • putToAll

        public void putToAll​(Token token,
                             Receiver[] receivers)
                      throws NoRoomException,
                             IllegalActionException
        Put a single token to all receivers in the specified array. Implementers will assume that all such receivers are of the same class. If the specified token is null, this method inserts a null into the arrays.
        Specified by:
        putToAll in interface Receiver
        Overrides:
        putToAll in class AbstractReceiver
        Parameters:
        token - The token to put, or null to put no token.
        receivers - The receivers.
        Throws:
        NoRoomException - If there is no room for the token.
        IllegalActionException - If the token is not acceptable to one of the ports (e.g., wrong type).
      • setDynamic

        public void setDynamic​(boolean dynamic)
        Set whether this receiver is dynamic.
        Parameters:
        dynamic - True if this receiver is dynamic.
        See Also:
        isDynamic()
      • setExternalBuffer

        public void setExternalBuffer​(Actor actor,
                                      IOPort port,
                                      Token[] buffer)
        Specify a buffer to use for storing the array. This method is used by the PthalesDirector to provide a buffer for an external port of a composite actor containing said PthalesDirector.
        Parameters:
        actor - The composite actor containing the PthalesDirector.
        port - The external port.
        buffer - The external buffer.
      • setInputArray

        public void setInputArray​(IOPort port,
                                  Actor actor)
                           throws IllegalActionException
        Specifies the input array that will read the buffer allocated as output. Here we only check that everything is correct, and compute addresses in output buffer.
        Parameters:
        port - the associated port
        actor - the associated actor
        Throws:
        IllegalActionException
      • setOutputArray

        public void setOutputArray​(IOPort port,
                                   Actor actor)
                            throws IllegalActionException
        Specifies the output array that will be read by the receiver. It is the output array that determines the available size and dimensions for the receivers. This function allocates a buffer that is used as a memory would be (linear)
        Parameters:
        port - the associated port
        actor - the associated actor
        Throws:
        IllegalActionException
      • setReadParameters

        public void setReadParameters​(java.lang.Integer[] repetitions)
        Set repetitions of the actor containing the port that contains the receiver.
        Parameters:
        repetitions - An array of Integer repetitions.