Recent Changes - Search:

edit SideBar

CodeGeneration

Resources

Edward's 10/25/14 email

Documentation is pretty sparse. I've cc'd Christopher in case he has additional pointers.
Feel free to improve documentation that you find...

Here's what I see currently in the Ptolemy tree (the current development version from SVN):
The best starting point for documentation appears to be here:

$PTII/ptolemy/cg/README.html

You can access a bunch of demo by going to the "Complete list of demos" (Help->About->Tour of Ptolemy II-> Complete List of Demos)and looking in the code generation section.

Possibly more useful than demos are tests. Anything in the $PTII/ptolemy/cg/ subtree matching the pattern */test/auto/*.xml is a test.

Demos: I would start here... Just try some out to get a feel. Look at the generated code.

Java code generation:

  • Demo: $PTII/ptolemy/cg/lib/demo/CompiledCompositeActor/CompiledCompositeActor.xml
    Generates a Java class definition for a composite actor, then uses that generated class in place of the composite actor in a simulation.
  • Demo: $PTII/ptolemy/cg/lib/demo/ModularCG/ModularCG.xml
    Similar to above, but with multiple code-generated composites.

C code generation:

  • Test: $PTII/ptolemy/cg/adapter/generic/program/procedural/c/arduino/adapters/ptolemy/actor/lib/gui/test/auto/Display.xml
    Very simple C code generation test case. This is using the arduino tree, but I don't see anything arduino specific in it.
  • Demos: $PTII/ptolemy/cg/lib/demo/DECG/DECG.xml
    A few demos generating C code from discrete-event models. These generate a standalone program for a whole model.
  • Tests: $PTII/ptolemy/cg/lib/test/auto
    Generally, anything within a test/auto directory runs in the nightly build, so most of these should be working.

C code generation for Arduino:

  • $PTII/ptolemy/cg/adapter/generic/program/procedural/c/arduino/adapters/ptolemy/vergil/actor/lib/demo
    These are fairly raw. I'm not sure which (if any) actually work.
    There are probably more demos and tests within the arduino subtree (see below for directory organization).

Mixed code generation:

  • $PTII/ptolemy/cg/lib/demo/Scale has a model that currently fails to work that generates C code which it then embeds in a Java run. This used to work.

I'm not seeing any FSM code generation. It might be that FSM code generation never got ported from the older "codegen" code generation tree.

The general pattern of the "cg" code generator that every component in a model (an actor, a director) needs to have an "adapter" in order to be code generated. Adapters are looked for within the subtree $PTII/ptolemy/cg/adapter.

A particular model will specify a more specific subtree in which to look for adapters. For example, this model:

$PTII/ptolemy/cg/adapter/generic/program/procedural/c/arduino/adapters/ptolemy/actor/lib/gui/test/auto/Display.xml

has a CCodeGenerator attribute with the generator package specified to be generic.program.procedural.c.
It looks for adapters (generators) in subdirectories of $PTII/ptolemy/cg/adapter/generic/program/procedural/c.
I think that to use an Arduino-specific version of Display, you would change the package to generic.program.procedural.c.arduino.

Notes

Code generation for Ptides fails

The issue is that:

$PTII/bin/ptcg -language c -generateInSubdirectory false -inline false -maximumLinesPerBlock 2500 -variablesAsArrays false /home/hudson/jobs/ptII/workspace/ptolemy/cg/adapter/generic/program/procedural/c/adapters/ptolemy/domains/ptides/lib/test/auto/Network1.xml

fails:

./Network1
commons/_CompositeActor.c:101: CompositeActorFire():(1) director did not transfer inputs?.
commons/_CompositeActor.c:101: CompositeActorFire():(2) director did not transfer inputs?.
commons/_CompositeActor.c:101: CompositeActorFire():(3) director did not transfer inputs?.
commons/_CompositeActor.c:101: CompositeActorFire():(4) director did not transfer inputs?.

Test Network1_Test__0 fails in iteration 0.
Value was: -5. Should have been between: -4.00000000100000008274037099909 and -3.99999999899999991725962900091
make: *** [run] Error 255
Edit - History - Print - Recent Changes - Search
Page last modified on July 09, 2019, at 01:21 am