On Aug 3, 2007, at 11:53 AM, Stephen Neuendorffer wrote:

I think you want to use setTypeAtLeast(), not setTypeEquals().

However, likely this is insufficient to get the rest of the
model to typecheck unless you at least determine an arrayType
during preinitialize that has the correct element type.  You'll
probably at least need to use the single argument ArrayType
constructor to specify the element type...

Ah.. That did the trick. Thanks!


Steve

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On
Behalf Of Nathan Potter
Sent: Friday, August 03, 2007 11:27 AM
To: ptolemy-hackers@eecs.berkeley.edu
Cc: Nathan Potter
Subject: Output Port Configuration



Greetings,

I am new Ptolemy, and I am working on a data source actor for
Kepler.
I need to dynamically configure the output port(s) based on
Actor parameters that the user sets.

Because the data repository that the user is accessing may be
quite large it is important not to attempt to download the
entire thing. By adjusting the parameters of the Actor the
user can cause the repository server to subset the data prior
to tranmission. This sub- setting will cause the
shape/structure of the returned data to change.

Ideally, I would like the actor to get the shape/structure
metadata when the user changes the parameters (Say in my
attributeChanged() method). At this point change the output
port configuration to match the request. Then at "fire" time,
download the data and push it out the output port.

My issue is this:

I have a question about Type vs Token and getting Type values
for configuring ports.

In BaseType, there are a bunch of static Type members like
BaseType.INT, BaseType.DOUBLE, etc

But the only array type is ARRAY_BOTTOM. (When I ask an
ArrayToken for it's Type and run a toString() on the returned
class I get something like arrayType(double,16))

If I try Setting the array types to BaseType.ARRAY_BOTTOM :


         Enumeration e = dds.getVariables();
         int i =0;
         while (e.hasMoreElements()) {
             opendap.dap.BaseType bt = (opendap.dap.BaseType)
e.nextElement();
             labels[i] = bt.getName();
             // mapDapObjectToType  maps the types and all
array types get returned as BaseType.ARRAY_BOTTOM
             types[i] = mapDapObjectToType(bt);
             i++;
         }

         RecordType declaredType = new RecordType(labels, types);

         output.setTypeEquals(declaredType);



The output port finds the actually ArrayTokens incompatible
with the ARRAY_BOTTOM Type:

      [java] ptolemy.kernel.util.IllegalActionException:
Run-time type checking
      failed. Token {lat = {50.0, ...

      *snip*

      -27}} with type {lat = arrayType(double,17), lon =
arrayType (double,21),
      time = arrayType(double,16), u = arrayType(int,5712), v
= arrayType(int,5712)}
      is incompatible with port type: {lat = arrayBottom,
time = arrayBottom,
      u = arrayBottom, v = arrayBottom}


I was trying to avoid getting all of the data every time a
user changes the access URL. What I would like to do is get
the "shape" of the data and modify the output port to reflect
it. Then in fire() go and get the data and push it out onto the port.

But... I can't figure out how to do the array type mapping
with out creating the actual ArrayTokens which either
requires that I make empty ones and pitch them out (ew...) or
read the data into them and cache them for fire time (the
result is that the data gets read in total every time the
attributeChanged() method is called with new
parameters)


So... Is there a way to know/identify the Type of an
ArrayToke until it's instantiated?



Nathan


= = =
Nathan Potter                        ndp at opendap.org
OPeNDAP, Inc.                        541.752.1852



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




= = =
Nathan Potter                        ndp at opendap.org
OPeNDAP, Inc.                        541.752.1852



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

Reply via email to