‎03-29-2017 02:54 PM
While troubleshooting code on-site written by someone else I found a race conditions between two control loops where the stop Boolean was being set in one loop and un-set in the other loop.
It appeared the second loop was an attempt to just cut-n-paste a duplicate of the first loop the be able run a second test at the same time.
So I did what I have not done in almost two decades...
I created a Global Boolean to correct the race condition.
Please forgive me!
Ben
‎03-29-2017 03:33 PM
So the end justifies the means now?
‎03-29-2017 08:11 PM
@Ben wrote:
I created a Global Boolean to correct the race condition.
Please forgive me!
I'm sorry Ben but you'll have to turn in your LabVIEW Champion's badge.
Not that I can really take the high ground on this issue. I'm sure I've recommended just about everything that could be considered bad practice at one point or another in a support call.
‎03-29-2017 09:08 PM
A global to tell everyone when to stop? Sounds reasonable to me. Remember, globals are not evil, they are just often abused.
Now if you used a Network Published Shared Variable, I might have to drive 4.5 hours and smack you silly.
‎03-30-2017 01:23 AM
I forgive you😀
‎03-30-2017 01:50 AM
... now we'll only need Ben to drop some stacked sequences also ...
/Y
‎03-30-2017 05:11 AM
@crossrulz wrote:
A global to tell everyone when to stop? Sounds reasonable to me. Remember, globals are not evil, they are just often abused.
Now if you used a Network Published Shared Variable, I might have to drive 4.5 hours and smack you silly.
I still think globals are evil, but if you can bend them to your will, you have a powerful ally. 😉
(Actually they aren't evil, but it made for a nice potential LV Proverb.)
‎03-30-2017 05:18 AM
Globo considered evil! 😉
‎03-30-2017 08:19 AM
@crossrulz wrote:
A global to tell everyone when to stop? Sounds reasonable to me. Remember, globals are not evil, they are just often abused.
Now if you used a Network Published Shared Variable, I might have to drive 4.5 hours and smack you silly.
I believe Tim, that our differing view of global variables is due to our differing perspective...
Please correct me if I am wrong in describing your view of them.
I BELIVE you see them as useful as long as YOU the developer understand their nature and are the person developing the code AND that anyone that may follow-up to maintain the code in the future has a similar understanding.
An analogy would be "A flat roof is fine as long nobody is stupid enough to try play Frisbee on it."
For myself, I have to assume those that follow my work will be at BEST people that have gone through LV I & II and only tinker with it when things need to change. I feel obligated to protect them from the dangers.
Continuing the analogy...
" I will argue that we need to put up a railing along the edge of the roof because I will not be around to warn them about playing Frisbee on the roof."
In fact the problem that I was trying to fix "The application does not stop when the user clicks 'stop' and they have to use the abort button to stop LV" is an example where the "railing" would have prevented that accident from happening.
I have read you suggesting using a User Event to stop loops. IF the original developer had used a User Event in the first loop and had cloned the second from the first, the wires of the user event would have prevented to interactions between the two loops.
Alternatively, if the had developed a "Stop" Action Engine" that would latched-up the stop condition the problem would have been noticeable in that stopping one test (loop) would have stopped both. The Action Engine could have then ben extended to support unique stop states to solve the problem.
Re: Forgiveness
Thank you!
Ben
‎03-30-2017 08:32 AM
@Yamaeda wrote:
... now we'll only need Ben to drop some stacked sequences also ...
/Y
I have done that and I am not ashamed to admit it. But I use them not as a means to control the code execution sequence but rather to hold documentation IN THE DIAGRAM. State "0" is the code and state "1" or more will hold flow diagrams or images of the industry standards describing the math etc.
Am I being a hypocrite railing against Global variables but still advocating for preserving the Stacked-sequence?
I think not (please help me out if I am missing something) because cloning a SS will not introduce a bug. After all a SS differs from a flat sequence or a set of flat sequence frames coupled together using an error cluster.
Ben