|
|
 | | From: | Christopher Brooks | | Subject: | Re: SequenceToArray in PN | | Date: | Tue, 14 Dec 2004 13:35:56 -0800 |
|
|
 | Fixed! I also added a test to pn/test/auto.
_Christopher
--------
Ahh! You're right--good catch! So if I made the following change to SequenceToArray, then it works: $ cvs diff ptolemy/domains/sdf/lib/SequenceToArray.java Index: ptolemy/domains/sdf/lib/SequenceToArray.java =================================================================== RCS file: /home/cvs/cvsanon/ptII/ptolemy/domains/sdf/lib/SequenceToArray.java,v retrieving revision 1.47 diff -r1.47 SequenceToArray.java 132c132,134 < Token[] valueArray = input.get(0, length); --- > > Token[] valueArray = new Token[length]; > System.arraycopy(input.get(0, length), 0, valueArray, 0,length); If this looks OK, will someone from Ptolemy please commit such a change to CVS, so that it will make it into the next release? Thanks! Xiaowen On 13.12.2004, at 22:44, Neil E. Turner wrote: > > I found this in the JavaDocs for IOPort.get(int channelIndex, int > vectorLength) > > "Get an array of tokens from the specified channel. The parameter > channelIndex specifies the channel and the parameter vectorLength > specifies > the number of valid tokens to get in the returned array. The length of > the > returned array can be greater than the specified vector length, in > which > case, only the first vectorLength elements are guaranteed to be valid." > > If you "look inside" the SequenceToArray actor you will see the Java > code... > go to the fire() method. You will see in the code > > Token[] valueArray = input.get(0, length); > > I put a print statement to see the length of 'valueArray'. It indeed > was > longer than the PortParameter 'arrayLength'. > > Neil > > > ----- Original Message ----- > From: "xiaowen" > To: > Cc: "xiaowen Xin" ; "Kepler-Dev" > > Sent: Monday, December 13, 2004 8:13 PM > Subject: SequenceToArray in PN > > >> Hi Everyone, >> >> >> Is the SequenceToArray actor meant to be used in the PN domain? I've >> attached a workflow that demonstrates behavior that I don't >> understand. >> >> A SequenceToArray actor has two ports: input and arrayLength. It >> should package up arrayLength number of input tokens into an array and >> send that out along its output port. >> >> In the attached workflow, I send 7, then 2 to the arrayLength port. >> However, the output consists of two array tokens both with length 7. >> >> Can someone please explain to me why the second output isn't an array >> of length 2? >> >> I'm using Ptolemy 4.0.1. >> >> >> Thanks in advance! >> Xiaowen >> >> > > > ----------------------------------------------------------------------- > ----- > Posted to the ptolemy-hackers mailing list. Please send administrative > mail for this list to: > ptolemy-hackers-request@ptolemy.eecs.berkeley.edu --------------------------------------------------------------------------- - Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: ptolemy-hackers-request@ptolemy.eecs.berkeley.edu --------
---------------------------------------------------------------------------- Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: ptolemy-hackers-request@ptolemy.eecs.berkeley.edu
|
|
|