[kepler-users] receiving tokens on different ports

Edward A. Lee eal at eecs.berkeley.edu
Sat Aug 15 06:30:11 PDT 2009


Seems like what you need is for multiple actors to be able to share
one display object. This might be a better design than using extended
PN, which will be very domain-specific (it will only work with the PN
director).

I suggest creating a static class to manage the display, or a class
with a singleton instance accessible through a static variable or
static method. Then I would give the shared display a name, and
each actor that wants to write to it would call the static method
in initialize() to access it.  If it doesn't yet exist, it will
be created at that point.

Of course, this requires thread programming (as does the extended
PN approach), which is quite difficult to get right.

An even better approach might be to subclass Ptolemy's SharedParameter
to be your shared display manager.  Then the sharing of the object
across a model is already taken care of for you.

Good luck!

Edward


Chris Weed wrote:
> Yea, the idea of using multiple inputs is that the display is going to
> be a GIS display
> with different data layers. Each channel connected to the display will
> be a different
> layer in the display. So one layer could be a series of detections on
> top of another
> layer with some aerial imagery, etc. These input data sources will
> feed data at different
> times, but the idea is that it would update that layer as the data comes in.
> I will look into the extended PN model to see if that fits, or maybe
> try the threading.
> I'm sorry I wasn't a little more specific about what the display shows,
> and the use case.
> Chris
> 
> On Fri, Aug 14, 2009 at 1:20 PM, Edward A. Lee<eal at eecs.berkeley.edu> wrote:
>> PN has "blocking read" semantics. Here is a paper on why this is:
>>
>> http://ptolemy.eecs.berkeley.edu/publications/papers/95/processNets/
>>
>> A consequence is that in PN, there is no such thing as a port
>> that has no input token available.
>>
>> There are two ways to accomplish what you want:
>>
>> 1) Build an actor in extended PN that is nondeterminate.
>>   The NondeterminateMerge actor can serve as a model.
>>
>> 2) Use multiple actors. This seems like the right solution.
>>   Why do you want this in one actor?  Anything the actors
>>   post to the GUI has to be done in the event thread anyway,
>>   so there is no real advantage to having them in separate
>>   threads...
>>
>> Edward
>>
>>
>> Chris Weed wrote:
>>> I am creating a custom display that receives different data types on
>>> different ports,
>>> image URL on one, GML data on another, etc.
>>> When my actor fires, any one of these ports could have new data.
>>> How do I figure out which one when I am using the PN director?
>>> Normally, I would just loop through all of the ports, but
>>> won't the port always return true for hasToken and then block when I call
>>> port.get()?
>>> I am confused how this should work.
>>> Chris
>>> _______________________________________________
>>> Kepler-users mailing list
>>> Kepler-users at kepler-project.org
>>> http://mercury.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users
-------------- next part --------------
A non-text attachment was scrubbed...
Name: eal.vcf
Type: text/x-vcard
Size: 351 bytes
Desc: not available
URL: <http://lists.nceas.ucsb.edu/kepler/pipermail/kepler-users/attachments/20090815/088d4d4a/attachment.vcf>


More information about the Kepler-users mailing list