Need a logic!

This is a discussion on Need a logic! within the Tech Board forums, part of the Community Boards category; Hello, Its been a while i have been working on my project. Now getting somewhere. But now i am after ...

  1. #1
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,682

    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

    SSHarish

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,855
    - Sleep for 60 seconds
    - read the current time
    - see what needs doing
    - do it
    Put all that in a while(1) loop.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Or:

    - 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.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Digital Logic
    By strokebow in forum Tech Board
    Replies: 3
    Last Post: 12-09-2006, 01:05 PM
  2. Logic
    By LordBronz in forum C++ Programming
    Replies: 6
    Last Post: 05-23-2006, 06:41 PM
  3. Actors, cues, event based logic.
    By Shamino in forum Game Programming
    Replies: 2
    Last Post: 04-27-2006, 11:58 PM
  4. Circular Logic
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 10-15-2001, 09:10 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21