05-13-2022 08:25 AM
Hello,
when I run my program, I click a button to read some data over TCP/IP for 40 seconds. This data is inserted into an array.
When I click the button the second time, I want the array to be reinitialized so that I get new data in it.
The problem is that the second time I still get the old values, even though I set the array to default values before I get the new data.
Is there any other way I can clear everything in the array without stopping the VI?
Any tips would be appreciated 🙂
Best regards
Edmond
05-13-2022 08:59 AM - edited 05-13-2022 09:03 AM
Hallo Edmond,
it doesn't help to clear any indicators/data sinks!
When you "think dataflow!" then you need to reset the data buffers/sources!
LabVIEW keeps data in wires and shift registers/feedback nodes.
In your case you need to reset your feedback nodes...
Even better would be to redesign the whole VI. No need to set all those front panel elements to default, no need to close front panel references.
What about a proper statemachine? What about LabVIEW style guide? What about removing all those Rube-Goldbergs?
05-13-2022 10:07 AM - edited 05-13-2022 10:09 AM
While it is almost impossible to debug a truncated picture, I agree with Gerd that you are way overcomplicating this.
My guess is that you have more than three times the code needed for all required functionality. Simplify!!!
Any indicator just displays whatever data it receives, so just change what's in the wire. Indicators never need to be reset to default! In rare instances, resetting a control is sometimes used, but typically a local variable is preferable over that. None of these invoke nodes are needed. And no, you don't need to close static references. That's a no-op.
Maybe if you would attach your VI, we could give more specific advice. Many things cannot be seen in an image (VI settings, mechanical actions settings, code in other cases, code outside the truncated view, etc.). We are here to help. 😄
05-13-2022 11:43 AM
Hello,
It's my first Labview project ever and I was asked to do difficult things for a beginner 🤣. Yes I believe the whole thing can be simplified.
I have attached my VI, thanks for your help!!!
05-13-2022 03:07 PM
See if this can give you some ideas.
(cannot test, so there are probably bugs. This is a "near literal" translation of your code. Most likely there are better approached to several of the constructs and I would probably do things differently once I know all requirements, but this should get you started.)