PDA

View Full Version : add a delay before return in script



lefko
21st June 2011, 17:31
Hi,
I am new in QT(yesterday started). I use the following piece of code in a packet generator.
What I would like to do is to add a delay in ms before or after the return pvf line.
I want my script to hang there for a few miliseconds before ends.

Is there a way I can do that?

Any help appreciated.

Thanks in advance.

protocol.protocolFrameSize = function() { return 12; }

> protocol.protocolFrameValueVariable = true;

> protocol.protocolFrameValue = function(index)

> {

> var pfv = [0x80, 0x08, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x36, 0x20, 0xfb,
> 0x90];

> var seq = (index+1) & 0xFFFF;

> var timesync = (index * 160) & 0xFFFFFFFF;

> pfv[2] = seq >> 8;

> pfv[3] = seq & 0xFF;

> pfv[4] = (timesync >> 24) & 0xFF;

> pfv[5] = (timesync >> 16) & 0xFF;

> pfv[6] = (timesync >> 8) & 0xFF;

> pfv[7] = timesync & 0xFF;

> return pfv;

> }

Rachol
21st June 2011, 19:48
Basically you can use sleep command( on *nix systems) and Sleep on windows. There is no sleep command in Qt, unless you need it for your custom QThread. You can always set some loop and check if QTime::elapsed is bigger than something.