Code Generation

This code generator is patterned after the Ptolemy Classic code generator where actors have template files consisting of code blocks. The code blocks are stitched together to create the resulting file.

Simple Demo

  1. Open $PTII/ptolemy/codegen/Demo/Ramp/RampDisplay.xml
  2. Click on the StaticSchedulingCodeGeneratorIcon.
  3. A dialog box will appear, click on "Generate"
  4. The code will be generated, compiled, run and the results displayed.
Other Codegen Demonstrations

Limitations

This is a highly preliminary code generator facility, with many limitations. It is best viewed as a concept demonstration.

FAQ
Models that use a plotter fail to compile.
Models that use the plotter use the Java Native Interface (JNI) to invoke the plotter from within the C process. This is done so that the plotter is interactive while the model is running as opposed to plotting the data after the model completes. The JNI facility requires that a Java Development Kit (JDK) be installed instead of a Java Runtime Environment (JRE). The Ptolemy II Windows installer includes a JRE which is optionally installed. If the Windows installer is installed with the bunded JRE, then models that use the plotter will probably fail to compile with message like:
make: *** [Ramp] Error 1
Models that use the plotter require setup
To properly run a model that has a plotter, you must have jvm.dll in your path. If you do not, then when you run the executable, it will immediately exit with no message! For example, place
C:\Progra~1\Java\jdk1.5.0_11\jre\bin\client
in your path. If you are running Vergil from the command line as $PTII/bin/ptinvoke, then this has been handled for you. If you are running via Eclipse, then you must update your path by hand.
When in Windows, clicking on a .exe produced by the code generator fails to start up. The message is:
The procedure entry point _impure_ptr could not be located in the dynamic link library cygwin1.dll
The solution is to add C:\cygwin\bin to the Windows path by doing: Start Menu -> Settings -> Control Panels -> System -> Advanced -> Environment Variables and adding C:\cygwin\bin to the path.
To get rid of the console, compile with the exe with -mwindows:
make -f Model.mk CC_FLAGS=-mwindows
Generating code results in IOException: java.io.IOException: CreateProcess: make -f Model.mk error=2
This will happen if make is not in your path. Under Windows, you may need to install Cygwin, see the Ptolemy II Cygwin installer. Under Windows, if Cygwin is installed, then be sure that C:\cygwin\bin is in your Windows path. To edit your path, do Start Menu -> Settings -> Control Panels -> System -> Advanced -> Environment Variables.