ptolemy.codegen.rtmaude.actor
Class IOPort

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.codegen.kernel.CodeGeneratorHelper
          extended by ptolemy.codegen.rtmaude.kernel.RTMaudeAdaptor
              extended by ptolemy.codegen.rtmaude.actor.IOPort
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, ActorCodeGenerator, ComponentCodeGenerator, PortCodeGenerator, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable
Direct Known Subclasses:
ParameterPort

public class IOPort
extends RTMaudeAdaptor
implements PortCodeGenerator

Generate RTMaude code for an IOPort in DE domain.

Since:
Ptolemy II 8.0
Version:
$Id: IOPort.java 59167 2010-09-21 17:08:02Z cxh $
Author:
Kyungmin Bae
See Also:
IOPort, Serialized Form
Accepted Rating:
red (kquine)
Proposed Rating:
red (kquine)

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
 
Fields inherited from class ptolemy.codegen.rtmaude.kernel.RTMaudeAdaptor
defaultTermBlock
 
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 the code generator adaptor associated with the given IOPort.
 
Method Summary
 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 generateOffset(java.lang.String offset, int channel, boolean isWrite, Director directorHelper)
          Generate the expression that represents the offset in the generated code.
 java.lang.String generateTermCode()
          Generate a Real-time Maude term representation of given component.
 int getBufferSize(int channelNumber)
          Get the buffer size of channel of the port.
 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 ptolemy.codegen.rtmaude.kernel.RTMaudeAdaptor
_generateBlockCode, _generateTypeConvertMethod, _replaceMacro, generateEntryCode, generateExitCode, generateFireCode, generateFireFunctionCode, getBlockCodeList, getInfo, getModuleCode, getParseTreeCodeGenerator, getRTMmodule, getSharedCode, getTranslatedExpression
 
Methods inherited from class ptolemy.codegen.kernel.CodeGeneratorHelper
_createBufferSizeAndOffsetMap, _createInputBufferSizeAndOffsetMap, _findClosedParen, _generateBlockCode, _generateBlockCode, _generateFireCode, _generateTypeConvertStatement, _generateTypeConvertStatements, _getCastType, _getChannelAndOffset, _getFireFunctionArguments, _getHelper, _getHelper, _getIndentPrefix, _getReference, _getReferenceChannels, _getTypeConvertChannels, _getTypeConvertReference, _indexOf, addFunctionUsed, addNewTypeUsed, analyzeTypeConvert, checkLocal, checkRemote, codeGenType, copyFilesToCodeDirectory, createOffsetVariablesIfNeeded, generateChannelOffset, generateFireFunctionCode2, generateInitializeCode, generateModeTransitionCode, generateName, generateOffset, generatePortReference, generatePostfireCode, generatePrefireCode, generatePreinitializeCode, generateSimpleName, generateTypeConvertFireCode, generateTypeConvertFireCode, generateVariableDeclaration, generateVariableInitialization, generateVariableName, generateWrapupCode, getBufferSize, getBufferSize, getCodeGenerator, getComponent, getDefaultBlocks, getDirector, getDirectorHelper, getFunctionInvocation, getHeaderFiles, getIncludeDirectories, getLibraries, getLibraryDirectories, getModifiedVariables, getNewInvocation, getObject, getParameterValue, getPort, getRates, getReadOffset, getReference, getReference, getReference, getReference, getSinkChannels, getSize, getSourceChannel, getWCET, getWriteOffset, isPrimitive, isPrimitive, parseList, processCode, resetInputPortsOffset, setBufferSize, setCodeGenerator, setReadOffset, setWriteOffset, targetType, toString
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _description, _exportMoMLContents, _getContainedObject, _isMoMLSuppressed, _markContentsDerived, _propagateExistence, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, attributeTypeChanged, clone, clone, containedObjectsIterator, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getContainer, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setName, setPersistent, setSource, sortContainedObjects, toplevel, uniqueName, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ptolemy.codegen.kernel.ComponentCodeGenerator
generateInitializeCode, generateWrapupCode, getComponent, setCodeGenerator
 

Constructor Detail

IOPort

public IOPort(IOPort component)
Construct the code generator adaptor associated with the given IOPort.

Parameters:
component - The associated IOPort.
Method Detail

generateTermCode

public java.lang.String generateTermCode()
                                  throws IllegalActionException
Description copied from class: RTMaudeAdaptor
Generate a Real-time Maude term representation of given component.

Overrides:
generateTermCode in class RTMaudeAdaptor
Returns:
the term representation of a component
Throws:
IllegalActionException

generateCodeForGet

public java.lang.String generateCodeForGet(java.lang.String channel)
                                    throws IllegalActionException
Description copied from interface: PortCodeGenerator
Generate code for replacing the get() macro. This delegates to the receiver adapter for the specified channel and asks it to generate the get code.

Specified by:
generateCodeForGet in interface PortCodeGenerator
Parameters:
channel - The channel for which the get code is generated.
Returns:
The code that gets data from the channel.
Throws:
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.

