Constraints with assignment to parameters

2004-05-21 Thread Marija Surnaite
Hello,
we are three students from Aalborg University. We are using Ptolemy II 
for our study project. We encountered a few problems and would like to 
know if they are constraints of Ptolemy II or if we are just doing 
things in the wrong way.

1) In expression editor it is normal to assign a value to a variable. In 
 an Expression actor we tried to assign a value to a parameter and 
it throws a parsing error.
In FSM model, assigning to a parameter (set action) works correctly.

2) We decided to model a block of RAM as an array (FSM model). We put a 
parameter named RAM and assigned initial values as following:
([1:1:length]*0.0).toArray()
We encountered a problem while assigning a value to a element of this 
array (set action RAM[c]=value, where c is a parameter with integer 
value). The expression says that it requires INTEGER instead of c.

We would be really grateful if anyone could explain these problems
 Regards,
Marija

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


Re: Constraints with assignment to parameters

2004-05-21 Thread Edward A Lee
The expression language itself is not a programming language.
It does not have statements (sequencing of operations) nor
does not support assignments...  It supports just expressions.
The result of evaluating an expression is an immutable (unchangable)
token. If the result is an array, you cannot modify the elements
of the array.  You would have to create a new array.
FSM augments the expression language with assignments, but this
makes sense because FSM has sequencing in its semantics.
If what you really want is a scripting capability, I suggest
using the Python actor.  Then you have a full programming language
accessible rather than just an expression language.  You can
also use Matlab as a scripting language using the MatlabExpression
actor.
Edward
At 12:55 PM 5/21/2004 +0200, Marija Surnaite wrote:
Hello,
we are three students from Aalborg University. We are using Ptolemy II for 
our study project. We encountered a few problems and would like to know if 
they are constraints of Ptolemy II or if we are just doing things in the 
wrong way.

1) In expression editor it is normal to assign a value to a variable. 
In  an Expression actor we tried to assign a value to a parameter and 
it throws a parsing error.
In FSM model, assigning to a parameter (set action) works correctly.
2) We decided to model a block of RAM as an array (FSM model). We put a 
parameter named RAM and assigned initial values as following:
([1:1:length]*0.0).toArray()
We encountered a problem while assigning a value to a element of this 
array (set action RAM[c]=value, where c is a parameter with integer 
value). The expression says that it requires INTEGER instead of c.


Edward A. Lee, Professor
518 Cory Hall, UC Berkeley, Berkeley, CA 94720
phone: 510-642-0455, fax: 510-642-2739
[EMAIL PROTECTED], http://ptolemy.eecs.berkeley.edu/~eal

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


Re: Ptolemy applets problems

2004-05-21 Thread Christopher Hylands Brooks
Efrat Jaeger [EMAIL PROTECTED] writes:
-
I created the following applet,
http://users.sdsc.edu/~efrat/workflows/queryPGAP.htm, very similar to
the demo applets. Apparently it loads on some computers but on others I
get a java.lang.NoClassDefFoundError: ptolemy/actor/gui/MoMLApplet
error. On the same computers the existing demo applets load perfectly. I
wasn't able to figure out what causes the exception. Does anyone have
any suggestions?
-

Applets are notoriously tricky to get right.
I looked over the source code and did not see anything obvious. 

There is some documentation at
http://ptolemy.eecs.berkeley.edu/ptolemyII/ptIIlatest/ptII/doc/coding/applets.htm

and there is a custom applet chapter in Volume 2 of the Ptolemy II
design doc:
http://ptolemy.eecs.berkeley.edu/papers/03/ptIIDesignSoftware

The applet code you are using is the complex applet code that
will work under Netscape 4.x.  If you do not require support
of Netscape 4.x, then you could use the much simpler 
applet
..
/applet
code.

In fact, for debugging, I would use the simple applet code so
that you are testing the same html code on the different platforms.

Another trick is to look at the website logs and see what files
are being downloaded.

With Java 1.4.2, I noticed that if a class was loaded from a jar
file, then it seemed like the applet class loader would not
find individual .class files on the file system.  The solution
was to make sure and have the archive= tag include jar
files that included all the .class files.  I'm not
sure about the details of this new behaviour, I poked
around on the Sun website but did not see anything.

When I tried to run your applet, I had to install Java 1.4.1_02,
the applet would not run with Java 1.5.0-beta under Mozilla.

Applets can have dynamic versioning or static versioning.

Dynamic versioning permits a JRE greater or equal to a a certain
version to be used.

Static versioning requires that a certain version of JRE 
be used.

The details are covered in:
  http://java.sun.com/products/plugin/versions.html

From the title tag, it looks like your applet is based on one of the
Ptolemy Eye applets.

It looks like your applet and the Ptolemy II 3.0 SDF Eye applet are
using dynamic versioning under IE, but static versioning under
Mozilla?  This would be a bug.

The IE section says:
   classid=clsid:8AD9C840-044E-11D1-B3E9-00805F499D93
which
http://java.sun.com/products/plugin/versions.html
indicates is for dynamic versioning.

The Netscape section says:
   application/x-java-applet;jpi-version=1.4.1_02
http://java.sun.com/products/plugin/versions.html
indicates is for static versioning.

The applet code shipped in Ptolemy II 3.0 in theory uses static
version to restrict the version of the JVM can be used to 1.4.1_02.
This was done because of a bug in 1.4.1 and 1.4.1_01 that machines
that use a particular video chip set to hang.  Since Professor Lee and
I were affected by this bug, we restricted the JVM choice to 1.4.1_02.
I tried to make the applet use dynamic versioning for Netscape so
we would accept 1.4.1_02 or greater, but could not
get this to work, it appeared to be a problem with the patch level.

If possible, it is better to use dynamic versioning.
The Ptolemy II 4.0 applets use dynamic versioning correctly to
require Java 1.4.2 or later.  In principle, Java 1.5.0-beta
should work with these applets.

In general, applets have restrictions:

1) Don't use the readFile() expression function in a model that
is within an applet.  This is because of restrictions in the
applet class loader.

2) If possible, use the simple applet .../applet code
and avoid the really complex javascript code.  If you really
think you need to support Netscape 4.x, consider looking
at the web server logs for the number of Netscape 4.x users
and evaluate the cost of supporting applets for those
users.  Note that Ptolemy II 4.0 supports Netscape 4.x.
Perhaps the next release of Ptolemy II applets will not
support Netscape 4.x?

3) The MoMLViewerApplet class does not permit look inside.
It would be cool if we could use the Single Window interface created
by Thales within an applet.
To run the single window interface in Ptolemy II 4.0, do
   $PTII/bin/vergil -single
The idea would be to create an applet that would use this interface

4) The code generator will generate applets for a model. 
See $PTII/doc/codegen.htm for somewhat out of date documentation.
There will be a chapter in the design doc about how to use the
applet generator.

5) For vergil applets, it might be better to create Web Start
versions.  I noticed that the Java Event Listener Tutorial
is now using Web Start, see
http://java.sun.com/docs/books/tutorial/uiswing/events/example-1dot4/
I started hacking up the applet code generator to generate both
applets and Web Start configurations, but I never really finished
that work

BTW - If you use the controls parameter in your applet, then users
can run the applet.  
To do this,