Replies: 4 comments 3 replies
-
I'm not sure what you want to do but I assume that you want to plot (or similar) the values using the absolute time. This is typical when merging measurements. We need some common naming standard.
Back to your original question. You can setup a remote master CG block. This means that you configure one CG block that stores the time channel and the other CG blocks stores the data values. This is a new feature in MDF 4.2 and I don't see any use of it. You still have to order your sample in time order. You can however setup a default X channel for each CN block. Normally the master channel is what viewer uses on X-axis but you can redirect this to point to another channel in another DG/CG/CN block. This default X channel doesn't need to be ordered. I think this is more what you want. Assume that your application get samples with absolute time unordered. A sample is equal to a CG block not at channel. You should skip the master channel on the CG block and store the absolute time as data channel together with the other sample data channels. The data channels should now set the default X-axis to the absolute time channel. To get this working, the current pre-trig cache might cause a problem as it do store the samples with the absolute time but there a need of twist to fix the pre-trig issue. Maybe the pre-trig function is not needed? I have not tested the default x channel functionality in MDF viewers so we might need to take a rain check that some changes are needed. |
Beta Was this translation helpful? Give feedback.
-
Your use cases are very similar to the event log server application (github: ihedvall/eventlog). I'm using a SQLite database file instead of an MDF file. This might be a better solution. The basic problem with MDF is that it appends the events at the end of the file. The only solution I recommend is to do the above or redesign the cache so it sorts the events before inserting them. This implies that the cache has some time window before storage. Maybe it's time for a MS Teams meeting? |
Beta Was this translation helpful? Give feedback.
-
Thanks for all the replies... It seems something is still not right in my tests. I have wrote a trivial example:
When trying to read it back, all times are 0 and the payloads read back are just two samples, 8 an 9... I am missing something? This is the channel creation code:
This is the code for reading the file:
|
Beta Was this translation helpful? Give feedback.
-
I have not tested your code but I suspect that the problem is in the StartMeasurement(0) call. The input argument is the start time of the measurement in absolute time (ns since 1970). Unfortunately, I'm using the start time equal to zero as an initial value, indicating that the measurement is not started. The effect in your example is that the measurement is stopped but never started. I have not tested this but I recommend that you define an uint64_t start_time = 1 (or some valid time) and use this as an offset in the StartMeasurent(start_time), SaveSample(..., start_time + i) and last StopMeasurement(start_time + 10). I think you get 10 samples after that. You can return if it doesn't work. |
Beta Was this translation helpful? Give feedback.
-
Is it possible to reorder measurements according to some other channel? The goal is to be able to write in log time and read in publish time.
Beta Was this translation helpful? Give feedback.
All reactions