generateCodeForSend

public java.lang.String generateCodeForSend(java.lang.String channel,
                                            java.lang.String dataToken)
                                     throws IllegalActionException
Description copied from interface: PortCodeGenerator
Generate code for replacing the send() macro.

Specified by:
generateCodeForSend in interface PortCodeGenerator
Parameters:
channel - The channel for which the send code is generated.
dataToken - The token to be sent
Returns:
The code that sends the dataToken on the channel.
Throws:
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.

generateOffset

public java.lang.String generateOffset(java.lang.String offset,
                                       int channel,
                                       boolean isWrite,
                                       Director directorHelper)
                                throws IllegalActionException
Description copied from interface: PortCodeGenerator
Generate the expression that represents the offset in the generated code.

Specified by:
generateOffset in interface PortCodeGenerator
Parameters:
offset - The specified offset from the user.
channel - The referenced port channel.
isWrite - Whether to generate the write or read offset.
directorHelper - The helper of the director associated with the port.
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.

getBufferSize

public int getBufferSize(int channelNumber)
                  throws IllegalActionException
Description copied from interface: PortCodeGenerator
Get the buffer size of channel of the port.

Specified by:
getBufferSize in interface PortCodeGenerator
Parameters:
channelNumber - The number of the channel that is being set.
Returns:
return The size of the buffer.
Throws:
IllegalActionException - If the buffer size cannot be set.
See Also:
PortCodeGenerator.setBufferSize(int, int)

getReadOffset

public java.lang.Object getReadOffset(int channelNumber)
                               throws IllegalActionException
Description copied from interface: PortCodeGenerator
Get the read offset of a channel of the port.

Specified by:
getReadOffset in interface PortCodeGenerator
Parameters:
channelNumber - The number of the channel.
Returns:
The read offset.
Throws:
IllegalActionException - If thrown while getting the channel.
See Also:
PortCodeGenerator.setReadOffset(int, Object)

getWriteOffset

public java.lang.Object getWriteOffset(int channelNumber)
                                throws IllegalActionException
Description copied from interface: PortCodeGenerator
Get the write offset of a channel of the port.

Specified by:
getWriteOffset in interface PortCodeGenerator
Parameters:
channelNumber - The number of the channel.
Returns:
The write offset.
Throws:
IllegalActionException - If thrown while getting the channel.
See Also:
PortCodeGenerator.setWriteOffset(int, Object)

initializeOffsets

public java.lang.String initializeOffsets()
                                   throws IllegalActionException
Description copied from interface: PortCodeGenerator
Initialize the offsets.

Specified by:
initializeOffsets in interface PortCodeGenerator
Returns:
The code to initialize the offsets.
Throws:
IllegalActionException - If thrown while getting the channel or initializing the offset.

setBufferSize

public void setBufferSize(int channelNumber,
                          int bufferSize)
Description copied from interface: PortCodeGenerator
Set the buffer size of channel of the port.

Specified by:
setBufferSize in interface PortCodeGenerator
Parameters:
channelNumber - The number of the channel that is being set.
bufferSize - The size of the buffer.
See Also:
PortCodeGenerator.getBufferSize(int)

setReadOffset

public void setReadOffset(int channelNumber,
                          java.lang.Object readOffset)
Description copied from interface: PortCodeGenerator
Set the read offset of a channel of the port.

Specified by:
setReadOffset in interface PortCodeGenerator
Parameters:
channelNumber - The number of the channel that is being set.
readOffset - The offset.
See Also:
PortCodeGenerator.getReadOffset(int)

setWriteOffset

public void setWriteOffset(int channelNumber,
                           java.lang.Object writeOffset)
Description copied from interface: PortCodeGenerator
Set the write offset of a channel of the port.

Specified by:
setWriteOffset in interface PortCodeGenerator
Parameters:
channelNumber - The number of the channel that is being set.
writeOffset - The offset.
See Also:
PortCodeGenerator.getWriteOffset(int)

updateConnectedPortsOffset

public java.lang.String updateConnectedPortsOffset(int rate,
                                                   Director director)
                                            throws IllegalActionException
Description copied from interface: PortCodeGenerator
Update the write offset of the [multiple] connected ports.

Specified by:
updateConnectedPortsOffset in interface PortCodeGenerator
Parameters:
rate - The rate of the channels.
director - The Director helper.
Returns:
The offset.
Throws:
IllegalActionException - If thrown while getting the channel or updating the offset.

updateOffset

public java.lang.String updateOffset(int rate,
                                     Director directorHelper)
                              throws IllegalActionException
Description copied from interface: PortCodeGenerator
Update the read offset.

Specified by:
updateOffset in interface PortCodeGenerator
Parameters:
rate - The rate of the channels.
directorHelper - The Director helper
Returns:
The offset.
Throws:
IllegalActionException - If thrown while getting the channel or updating the offset.