08-01-2013 10:46 AM - edited 08-01-2013 10:47 AM
Hi Lars,
your own solution using data dependency of WAIT timers is what I called "THINK DATAFLOW"...
I would suggest not to connect the button to the connector pane. So it doesn't receive any value from mainVI, neither by wire nor by default...
When the button should be visible (and usable) all the time it should be placed in the mainVI anyway!
08-01-2013 11:32 AM
I have tried to think of a way to make this button usable from the main.vi...
The problem is that this specific program is so time-dependent and order-oriented that there are elements to the program that have prevented me from doing so. It is meant for the user to input his initial data and values, click a 'Start' button, and then the program will run by itself for a good 2 hours with 0 user input, save for the potential of this "everything off" button. Producer Consumer loops haven't been able to do it for me because when I want to freeze the program from the main.vi, it will always be in the middle of running a for loop in a smaller sub.vi.
Unless there is a way to pass real time input on the boolean control through about 4-5 levels of sub.vis, instead of being locked into the value of the main panel boolean when the 1st layer of sub.vi is called (which is pretty close to the problem I am having here anyway...) I am not sure how I can make that work.
08-01-2013 11:51 AM
Make a functional global variable that holds the status of the emergency. Have 3 actions: Set Emergency stop, Clear emergency stop, and Do nothing (Default).
Now you can set or clear the emergency stop in the one or two locations you may have to do it. Key thing is that you don't want to have a race condition where something sets the stop and another locations clears it and they fight back and forth. Then you can have numerous locations that read the functional global variable that can read the current status no matter how deeply into loops or subVI's they are buried.
08-01-2013 12:20 PM
Sorry Raven, but I am not exactly sure how to do that.
I made a sample sub.vi, attached. It is a simple for loop that counts the iterations, and has a "Freeze" button attached to a while loop inside the for loop, which will freeze the iteration counter when pressed.
Can you make and show me a .vi that calls this example "Stop Button.vi" with a 'functional global variable' that can control the "Freeze" button from a higher level?
08-01-2013 12:23 PM
08-01-2013 12:27 PM
BTW I am using labview 8.5...
08-01-2013 03:36 PM
http://www.ni.com/white-paper/7585/en/
...could it be as simple as just right clicking on the button and making it a global variable?
08-01-2013 03:43 PM
LarsUlrich wrote:...could it be as simple as just right clicking on the button and making it a global variable?
Really? I have never heard of that...
08-01-2013 06:24 PM
For instances like this I like to use notifiers. It is an easy way to broadcast your stop to as many sections of your code as necessary.
The above code is a subVI that I place wherever I need to check for a stop. In the main UI code I would fire off the notifier to indicate a stop has been triggered.
08-01-2013 10:27 PM
@LarsUlrich wrote:
Sorry Raven, but I am not exactly sure how to do that.
See Ben's Action Engine Nugget