07-31-2017 07:39 AM
Hi all,
I want to do some sort of undo function, in the form of reloading the original data from the first iteration of a while loop.
Data is passed into a graph, and can be edited there. However, the user can make a mistake in the editing. I want to let the user press a boolean button to reload the original data. I have found several posts about comparable subjects, but they all use extra while loops or a state machine structure , and since I already have a while loop inside a case structure, I prefer not having to add more loops.
I cannot add the VI for reasons, but I have added a screenshot instead.
The program seen is repeated several times in a flat sequence structure, so I need to reload an individual loop, not the whole program.
Thanks in advance
Solved! Go to Solution.
07-31-2017 07:43 AM
Hi LvL,
I want to let the user press a boolean button to reload the original data.
And what's your problem to implement just exactly this code?
The "original" data is available just in front of this WHILE loop - all you need is a button, a Select function and some wire…
I prefer not having to add more loops.
You don't need to if you would implement a state machine…
(What's wrong with an additional loop? Are you paid by how many loops you use???)
07-31-2017 07:58 AM
Thanks,
Indeed with the use of a simple select function it worked out.
I didn't want to use more loops because I think it makes the code look messy.
07-31-2017 08:59 AM
Hi LvL,
I didn't want to use more loops because I think it makes the code look messy.
Only when you use them without planning.
I think I already mentioned this sheet of paper… 😄
07-31-2017 09:59 AM
In addition to what has been said already, there is plenty more horribly wrong with this code:
08-01-2017 01:36 AM
Thanks for your input altenbach.
I'm pretty new to labview so that's why there are these stupid mistakes.
Simply forgot about the wait in the loop... GerdW gave me the tip to use event structure, but when I tried there appeared some weird bugs, so I'm not sure how to wire it properly. I had planned to first take care of the program, and then place it in an event structure somehow.
The reason I added the shift register is because I want the program to remember what has already been clipped. I want the user to be able to clip as many things as he/she would like.
I've only found out about the existence of a state machine yesterday, so I'm not sure when/why/how to use it.
Since I would really like your help I've decided to attach the code anyways.
Thanks in advance!
LvL
08-01-2017 10:06 AM
I think you should start from scratch. You can do all that with 5% of the code.
You said something about event structure. I cannot find it.
So:
Use an event structure with events to (1) load a new file, (2) select a certain data row, and (3) process the current row using the cursors and other controls while updating the edit graph (cursor change event, value change event). Go back to wait for user input using 0% CPU.
08-02-2017 04:27 AM
Hi,
Thank you so much for your elaborate tips! It helped me a lot already.
So, I've managed to do a couple of things from your list:
- got rid of the sequence structure
- not using controls with the same label
- wait in while loop (not sure what time is appropriate though)
- replaced the 'replace zeroes with NaN' loop with the bit of code you suggested.
- made an event structure
There are some things I struggle with:
- I'm not sure what you mean with ' a single set of graphs' . What I've done now is using a single graph to clip the data, and let that send to a next graph. Is this what you meant?
- I don't understand what you mean by the index inputs of my subVI seem to have the wrong representation.
- I have no idea what you mean with 'recalculate the "edit" graph while you pick thresholds'
- setting up the event structure. I now have a lot of buttons which the operator has to click but nothing visible happens, so I guess it's easy to make mistakes this way. I've not worked a lot with event structures before, so I'm a bit uncertain about how to wire them correctly (I've seen some youtube videos about them but they mainly explain the basics).
- The graphs. The operator wants to have a maximum of 32 possible graphs at the end of the process (or less if desired). So my idea was to do the clipping in one graph, and when that's done, send that data to graph number one. Then clip the second set of data, and send that to graph number two, etc. Because the smoothing and coating offset are the same for every set of data, I figured it would be easier to do that after all the graphs are clipped. Th problem is that when I want to update after clipping the second graph, it loads this clipped data to both graphs, where I only want it to by put in the second graph.
I've attached the code I made so far. Thanks a lot in advance.
08-02-2017 03:54 PM - edited 08-02-2017 03:55 PM
OK, that already looks better. last night I spent a few minutes and modified a version using some of my stated ideas. (note that it will only process one subset per column, but it can easily be expanded to incrementally allow selection of multiple ranges per column. Just needs a bit more code :D)
@LvL1995 wrote:
- I'm not sure what you mean with ' a single set of graphs' . What I've done now is using a single graph to clip the data, and let that send to a next graph. Is this what you meant?
See my code example. If you want to output the processed array at the end, place an indicator after the while loop and tap into the 2D array after the processing.
@LvL1995 wrote:
- I don't understand what you mean by the index inputs of my subVI seem to have the wrong representation.
Indices are integers and should be blue (I32). Yours are DBL (several places, also the "select row" control). Right-click...representation" will fix it. Of course DBL (orange) will also work correctly, but the compiler needs to internally coerce, causing extra memory allocations and potentially (unlikely here) incorrect results. Noticeable whenever you see a red coercion dot :D).
LvL1995 wrote:
- I have no idea what you mean with 'recalculate the "edit" graph while you pick thresholds'
You can update the final graph at all times. pretty cheap. I do it outside the event structure whenever something has changed then wait again for user interactions. With event structures, indicators hidden inside other event will not update unless that event gets triggered. Thus I update everything outside.
Attached is some simple code. It loads the available columns into a listbox (no limit on the number) and you can process any one of them by selecting. Every time you switch columns, updates the controls, cursors, etc. to the last setting for that column.
Modify as needed. It is definitely not polished, but should give you some ideas. I also simplified some other things and added a few diagram comments.
08-04-2017 03:39 AM
Wow! This is really great! Thank you so much!!
It is going to take a while for me though to completely understand all the things you've done. But this is a really good way to learn more of the many possibilities Labview offers.
I really appreciate that you put time into this to help me. I understand the things I did wrong, and I think that's already a big step.
I'll look closely into your code, and I'll definitely process parts of it in mine.
I'll let you know when I have worked it all out! 😄