dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: need help !!

  1. #1
    Join Date
    Apr 2008
    Posts
    93

    need help !!

    im doing a short program for an aircraft throttles (quadrant throttle).

    if i move the throttles initially from 0% to 100% position. and its stay there (at 100% position) for a long time. now i want check if the throttles whether has been stationary there for a period of time (e.g. stay there for more than 3 seconds). if condition meet then i will store the position of the throttles into a group of arrays.

    now what i want to ask is that is there a way to check whether the throttles is remain stationary for that certain period of time. how the condition look like?

  2. #2
    Join Date
    May 2006
    Location
    Dresden, Germany
    Posts
    458

    Re: need help !!

    Your explanation of the problem is very vague.

    Please read the FAQ's to this forum.

    No one will write your "short program" for you.

    What do you have so far?
    Where exactly is the problem?
    Which problem?

    You will either need a timer or a notification (with timestamp) of changes of the throttle.

    With regards
    Programartist

  3. #3
    Join Date
    Apr 2008
    Posts
    93

    Re: need help !!

    i haven start yet, but all this points wass discovered after a discussion with a group of my friends and have to take note about.

  4. #4
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: need help !!

    Most of the "change over time" problems more or less boil down to...

    Recording machine state (throttle % in your case) and a system time indicator (GetTickCount(), GetSystemTime()... or something similar).

    When the machine state changes, you update the "state changed at time" variable. Otherwise you don't, and you also record the state at that point.

    You can later compare this and do stuff when it's been at a certain state for a certain amount of time...

    You will typically have a timer function or a thread to continuously check the machine state to do this. Or if you'd have this elsewhere in your code that gets called regularly.
    Code:
    int iThrottle = GetThrottle();
    DWORD dwTimeNow = GetTickCount();
    if (iThrottle!=iLastThrottle)
    {
        iLastThrottle = iThrottle;
        dwLastChangeTime = dwTimeNow;
    }
    
    if (dwTimeNow >= dwLastChangeTime+3000)  // No change for at least 3000ms
    {
         // Do something
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)