[kepler-dev] Token Types: resolving, setting etc
Christopher Brooks
cxh at eecs.berkeley.edu
Wed Oct 20 08:18:59 PDT 2010
Hi Panickos,
Offhand, I'm not sure. Records are a little complex.
The Ptolemy Design docs are at
http://ptolemy.eecs.berkeley.edu/ptolemyII/designdoc.htm
Chapter 5 of Volume 2 covers the type system.
Also, there is a chapter about the expression language that
in Volume 1 that covers Records.
There is a more up to date version at
http://ptolemy.eecs.berkeley.edu/ptolemyII/ptIIlatest/ptII/doc/expressions.pdf
What I do for problems like this is search the tree for similar code.
Searching for "new RecordType", I find
ptolemy/domains/wireless/lib/LimitedRangeChannel.java
which has:
// Force the type of the defaultProperties to at least include
// the range field.
String[] labels = { "range" };
Type[] types = { BaseType.DOUBLE };
RecordType type = new RecordType(labels, types);
// Setting an upper bound allows the addition of fields.
defaultProperties.setTypeAtMost(type);
Note this uses setTypeAtMost() instead of setTypeEquals() in your
example. You might try calling setTypeAtMost().
You might look at other code that calls "new RecordType"
Also, creating a small test case could help you.
However, I'm not totally sure what will happen when you pass a record
to an actor that takes an untyped token. It should just work out,
but a test case would be helpful. Maybe look for Ptolemy actors that
have Record outputs and try connecting them to an actor that takes a generic
type?
Hope this helps, let me know how it goes.
_Christopher
On 10/20/10 3:25 AM, Panickos Neophytou wrote:
> Hi all,
>
> I'm trying to use a RecordType token that has just 2 fields: {long, Token}
>
> When I declare a port that outputs token of this record type (on an
> actor that I have implemented)
>
> outputPort.setTypeEquals(new RecordType(new
> String[]{EventRecordToken.TIMESTAMP_LABEL,
> EventRecordToken.VALUE_LABEL}, new Type[]{BaseType.LONG,
> BaseType.STRING}));
>
> and connect it to a port that accepts type generic I get this error:
>
> "Types resolved to unacceptable types in .workflowName due to the
> following inequalities:
> (ptolemy.actor.TypedIOPort {...output port info here...},unknown)<=
> (ptolemy.actor.TypedIOPort {...input port info here...}, general)"
>
> Why is the port type resolved as Unknown?
>
> I don't quite understand how the type framework works. Is there some
> documentation about the types?
> The input port is on a TextDisplay actor. Shouldn't it just display
> the contents of the records without any problems?
>
> I thought I'd ask for some directions before digging deeper.
>
> Thanks,
> Panickos
>
> -------------------------------------
> Panickos Neophytou
> Advanced Data Management Technologies Lab
> Department of Computer Science, University of Pittsburgh
> http://www.cs.pitt.edu/~panickos
> _______________________________________________
> Kepler-dev mailing list
> Kepler-dev at kepler-project.org
> http://lists.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-dev
--
Christopher Brooks, PMP University of California
CHESS Executive Director US Mail: 337 Cory Hall
Programmer/Analyst CHESS/Ptolemy/Trust Berkeley, CA 94720-1774
ph: 510.643.9841 fax:510.642.2718 (Office: 545Q Cory)
home: (F-Tu) 707.665.0131 cell: 707.332.0670
More information about the Kepler-dev
mailing list