gillecaluimi Posted October 5, 2013 Share Posted October 5, 2013 I'm updating a mysql database with a sequence which inserts weather data into a weather table. Is there a system timer function which I can trigger this sequence to start? Link to comment Share on other sites More sharing options...
AzeoTech Posted October 6, 2013 Share Posted October 6, 2013 Just create an infinite loop with delay(): while(1) // do the mysql write, or call the sequence delay(300) endwhile If you want it on the 5 minute mark, use a little math: private nextTime = floor(systime() / 300) * 300 + 300 while(1) waitUntil(nextTime) // do the mysql stuff nextTime += 300 endwhile This is also a bit more precise in its timing. Link to comment Share on other sites More sharing options...
gillecaluimi Posted October 6, 2013 Author Share Posted October 6, 2013 that's what I'd finally found in the user pdf but wasn't sure if it chewed up a bunch of cpu cycles constantly checking for nextTime? I'm used to programming event driven software and thought there might be a timer where you could set the interval and trigger a sequence. Link to comment Share on other sites More sharing options...
AzeoTech Posted October 7, 2013 Share Posted October 7, 2013 Its not constantly checking nexttime. waitUntil() handles all the cpu management for you. Of course this would chew up your cpu: while(systime() < nexttime) endwhile but waituntil() along with the other time functions in DAQFactory are designed not to simply spin like that. In fact, I'd imagine most of the event driven software you've used is doing it in software anyway, and is not truly event driven (i.e. interrupt driven). DAQFactory is just much more linear in its thinking, which makes it much easier for you as the developer. We use events internally to avoid using the cpu, but you never have to see it. You can just call waituntil() and know that we'll wake up at the right moment using the minimal amount of cpu possible. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.