Contents
The CGC TychoTarget is an experimental target that provides a way to create CGC control panels that use the functionality in Tycho. A universe that uses TychoTarget must provide a script that creates the control panel that the user sees. Currently, all the TychoTarget demos implement real-time audio processing demos, and will only work on Sun work-stations.
For information about the Sun Audio system, see the Sun Audio page.
cd
$PTOLEMY/tycho; make tclexts
. TychoTarget uses
$PTOLEMY/tycho/obj.$PTARCH/tcl.mk
and
java.mk
.
To use TychoTarget, simply select TychoTarget from the Targets menu in your VEM window. By default, TychoTarget is set to compile the generated file, start a separate Tycho process, and load the generated system into Tycho. The generated file can also be compiled and loaded into a running Tycho "by hand" -- see below.
The key setting in the TychoTarget parameters window is the name
of the TychoTarget script file -- this is a Tcl file that is sourced
by the generated file after it has been loaded into Tycho, and is
where the control panel that the user sees is created. The scripts for
the TychoTarget demos are located in $TYCHO/typt/demo
. By
convention, the name of the script file is the name of the Ptolemy
universe with suffix .tcl
. For each script file, there is
also an HTML help file with suffix .html
.
Each star in your universe that can be controlled by TychoTarget
in real-time must have a unique identifier. Currently, this is
in the Edit Parameters window of the star as the starName
state.
TychoTarget generates a C file in a format that can be loaded into Tycho as a Tcl package. The Tcl package format is the standard one (see the book Tcl and the Tk Toolkit by John K. Ousterhout for details). Apart from the Tcl package interface, the generated file differs from that produced by the TclTkTarget in the following ways:
main()
function, TychoTarget
generates three functions: setup()
,
execute()
, and wrapup()
. These are called by
Tycho to manage execution of the program. (In theory, this allows us
to execute multiple generated systems within the one Tycho, but we
haven't demonstrated this yet.)
static
to
prevent name collisions with other packages.
execute()
is called, it is obliged to
return start the C timer and return when the timer expires. This is in
contrast to the TclTkTarget, in which the main loop starts the timer,
checks it on each iteration, and calls the Tk event loop when it
expires. (In effect, it's upside-down.)
The Tcl package format consists of two functions: an
initialization function called
universe-name_Init()
, which adds a new Tcl command
::tycho::universe-name
to Tycho, and a Tcl
interface function called (surprisingly enough..)
tclinterface()
. This function is included directly from
the file $PTOLEMY/tycho/src/tycgc/tclif.c.
The Tcl command ::tycho::universe-name
is used by the
Tycho scheduler class to execute the universe. Its first argument
controls what happens in the (generated) package:
tychoSetup()
function,
causing stars to tell Tycho what to do when controls
are moved by the user.
setup()
function. If
an additional argument is called, it is the name of a Tcl
variable that is updated with the iteration count after
each call to execute()
.
wrapup()
function.
universe-name.c
universe-name_ld.tcl
in the directory
~/PTOLEMY_SYSTEMS/TYCHO
.
::tycho::compileC
procedure within the
Tycho running in Ptolemy to compile the file, generating
.o
and .so
files.
universe-name_ld.tcl
filename as an argument that
Tycho will execute. The universe-name_ld.tcl
causes Tycho to load the universe-name.so
library,
and then execute the user interface script file. In the process,
Tycho will load the TyTimer
and TyCGC support packages.
Each star that has a state that can be controlled in real-time by
Tycho needs a unique, user-settable identifier. Currently, those stars
that support TychoTarget have a state called starName
that the user can set from the Edit parameters window.
Each star that has a state that can be controlled in real-time
must add code to the tychoSetup
code-block. This
code-block serves the same purpose as the tkSetup
code-block used with the TclTkTarget -- we introduced a new codeblock
because the interface functions to TychoTarget are different. Here is
a sample code-block (from $PTOLEMY/src/domains/cgc/tcltk/stars/CGCTkStereoIn.pl:
codeblock (tychoSetup) { /* Call tycho to connect a control to the volume parameter */ connectControl( moduleName, "$val(starName)", "volume", $starSymbol(setVolume)); }The arguments are:
Currently, connectControl
is the only interface
function provided. It is intended for controls that provide input over
a range, such as 0 to 100. It is implemented in the TyCGC support package. In future,
other interface functions will be added for one-of-many selection, so
that buttons can be added to custom interfaces.
Tycho contains support to make it easy to create custom user
interfaces for TychoTarget universes. One good source of information,
of course, is the existing demonstration files, in $TYCHO/typt/demo
.
The documentation on the operation of the Tycho portion of TychoTarget is in the Tycho documentatation tree:
ControlPanel
class, which is the top-level window
that control panels are embedded in. This class also manages
the calling interface between slider and button widgets and the
underlying C code generated by TychoTarget.
::tycho::controlpanel
procedure, which is responsible
for loading the compiled TychoTarget package.
$PTOLEMY/tycho/typt/controls
.
ptdsp
or on header files
such as those in $PTOLEMY/src/ptklib
will not currently work with TychoTarget.
tychoSetup
code-block
will run with TychoTarget but their parameters cannot be accessed from
Tycho.
update
command works. Anything that deals
with Tcl update
is inherently flaky. We still need to do
more work on making the scheduling more robust.