Externally triggered countdown timer

Hi,
Up till now, I have been assuming that I would run all my software on my control system and just read and write the inputs/outputs from there. The controller is all asynchronous and I have run into a race condition that I would like to solve with local software on the t3.
I want to create something where the external program sets something on the t3, then have the t3 have a count down timer. Any client should be able to read the state of the timer and see how many seconds are left to wait. In the ideal case, the external program would simply set the number of seconds.
I am assuming this will be done with virtual control points, but have not done any of this before. I can imagine the code looking something like
10 rem count down timer using variable “count_down_1”
20 count_down_1 = 0
30 if count_down_1 > 0 gosub 100
40 wait 1
50 goto 30
100 if count_down1 < 1 then
110 count_down_1 = 0
120 else
130 count_down_1 = count_down_1 - 1
140 return

My biggest question is how to read and write count_down_1 from an remote bacnet client.
Second is whether there is a more natural way to write this?

thanks in advance,
jerry

Your sequence sounds overly complex. Why not run the logic on the controller directly as normally intended. If you have some big/ advanced logic running on an external machine do that there and send just the important setpoints and modes to the t3 variables.

—From Maurice

I do a combination of total energy balance, statistical analysis and human factors reasoning. All this is possible with a modern desktop computer and appropriate languages and libraries. It’s certainly not possible on the t3.
The challenge I am addressing here is that in a multiprocess system, I can’t assume that there is exactly one logic path that can do countdown that are seen by all others. This is for equipment protection, so race conditions could be very expensive. I am trying to avoid having to create an entire messaging platform that would be required to force localization in my code. Thus I was trying to see if the existing bacnet messaging of the t3 could be twisted to manage the synchronization.

How can I create something that:

  • can be read and written by external bacnet clients
  • can have an internal program that subtracts 1 from the current value every second until it reaches 0

I know I could use an empty analog_output and range scaling (1 second = .01V) to do this, but I have none to spare on my two main controllers.

jerry

Sure you have some high level resources and logic but mainly it boils down to a few setpoints and modes. We can’t have the mechanical equipment jumping all over the place to follow your advanced algorithms right. Mainly the valves open or close to maintain a setpoint. You work out the setpoint and hand that off to the controller.

No need to worry about race conditions amongst multiple controllers in the system.

My two bits worth. Maybe Lijun can chime in and offer some tips.

—From Maurice

I made the question too complex. Let me boil it down to the absolute essential.
You have these virtual points.
Is there a way to read and write these from an external bacnet client?
Is there a way for a program to read/modify the virtual points.
Everything else is just me abusing the system to do something not directly related to the actions of the inputs and outputs of the controller.

Yes of course, you can read and write to the bacnet variables. They show up as avs and bvs and can bead read and written like any bacnet object. Note that you need to set the range before they show up in a bacnet discovery.

—Maurice