LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Forgive me for I have sinned...

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

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 1 of 28
(5,299 Views)

So the end justifies the means now?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 2 of 28
(5,270 Views)

@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.

Matt J | National Instruments | CLA
Message 3 of 28
(5,235 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 28
(5,226 Views)

I forgive you😀

Certified LabVIEW Architect
Certified TestStand Architect
Message 5 of 28
(5,200 Views)

excellent.jpg

... now we'll only need Ben to drop some stacked sequences also ...

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 6 of 28
(5,195 Views)

@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.)

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 7 of 28
(5,172 Views)

Globo considered evil! 😉

 

 

Message 8 of 28
(5,168 Views)

@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

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 9 of 28
(5,117 Views)

@Yamaeda wrote:

excellent.jpg

... 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

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 10 of 28
(5,109 Views)