Top Up Prev Next Bottom Contents Index Search

2.5 Particle types

The packets of data that pass from one star to another in Ptolemy are called particles. So far, all particles have simply been floating-point numbers representing samples of signals. However, several other data types are supported. Each star icon has a stem for each porthole. In pigi, if you are using a color monitor, the color of the stem indicates the type of data that the porthole consumes or produces, as summarized in table 2-5
. A blue stem on an input or output of a star icon indicates type "float", a purple stem indicates type "fix" for fix-point particles, a white stem indicates type "complex", an orange stem indicates type "int" for integer particles, a green stem indicates "message", a black stem indicates type "string", a yellow stem indicates type "file", and a red stem indicates "anytype". The "message" type is a user-defined data type (see the programmer's manual). A star that operates on "anytype" particles is said to be polymorphic. Polymorphic stars operate on multiple types of data. For example, a Printer star can produce a textual representation of any type of particle. In addition, stars which input or output Matrix type particles have stems which are extra thick with colors corresponding to the four main types, float, int, complex, and fix.

Ptolemy usually makes conversions between numeric particle types automatically. The float to complex conversion does the obvious thing, putting the float value into the real part of the complex number and setting the imaginary part to zero. The complex to float conversion computes the magnitude of the complex number. Int to float is easy enough. Float to int rounds to the nearest integer.

The Xscope star, and some other stars that generate output, accept "anytype" of input. However Xscope isn't completely polymorphic, because it converts all inputs to float internally. So for a complex input, the magnitude will be plotted. If you want to plot both the real and imaginary parts you should use the ComplexReal conversion star first.

In some situations automatic type conversions cannot be made. A common difficulty involves several outputs of different types feeding a Merge star. Ptolemy must assign a specific type to the Merge star's output, but in this case it will be unable to decide which type to use, so it will complain that it "can't determine DataType" for the output. The solution is to insert one or more type conversion stars, so that all the values arriving at the Merge star have the same type. (The type conversion stars can be found in the "conversion" palette of the appropriate domain. It will be explained below how to find this.)

There are no automatic conversions between matrix particles and scalar particles; in fact the matrix particle types do not support automatic type conversion at all. Conversion stars need to be explicitly inserted between two stars that work on different Matrix types.

Some domains are more restrictive about particle type conversions than others. Assignment of types to ANYTYPE portholes and resolution of type conflicts is discussed further in section 4.6 of the Ptolemy Programmer's Manual, and in the Ptolemy Kernel Manual.



Top Up Prev Next Bottom Contents Index Search

Copyright © 1990-1997, University of California. All rights reserved.