Cool, glad it works.  Sounds like an interesting application.
What is a "DES"?  You said

>  We are looking at replacing this with Ptolemy as a DES with actors
>  that call the spreadsheet models.

$PTII/bin/vergil.bat is created by running make in $PTII/bin
which uses a great hack to generate the .bat files.

I think if you have your $CLASSPATH set to include your jar file
and then do the following from a Cygwin bash shell:
    cd $PTII/bin
    make clean
    make

then you will find that your CLASSPATH will be included in vergil.bat.

It is arguable that the .bat files should read the users %CLASSPATH%
at runtime instead of at compile time.  I leave this up to the reader.
:-)


The quick and dirty thing would be to modify the vergil script
so that it properly sets the classpath to include the jar file and
distribute that along with a tar of the installation.

Another idea would be to modify the Windows Installer files so
that the jar files are present and the actors are listed in the 
configuration.

To do this, place your actors in a jar file and add the actor jar file
and the poi-2.5.1-final-20040804.jar file to the lax.class.path
parameter in vergil-full.lax.  When you run vergil-full.exe,
vergil-full.lax is read, so your jar files will be accessible.

You would also need to create a configuration file that listed your
actor so that it would show up in the user's browser.

One way to do this is to use the user library.

When Ptolemy starts up, it looks for $HOME/.ptolemyII/UserLibrary.xml
which can contain user actors.
Usually, one can right click on an actor and select "Save in Library",
but I managed to break that in the beta.  The final release, due
out sometime soon (maybe on July 22) will have that fixed.

In the short term, you could edit
ptolemy/vergil/actor/ActorController.java 
and change:
        if (((BasicGraphController) getController()).getFrame() != null) {
            // If we are in an applet, then we have no frame, so no need
            // for a "Listen to Actor" or "Save in Library" menu choices.
            // FIXME: this is not perfect, it would be better if we
            // could just test if we are in an applet or else fix this
            // so we have a frame.
            // NOTE: This requires that the configuration be non null, or it
            // will report an error.
            _menuFactory.addMenuItemFactory(new MenuActionFactory(
                                                    new SaveInLibraryAction()));

            _listenToActorAction = new 
ListenToActorAction((BasicGraphController) getController());
            _menuFactory.addMenuItemFactory(new MenuActionFactory(
                                                    _listenToActorAction));
            _listenToActorAction.setConfiguration(_configuration);
        }

to:

//        if (((BasicGraphController) getController()).getFrame() != null) {
            // If we are in an applet, then we have no frame, so no need
            // for a "Listen to Actor" or "Save in Library" menu choices.
            // FIXME: this is not perfect, it would be better if we
            // could just test if we are in an applet or else fix this
            // so we have a frame.
            // NOTE: This requires that the configuration be non null, or it
            // will report an error.
            _menuFactory.addMenuItemFactory(new MenuActionFactory(
                                                    new SaveInLibraryAction()));

            _listenToActorAction = new 
ListenToActorAction((BasicGraphController) getController());
            _menuFactory.addMenuItemFactory(new MenuActionFactory(
                                                    _listenToActorAction));
            _listenToActorAction.setConfiguration(_configuration);
//        }

and then recompile.  Once you have the "Save in library" menu
choice working, you could follow the instructions in
Volume 1 of the Ptolemy II Design doc, Chapter 5 "Designing Actors"
"Appendix B: Creating and Using a simple actor"
to add your actor to your $HOME/.ptolemyII/UserLibrary.xml
file, which is probably found in 
C:/Documents and Settings/yourlogin/.ptolemyII/UserLibrary.xml  
where "yourlogin" is your Windows login.

Then, you could distribute that UserLibrary.xml file and a tar of the
installed Windows installer to other users.  They would need to put
the UserLibrary.xml file in the right place and then, if your user
clicked on the vergil-full icon, they would get your actor and the
poi*.jar file in their classpath.

