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

BCVTB: Fire a script at midnight only?

asked 2016-06-27 17:16:25 -0500

updated 2016-06-27 17:22:17 -0500

I'm trying to launch an external script to run at midnight of each day during my E+ simulation.

In pseudo code I'd do something like:

if simulation_timestep % (24*timestep_per_hour) == 0:
    // call my script

I'm facing two isues:

I wasn't sure how to do a modulo operation in BCVTB, I thought the UnaryMathFunction would do, but there's no modulo under it, so I've used Remainder, which for positive values such as mine is exactly the same. Problem is, I'm getting this error:

java.lang.ClassCastException: cannot be cast to

Bigger problem, I cannot seem to figure out how to trigger an event at the specific timestep I want. I've tried using a a Const, my timestep and a Logic > Equal box in conjuncton with a Boolean Switch, trying to create a dummy csv file only at timestep = 320. Problem is, it does output at 320, but also for all the following timesteps.

I tried using a Boolean Select, but got a type error too.

Here is an example of what I've tried. The remainder portion fails, I have to delete it and replace it by the "Const 320" in order to try the boolean switch.

bad tries

How can I trigger an event every day at the same time in the BCVTB?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-06-27 18:19:17 -0500

I constructed a simple system model which might address your concern.

The model has a DiscreteClock and a LineWriter. You can find the Clock in Actors/Sources/TimedSources. The clock fires (produces an output) every 86400 seconds. At every tick, it causes the LineWriter to write its output to a file (ClockOutput.txt) which must be on your file system.

Although the system model runs from 0 to 172800s with a period of 900 seconds, you can see that ClockOutput.txt has only three entries. Is that what you would like to achieve?


  • The model is at C:\fakepath\model.png.
  • Please rename the model from model.png to model.xml so you can run it.
  • Do not forget to specify the path to the output file (ClockOutput.txt) so the model can find it.
edit flag offensive delete link more


Thanks, that's really helpful! That's almost what I want. In the end I want to trigger a SystemCommand at a given timestep. How do I connect your discrete clock to trigger events?

It got messy with my example above, but if you're curious, I'm really doing something along the line of load forecasting and determining the optional operation of an electrical battery, which I want to do at midnight of each day, and I want to avoid launching the SystemCommand at all cost the rest of the time: just the fact of calling python to do nothing slows down the simulation a ton

Julien Marrec's avatar Julien Marrec  ( 2016-06-28 00:24:27 -0500 )edit

If you right click on the SystemCommand actor, and go to Customize -> Ports, you will see that you can add inputs ports. If you connect these ports to your trigger signal, then the SystemCommand will fire when data are available at this port. Note that all inputs ports need to be connected for the SystemCommand to fire.

Thierry Nouidui's avatar Thierry Nouidui  ( 2016-06-28 09:09:52 -0500 )edit

Furthermore, rather than writing and reading csv, you could also print the output that you want to use in downstream actors in your Python script. If you use print in your Python script, then the printed output will be available at the output port of the SystemCommand actor. Note that this output is a string which could be post process for further use. Take a look at the BCVTB radiance40 example. You can in this example open the String2Double composite actor to see how strings have been parsed there.

Thierry Nouidui's avatar Thierry Nouidui  ( 2016-06-28 09:16:22 -0500 )edit

Thanks Thierry. I'm getting an "Actor is not ready to fire" when I do that? any clues?

Julien Marrec's avatar Julien Marrec  ( 2016-06-28 10:09:23 -0500 )edit

How many inputs do you have? Are they all connected? In the SDF domain, an actor will fire only if all its inputs are connected and available...

Thierry Nouidui's avatar Thierry Nouidui  ( 2016-06-28 11:11:51 -0500 )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

1 follower


Asked: 2016-06-27 17:16:25 -0500

Seen: 233 times

Last updated: Jun 27 '16