1

I'm writing an app that hooks into a data stream from a race simulator. My app has various gauges that display this info to the user while they are in the event. I'm saving this data to a file as part of the display process.

What I'd like to do is then replay this through the gauges, but at real-time speed. My app replays the data from this stored file fine, but it's running as fast as the data can be read, which is too fast.

The data is stored in a byte array and written to disk, and read in a serial fashion, i.e. I don't read all the data at once. I had thought about writing a field with the time length of the data stream and then map that, somehow, when replaying, but it seemed overly complex to me.

I'm struggling to figure out how to match this to real-time. Now whilst I could put in a delay to simulate it to real-time the issue is that depending on how quickly the data is written, will impact what this "delay" value would be. Some systems will write at 60 records/sec others at 20 or 30 records/sec.

Within the data I capture is a time value, albeit a lap time, but I could put in an actual time field without much issue if needed.

So how do I match a recorded time stamp to replay in real-time on a replay.

The app is a C# WPF app. I've read a couple of posts about replay design, but they are all related to deterministic game development, which isn't what I'm doing.

MikeyTT
  • 222
  • 3
  • 11

2 Answers2

1

Within the data I capture is a time value, albeit a lap time, but I could put in an actual time field without much issue if needed. [...] So how do I match a recorded time stamp to replay in real-time on a replay.

Some code will help, but basically you'll just have to wait (nextFrame.Timestamp - currentFrame.Timestamp) timestamp units between drawing each frame.

See this question and others on what is the best way to let your program "wait".

Community
  • 1
  • 1
CodeCaster
  • 147,647
  • 23
  • 218
  • 272
  • 1
    Sorry it took me a while to get back to this. Work has been mental. I had thought that that would be the way. Thanks for the confirmation. – MikeyTT Jun 15 '13 at 18:18
1

What about if you store a time offset since the start of recording together with each data entry. Then to replay the data at the same speed you just need to get the time difference to the next entry and sleep or wait.

NeddySpaghetti
  • 13,187
  • 5
  • 32
  • 61