Notes about Eclipse and Ptolemy II
Contents
- In the Navigator view scroll/open until you see the resource
(directory or file) to be synchronized.
- Right click that resource and select Team->Synchronize With Repository...
- The Synchronize view should then be visible.
- Select the Incoming, Outgoing, or Incoming/Outgoing menu bar icon as appropriate
- In the Navigator view scroll/open until you see the resource (directory or file) to be restored.
- Right click that resource and select Replace With->Latest From Head.
Usually, it is better to extend Java classes than to copy them, but sometimes copying files
under Subversion is useful. To copy files, use the svn cp command. Do
not drag and drop directories as the directories contain a .svn directory
that will have settings for the source location. Instead, use svn cp.
See also svn mv.
See Testing Ptolemy II for details.
- In Eclipse, go to Run -> Debug Configurations
- Select Java Application and then click the New icon.
- In the Main tab, set the "Name:" to ptjacl, in "Main class:", enter
tcl.lang.Shell.
If tcl.lang.Shell is not found, then be sure that $PTII/lib/ptlang.jar is in the class path of the project by right clicking on the project and selecting Properties > Java Build Path >> Libraries.
- Optional: In the Arguments tab, under "Program arguments", enter
alljtests.tcl or any individual test tcl file.
(E.g. SimpleDelay.tcl).
Or, leave the "Program arguments" field blank and when ptjacl is running (see below), enter text in to the Eclipse console.
- Optional: In the Arguments tab, under "VM arguments", enter
-Dptolemy.ptII.dir=your PtII directory
(E.g. -Dptolemy.ptII.dir=c:/hyzheng/ptII).
In case your directory path contains
spaces, you need to use quotes. (E.g. -Dptolemy.ptII.dir="c:/my workspace/ptII").
- In the "Working directory:" pane, select "Other:", browse to the directory containing the tcl
tests.
(E.g. C:\hyzheng\ptII\ptolemy\domains\de\lib\test)
- Select Debug.
The nice thing of using Eclipse is that you can very easily locate where
the exception is thrown by clicking the classes listed in the stack trace.
You may further register a breakpoint to do more diagnosis.
If you have already used Eclipse and you would like to start over with
new projects and preferences, remove the workspace directory in the
Eclipse directory. The workspace directory will only
appear if you have already run Eclipse. Note that removing the
workspace directory will cause Eclipse to 'forget'
about any projects that you may have set up
Build Error: Assert cannot be resolved
If, when building, the Problem tab shows "Assert cannot be resolved",
then the problem is that Junit is not being found.
Rebuilding Briefly flashes a window
If you have problems where clicking on build briefly flashes up
a window, look in $PTII/.classpath for and empty
exclusion that looks like ||
If you have problems with the classpath, look in the
workspace/.metadata/log file that is in
the directory where eclipse is installed. For more information
about the .metadata directory, see
below.
Eclipse takes a long time to start up
If Eclipse takes a long time to start up, then the problem could be
a problem in your .metadata file.
Basically, when eclipse starts up, it might try to update
H:/workspace/.metadata
. The solution is covered in
http://www.eclipse.org/documentation/html/plugins/org.eclipse.platform.doc.user/doc/tasks/running_eclipse.htm:
The way I figured this out was by running Norton Antivirus and
doing View -> File System Realtime Scan Statistics and then I noticed
that my machine was updating H:/workspace/.metadata
I think I introduced the problem by clicking on the Eclipse.exe
binary and selecting Pin to Start Menu. My solution was to remove the
Eclipse bogus entry in the start menu and then create a shortcut,
change Start in property and then pin that shortcut to my start menu.
Based on text by Mehran Meschian. See
also
Adding An Actor to Ptolemy II
at $PTII/doc/coding/addinganactor.htm.
In this example, we copy ptolemy/actor/lib/Ramp.java and create a new actor
called Ramp2
- Open Eclipse and choose the work space that you have your Ptolemy project there (mine is PtII 8.1.devel)
- Open the PtII8.1.devel folder in eclipse and then open Ptolemy -> actor -> lib -> string
- In string folder copy the java class (our simple actor)
- Rename the java file to Bmh and debug the errors that come because of this renaming.
- At the first line of the Java code add: package ptolemy.actor.lib.string;
- When there is no more error Run the java file and you should see a Bmh.class file in the tree as well (In the string branch). For now close the GUI window that opened after running.
- In the same place that Bmh.java and Bmh.class files exist, there is a string.xml file. Open it.
- At the top of the eclipse console, you should see two options: Design & Source. Click on Source to see the content of the xml
- Add the following bold and red text to the location in the xml file. Then save and run the xml file:
<property name="_icon" class="ptolemy.vergil.icon.AttributeValueIcon">
<property name="attributeName" value="function"/>
<property name="displayWidth" value="11"/>
</property>
</entity>
<entity name="Bmh" class="ptolemy.actor.lib.string.Bmh">
<doc>Boyer Moore Horspool</doc>
</entity>
<entity name="StringIndexOf" class="ptolemy.actor.lib.string.StringIndexOf">
<doc>Output the length of an input string</doc>
</entity>
- Again in the same tree there is makefile. Open and add the following bold and red text to the location and save and run:
PTDIST = $(PTPACKAGE)$(PTVERSION)
PTCLASSJAR = $(PTPACKAGE).jar
# Keep this list alphabetized.
JSRCS = \
Bmh.java \
StringCompare.java \
StringFunction.java \
StringIndexOf.java \
StringLength.java \
StringMatches.java \
- Now, back to your Bmh.java and run it again. You should see the welcome window of Vergil.
- Now in the window, go to file- > New -> Graph editor. You should see a new window of graph editor.
- Go to Graph -> instantiate Entity. Then type Ptolemy.actor.lib.string.Bmh in the class name and you will see our Bmh actor in the window.
- Right click on the actor and choose Save Actor in Library. Now if you open the User Library (left side) you can see the Bmh actor there.
- In the case after all of these steps it doesn't work, restart your eclipse and make sure you have saved your xml file and there are Bmh.java and Bmh.class there. If again it doesn't work, there should be something wrong regarding your Ptolemy installation in eclipse. Hope not!!