05-07-2010 09:01 AM
I have what I think should be a fairly simple problem to solve, but I just can' t work out where to begin.
I have an "Event" - not a LabVIEW event, but a thing that happens. I measure when it starts happening and when it stops happening and record the value of the timestamp at those times. - Simplest way to demo this would be to record the timestamp every time a boolen changes state (I've simplified my problem a bit for this).
The Event occurs over an unknown duration - could be 3 days of more, chaning state every 60 - 2 mins.
I want to plot a graph of the event history.
1) in real time
2) from the log file I have made (should/could be the same code)
I basically want to turn a set of n data points, at different times into a square wave graph with a timestamp as the base. The data points are not equally spaced.
How would anyone set about this?
Cheers
James
Solved! Go to Solution.
05-07-2010 09:46 AM
Ben?
Altenbach?
smercurio?
Coq Rouge?
muks?
Ray?
ANYONE???
I'm running out of time get a labour contraction logger written
05-07-2010 10:21 AM
James W wrote:I have what I think should be a fairly simple problem to solve, but I just can' t work out where to begin.
I have an "Event" - not a LabVIEW event, but a thing that happens. I measure when it starts happening and when it stops happening and record the value of the timestamp at those times. - Simplest way to demo this would be to record the timestamp every time a boolen changes state (I've simplified my problem a bit for this).
The Event occurs over an unknown duration - could be 3 days of more, chaning state every 60 - 2 mins.
I want to plot a graph of the event history.
1) in real time
2) from the log file I have made (should/could be the same code)
I basically want to turn a set of n data points, at different times into a square wave graph with a timestamp as the base. The data points are not equally spaced.
How would anyone set about this?
Cheers
James
A chart that uses a Waveform data type (uncheck ignore attributes) will plot the data based on "t0" in the waveform. This thread reply #8 has code i posted that does this;
As you can see there are different numbers of "events" ploted for each plot.
If you don't have any data for one of the plots at the moment but need to update the other, then make sure the "Y" array is empty.
See that thread for other notes.
Does that help or what did I miss?
Ben
05-07-2010 10:42 AM
Hi James,
Didnt want to post this as not completely happy with it but it may give you something to look at:
Had to set the scale with a property node as for some reason when auto scaling it left all the data in the middle with big gaps either end.
Does not actually look as bad as this. The data now fills the whole graph. Dont know why but when i copied into 'Paint' it reverted back to data in the middle with gaps either side.
Hope it helps.
Rgs,
Lucither
05-07-2010 10:47 AM - edited 05-07-2010 10:50 AM
The graph will actually look like this:
Obviously needs some work on. Would be better if the x axis showed more time points.
Rgs,
Lucither
05-07-2010 10:51 AM
Hi Ben,
Thanks for the reply, it's always nice to be reminded of things lurking at the back of your mind.
I'll try and explain again.
I have an cluster array of timestamps and booleans- these are the times when an event change occured (and what the state was). What I want to do is change these into a square wave.
e.g.
10:40:10 (TRUE)
10:40:30 (FALSE)
10:45:20 (TRUE)
10:45:21 (FALSE)
11:50:10 (TRUE)
11:52:00 (FALSE)
basically I only have 1 array (Time) - I would like this on the X axis and the boolean state (1 or 0) on the Y axis.
As you can see, although I have T0, dt is irregular, so I can't build a waveform from this data. - What can I do to plot this on a chart/graph?
Cheers
James
05-07-2010 11:03 AM
Genius,
That's just what I wanted to do Lucither.
You understood the problem exactly (and I had most of the code in place already).
Now I just to remember how to get X in time not DBL - I'm too full of adrenaline.
(I just wish I could get snippets to work for me)
Thanks
James
05-07-2010 11:14 AM
Ben
05-07-2010 11:52 AM
Ahh,
I've finally worked out what you are doing there Ben.
There's more than 1 way to skin a cat!
Which is better over a long time period?
(Should I really be asking if you would post inferior code?)
James
05-07-2010 12:10 PM
James W wrote:Ahh,
I've finally worked out what you are doing there Ben.
There's more than 1 way to skin a cat!
Which is better over a long time period?
(Should I really be asking if you would post inferior code?)
James
I gave Lucither a Kudos as a preventative action.
Draw-backs with my version:
1) The Chart history (set at development time) will determine the number of events you can plot. If you set it too small you may have old data drop of the plot that you wanted to keep.
2) It is a chart so no cursors (but same will work with graphs)
3) Can not go back in time (plot values earlier than what is already plotted)
Advantage of my version:
1) No need to set properties since chart handle that
2) No need to maintain the history
3) UI Thread not needed because no property node.
While responding I just now noticed (yelled out the bull-pen and it turns out all of the Certified Instructors knew) in Lucither's image that we can show the index on the plot legend, and use horizontal plot legends!
Now that is Cool!
Ben