01-18-2023 02:28 PM
Hi,
I am using graphs to plot friction coefficient data. I would likw to know how to get the cursor position points as usable variables for further calculations within the program.
the picture shows what i have in the program now. I used property node to get the position points of Cursor 1 as highlighted in yellow, but i don't see a property to get the position points of cursor 0, in this case circled in red, in a usable form. I might have gone totally missed seeing if there is one at all, but anyways hope i get some help with this.
Cheers!!
Solved! Go to Solution.
01-18-2023 02:47 PM
Use property node to set the active cursor first.
01-18-2023 03:01 PM - edited 01-18-2023 03:06 PM
Especially if you want the positions quantized to data values, I recommend cursors locked to the plot and using the cursor.index property. Especially convenient if you e.g. want the subset or similar later.
Here's a very old example that should give you some ideas (posted here )
If you have free cursors, just get the cursor-x property.
Yes, property nodes execute top to bottom, that's why the above works correctly. If you have many cursors, iterate over all cursors to create an array of x positions.
01-18-2023 03:05 PM
You have only showed us the front panel, so we don't really know what your needs are.
If these cursors are moved by the user, I would use graph:cursor.move events. They will give you the information (cursor#, index, coordinates, etc.) from the event data node.
01-19-2023 09:49 AM
I am using graph cursor move events to get the mean average data between cursors and was hoping to use the cursor position property node to get the points on the graph where the cursor intersect at. i have attached my code here. I could only get the position of one of the cursors but not the other. I have not used the dynamic event nodes as much, so i have very less idea about it.
01-19-2023 10:21 AM
(Sorry, I cannot look at your code at the moment because this computer only has LabVIEW 2020. Consider "save for previous" before attaching.)
My example gets the array subset between the two cursors and it would be trivial to calculate the mean of that subarray, right? The only thing left is to decide if you want to include or exclude the points under the cursor.
My code can easily be adjusted for other graph data types (waveform, dynamic, etc.).
01-19-2023 10:32 AM
Here is the code saved for previous version.
01-19-2023 10:39 AM
what i am really after is the points where the intersections happen between the cursor and the graph. To be more precise, what i require is the Cursor Y positions. The Cursor X positions are of no use for my further calculations.
01-19-2023 11:05 AM - edited 01-19-2023 11:07 AM
As a first step, you need to fix your glaring race condition due to blatant overuse of local variables. For example, the local variable at A will get read way before the terminal at B gets new data. The result critically depends on what happens first and there are currently no guarantees.
Your code currently is full of landmines, for example if any of the events fire before the stop is pressed, the panel will lock up forever. You need a simple state machine with one toplevel while loop and not a sequence of loops. Your stop button also has the wrong mechanical action.
You can get the cursor Y in the same way. Here's a quick draft using simulated data.
01-19-2023 01:03 PM
Thanks for the feedback on the code. I knew there was a lot of improvements i could make to the code. I'll definitely look into it and solve the problems that you addressed.
As for the Y coordinates from the cursor, thanks a lot for helping with that. I really appreciate that.