Click here to Skip to main content
15,915,771 members

Comments by marreoragarn (Top 2 by date)

marreoragarn 28-Oct-22 5:10am View    
My solution is very much like what you have suggested. I am not done yet but here is how I do:
SetTimer(wnd_main, TIMER_DO_SET + i, delay + Extended_ms, (TIMERPROC)SetOutput);

I calculate the ext like this:
struct _timeb timebuffer;
time_t CurrentTimeS;
unsigned short CurrentTimeMS;
_ftime64_s(&timebuffer);
CurrentTimeS = timebuffer.time;
CurrentTimeMS = timebuffer.millitm;
int delay = IO_data.DO_Run[i].Value ? PimIniStruct.DO[i].DelaySet : PimIniStruct.DO[i].DelayReset;
int val = CurrentTimeS + delay;
if (val == PimIniStruct.DO[DO_No].NextTimeS)
{
if(abs(PimIniStruct.DO[DO_No].NextTimeMS - CurrentTimeMS) < 200)
{
Extended_ms += 3 * USER_TIMER_MINIMUM; // Move the timer to the third time slot
break;
}
}
marreoragarn 28-Oct-22 5:05am View    
I have started a way to calculate when a certain timer is supposed to execute and if there is another timer (controlling the same hardware) executing the same time, within 10 ms, I adding 30ms delay extra on the second timer to avoid to get the in the wrong order.
The reason is that timers controlling hardware outputs and if they execute in the wrong order the lamp can be turned of when it is supposed to be turned of.
The problem with execution order seems to have come with VS2019, software compiled in VS6 did not had any problems to execute timers in the order they where set.