Class PortInfo
- java.lang.Object
-
- ptolemy.cg.adapter.generic.adapters.ptolemy.actor.PortInfo
-
public class PortInfo extends java.lang.Object
A class that keeps track of information necessary to generate communication code at ports inside a StaticScheduled model.- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Gang Zhou, Contributor: Bert Rodiers, Christopher Brooks
- Pt.AcceptedRating:
- Red (eal)
- Pt.ProposedRating:
- Yellow (zgang)
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.String
_eol
The value of the line.separator property.
-
Constructor Summary
Constructors Constructor Description PortInfo(IOPort port, Ports ports, NamedObj component, PortDirector director)
Create a PortInfo instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
generateOffset(java.lang.String offset, int channel, boolean isWrite)
Generate the expression that represents the offset in the generated code.int
getBufferSize()
Return the buffer size of the port, which is the maximum of the bufferSizes of all channels the port.int
getBufferSize(int channelNumber)
Get the buffer size of channel of the port.GenericCodeGenerator
getCodeGenerator()
Return the code generator of the director.java.lang.Object
getReadOffset(int channelNumber)
Get the read offset of a channel of the port.java.lang.Object
getWriteOffset(int channelNumber)
Get the write offset of a channel of the port.java.lang.String
initializeOffsets()
Initialize the offsets.void
setBufferSize(int channelNumber, int bufferSize)
Set the buffer size of channel of the port.void
setReadOffset(int channelNumber, java.lang.Object readOffset)
Set the read offset of a channel of the port.void
setWriteOffset(int channelNumber, java.lang.Object writeOffset)
Set the write offset of a channel of the port.java.lang.String
updateConnectedPortsOffset(int rate)
Update the offsets of the buffers associated with the ports connected with the given port in its downstream.java.lang.String
updateOffset(int rate)
Update the read offset.
-
-
-
Constructor Detail
-
PortInfo
public PortInfo(IOPort port, Ports ports, NamedObj component, PortDirector director)
Create a PortInfo instance.- Parameters:
port
- The port for which we are doing extra bookkeeping to generate code.ports
- The ports the portscomponent
- The component for which we are doing extra bookkeeping to generate code.director
- The director associated with the ports.
-
-
Method Detail
-
getCodeGenerator
public GenericCodeGenerator getCodeGenerator()
Return the code generator of the director.- Returns:
- the code generator.
-
getBufferSize
public int getBufferSize(int channelNumber) throws IllegalActionException
Get the buffer size of channel of the port.- Parameters:
channelNumber
- The number of the channel that is being set.- Returns:
- return The size of the buffer.
- Throws:
IllegalActionException
- If thrown while getting the channel or rate.- See Also:
setBufferSize(int, int)
-
getBufferSize
public int getBufferSize() throws IllegalActionException
Return the buffer size of the port, which is the maximum of the bufferSizes of all channels the port.- Returns:
- The buffer size of the port.
- Throws:
IllegalActionException
- If thegetBufferSize(int)
method throws it.- See Also:
setBufferSize(int, int)
-
generateOffset
public java.lang.String generateOffset(java.lang.String offset, int channel, boolean isWrite) throws IllegalActionException
Generate the expression that represents the offset in the generated code.- Parameters:
offset
- The specified offset from the user.channel
- The referenced port channel.isWrite
- Whether to generate the write or read offset.- Returns:
- The expression that represents the offset in the generated code.
- Throws:
IllegalActionException
- If there is problems getting the port buffer size or the offset in the channel and offset map.
-
getReadOffset
public java.lang.Object getReadOffset(int channelNumber) throws IllegalActionException
Get the read offset of a channel of the port.- Parameters:
channelNumber
- The number of the channel.- Returns:
- The read offset.
- Throws:
IllegalActionException
- If thrown while getting the channel.- See Also:
setReadOffset(int, Object)
-
getWriteOffset
public java.lang.Object getWriteOffset(int channelNumber) throws IllegalActionException
Get the write offset of a channel of the port.- Parameters:
channelNumber
- The number of the channel.- Returns:
- The write offset.
- Throws:
IllegalActionException
- If thrown while getting the channel.- See Also:
setWriteOffset(int, Object)
-
initializeOffsets
public java.lang.String initializeOffsets() throws IllegalActionException
Initialize the offsets.- Returns:
- The code to initialize the offsets.
- Throws:
IllegalActionException
- Thrown if offsets can't be initialized.
-
setBufferSize
public void setBufferSize(int channelNumber, int bufferSize)
Set the buffer size of channel of the port.- Parameters:
channelNumber
- The number of the channel that is being set.bufferSize
- The size of the buffer.- See Also:
getBufferSize(int)
-
setReadOffset
public void setReadOffset(int channelNumber, java.lang.Object readOffset)
Set the read offset of a channel of the port.- Parameters:
channelNumber
- The number of the channel that is being set.readOffset
- The offset.- See Also:
getReadOffset(int)
-
setWriteOffset
public void setWriteOffset(int channelNumber, java.lang.Object writeOffset)
Set the write offset of a channel of the port.- Parameters:
channelNumber
- The number of the channel that is being set.writeOffset
- The offset.- See Also:
getWriteOffset(int)
-
updateConnectedPortsOffset
public java.lang.String updateConnectedPortsOffset(int rate) throws IllegalActionException
Update the offsets of the buffers associated with the ports connected with the given port in its downstream.- Parameters:
rate
- The rate, which must be greater than or equal to 0.- Returns:
- The generated code.
- Throws:
IllegalActionException
- If thrown while reading or writing offsets, or getting the buffer size, or if the rate is less than 0.
-
updateOffset
public java.lang.String updateOffset(int rate) throws IllegalActionException
Update the read offset.- Parameters:
rate
- The rate of the channels.- Returns:
- The offset.
- Throws:
IllegalActionException
- If thrown while getting a token, adapter, read offset or buffer size.
-
-