Sounds like a lot of work, eh?  Another alternative would be to 
unjar ptolemy/ptsupport.jar and modify ptolemy/actor/lib/io/io.xml
to include your file, rejar up ptolemy/ptsupport.jar,
skip modifying UserLibrary.xml but add your jars to vergil-full.lax

Another solution that requires quite a bit more work is to create a
Web Start configuration or an InstallAnywhere or Installshield
installer includes your actors and jar files.  

_Christopher

--------

    It works now, sort of.
    
    I tried your instructions and found that it works if I start vergil from
    cygwin.  That solves my immediate problem--it now reads values from Excel
    files.  However, eventually I need to distribute the class for others
    (non-programmer types) to use.  Most of these won't have cygwin.  
    
    I checked as you suggested and the classpath is set in DOS and cygwin.  I
    will take a closer look at your comments and try to see why it works in
    cygwin, but not from Windows.
    
    BTW, the project I am working on (ATLAS, Advanced Technology Life-Cycle
    Analysis System) is an architecture/mission simulator for NASA's Return to
    the Moon project.  Others (non-programmers) have developed a lot of Excel
    models of launch vehicles, crew capsules, lunar rovers and habitats, etc.
    An analyst strings together a set of missions using combinations of the
    available models, selects the technologies (what type of batteries for the
    rover, for example) and runs an analysis to get results including a mass
    estimate and cost profile over time (including R&D, production, launch
    operations, mission operations, etc.).  Right now it is done with Excel &
    VBA.  We are looking at replacing this with Ptolemy as a DES with actors
    that call the spreadsheet models.
    
    Thanks for your help.
    
    
    -----Original Message-----
    From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
    Sent: Friday, July 08, 2005 5:15 PM
    To: Goode, Wayne
    Cc: ptolemy-hackers@messier.eecs.berkeley.edu
    Subject: Re: Probem writing a Ptolemy actor with POI/HSSF 
    
    
    Hi Wayne,
    
    You will need to start a new Cygwin bash shell to see the new value of
    $CLASSPATH.
    
    To verify that CLASSPATH is set, start up Cygwin bash and run:
    
        echo $CLASSPATH
    
    $PTII/bin/vergil -v works fine for me, I suspect we are running different
    vergil scripts or binaries.
    
    Below, in a Cygwin bash shell, I set CLASSPATH, verify it, set PTII, verify
    it and run vergil -v
    
    
    [EMAIL PROTECTED] ~
    $ export
    "CLASSPATH=c:/Ptolemy/ptII5.0-beta/poi/poi-2.5.1-final-20040804.jar;${CLASS
   P
    ATH}"
    
    [EMAIL PROTECTED] ~
    $ echo $CLASSPATH
    c:/Ptolemy/ptII5.0-beta/poi/poi-2.5.1-final-20040804.jar;.;C:\PROGRA~1\JMF2
   1
    ~1.1E\lib\sound.jar;C:\PROGRA~1\JMF21~1.1E\lib\jmf.jar;C:\PROGRA~1\JMF21~1.
   1
    E\lib;C:\WINDOWS\java\classes;.;"C:\Program
    Files\Java\j2re1.4.2_08\lib\ext\QTJava.zip"
    
    [EMAIL PROTECTED] ~
    $ cd c:/Ptolemy/ptII5.0-beta
    
    [EMAIL PROTECTED] /cygdrive/c/Ptolemy/ptII5.0-beta
    $ export PTII=c:/Ptolemy/ptII5.0-beta
    
    [EMAIL PROTECTED] /cygdrive/c/Ptolemy/ptII5.0-beta
    $ echo $PTII
    c:/Ptolemy/ptII5.0-beta
    
    [EMAIL PROTECTED] /cygdrive/c/Ptolemy/ptII5.0-beta
    $ cd $PTII
    
    [EMAIL PROTECTED] /cygdrive/c/Ptolemy/ptII5.0-beta
    $ $PTII/bin/vergil -v
    "/cygdrive/c/j2sdk1.4.2_08/bin/java" -Xmx256M
    "-Dptolemy.ptII.dir=c:/Ptolemy/ptII5.0-beta" -Duser.language=en
    -Duser.region=US -classpath
    "c:\Ptolemy\ptII5.0-beta;c:/Ptolemy/ptII5.0-beta/lib/diva.jar;c:/Ptolemy/pt
   I
    I5.0-beta/lib/ptCal.jar;c:/Ptolemy/ptII5.0-beta/lib/java_cup.jar;c:/Ptolemy
   /
    ptII5.0-beta/lib/ptcolt.jar;c:/Ptolemy/ptII5.0-beta/lib/sootclasses.jar;c:/
   P
    tolemy/ptII5.0-beta/lib/jasminclasses.jar;c:\j2sdk1.4.2_08\jre\lib\rt.jar;c
   :
    /Ptolemy/ptII5.0-beta/lib/ptjacl.jar;c:/Ptolemy/ptII5.0-beta/lib/jython.jar
   ;
    ;C:/Program
    Files/java/j2re1.4.2_08/lib/ext/QTJava.zip;c:/Ptolemy/ptII5.0-beta/lib/maps
   s
    .jar;c:/Ptolemy/ptII5.0-beta/lib/saxon7.jar;c:/Ptolemy/ptII5.0-beta/vendors
   /
    misc/x10/tjx10p-11/lib/x10.jar;c:/Ptolemy/ptII5.0-beta/poi/poi-2.5.1-final-
   2
    0040804.jar;.;C:\PROGRA~1\JMF21~1.1E\lib\sound.jar;C:\PROGRA~1\JMF21~1.1E\l
   i
    b\jmf.jar;C:\PROGRA~1\JMF21~1.1E\lib;C:\WINDOWS\java\classes;.;\"C:\Program
    Files\Java\j2re1.4.2_08\lib\ext\QTJava.zip\""
    ptolemy.vergil.VergilApplication Opening user library C:\Documents and
    Settings\cxh\.ptolemyII\UserLibrary.xml...
     Done
    
    [EMAIL PROTECTED] /cygdrive/c/Ptolemy/ptII5.0-beta
    $
    
    
    The message about "Cannot set parameter -v" indicates that there is
    something wrong with the command line argument parsing and that the -v is
    not getting getting handled.
    
    One problem could be that you are running the Windows Installer vergil
    binary instead of $PTII/bin/vergil.
    
    For example, if I run the Windows Installer vergil-full.exe binary with
    ./vergil-full.exe -v Then I see such a message.
    
    Also, it looks like the DOS batch file $PTII/bin/vergil.bat does not
    properly handle -v.  If you are running in a DOS shell, you could edit
    $PTII/bin/vergil.bat and remove the 
       @echo off
    line
    Also, you will need to restart your DOS shell to see the new value of
    CLASSPATH.  You can verify the value in a DOS shell with:
       echo %CLASSPATH%
    
    Try using $PTII/bin/vergil instead of vergil from within Cygwin bash.
    
    If you are still having problems, send me the contents of 
        sh -x $PTII/bin/vergil -v
    
    For information about setting up copy and paste under bash, see
       http://ptolemy.eecs.berkeley.edu/ptolemyII/ptII5.0/cygwin.htm
    
    Compiling RangeReader under DOS should not present a problem. Once you have
    the RangeReader .class file in the right place, then things should work.
    
    Feel free to send me email directly if you continue to have problems.
    
    BTW - Professor Lee and I were both C++ programmers when we first learned
    Java.  We found the O'Reilly "Java in a nutshell"
    (http://www.oreilly.com/catalog/javanut3/) book to be very valuable. We wer
   e
    using the 1st ed., but I'm guessing the current version is quite good.  In
    fact, if you click on the Edward's picture on his home page
    (http://ptolemy.eecs.berkeley.edu/~eal), you will see him reading that book
   .
    
    _Christopher
--------

----------------------------------------------------------------------------
Posted to the ptolemy-hackers mailing list.  Please send administrative
mail for this list to: [EMAIL PROTECTED]

Reply via email to