Class IOPort
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.cg.kernel.generic.CodeGeneratorAdapter
-
- ptolemy.cg.kernel.generic.program.ProgramCodeGeneratorAdapter
-
- ptolemy.cg.kernel.generic.program.NamedProgramCodeGeneratorAdapter
-
- ptolemy.cg.adapter.generic.program.procedural.adapters.ptolemy.actor.IOPort
-
- All Implemented Interfaces:
java.lang.Cloneable
,PortCodeGenerator
,Changeable
,Debuggable
,DebugListener
,Derivable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
- Direct Known Subclasses:
IOPort
,MultiCompositePort
,RefinementPort
public class IOPort extends NamedProgramCodeGeneratorAdapter implements PortCodeGenerator
Code generator adapter forIOPort
.- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Man-Kit Leung
- Pt.AcceptedRating:
- Red (mankit)
- Pt.ProposedRating:
- Red (mankit)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.cg.kernel.generic.program.NamedProgramCodeGeneratorAdapter
NamedProgramCodeGeneratorAdapter.VariableScope
-
Nested classes/interfaces inherited from class ptolemy.cg.kernel.generic.program.ProgramCodeGeneratorAdapter
ProgramCodeGeneratorAdapter.Channel
-
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
-
-
Field Summary
-
Fields inherited from class ptolemy.cg.kernel.generic.program.ProgramCodeGeneratorAdapter
_component, _defaultBlocks, _eol, _templateParser
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
generateGetAndFree(java.lang.String channel, java.lang.String offset)
Generate code for replacing the getAndFree() macro.java.lang.String
generateGetCode(java.lang.String channel, java.lang.String offset)
Generate code for replacing the get() macro.java.lang.String
generateGetCodeWithoutType(java.lang.String channel, java.lang.String offset)
Generate the code to get a token from a port, but don't include the type, for example payload.Int.java.lang.String
generateHasTokenCode(java.lang.String channel, java.lang.String offset)
Generate code to check if the receiver has a token.java.lang.String
generateInitializeCode()
Generate the initialize code for this IOPort.java.lang.String
generatePutCode(java.lang.String channel, java.lang.String offset, java.lang.String dataToken)
Generate code for replacing the send() macro.java.lang.String
generatePutLocalInsideCode(java.lang.String channel, java.lang.String offset, java.lang.String dataToken)
Generate code for replacing the sendLocalInside() macro.Receiver[][]
getReceiverAdapters()
Get the adapters for receiver contained in this port.Receiver[][]
getRemoteReceiverAdapters()
Get the adapters for the remote receivers connected to this port.-
Methods inherited from class ptolemy.cg.kernel.generic.program.NamedProgramCodeGeneratorAdapter
_generateFireCode, _generateTypeConvertStatement, analyzeTypeConvert, copyFilesToCodeDirectory, generateFireCode, generateFireFunctionCode, generateMainLoop, generateModeTransitionCode, generatePostfireCode, generatePrefireCode, generatePreinitializeCode, generatePreinitializeMethodBodyCode, generateSimpleName, generateTypeConvertFireCode, generateTypeConvertFireCode, generateVariableDeclaration, generateVariableInitialization, generateWrapupCode, getAddTimeString, getBufferSize, getBufferSize, getComponent, getDeclareSharedCode, getDefaultBlocks, getFireFunctionParameters, getHeaderFiles, getIncludeDirectories, getLibraries, getLibraryDirectories, getModifiedVariables, getName, getParameterValue, getReference, getReference, getSharedCode, getSinkChannels, getSourceTimeString, getTimeSourcePortName, getTypeConvertChannels, getTypeConvertReference, getTypeConvertSinkChannels, setupAdapter, targetType
-
Methods inherited from class ptolemy.cg.kernel.generic.program.ProgramCodeGeneratorAdapter
_generateBlockByName, getAdapter, getCodeGenerator, getTemplateParser, processCode, setCodeGenerator, setTemplateParser, toString
-
Methods inherited from class ptolemy.cg.kernel.generic.CodeGeneratorAdapter
createDecoratorAttributes, generateName
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _description, _executeChangeRequests, _exportMoMLContents, _getContainedObject, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateExistence, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeChanged, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, clone, containedObjectsIterator, decorators, 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, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setName, setPersistent, setSource, sortContainedObjects, toplevel, uniqueName, validateSettables, workspace
-
-
-
-
Constructor Detail
-
IOPort
public IOPort(IOPort component)
Construct the code generator adapter for the given IOPort.- Parameters:
component
- The IOPort.
-
-
Method Detail
-
generateGetCode
public java.lang.String generateGetCode(java.lang.String channel, java.lang.String offset) throws IllegalActionException
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:
generateGetCode
in interfacePortCodeGenerator
- Parameters:
channel
- The channel for which to generate the get code.offset
- The offset in the array representation of the port.- Returns:
- The code that gets data from the specified channel.
- Throws:
IllegalActionException
- If the receiver adapter is not found or it encounters an error while generating the get code.
-
generateGetCodeWithoutType
public java.lang.String generateGetCodeWithoutType(java.lang.String channel, java.lang.String offset) throws IllegalActionException
Generate the code to get a token from a port, but don't include the type, for example payload.Int.- Specified by:
generateGetCodeWithoutType
in interfacePortCodeGenerator
- Parameters:
channel
- The channel for which the get code is generated.offset
- The offset in the array representation of the port.- Returns:
- The code that gets data from the channel.
- Throws:
IllegalActionException
- If the director adapter class cannot be found.
-
generateGetAndFree
public java.lang.String generateGetAndFree(java.lang.String channel, java.lang.String offset) throws IllegalActionException
Generate code for replacing the getAndFree() macro. This delegates to the receiver adapter for the specified channel and asks it to generate the get code.- Specified by:
generateGetAndFree
in interfacePortCodeGenerator
- Parameters:
channel
- The channel for which to generate the get code.offset
- The offset in the array representation of the port.- Returns:
- The code that gets data from the specified channel.
- Throws:
IllegalActionException
- If the receiver adapter is not found or it encounters an error while generating the get code.
-
generateHasTokenCode
public java.lang.String generateHasTokenCode(java.lang.String channel, java.lang.String offset) throws IllegalActionException
Generate code to check if the receiver has a token. This delegates to the receiver adapter for the specified channel and asks it to generate the hasToken code.- Specified by:
generateHasTokenCode
in interfacePortCodeGenerator
- Parameters:
channel
- The channel for which to generate the hasToken code.offset
- The offset in the array representation of the port.- Returns:
- The code that checks whether there is data in the specified channel.
- Throws:
IllegalActionException
- If the receiver adapter is not found or it encounters an error while generating the hasToken code.
-
generatePutCode
public java.lang.String generatePutCode(java.lang.String channel, java.lang.String offset, java.lang.String dataToken) throws IllegalActionException
Generate code for replacing the send() macro. This delegates to the receiver adapter for the specified channel and asks it to generate the send code.- Specified by:
generatePutCode
in interfacePortCodeGenerator
- Parameters:
channel
- The channel for which to generate the send code.offset
- The offset in the array representation of the port.dataToken
- The token to be sent.- Returns:
- The code that sends data to the specified channel.
- Throws:
IllegalActionException
- If the receiver adapter is not found or it encounters an error while generating the send code.
-
generateInitializeCode
public java.lang.String generateInitializeCode() throws IllegalActionException
Generate the initialize code for this IOPort. The initialize code is generated by appending the initialize code for each receiver contained by this IOPort.- Overrides:
generateInitializeCode
in classNamedProgramCodeGeneratorAdapter
- Returns:
- The generated initialize code.
- Throws:
IllegalActionException
- If an error occurs when getting the receiver adapters or generating their initialize code.
-
getReceiverAdapters
public Receiver[][] getReceiverAdapters() throws IllegalActionException
Get the adapters for receiver contained in this port.- Returns:
- The adapters.
- Throws:
IllegalActionException
- Thrown ifProgramCodeGeneratorAdapter.getAdapter(Object)
throws it.
-
getRemoteReceiverAdapters
public Receiver[][] getRemoteReceiverAdapters() throws IllegalActionException
Get the adapters for the remote receivers connected to this port.- Returns:
- The adapters.
- Throws:
IllegalActionException
- Thrown ifProgramCodeGeneratorAdapter.getAdapter(Object)
throws it.
-
generatePutLocalInsideCode
public java.lang.String generatePutLocalInsideCode(java.lang.String channel, java.lang.String offset, java.lang.String dataToken) throws IllegalActionException
Generate code for replacing the sendLocalInside() macro.- Specified by:
generatePutLocalInsideCode
in interfacePortCodeGenerator
- Parameters:
channel
- The channel for which to generate the send code.offset
- The offset in the array representation of the port.dataToken
- The token to be sent.- Returns:
- The code that sends data to the specified channel.
- Throws:
IllegalActionException
- If the receiver adapter is not found or it encounters an error while generating the send code.
-
-