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

Revision history [back]

BCTVB: Fire a script at midnight only?

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 BCTVB, 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: ptolemy.data.IntToken cannot be cast to ptolemy.data.DoubleToken
at ptolemy.actor.lib.Remainder.fire(Remainder.java:113)
at ptolemy.actor.AtomicActor.iterate(AtomicActor.java:497)
at ptolemy.actor.sched.StaticSchedulingDirector.fire(StaticSchedulingDirector.java:216)
at ptolemy.domains.sdf.kernel.SDFDirector.fire(SDFDirector.java:500)
at ptolemy.actor.CompositeActor.fire(CompositeActor.java:454)
at ptolemy.actor.Manager.iterate(Manager.java:841)
at ptolemy.actor.Manager.execute(Manager.java:367)
at ptolemy.actor.Manager.run(Manager.java:1252)

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?

BCTVB: Fire a script at midnight only?

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 BCTVB, 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: ptolemy.data.IntToken cannot be cast to ptolemy.data.DoubleToken
at ptolemy.actor.lib.Remainder.fire(Remainder.java:113)
at ptolemy.actor.AtomicActor.iterate(AtomicActor.java:497)
at ptolemy.actor.sched.StaticSchedulingDirector.fire(StaticSchedulingDirector.java:216)
at ptolemy.domains.sdf.kernel.SDFDirector.fire(SDFDirector.java:500)
at ptolemy.actor.CompositeActor.fire(CompositeActor.java:454)
at ptolemy.actor.Manager.iterate(Manager.java:841)
at ptolemy.actor.Manager.execute(Manager.java:367)
at ptolemy.actor.Manager.run(Manager.java:1252)

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?

BCTVB: BCVTB: Fire a script at midnight only?

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, Remainder, which for positive values such as mine is exactly the same. Problem is, I'm getting this error:

java.lang.ClassCastException: ptolemy.data.IntToken cannot be cast to ptolemy.data.DoubleToken
at ptolemy.actor.lib.Remainder.fire(Remainder.java:113)
at ptolemy.actor.AtomicActor.iterate(AtomicActor.java:497)
at ptolemy.actor.sched.StaticSchedulingDirector.fire(StaticSchedulingDirector.java:216)
at ptolemy.domains.sdf.kernel.SDFDirector.fire(SDFDirector.java:500)
at ptolemy.actor.CompositeActor.fire(CompositeActor.java:454)
at ptolemy.actor.Manager.iterate(Manager.java:841)
at ptolemy.actor.Manager.execute(Manager.java:367)
at ptolemy.actor.Manager.run(Manager.java:1252)

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, Const, my timestep and a "Logic Logic > Equal" 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. timesteps.

I tried using a boolean Select, 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?

BCVTB: BCTVB: Fire a script at midnight only?

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: ptolemy.data.IntToken cannot be cast to ptolemy.data.DoubleToken
at ptolemy.actor.lib.Remainder.fire(Remainder.java:113)
at ptolemy.actor.AtomicActor.iterate(AtomicActor.java:497)
at ptolemy.actor.sched.StaticSchedulingDirector.fire(StaticSchedulingDirector.java:216)
at ptolemy.domains.sdf.kernel.SDFDirector.fire(SDFDirector.java:500)
at ptolemy.actor.CompositeActor.fire(CompositeActor.java:454)
at ptolemy.actor.Manager.iterate(Manager.java:841)
at ptolemy.actor.Manager.execute(Manager.java:367)
at ptolemy.actor.Manager.run(Manager.java:1252)

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, 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?