Need a logic!
Hello, Its been a while i have been working on my project. Now getting somewhere. But now i am after a logic or an idea which could be used for my application. Let me explain, what i am looking for.
I believe quite a few people here would aready know my project, since i been posting few things about it.
I have got a web interface, where user can use that to see which are the light or any electrical equipments in the house are siwtched on or off. What i though of adding a one more feature within the web interface where user can set the time. So for example when a user sets a time for a light (like say for 5 min) tell the system to switch off the light in next five min. So u get some sort of idea of what i am after.
Is there any function or something at the kernel level where signal will be raised when the time elapsed, so that the system can tiggered to take appropriate action on switching it on or off the light. Or do I have to run a daemon server and the server should keep track all the timing and when the time gets elapsed i will send a signal to the main system to switch off or on the appropriate souce.
I am on Linix, GCC.
Thanks a lot
- Sleep for 60 seconds
- read the current time
- see what needs doing
- do it
Put all that in a while(1) loop.
- Check what job needs to be done next.
- Calculate time until it needs to be done.
- Sleep for that time.
- Do the job.
- Start over.
If the user adds a job, wake up from sleeping and recalculate.
That's the way the Java Timer class works.