lundi 8 juin 2015

Convert IEnumerable to IObservable with variable Period

I am consuming 3-axis accelerometer data using Rx. I need to set up some unit tests. The data frames come in fast, with the median timespan between frames being 80ms, but on occasion it comes in at 120ms. Also, it is never exactly 80ms, but hovers in that range.

So I have created a class that subscribes to the IObservable and records the dataframes sequentially in a .csv file. One of the fields in the .csv file is the start time of the frame with the first frame having start time = 0.0.

Now I want to read that file and stream it again for the purpose of testing and development. I want to use the StartTime field as the schedule for when I will fire any given Accelerometer frame when testing.

I looked over the answers in this question, Scheduling a IEnumerable periodically with .NET reactive extensions but it seems only to address constant timespans.

Question: Is there already a canonical and preferred way to schedule frame pushes at irregular (but known) intervals in the Rx framework, or should I just roll my own somehow?

Aucun commentaire:

Enregistrer un commentaire