.pl" extensions on the file names stand for "Ptolemy language" or "preprocessor language." The file name must be of the form
.plfor dynamic linking and the
look-insidecommand to work. The last command just ensures that you can modify the file. Edit the file to change the name of the star from
MyStar. This is necessary so that the name does not conflict with the existing
Sinstar in the SDF domain.
You can now dynamically link your new star. Start
pigi, the graphical editor. If you start
pigiin your new directory, you will get a blank
init.palfacet. Place your mouse cursor in this facet, and issue the " make-star" command (the shortcut is "
*"). A dialog box like the following will appear:
Enter the name of the star,
MyStar, its domain,
SDF, the location of the directory that defines it, such as
~user_name/my_directory, and the name of palette in which you would like its icon to appear,
user.pal. The star will be compiled and dynamically linked with the Ptolemy executable. An icon for it will appear in the facet
user.pal. Try using this in a simple system.
Three details about dynamic linking may prove useful:
pigiwill replace this with
/obj.$PTARCH/depending on the type of machine you are running, to get the name of the directory in which to store the object file. This is especially useful if you are jointly doing development with others who use a different type of machine. If there is no
/src/component in the name, then the object file is placed in the same directory with the source file.
makefilein the object file directory,
pigiwill run the
makeprogram, using the
makefileto create the object file (or make sure it is up to date). If there is no
pigiwill run a make-like procedure on its own, running the preprocessor as needed to produce the C++ source files, then running the C++ compiler to create the object file. By default, the C++ compiler will be told to look for include files in the kernel directory and the domain-specific kernel and star directories; if this is not adequate, then you need to write a makefile. Once compilation (if any) is complete, the dynamic linker is used to load the star into the system. Compilation errors, if any, will appear in a popup window.
/users/ptolemy. See Appendix A of the Ptolemy User's Manual for more information.
makefileexists in your directory. If a
makefileexists in your directory, Ptolemy will attempt to use it to compile your star. Remove it, and try again.
/src/component in the directory name, but the corresponding
/obj.$PTARCH/directory does not exist or cannot be written. A common error is to put the Ptolemy sources in
/usr/local/src/ptolemy, which confuses Ptolemy since a star might be in
/usr/local/src/ptolemy/src/domains/sdf/stars, which has two
/src/directories in the path.
The star you just created performs exactly the same function as an existing star in the Ptolemy library, and hence is not very interesting. Try modifying the star. For example, you could add 1.0 to the sine before producing the output. Find the definition of the
gomethod, which should look like this:
<<" and "
%" operators have been overloaded. This line means that the current value (
%0) of the output named "
output" should be assigned the value returned by the
sinfunction applied to the current value of the input named "
input". The cast to
doubleindicates that we are not really interested in the
Particleobject supplied by the input, but rather its value, interpreted as a double-precision floating point number. Try changing this code to
L" (or invoke the "Extend: load-star" command through the menus).
Sometimes, you will wish to dynamically link stars that are derived from other stars that you have dynamically linked. To do this, the base class stars must be permanently linked. This can be done with the "Extend:load-star-perm" command ("
K"). To do this, place the mouse over an icon representing the parent star, and type "
K". Once the parent star is permanently linked, it cannot be replaced or redefined: you must restart
goand all other entries in the
.plfile defining the star are explained in the following sections.