AnsweredAssumed Answered

How do I execute code on a timer, at a specific time of day, or tag value change using VBA?

Question asked by JeremyMahon on Aug 17, 2016
Latest reply on Sep 12, 2016 by pmartin

Hi all. I have a piece of code that I want to run on a daily basis either triggered by a tag value or on a schedule. I have found that PB doesn't support OnTime and thus a timer is required, but that seems like a lot of work for a simple code execution. Is there a way to run the code when a value of a Pi tag changes?

 

I have a PE running every hour with this definition: TagMax('futureDataTag','today','+24h'). In theory, it should only be updated once per day when the market publishes the day-ahead prices.

 

Basically, what I want to do is get the maximum value of a price forecast tag and then set a trend's max Y-axis value to the new max. I have the trend SetTraceScale method working great, but I just can't figure out a way to execute the code either on a set schedule or when the PE gets a new value. Either way would work for me. I'd prefer using the PE's value change but if there is a simple way to schedule the code run, that works too.

 

Thanks

Outcomes