public class Ports
extends java.lang.Object
Red (eal) |
Yellow (zgang) |
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<IOPort,PortInfo> |
_portInfo
A map from IOPort to PortInfo.
|
Constructor and Description |
---|
Ports(NamedObj component,
PortDirector director)
Create a Ports instance.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
generateOffset(IOPort port,
java.lang.String offset,
int channel,
boolean isWrite)
Generate the expression that represents the offset in the generated
code.
|
int |
getBufferSize(IOPort port)
Return the buffer size of a given port, which is the maximum of
the bufferSizes of all channels of the given port.
|
int |
getBufferSize(IOPort port,
int channelNumber)
Get the buffer size of channel of the port.
|
GenericCodeGenerator |
getCodeGenerator()
Return the code generator associated with the director.
|
NamedObj |
getComponent()
Return the component associated with the ports.
|
java.lang.Object |
getReadOffset(IOPort inputPort,
int channelNumber)
Get the read offset in the buffer of a given channel from which a token
should be read.
|
java.lang.Object |
getWriteOffset(IOPort port,
int channelNumber)
Get the write offset in the buffer of a given channel to which a token
should be put.
|
java.lang.String |
initializeOffsets(IOPort port)
Initialize the offsets.
|
void |
setBufferSize(IOPort port,
int channelNumber,
int bufferSize)
Set the buffer size of channel of the port.
|
void |
setReadOffset(IOPort port,
int channelNumber,
java.lang.Object readOffset)
Set the read offset in a buffer of a given channel from which a token
should be read.
|
void |
setWriteOffset(IOPort port,
int channelNumber,
java.lang.Object writeOffset)
Set the write offset in a buffer of a given channel to which a token
should be put.
|
java.lang.String |
updateConnectedPortsOffset(IOPort port,
int rate)
Update the offsets of the buffers associated with the ports connected
with the given port in its downstream.
|
java.lang.String |
updateOffset(IOPort port,
int rate)
Update the read offset.
|
public Ports(NamedObj component, PortDirector director)
component
- The component for which we are doing
extra bookkeeping to generate code.director
- The director associated with the ports.public GenericCodeGenerator getCodeGenerator()
public NamedObj getComponent()
public java.lang.String generateOffset(IOPort port, java.lang.String offset, int channel, boolean isWrite) throws IllegalActionException
port
- The given port.offset
- The specified offset from the user.channel
- The referenced port channel.isWrite
- Whether to generate the write or read offset.IllegalActionException
- If there is problems getting the port
buffer size or the offset in the channel and offset map.public int getBufferSize(IOPort port, int channelNumber) throws IllegalActionException
channelNumber
- The number of the channel that is being set.port
- The given port.IllegalActionException
- If thrown while getting the port
information or getting the buffer size.setBufferSize(IOPort, int, int)
public int getBufferSize(IOPort port) throws IllegalActionException
port
- The given port.IllegalActionException
- If the
getBufferSize(IOPort, int)
method throws it.setBufferSize(IOPort, int, int)
public java.lang.Object getReadOffset(IOPort inputPort, int channelNumber) throws IllegalActionException
inputPort
- The given port.channelNumber
- The given channel number.IllegalActionException
- Thrown if the adapter class cannot
be found.setReadOffset(IOPort, int, Object)
public java.lang.Object getWriteOffset(IOPort port, int channelNumber) throws IllegalActionException
port
- The given port.channelNumber
- The given channel number.IllegalActionException
- Thrown if the adapter class cannot
be found.setWriteOffset(IOPort, int, Object)
public java.lang.String initializeOffsets(IOPort port) throws IllegalActionException
port
- The given port.IllegalActionException
- Thrown if offsets can't be initialized.public void setBufferSize(IOPort port, int channelNumber, int bufferSize) throws IllegalActionException
port
- The given port.channelNumber
- The number of the channel that is being set.bufferSize
- The size of the buffer.IllegalActionException
- If thrown while getting the port
information or while setting the buffer size.getBufferSize(IOPort, int)
public void setReadOffset(IOPort port, int channelNumber, java.lang.Object readOffset) throws IllegalActionException
port
- The given port.channelNumber
- The given channel.readOffset
- The offset to be set to the buffer of that channel.IllegalActionException
- Thrown if the adapter class cannot
be found.getReadOffset(IOPort, int)
public void setWriteOffset(IOPort port, int channelNumber, java.lang.Object writeOffset) throws IllegalActionException
port
- The given port.channelNumber
- The given channel.writeOffset
- The offset to be set to the buffer of that channel.IllegalActionException
- If
setWriteOffset(IOPort, int, Object)
method throws it.getWriteOffset(IOPort, int)
public java.lang.String updateConnectedPortsOffset(IOPort port, int rate) throws IllegalActionException
port
- The port whose directly connected downstream actors update
their write offsets.rate
- The rate, which must be greater than or equal to 0.IllegalActionException
- If thrown while reading or writing
offsets, or getting the buffer size, or if the rate is less than 0.public java.lang.String updateOffset(IOPort port, int rate) throws IllegalActionException
port
- The given port.rate
- The rate of the channels.IllegalActionException
- If thrown while getting a token,
adapter, read offset or buffer size.