02-24-2016 11:36 AM
I have uploaded a program which I am doing. It is the code to back up data by sending files over network using tcp. It is divided into 4 cases. But the problem is my whole program is kept inside a while loop and stop button is used to stop the program. But unfortunately the stop button is not working. I dont know why is that. Can someone please help me by saying why is the stop button not working and what should be done to make it work. Thanking You in advance.
02-24-2016 11:51 AM
LabVIEW programming is based entirely on dataflow and parallelism. This is incredibly powerful and has lead to its success over the years (coupled with the graphical programming), but is usually one of the first things that new developers stumble over. Here's a simple resource to become more familiar with how it works. The Highlight Execution feature is a great way to watch how your application utilizes dataflow.
Your Stop button is being read after every iteration of your loop, but your program is running and not looping while doing other things. You have waaaay too many event structures. Your code sits and waits at every single one of them until the button you want is pressed. You should only have one event structure that handles all of your user events. You even have events with different structures that will compete with each other in different cases of your case structure.
You need to rebuild your application from scratch with a better architecture. This will never work the way you have it and it would just be faster to re-do.
The Simple State Machine template that ships with LabVIEW is really the best way for new developers to get familiar with LabVIEW while utilizing a semi-scalable architecture.
Here's a broad example of how a state machine works:
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
02-24-2016 05:31 PM - edited 02-24-2016 05:36 PM
@vindsan wrote:But unfortunately the stop button is not working. I dont know why is that.
I think nothing is working right and you already got a few good tips how to correctly architect your application.
You have multiple hard event structures in the same cases and even in different cases. Even the ones that are in the "other case" will queue up events, but will never be able to service them. They lock the front panel until the event completes, but the event cannot complete because it is not in the dataflow. Deadlock!
A case with multiple timeout-free event structure can only complete once all event structures have been triggered.
Then you have serious race conditions that make the outcome completely unpredictable. Most of it is cause by mindless overuse of local variables.
Let's have a look at the following code section:
Once the event triggers, the listbox output is read and pushed into an array indicator (A). In parallel, the array indicator gets read via a local variable (B). Since there is no data dependency both things occur in parallel and most likely the local variable gets read before the indicator gets updated with the new listbox values and you are processing values from a stale state. Eliminate the local variable and simply branch the wire form the listbox. You can even delete the "array" indicator once you are done debugging, it is not doing anything useful.
Never use exotic mechanical actions such as "switch until released". They have their use, but 99% of all boolean controls are typically either "switch when released" or "latch when released". Don't try to micromanage such details without plenty of thinking. Typically you should use value events instead of mouse events.
You need to learn about the basics of dataflow. Then look at the common design patterns that ship with LabVIEW I am sure there is something that fits.