Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Time response delay source code

rickysririckysri Posts: 21Member
Hi

I am having a problem here... I have a website that has random images displayed one by one and upon the user pressing a particular key to answer the question so as to which image expresses the word happy or sorrow the answers are coded and the string parsed is extracted into a database a MS Sql server.... my problem is that i need t implement a sresponse delay of 250 ms before loading the next stimuli(i.e) the next picture... this has to be done mmediately after selecting an answer for the current stimuli (or) picture.any further processing of the current stimuli(checking if the answer is correct or wrong) should be done within 250 ms and the system pauses for any extra time that is left...if the response to the stimuli turns out to be incorrect the counter will be reset on the next response......

How to work this out...Can anyone help me there

Appreciate your help there

Ram

Comments

  • tvientitvienti Posts: 230Member
    : Hi
    :
    : I am having a problem here... I have a website that has random
    : images displayed one by one and upon the user pressing a particular
    : key to answer the question so as to which image expresses the word
    : happy or sorrow the answers are coded and the string parsed is
    : extracted into a database a MS Sql server.... my problem is that i
    : need t implement a sresponse delay of 250 ms before loading the next
    : stimuli(i.e) the next picture... this has to be done mmediately
    : after selecting an answer for the current stimuli (or) picture.any
    : further processing of the current stimuli(checking if the answer is
    : correct or wrong) should be done within 250 ms and the system pauses
    : for any extra time that is left...if the response to the stimuli
    : turns out to be incorrect the counter will be reset on the next
    : response......
    :
    : How to work this out...Can anyone help me there
    :
    : Appreciate your help there
    :
    : Ram
    :

    If I understand your problem correctly, I feel compelled to point out a major complication: you can never predict network latency. The simplest solution that comes to mind is (in pseudo code):

    [code]
    // we do this each time they submit an answer
    last_hit = SESSION[last_hit];
    Handle the user's answer;
    While ((current time - last_hit) < 250)
    Do nothing;

    // We now know it's been at least 250 ms since the last time they submitted something
    SESSION[last_hit] = current time;
    Show them the next image;
    [/code]

    The problem is it doesn't account for network latency and the actual time between hits will not be 250. It may be off by a few ms or much longer.
Sign In or Register to comment.