|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.kernel.util.NamedObj
ptolemy.codegen.kernel.CodeGeneratorHelper
ptolemy.codegen.c.kernel.CCodeGeneratorHelper
ptolemy.codegen.c.actor.IOPort
public class IOPort
Code generator helper for IOPort.
Red (mankit) |
Red (mankit) |
Nested Class Summary |
---|
Nested classes/interfaces inherited from class ptolemy.codegen.kernel.CodeGeneratorHelper |
---|
CodeGeneratorHelper.Channel, CodeGeneratorHelper.VariableScope |
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj |
---|
NamedObj.ContainedObjectsIterator |
Field Summary | |
---|---|
protected java.util.HashMap<CodeGeneratorHelper.Channel,java.lang.Integer> |
_bufferSizes
A HashMap that keeps track of the bufferSizes of each channel of the actor. |
protected java.util.HashMap<CodeGeneratorHelper.Channel,java.lang.Object> |
_readOffsets
A HashMap that keeps track of the read offsets of each input channel of the actor. |
protected java.util.HashMap<CodeGeneratorHelper.Channel,java.lang.Object> |
_writeOffsets
A HashMap that keeps track of the write offsets of each input channel of the actor. |
Fields inherited from class ptolemy.codegen.kernel.CodeGeneratorHelper |
---|
_codeGenerator, _codeStream, _eol, _INDENT1, _INDENT2, _parseTreeCodeGenerator, _portConversions, _referencedParameters |
Fields inherited from class ptolemy.kernel.util.NamedObj |
---|
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
Constructor Summary | |
---|---|
IOPort(IOPort component)
Construct a code generator helper associated with the given IOPort. |
Method Summary | |
---|---|
protected java.lang.String |
_generateOffset(java.lang.String offsetString,
int channel,
boolean isWrite)
Generate the expression that represents the offset in the generated code. |
private CodeGeneratorHelper.Channel |
_getChannel(int channelNumber)
|
private Director |
_getDirectorHelper()
|
private Receiver |
_getReceiver(java.lang.String offset,
int channel,
IOPort port)
|
private boolean |
_isInteger(java.lang.String numberString)
Return true if the given string can be parse as an integer; otherwise, return false. |
private boolean |
_isPNQueueReceiver(Receiver receiver)
Return true if the specified receiver is a PNQueueReceiver; otherwise, false. |
private boolean |
_isPthread()
|
protected java.lang.String |
_updateOffset(int channel,
int rate)
Update the offset for each channel of a port. |
private java.lang.String |
_updatePNOffset(int rate,
IOPort port,
int channelNumber,
Director directorHelper,
boolean isWrite)
|
java.lang.String |
generateCodeForGet(java.lang.String channel)
Generate code for replacing the get() macro. |
java.lang.String |
generateCodeForSend(java.lang.String channel,
java.lang.String dataToken)
Generate code for replacing the send() macro. |
java.lang.String |
generateInitializeCode()
Generate the initialize code. |
java.lang.String |
generateOffset(java.lang.String offset,
int channel,
boolean isWrite,
Director director)
Generate the expression that represents the offset in the generated code. |
java.lang.String |
generatePostFireCode()
Generate the code for postfire(). |
java.lang.String |
generatePreFireCode()
Generate the code for prefire(). |
int |
getBufferSize(int channelNumber)
Get the buffer size of channel of the port. |
Director |
getDirector()
Return the executive 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,
Director director)
Update the write offset of the [multiple] connected ports. |
java.lang.String |
updateOffset(int rate,
Director directorHelper)
Update the read offset. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface ptolemy.codegen.kernel.ComponentCodeGenerator |
---|
generateWrapupCode, getComponent, setCodeGenerator |
Field Detail |
---|
protected java.util.HashMap<CodeGeneratorHelper.Channel,java.lang.Integer> _bufferSizes
protected java.util.HashMap<CodeGeneratorHelper.Channel,java.lang.Object> _readOffsets
protected java.util.HashMap<CodeGeneratorHelper.Channel,java.lang.Object> _writeOffsets
Constructor Detail |
---|
public IOPort(IOPort component)
component
- The given IOPort.Method Detail |
---|
public java.lang.String generateCodeForGet(java.lang.String channel) throws IllegalActionException
PortCodeGenerator
generateCodeForGet
in interface PortCodeGenerator
channel
- The channel for which the get code is generated.
IllegalActionException
- If the director adapter class cannot be found.
FIXME: potentially, we could also pass in a boolean that indicates whether
the port the channel resides is a multiport, if it is, then only a static
variable is needed instead of an array of length 1.public java.lang.String generateCodeForSend(java.lang.String channel, java.lang.String dataToken) throws IllegalActionException
PortCodeGenerator
generateCodeForSend
in interface PortCodeGenerator
channel
- The channel for which the send code is generated.dataToken
- The token to be sent
IllegalActionException
- If the director adapter class cannot be found.
FIXME: potentially, we could also pass in a boolean that indicates whether
the port the channel resides is a multiport, if it is, then only a static
variable is needed instead of an array of length 1.public java.lang.String generateInitializeCode() throws IllegalActionException
CodeGeneratorHelper
generateInitializeCode
in interface ComponentCodeGenerator
generateInitializeCode
in class CodeGeneratorHelper
IllegalActionException
- If thrown while appending to the the
block or processing the macros.public java.lang.String generateOffset(java.lang.String offset, int channel, boolean isWrite, Director director) throws IllegalActionException
PortCodeGenerator
generateOffset
in interface PortCodeGenerator
offset
- The specified offset from the user.channel
- The referenced port channel.isWrite
- Whether to generate the write or read offset.director
- The helper of the director associated with the port.
IllegalActionException
- If there is problems getting the port
buffer size or the offset in the channel and offset map.public java.lang.String generatePostFireCode() throws IllegalActionException
IllegalActionException
- Not thrown in this base class.public java.lang.String generatePreFireCode() throws IllegalActionException
IllegalActionException
- Not thrown in this base class.public int getBufferSize(int channelNumber) throws IllegalActionException
getBufferSize
in interface PortCodeGenerator
channelNumber
- The number of the channel that is being set.
IllegalActionException
- If thrown while getting the width of
the port of the channel.setBufferSize(int, int)
public Director getDirector()
CodeGeneratorHelper
getDirector
in class CodeGeneratorHelper
public java.lang.Object getReadOffset(int channelNumber) throws IllegalActionException
getReadOffset
in interface PortCodeGenerator
channelNumber
- The number of the channel.
IllegalActionException
- If thrown while getting the channel.setReadOffset(int, Object)
public java.lang.Object getWriteOffset(int channelNumber) throws IllegalActionException
getWriteOffset
in interface PortCodeGenerator
channelNumber
- The number of the channel.
IllegalActionException
- If thrown while getting the channel.setWriteOffset(int, Object)
public java.lang.String initializeOffsets() throws IllegalActionException
PortCodeGenerator
initializeOffsets
in interface PortCodeGenerator
IllegalActionException
- If thrown while getting the channel
or initializing the offset.public void setBufferSize(int channelNumber, int bufferSize)
setBufferSize
in interface PortCodeGenerator
channelNumber
- The number of the channel that is being set.bufferSize
- The size of the buffer.getBufferSize(int)
public void setReadOffset(int channelNumber, java.lang.Object readOffset)
setReadOffset
in interface PortCodeGenerator
channelNumber
- The number of the channel that is being set.readOffset
- The offset.getReadOffset(int)
public void setWriteOffset(int channelNumber, java.lang.Object writeOffset)
setWriteOffset
in interface PortCodeGenerator
channelNumber
- The number of the channel that is being set.writeOffset
- The offset.getWriteOffset(int)
public java.lang.String updateConnectedPortsOffset(int rate, Director director) throws IllegalActionException
PortCodeGenerator
updateConnectedPortsOffset
in interface PortCodeGenerator
rate
- The rate of the channels.director
- The Director helper.
IllegalActionException
- If thrown while getting the channel
or updating the offset.public java.lang.String updateOffset(int rate, Director directorHelper) throws IllegalActionException
PortCodeGenerator
updateOffset
in interface PortCodeGenerator
rate
- The rate of the channels.directorHelper
- The Director helper
IllegalActionException
- If thrown while getting the channel
or updating the offset.protected java.lang.String _generateOffset(java.lang.String offsetString, int channel, boolean isWrite) throws IllegalActionException
offsetString
- 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.protected java.lang.String _updateOffset(int channel, int rate) throws IllegalActionException
channel
- The channel for which the the offset is to be updatedrate
- The rate of the channel
IllegalActionException
- If thrown while accessing the port
or read offsetprivate CodeGeneratorHelper.Channel _getChannel(int channelNumber)
private Director _getDirectorHelper() throws IllegalActionException
IllegalActionException
private Receiver _getReceiver(java.lang.String offset, int channel, IOPort port)
private boolean _isInteger(java.lang.String numberString)
numberString
- The given number string.
private boolean _isPNQueueReceiver(Receiver receiver)
receiver
- The specified receiver.
private boolean _isPthread()
private java.lang.String _updatePNOffset(int rate, IOPort port, int channelNumber, Director directorHelper, boolean isWrite) throws IllegalActionException
IllegalActionException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |