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
-
- ptolemy.cg.adapter.generic.program.procedural.c.adapters.ptolemy.actor.IOPort
-
- All Implemented Interfaces:
java.lang.Cloneable
,PortCodeGenerator
,Changeable
,Debuggable
,DebugListener
,Derivable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
public class IOPort extends IOPort
Code generator C adapter forIOPort
.- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- William Lucas
- Pt.AcceptedRating:
- Red (wlc)
- Pt.ProposedRating:
- Red (wlc)
-
-
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 the code to get a token from a port and then free it.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
generatePortDeclaration()
Generate the code of the declaration of an IOPort (or a subclass) Initialize all its dependencies (container, widths ...) In this base class we deal with all the known kinds of ports, however ideally we should create an adapter for each type of port.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.-
Methods inherited from class ptolemy.cg.adapter.generic.program.procedural.adapters.ptolemy.actor.IOPort
generateInitializeCode, getReceiverAdapters, getRemoteReceiverAdapters
-
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.- Specified by:
generateGetCode
in interfacePortCodeGenerator
- Overrides:
generateGetCode
in classIOPort
- 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
- Overrides:
generateGetCodeWithoutType
in classIOPort
- 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 the code to get a token from a port and then free it.- Specified by:
generateGetAndFree
in interfacePortCodeGenerator
- Overrides:
generateGetAndFree
in classIOPort
- 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.
-
generatePortDeclaration
public java.lang.String generatePortDeclaration() throws IllegalActionException
Generate the code of the declaration of an IOPort (or a subclass) Initialize all its dependencies (container, widths ...) In this base class we deal with all the known kinds of ports, however ideally we should create an adapter for each type of port. There are essentially four types of ports : - input/output - from a composite/atomic actor The creation of the receivers relies on this distinction.- Returns:
- the port declaration to include in the actor constructor
- Throws:
IllegalActionException
- if the getWidth or getWidthInside throws an exception
-
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.- Specified by:
generateHasTokenCode
in interfacePortCodeGenerator
- Overrides:
generateHasTokenCode
in classIOPort
- 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.- Specified by:
generatePutCode
in interfacePortCodeGenerator
- Overrides:
generatePutCode
in classIOPort
- 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.
-
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
- Overrides:
generatePutLocalInsideCode
in classIOPort
- 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.
-
-