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[]_bufferBuffer memory.protected java.util.LinkedHashMap<java.lang.String,java.lang.Integer>_sizesarray 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 voidcheckArray(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.voidclear()Do nothing.java.util.List<Token>elementList()Return a list with tokens that are currently in the receiver available for get() or getArray().voidfillParameters(Actor actor, IOPort port)Update parameters of this receiver according to the actor and port.Tokenget()Get a token from this receiver.Token[]getArray(int numberOfTokens)Get an array of tokens from this receiver.booleanhasRoom()Return true if the buffer can contain one more token.booleanhasRoom(int numberOfTokens)Return true if the buffer can contain n more token.booleanhasToken()Return if the buffer contains 1 more token to be read.booleanhasToken(int numberOfTokens)Return if the buffer contains n more token to be read.booleanisDynamic()Return true if the receiver is dynamic.booleanisKnown()Return true.voidput(Token token)Put the specified token into the next appropriate array position, given the FIXME.voidputArray(Token[] tokenArray, int numberOfTokens)Put a portion of the specified token array into this receiver.voidputArrayToAll(Token[] tokens, int numberOfTokens, Receiver[] receivers)Put a sequence of tokens to all receivers in the specified array.voidputToAll(Token token, Receiver[] receivers)Put a single token to all receivers in the specified array.voidreset()Reset this receiver to its initial state, which is typically either empty (same as calling clear()) or unknown.voidsetDynamic(boolean dynamic)Set whether this receiver is dynamic.voidsetExternalBuffer(Actor actor, IOPort port, Token[] buffer)Specify a buffer to use for storing the array.voidsetInputArray(IOPort port, Actor actor)Specifies the input array that will read the buffer allocated as output.voidsetOutputArray(IOPort port, Actor actor)Specifies the output array that will be read by the receiver.voidsetReadParameters(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 IllegalActionExceptionCheck 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:
clearin interfaceReceiver- Overrides:
clearin 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:
elementListin interfaceReceiver- Overrides:
elementListin 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:
getin interfaceReceiver- Overrides:
getin 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:
getArrayin interfaceReceiver- Overrides:
getArrayin 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:
hasRoomin interfaceReceiver- Overrides:
hasRoomin classSDFReceiver- Returns:
- true or false.
-
hasRoom
public boolean hasRoom(int numberOfTokens)
Return true if the buffer can contain n more token.- Specified by:
hasRoomin interfaceReceiver- Overrides:
hasRoomin 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:
hasTokenin interfaceReceiver- Overrides:
hasTokenin classSDFReceiver- Returns:
- True.
-
hasToken
public boolean hasToken(int numberOfTokens)
Return if the buffer contains n more token to be read.- Specified by:
hasTokenin interfaceReceiver- Overrides:
hasTokenin 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:
isKnownin interfaceReceiver- Overrides:
isKnownin 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:
putin interfaceReceiver- Overrides:
putin 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:
putArrayin interfaceReceiver- Overrides:
putArrayin 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:
putArrayToAllin interfaceReceiver- Overrides:
putArrayToAllin 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:
putToAllin interfaceReceiver- Overrides:
putToAllin 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 IllegalActionExceptionReset this receiver to its initial state, which is typically either empty (same as calling clear()) or unknown.- Specified by:
resetin interfaceReceiver- Overrides:
resetin 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.
-
-