LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding an XY graph element only while a specific state is running in a state machine.


@ijustlovemath wrote:

Altenbach is storing all the state in a shift register, which is the cleanest way to handle these sorts of things, but depending on your architecture, you could opt for the (much slower) Value property node of your XY graph indicator.


A value property is only needed if you update the graph from another VI via reference. Else a local variable would be sufficient and much more light-weight. Still, since the graph data is in a shift register, all state cases have access to it. No reasonable architecture would need any secondary access to the graph.

 


@ijustlovemath wrote:

Additionally, he's using an inplace element structure with the Index/Replace node (that's the tan box with thin border and the index array built into it). This just prevents the program from making unnecessary copies of the XY graph state, but is also quite expressive for operating on clusters and arrays of all kinds.


Nothing is making copies of any "state", I think you are talking about the graph data. Of course the data needs to be kept somewhere and since the two plots have typically a different number of elements, we need to bundle one way or another. At least using complex arrays keeps the code relatively simple (compared to the other datatypes an XY graph accepts). The structure here is a bit of a misnomer, because things cannot be "in-place" because the array sizes change. Here it just makes clean and readable code. The compiler knows what to do. 😄 If we know an upper bound of the final number of points, we can use fixed sizes (initialized with complex NaNs) and replace with real data when available, keeping track of the insert point.

 

Yes, eventually we will run out of memory and (way before that), updating the graph with millions of points will tax the UI thread and things might become sluggish. That's why I suggested mapping the data into an intensity graph (not shown) for full in-placeness and constant memory.

 

I don't think the OP will run into any memory problems, because a typical THD test does not have massive amounts of data.

 

 

 

 

 

0 Kudos
Message 11 of 11
(351 Views)