Question-and-Answer Resource for the Building Energy Modeling Community
Get s tarted with the Help page
Ask Your Question

[BCVTB] Is it possible to use print statement for debugging purposes in ?

asked 2017-10-24 00:57:45 -0600

cs_bot gravatar image

updated 2017-10-24 11:06:24 -0600

I am new to thefield and I want to explore more into the programming capabilities of the PyhtonActor component in BCVTB. If I am to attempt debugging in the fire() of the PythonActor, is it possible to have dummy print statements? Or every correspondence wrt debugging has to be via files?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-10-31 12:29:19 -0600

cxbrooks gravatar image

I'm not much of a Python programmer, but you should be able to print to stdout from within a PythonScript actor, see below where I added to print() calls to the script.

BCVTB used Ptolemy II as its execution engine. In Ptolemy II, it is possible to listen to actors by right clicking on the actor and selecting "Listen to Actor". At runtime, messages will be displayed in a separate window. To write to the listener from within your Python code, see

In the script, use to access the actor. For example, returns the current director of the actor. For debugging, use The final message sent to the debug listeners of the actor will have the string "From script: " inserted at the beginning. To avoid generating the debug message when there are no listeners, use:

if :

I'm not sure about the indentation of the above.

To print to an output, see $PTII/ptolemy/actor/lib/python/test/PythonSysPath.xml , which has a PythonActor with the following. Note that I added two print() calls, which seem to work.

import sys.path


class Main :
  "Report the components of Jython's syspath"
  def preinitialize(self):
  def prefire(self):
    return self.input.hasToken(0)
  def fire(self) :
    y=self.input.get(0) # retrieve and discard the trigger
    for i in range(len(sp)) :
      if (len(result) > 0):
    print('The result is')
edit flag offensive delete link more


Thanks for the answer! But unfortunately, I am facing two issues.

  1. I am pretty sure that I don't have the XML file available ( I dont have a 'test' folder inside the 'python' directory ) in the given installed set of directories.

  2. I tried adding some print() statements in the fire function, and when i did press 'Listen to Actor', I am only able to see this, repeatedly:

    "Called prefire() Called fire() Called postfire() Called iterate(1)"

Any further help will be appreciated!

cs_bot gravatar image cs_bot  ( 2017-11-02 06:32:26 -0600 )edit

The file is available at

For listening to work, you would need to add

if :

The output of the print statements would appear on stdout, which requires that you start BCVTB from a shell. The output of the print() statement does not appear in the listener window. BCVTB might have the functionality to display the console by doing View -> Console.

cxbrooks gravatar image cxbrooks  ( 2017-11-02 09:18:39 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer


Question Tools



Asked: 2017-10-24 00:57:45 -0600

Seen: 95 times

Last updated: Oct 24 '17