|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ptolemy.kernel.util.NamedObj ptolemy.codegen.kernel.CodeGeneratorHelper ptolemy.codegen.actor.Director ptolemy.codegen.c.targets.openRTOS.domains.pn.kernel.PNDirector
public class PNDirector
Code generator helper associated with the PNDirector class. This helper generates OpenRTOS specific code. OpenRTOS is a real-time operating system for the Luminary Micro target. It features a small preemptive, priority-based kernel. For further documentation, one can refer to http://www.freertos.org/. 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 helper 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. The communication between tasks use the OpenRTOS queues. These queues provide synchronized access methods. This director helper generates a queue for each connection which is referenced by its referable port channel. There is one referable port channel for each connection.
Yellow (mankit) |
Yellow (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 | |
---|---|
private java.util.HashSet<CodeGeneratorHelper.Channel> |
_queues
The set of referable channels that are associated with a generated queue. |
Fields inherited from class ptolemy.codegen.actor.Director |
---|
_director, _eol, _INDENT1, _INDENT2, _INDENT3, _INDENT4 |
Fields inherited from class ptolemy.codegen.kernel.CodeGeneratorHelper |
---|
_codeGenerator, _codeStream, _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 | |
---|---|
PNDirector(PNDirector pnDirector)
Construct the code generator helper associated with the given PNDirector. |
Method Summary | |
---|---|
protected java.lang.String |
_createDynamicOffsetVariables(TypedIOPort port)
Create the offset variables for the given port. |
private static java.lang.String |
_generateQueueReference(IOPort port,
int channelNumber)
Generate the reference of the queue generated for the specified port and channel number. |
private void |
_generateTaskFunctionCode(java.lang.StringBuffer code)
Generate the task functions. |
private java.lang.String |
_getActorTaskLabel(Actor actor)
Generate the label of the task generated for the specified actor. |
private java.lang.String |
_getMaxDelay(CodeGeneratorHelper.Channel channel)
Return the maximum wait time for getting and sending data on the specified port channel. |
private java.lang.String |
_getPriority(Actor actor)
Return the task priority associated with the specified actor. |
private int |
_getQueueSize(IOPort port,
int channelNumber)
Return the size of the queue to be generated for the specified port channel. |
private java.lang.String |
_getStackSize(Actor actor)
Return the expression of the stack size value for the specified actor task. |
java.lang.String |
generateCodeForGet(IOPort port,
int channelNumber)
Generate code for getting data from the specified channel. |
java.lang.String |
generateCodeForSend(IOPort port,
int channelNumber,
java.lang.String dataToken)
Generate code for sending data to the specified channel. |
java.lang.String |
generateFireCode()
Generate the director fire code. |
java.lang.String |
generateInitializeCode()
Generate the initialize code. |
java.lang.String |
generateMainLoop()
Generate the main loop code. |
java.lang.String |
generatePreinitializeCode()
Generate the preinitialize code for the associated PN director. |
void |
generateTransferInputsCode(IOPort inputPort,
java.lang.StringBuffer code)
Generate code for transferring tokens into a composite. |
void |
generateTransferOutputsCode(IOPort port,
java.lang.StringBuffer code)
Generate code for transferring tokens outside of a composite. |
java.lang.String |
generateVariableInitialization()
Generate variable initialization for the referenced parameters. |
int |
getBufferSize(IOPort port,
int channelNumber)
Return the buffer size to generate the variable for the specified port channel. |
java.util.Set<java.lang.String> |
getHeaderFiles()
Get the files needed by the code generated from this helper class. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private java.util.HashSet<CodeGeneratorHelper.Channel> _queues
Constructor Detail |
---|
public PNDirector(PNDirector pnDirector)
pnDirector
- The associated
ptolemy.domains.pn.kernel.PNDirectorMethod Detail |
---|
public java.lang.String generateCodeForGet(IOPort port, int channelNumber) throws IllegalActionException
generateCodeForGet
in class Director
port
- The specified port.channelNumber
- The specified channel.
IllegalActionException
- If the specified port channel has
more than one referable queues.
IllegalActionException
- If an error occurs when getting
the helper for the actor containing the given port, or reading
the width of the referenced port, or
Director.getReferenceChannels(IOPort, int)
or
CodeGeneratorHelper.processCode(String)
throw it.public java.lang.String generateCodeForSend(IOPort port, int channelNumber, java.lang.String dataToken) throws IllegalActionException
generateCodeForSend
in class Director
port
- The specified port.channelNumber
- The specified channel.dataToken
- The specified expression for the data being send.
IllegalActionException
- If an error occurs when getting
the helper for the actor containing the given port, or
Director.getReferenceChannels(IOPort, int)
or
CodeGeneratorHelper.processCode(String)
throw it.public java.lang.String generateFireCode() throws IllegalActionException
generateFireCode
in interface ActorCodeGenerator
generateFireCode
in class Director
IllegalActionException
- Not thrown in this class.public java.lang.String generateInitializeCode() throws IllegalActionException
generateInitializeCode
in interface ComponentCodeGenerator
generateInitializeCode
in class Director
IllegalActionException
- If the helper associated with
an actor throws it while generating initialize code for the actor.public java.lang.String generateMainLoop() throws IllegalActionException
generateMainLoop
in class Director
IllegalActionException
- Thrown if an error occurs
when getting the helper or generating the fire code from it.public java.lang.String generatePreinitializeCode() throws IllegalActionException
generatePreinitializeCode
in interface ActorCodeGenerator
generatePreinitializeCode
in class Director
IllegalActionException
- If the helper associated with
an actor throws it while generating preinitialize code for the actor.public void generateTransferInputsCode(IOPort inputPort, java.lang.StringBuffer code) throws IllegalActionException
generateTransferInputsCode
in class Director
inputPort
- The port to transfer tokens.code
- The string buffer that the generated code is appended to.
IllegalActionException
- If thrown while transferring tokens.public void generateTransferOutputsCode(IOPort port, java.lang.StringBuffer code) throws IllegalActionException
generateTransferOutputsCode
in class Director
port
- The specified port.code
- The given code buffer.
IllegalActionException
- Not thrown in this class.public java.lang.String generateVariableInitialization() throws IllegalActionException
generateVariableInitialization
in interface ActorCodeGenerator
generateVariableInitialization
in class Director
IllegalActionException
- Not thrown in this class.public int getBufferSize(IOPort port, int channelNumber) throws IllegalActionException
getBufferSize
in class Director
port
- The specified portchannelNumber
- The specified channel number.
IllegalActionException
- Not thrown in this class.CodeGeneratorHelper.setBufferSize(IOPort, int, int)
public java.util.Set<java.lang.String> getHeaderFiles() throws IllegalActionException
getHeaderFiles
in interface ActorCodeGenerator
getHeaderFiles
in class Director
IllegalActionException
- Not thrown in this class.protected java.lang.String _createDynamicOffsetVariables(TypedIOPort port) throws IllegalActionException
port
- The specified port.
IllegalActionException
- If getting the code block
throws it.private static java.lang.String _generateQueueReference(IOPort port, int channelNumber)
port
- The specified port.channelNumber
- The specified channel number.
private void _generateTaskFunctionCode(java.lang.StringBuffer code) throws IllegalActionException
code
- The given code buffer.
IllegalActionException
- If getting the helper or
generating the actor initialize, fire, or wrapup code
throws it.private java.lang.String _getActorTaskLabel(Actor actor)
actor
- The specified actor.
private java.lang.String _getMaxDelay(CodeGeneratorHelper.Channel channel)
channel
- The specified port channel.
private java.lang.String _getPriority(Actor actor)
actor
- The specified actor.
private int _getQueueSize(IOPort port, int channelNumber) throws IllegalActionException
port
- The specified port.channelNumber
- The specified channel number.
IllegalActionException
private java.lang.String _getStackSize(Actor actor)
actor
- The specified actor.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |