Ptolemy II is statically typed, so after a model is preinitialized, the types of all ports must be known. The type system is described in chapter 5 of this document:
http://www.eecs.berkeley.edu/Pubs/TechRpts/2008/EECS-2008-29.html and also in this paper: http://chess.eecs.berkeley.edu/pubs/665.html For Record types, the most general record type is the empty record type. That is, a record type {fieldName = double}, for example, is also an instance of {}, the empty record type. Moreover, a record of type {a = int, b = double} is also an instance of {a = int}. So, for example, if you know that your output record will contain a field named "a" of type "int", then you can force the output type to be {a = int} (right click on the actor, select Configure Ports, and enter "{a = int}" in the type field). As long as there is actually such a field, in the record, this will work. But if you run the model and there is no such field, I believe you will get a run-time type error (which is probably what you want). Edward On 4/2/12 1:51 PM, Hogan, D. (GE Energy) wrote:
I have an actor that uses the structure of a file generated at runtime to create an output record. The actor is working, but I have a few questions on ObjectToRecord since it is similar. In ObjectToRecord, it does not change the type and lists it as fixme. The documentation for RecordType mentions using setTypeAtMost(new RecordType(new String[0], new Type[0])) when you want to specify a record without specifying the fields. Should I use that? Is there a better way to specify it is a record and the field names/types are discovered at runtime? Since unknown matches that type constraint, what is the best way to handle this? ObjectToRecord doesn't try to convert between standard Java types and Ptolemy types. I noticed there is a ptolemy.data.expr.ConversionUtilities, but it looks limited to the expression language needs. Is there another conversion in Kepler? _______________________________________________ Kepler-dev mailing list [email protected] http://lists.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-dev
<<attachment: eal.vcf>>
_______________________________________________ Kepler-dev mailing list [email protected] http://lists.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-dev
