Hi Saeed, I'm not totally sure I understand the bug. Type conversion in record tokens is subtle. The RecordType class comment says: --start-- Note that a record type with more fields is a subtype of a record type with a subset of the fields. For example, {x = double, y = int} is a subtype of {x = double}. When a record of type {x = double, y = int} is converted to one of type {x = double}, the extra field is discarded. The converted record, therefore, will have exactly the fields in the type.
A consequence of this is that all record types are subtypes of the empty record type. Hence, to require that a typeable object be a record type without specifying what the fields are, use typeable.setTypeAtMost(new RecordType(new String[0], new Type[0])); Note, however, that by itself this type constraint will not be useful because it does not, by itself, prevent the type from resolving to unknown (the unknown type is at the bottom of the type lattice, and hence satisfies this type constraint). --end-- My reading of the above, which I may have wrong, is that conversion from {x = double, y = int} to {x = double} is ok, but conversion from {x = double} to {x = double, y = int} is not permitted. In your error, it looks like the "from" token does not have a MES field, hence the error. You say you have four different record types. Perhaps you need to define your own token type that can handle these different record types? See ptolemy/data/type/test/TestToken.java and ptolemy/actor/lib/security/KeyToken.java for sample Token implementations. You would need to extend RecordToken and do quite a bit of work in the convert() method to get things right. Another hack is to pass ObjectTokens around instead of RecordTokens. Then you lose the type safety of RecordTokens, but things just work. >From your stack trace, it looks like you are running Ptolemy II 5.x. Can you update to Ptolemy II 6.0.1? _Christopher -------- Dear Reader According to previous question i send it and also i tested it again i send results. I want to have an TypedIOPort that sends messages to other actors. but my messages have 4 different record types that fields of each message varies with others. i did many works but i failed. for each message type i use such type changeing for output Port. for example i did in fire method of my actor as below String[] labels = {"TID" , "NAP" , "LID" , "SLID" , "MES"}; Token[] values = { TID, new IntToken(_NodeID) , new IntToken(_NodeID), new IntToken(_NHval) , new IntToken(_AEval) }; Token result = new RecordToken(labels, values); Type t = result.getType(); output.setTypeEquals(t); output.send(0,result); but when in next token i want to change type of message i see error message as below: java.lang.IllegalArgumentException: Conversion is not supported from ptolemy.data.RecordToken '{AE = 0, LID = 0, NAP = 0, NH = 1, TID = {INS = 43947, LI = 9, MT = 0, SN = 1, TLOC = {100, 43}}}' to the type {LID = int, MES = int, NAP = int, SLID = int, TID = {INS = int, LI = int, MT = int, SN = int, TLOC = {int}}}. at ptolemy.data.type.RecordType.convert(RecordType.java:153) at ptolemy.actor.TypedIOPort.convert(TypedIOPort.java:322) at ptolemy.actor.AbstractReceiver.putToAll (AbstractReceiver.java:315) at ptolemy.actor.IOPort.send(IOPort.java:2344) at ptolemy.actor.TypedIOPort.send(TypedIOPort.java:468) at ptolemy.domains.wireless.lib.SSensor.fire(SSensor.java:116) at ptolemy.domains.de.kernel.DEDirector.fire(DEDirector.java:507) at ptolemy.actor.CompositeActor.fire(CompositeActor.java:331) at ptolemy.domains.de.kernel.DEDirector.fire(DEDirector.java:507) at ptolemy.actor.CompositeActor.fire(CompositeActor.java:331) at ptolemy.actor.Manager.iterate(Manager.java:668) at ptolemy.actor.Manager.execute(Manager.java:327) at ptolemy.actor.Manager.run(Manager.java:1044) at ptolemy.actor.Manager$3.run(Manager.java:1085) Type t = result.getType(); output.setTypeEquals(t); Type s = output.getType(); // attributeChanged( outputType); String St= new String(s.toString()+"SMessage"); Token Sta = new StringToken(St); str.send(0,Sta); i added new port and tested the effect of setTypeEquals(t) excution output.getType() instruction showed me that this instruction works properly but in running example each time i see that my port works with previous type setting not currently applied setting. i see that i can't change type of my output before sending message with best regards Saeid Pashazadeh --------------------------------------------------------------------------- - Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED] -------- ---------------------------------------------------------------------------- Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED]