In comp.soft-sys.ptolemy,  Bill Ng writes:

> In my acadamic project, we need to write a new GUI on top of vergil
> and to run the model made by vergil.

That is a fairly big project!

> If I have a model xml file (
> c:/cygwin/ptII/ptolemy/vergil/project/model.xml), how can I use
> RunTableau to run the Model like in
> ptolemy/vergil/Basic/BasicGraphFrame.java .
> 
>  /** Open a run control window. */
>       public void actionPerformed(ActionEvent e) {
>           try {
>               PtolemyEffigy effigy =
>                   (PtolemyEffigy)getTableau().getContainer();
>               new RunTableau(effigy, effigy.uniqueName("tableau"));
>           } catch (Exception ex) {
>               MessageHandler.error("Execution Failed", ex);
>           }
>       }
>     }
> ************************************************


Right, the Effigy/Tableau design pattern is a little complex.
Effigy is another word for Model and Tableau is another word for View
Effigy was chosen so that we could avoid confusing Ptolemy models
with GUI models.

The RunTableau creates a run control panel and runs it.

You might look at how actor.gui.PtolemyApplication invokes a model

Try:
cd $PTII
$PTII/bin/ptolemy ptolemy/moml/demo/modulation.xml


PtolemyApplication gets configured by
ptolemy/configs/runPanelConfiguration.xml
which registers tableau and effigy factories to that bring up the run
control panel and possibly the html viewer.

Basically, when file is opened, each factory is called in order until
a factory decides that it can handle the file in question.

The key part is RunTableau.Factory.createTableau():

        /** If the specified effigy already contains a tableau named
         *  "runTableau", then return that tableau; otherwise, create
         *  a new instance of RunTableau for the effigy, and
         *  name it "runTableau".  If the specified effigy is not an
         *  instance of PtolemyEffigy, then do not create a tableau
         *  and return null. It is the responsibility of callers of
         *  this method to check the return value and call show().
         *
         *  @param effigy The model effigy.
         *  @return A new run tableau if the effigy is a PtolemyEffigy,
         *    or null otherwise.
         *  @exception Exception If the factory should be able to create a
         *   tableau for the effigy, but something goes wrong.
         */
        public Tableau createTableau(Effigy effigy) throws Exception {
            if (effigy instanceof PtolemyEffigy) {
                // First see whether the effigy already contains a RunTableau.
                RunTableau tableau =
                    (RunTableau)effigy.getEntity("runTableau");
                if (tableau == null) {
                    tableau = new RunTableau(
                            (PtolemyEffigy)effigy, "runTableau");
                }
                // Don't call show() here, it is called for us in
                // TableauFrame.ViewMenuListener.actionPerformed()
                return tableau;
            } else {
                return null;
            }
        }
    }


> RunTableau(PtolemyEffigy container, String name)
> 1) how can i get the container by being given a xml file.

This is usually the effigy that createTableau is called with. 

> 2) does the name mean the full path of the xml file? If yes , then can
> you kindly tell me the name in the above example(model.xml)?

The name is the name of the tableau, in createTableau(), it
is just a string

Someone else might have some insight into this.
See Chapter 14 "Vergil" in the Ptolemy II design document at
http://ptolemy.eecs.berkeley.edu/ptolemyII/designdoc.htm
for more information.


> Regards,
> 
> Bill Ng

-Christopher

----------------------------------------------------------------------------
Posted to the ptolemy-hackers mailing list.  Please send administrative
mail for this list to: [EMAIL PROTECTED]

Reply via email to