¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Re: S+ multiple waits


 

I dont fully grasp what you are trying to do here. I?ve done similar things with a flag and a timestamp for each timer. To illustrate (from the top of my head..)

integer timer_active[32]; // I normally use a bitfield, but this is easier
long_integer timer_time[32];
long_integer timer_start[32];

function start_timer(integer idx, long_integer t) {
..timer_active[idx] = 1;
..timer_start[idx] = GetHSeconds();
..timer_time[idx] = t;
}

function elapsed_time(integer idx) {
..if (timer_active[idx]) return(GetHSeconds()-timer_start[idx]);
}

Then somehow periodically schedule tests for your timers within acceptable resolution. I typically do this with a permanent task that loops with a delay(), but you might as well use wait(). The code might look something like

for (i = 1 to 32)
..if (timer_active[i] && elapsed_time(i) > timer_time[i])
....<whatever>

You can use dynamic arrays and scale for as many events as you need at runtime.

cheers,
-noob

--- In Crestron@..., Heath Volmer <hvolmer@...> wrote:

Is there any way I can spin up multiple waits for different events using the same event handler code? Let me see if I can explain.

I have data come in, and based on that data I want to spin up a wait and a function that will do something if a wait expires. If the data comes in again, it will reset the wait.

The problem lies in the data: It could be many different values, each relating to many different outputs, and I may need more than one wait running at a time. In OOP-land, I'd fire up a timer object for each different data thing, throw it in a pile and let it do it's thing

Is there any way to do this sort of thing? (I don't think so...) Best I can come up with is some sort of set of pre-defined waits that I choose one after another, recycling them as they finish up.

Heath

Join [email protected] to automatically receive all group messages.