7.9. Adding actors

The easiest way to add new actors is to add them to the directory lib/ptII/myActors which is described in Section 7.9.1, “Adding actors to lib/ptII/myActors. Section 7.9.2, “Adding actors to other directories” describes how to add actors to another directory.

Users can add new actors in the form of a Java class to the BCVTB. To add an actor, proceed as follows:

  1. Create a Ptolemy II actor in the directory bcvtb/lib/ptII/myActors. This may be easiest by copying and modifying an existing actor, such as done in the example bcvtb/lib/ptII/myActors/MyRamp.java. For instructions about creating actors, see http://www.eecs.berkeley.edu/Pubs/TechRpts/2008/EECS-2008-28.pdf .

  2. Edit the file bcvtb/lib/ptII/myActors/myActor.xml to include the new actor. This can be done by making a copy of the existing line

    <entity name="MyRamp" class="myActors.MyRamp"/>

    Edit the value of the name attribute (which is the name of the Java file without extension) and the class attribute (which is the Java package name).

  3. To compile the actor, type on a command shell

    cd bcvtb/lib/ptII/myActors
    ant all

    After the compilation, the message BUILD SUCCESSFUL should be displayed.

When the BCVTB is restarted, the new actor should be displayed in the actor menu.

[Note]Note

Note that adding actors to directories other than bcvtb/lib/ptII/myActors requires having Ptolemy II installed and compiled as described in Section 7.5, “Updating Ptolemy II”.

If the actor is in a different directory than bcvtb/lib/ptII/myActors, then the following additional steps are required:

  1. Create an entity file (similar to lib/ptII/myActors/myActor.xml) that points to the new actor.

  2. Open the file bcvtb/lib/ptII/build.xml.

  3. Make a copy of the section

      <entity name="MyActors" class="ptolemy.moml.EntityLibrary">
        <configure>
          <?moml
            <group>
    	<input source="myActors/myActor.xml"/>
            </group>
          ?>
        </configure>
      </entity>
      

    Replace MyActors with the name that you want to see in the class browser of the Ptolemy II graphical user interface, and replace the value myActors/myActor.xml with the path and name of the entity file of the new actor.

  4. Run

    cd bcvtb/lib/ptII
    ant updatePtolemyFiles

    This will copy the entity section to the Ptolemy II configuration file.