Package ptolemy.cg.adapter.generic.program.procedural.c.luminary.adapters.ptolemy.domains.ptides.kernel
Class PtidesPreemptiveEDFDirector
- 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.adapters.ptolemy.actor.Director
-
- ptolemy.cg.adapter.generic.program.procedural.c.adapters.ptolemy.domains.ptides.kernel.PtidesPreemptiveEDFDirector
-
- ptolemy.cg.adapter.generic.program.procedural.c.luminary.adapters.ptolemy.domains.ptides.kernel.PtidesPreemptiveEDFDirector
-
- All Implemented Interfaces:
java.lang.Cloneable
,Changeable
,Debuggable
,DebugListener
,Derivable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
public class PtidesPreemptiveEDFDirector extends PtidesPreemptiveEDFDirector
Code generator adapter associated with the PtidesPreemptiveEDFDirector class. This adapter generates Luminary specific code. This director starts a task for each actor. Each task has a specified name, stack size, priority and function code to execute. User can introduce annotations in an actor to specify these values. In particular, this adapter class looks for the "_stackSize" and "_priority" parameters and use their values to create the tasks. If these parameters are not specified, the code generator uses the default value 80 for stack size, and 0 for priority. Each task executes a given function which consists of the actor initialization, fire and wrapup code.- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Jia Zou, Isaac Liu, Jeff C. Jensen
- Pt.AcceptedRating:
- red (jiazou)
- Pt.ProposedRating:
- red (jiazou)
-
-
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.adapter.generic.program.procedural.c.adapters.ptolemy.domains.ptides.kernel.PtidesPreemptiveEDFDirector
actuators, sensors
-
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
-
-
Constructor Summary
Constructors Constructor Description PtidesPreemptiveEDFDirector(PtidesDirector ptidesPreemptiveEDFDirector)
Construct the code generator adapter associated with the given PtidesBasicDirector.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.String
_generateInitializeHardwareCode()
Generate the initialization code for any hardware component that is used.java.util.Map<java.lang.String,java.lang.String>
generateAdditionalCodeFiles()
Generate the assembly file associated for this PtidyOS program.java.lang.String
generateFireCode()
Generate the director fire code.java.lang.String
generateFireFunctionCode()
Generate the fire function code.java.lang.String
generateInitializeCode()
Generate the initialize code.java.lang.String
generatePreinitializeCode()
Generate the preinitialize code for the associated Ptides director.java.lang.String
generateVariableInitialization()
Generate variable initialization for the referenced parameters.java.util.Set
getSharedCode()
Generate the shared code.-
Methods inherited from class ptolemy.cg.adapter.generic.program.procedural.c.adapters.ptolemy.domains.ptides.kernel.PtidesPreemptiveEDFDirector
_generateActorFireCode, _generateActorFuncProtoCode, _generateActuatorActuationFuncArrayCode, _generateActuatorActuationFuncProtoCode, _generateClearEventHeadCode, _generateDirectorHeader, _generatePtrToEventHeadCodeInputs, _generateTypeConvertStatement, _modelStaticAnalysis, generateMainLoop, generateTransferInputsCode, generateTransferOutputsCode, generateTypeConvertFireCode, generateVariableDeclaration
-
Methods inherited from class ptolemy.cg.adapter.generic.adapters.ptolemy.actor.Director
_ceilToPowerOfTwo, _generateVariableDeclaration, _generateVariableInitialization, _getParameter, generateCodeForGet, generateCodeForSend, generateConstructorCode, generateModeTransitionCode, generatePostfireCode, generatePreinitializeMethodBodyCode, generateTransferInputsCode, generateTransferOutputsCode, generateVariableDeclaration, generateVariableInitialization, generateWrapupCode, getComponent, getIncludeDirectories, getLibraries, getLibraryDirectories, getModifiedVariables, getParameter, getReference
-
Methods inherited from class ptolemy.cg.kernel.generic.program.NamedProgramCodeGeneratorAdapter
_generateFireCode, analyzeTypeConvert, copyFilesToCodeDirectory, generatePrefireCode, generateSimpleName, generateTypeConvertFireCode, getAddTimeString, getBufferSize, getBufferSize, getDeclareSharedCode, getDefaultBlocks, getFireFunctionParameters, getHeaderFiles, getName, getParameterValue, getReference, getReference, 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
-
PtidesPreemptiveEDFDirector
public PtidesPreemptiveEDFDirector(PtidesDirector ptidesPreemptiveEDFDirector)
Construct the code generator adapter associated with the given PtidesBasicDirector.- Parameters:
ptidesPreemptiveEDFDirector
- The associated director ptolemy.domains.ptides.kernel.PtidesBasicDirector
-
-
Method Detail
-
generateAdditionalCodeFiles
public java.util.Map<java.lang.String,java.lang.String> generateAdditionalCodeFiles() throws IllegalActionException
Generate the assembly file associated for this PtidyOS program. Here we return an empty string, but the target specific adapter should overwrite it.- Overrides:
generateAdditionalCodeFiles
in classPtidesPreemptiveEDFDirector
- Returns:
- The generated assembly file code.
- Throws:
IllegalActionException
- If thrown while getting the configuration or if the configuration cannot be found or if thrown while the getting the codeBlock.
-
generateFireCode
public java.lang.String generateFireCode() throws IllegalActionException
Generate the director fire code. The code creates a new task for each actor according to their specified parameters (e.g. stack depth, priority, and etc.). The code also initiates the task scheduler.- Overrides:
generateFireCode
in classDirector
- Returns:
- The generated fire code.
- Throws:
IllegalActionException
- Not thrown in this class.
-
generateFireFunctionCode
public java.lang.String generateFireFunctionCode() throws IllegalActionException
Generate the fire function code. The code contains the function code for each actor. It is a collection of global functions, one for each actor that is visible to this director adapter. Creating each new task requires one of these function as parameter. It is the code that the task executes. When the inline parameter is checked, the task function code is generated ingeneratePreinitializeCode()
which is outside the main function.- Overrides:
generateFireFunctionCode
in classDirector
- Returns:
- The fire function code.
- Throws:
IllegalActionException
- If there is an exception in generating the task function code.
-
generateInitializeCode
public java.lang.String generateInitializeCode() throws IllegalActionException
Generate the initialize code. This generates the hardware initialization code and creates the queues for all referrable port channels.- Overrides:
generateInitializeCode
in classPtidesPreemptiveEDFDirector
- Returns:
- The generated initialize code.
- Throws:
IllegalActionException
- If the adapter associated with an actor throws it while generating initialize code for the actor.
-
generatePreinitializeCode
public java.lang.String generatePreinitializeCode() throws IllegalActionException
Generate the preinitialize code for the associated Ptides director.- Overrides:
generatePreinitializeCode
in classPtidesPreemptiveEDFDirector
- Returns:
- The generated preinitialize code.
- Throws:
IllegalActionException
- If the adapter associated with an actor throws it while generating preinitialize code for the actor. FIXME: Take care of platform dependent code.
-
generateVariableInitialization
public java.lang.String generateVariableInitialization() throws IllegalActionException
Generate variable initialization for the referenced parameters. This overrides the super class method and returns an empty string. It avoids generating any offset variables.- Overrides:
generateVariableInitialization
in classDirector
- Returns:
- code The empty string.
- Throws:
IllegalActionException
- Not thrown in this class.
-
getSharedCode
public java.util.Set getSharedCode() throws IllegalActionException
Generate the shared code. This is the first generate method invoked out of all, so any initialization of variables of this adapter should be done in this method. In this base class, return an empty set. Subclasses may generate code for variable declaration, defining constants, etc.- Overrides:
getSharedCode
in classPtidesPreemptiveEDFDirector
- Returns:
- An empty set in this base class.
- Throws:
IllegalActionException
- Not thrown in this base class.
-
_generateInitializeHardwareCode
protected java.lang.String _generateInitializeHardwareCode() throws IllegalActionException
Generate the initialization code for any hardware component that is used.- Returns:
- code initialization code for hardware peripherals
- Throws:
IllegalActionException
- If thrown while getting the adapter or generating hardware initialization code.
-
-