Modeling using PTcl - The Ptolemy Tcl interpreter


There are a few ways to work with MLDesigner: Firstly using the graphical user interface (GUI), and secondly using the built-in interpreter. This combination allows you to interact with MLDesigner using both graphical elements and textual commands. The MLDesigner GUI is described in Modeling with MLDesigner→Graphical User Interface. The MLDesigner built-in interpreter is called PTcl interpreter, where PTcl stands for Ptolemy Tool Command Language. It conveniently operates within the PTcl Shell window of MLDesigner. This chapter holds information about using the PTcl Shell.

The Ptolemy interpreter accepts input commands from the keyboard, from a file, or from combinations thereof. It allows you to set up a new simulation by creating instances of blocks (primitives, modules, or wormholes), connecting them together, setting the initial values of parameters, and running/restarting the simulation. It allows simulations to be run in batch mode.

PTcl is based on John Ousterhout's tool command language Tcl, pronounced "tickle", which is an extensible interpreted language. All the commands of Tcl are available in PTcl.

PTcl extends the Tcl interpreter language by adding new commands. The underlying grammar and control structure of Tcl are not altered. Commands in Tcl are string based with relatively few constructs and a simple syntax: the basic syntax is

command arg1 arg2 arg3 . . .

This chapter describes only the extensions to Tcl made by PTcl. Two excellent references on Tcl are books by Ousterhout 1 and Welch 2.

The interpreter has a list containing all the classes of primitives and modules it currently knows about. New primitives can be added to the list at run time by using the incremental linking facility, but this has restrictions (see Dynamically link new primitives).

Remember that the Ptolemy vocabulary for models and parameter differs from that in MLDesigner: star refers to primitive, galaxy refers to modules, universe refers to system, and state refers to parameter. Therefore, some PTcl commands still contain the Ptolemy vocabulary.

PTcl commands

A wormhole example

An example of a simulation that contains both an SDF part and a DE part.

PTcl as simulation control language

1 John K. Ousterhout. An Introduction to Tcl and Tk. Addison-Wesley Publishing Company Inc., Reading, MA, 1994.

2 Brent Welch. Practical Programming with Tcl and Tk. Prentice-Hall Inc., Englewood Cliffs, NJ, 1997.