Package ptolemy.domains.pthales.kernel
Class PthalesReceiver
- java.lang.Object
-
- ptolemy.actor.AbstractReceiver
-
- ptolemy.domains.sdf.kernel.SDFReceiver
-
- ptolemy.domains.pthales.kernel.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)
-
-
Field Summary
Fields Modifier and Type Field Description protected Token[]
_buffer
Buffer memory.protected java.util.LinkedHashMap<java.lang.String,java.lang.Integer>
_sizes
array size by dimension.-
Fields inherited from class ptolemy.domains.sdf.kernel.SDFReceiver
_waitingTokens, INFINITE_CAPACITY
-
-
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 ptolemy.domains.sdf.kernel.SDFReceiver
get, getCapacity, getHistoryCapacity, historyElements, historySize, setCapacity, setHistoryCapacity, size
-
Methods inherited from class ptolemy.actor.AbstractReceiver
getContainer, getCurrentTime, getModelTime, setContainer, toString
-
-
-
-
Field Detail
-
_buffer
protected Token[] _buffer
Buffer memory.
-
_sizes
protected java.util.LinkedHashMap<java.lang.String,java.lang.Integer> _sizes
array size by dimension.
-
-
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?
-
clear
public void clear()
Do nothing.- Specified by:
clear
in interfaceReceiver
- Overrides:
clear
in classSDFReceiver
-
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 interfaceReceiver
- Overrides:
elementList
in classSDFReceiver
- 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.
-
get
public Token get() throws NoTokenException
Get a token from this receiver.- Specified by:
get
in interfaceReceiver
- Overrides:
get
in classSDFReceiver
- Returns:
- A token read from the receiver.
- Throws:
NoTokenException
- If there is no token.
-
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 interfaceReceiver
- Overrides:
getArray
in classSDFReceiver
- 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 interfaceReceiver
- Overrides:
hasRoom
in classSDFReceiver
- Returns:
- true or false.
-
hasRoom
public boolean hasRoom(int numberOfTokens)
Return true if the buffer can contain n more token.- Specified by:
hasRoom
in interfaceReceiver
- Overrides:
hasRoom
in classSDFReceiver
- 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 interfaceReceiver
- Overrides:
hasToken
in classSDFReceiver
- Returns:
- True.
-
hasToken
public boolean hasToken(int numberOfTokens)
Return if the buffer contains n more token to be read.- Specified by:
hasToken
in interfaceReceiver
- Overrides:
hasToken
in classSDFReceiver
- 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)
-
isKnown
public boolean isKnown()
Return true.- Specified by:
isKnown
in interfaceReceiver
- Overrides:
isKnown
in classAbstractReceiver
- Returns:
- True.
-
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 interfaceReceiver
- Overrides:
put
in classSDFReceiver
- 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 interfaceReceiver
- Overrides:
putArray
in classAbstractReceiver
- 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 interfaceReceiver
- Overrides:
putArrayToAll
in classAbstractReceiver
- 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 interfaceReceiver
- Overrides:
putToAll
in classAbstractReceiver
- 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).
-
reset
public void reset() throws IllegalActionException
Reset this receiver to its initial state, which is typically either empty (same as calling clear()) or unknown.- Specified by:
reset
in interfaceReceiver
- Overrides:
reset
in classAbstractReceiver
- Throws:
IllegalActionException
- If reset() is not supported by the domain.
-
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 portactor
- 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 portactor
- 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.
-
-