BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Rube Goldberg Code


@James.M wrote:

I'm still not sure why this solved his problem because he didn't share the code itself... but this is an interesting way for the code to wait a few iterations before accepting a True boolean. My guess is there's something else in the code that needs a few iterations to fully initialize.

disable_connection_upon_start (5) - working.JPG


Since it's essentially summing the integers it could also be replaced by (i*(i+1))/2 in what ever way hey wanted to do that, which would remove the dependency on the feedback node.

Going even further, he could just work out that on iteration 15 (i=14) the comparison would go true (output of additon being 105), and wire the iteration counter straight into the comparison and change it to 14.

 

edit: Ahhh. Having actually read the thread now, I see it's actually been mentioned. Oopsie.

0 Kudos
Message 1701 of 2,635
(11,810 Views)

@Hornless.Rhino wrote:

@James.M wrote:

I'm still not sure why this solved his problem because he didn't share the code itself... but this is an interesting way for the code to wait a few iterations before accepting a True boolean. My guess is there's something else in the code that needs a few iterations to fully initialize.

disable_connection_upon_start (5) - working.JPG


Since it's essentially summing the integers it could also be replaced by (i*(i+1))/2 in what ever way hey wanted to do that, which would remove the dependency on the feedback node.

Going even further, he could just work out that on iteration 15 (i=14) the comparison would go true (output of additon being 105), and wire the iteration counter straight into the comparison and change it to 14.

 

edit: Ahhh. Having actually read the thread now, I see it's actually been mentioned. Oopsie.


Yea, the FBN and Pt-by-Pt function (along with all the convoluted logic) have a simpler implementation with Min/ Max and a SR that is properly initialized.  ON THE PLUS SIDE! Pavel seems to be working hard and learning!- Jump on in.


"Should be" isn't "Is" -Jay
0 Kudos
Message 1702 of 2,635
(11,746 Views)

Operating a simple 2 state (T/F) LED the hard way as seen here.

 

So we have four simple LEDs on the front panel that shold be red or green based on a boolean scalar.

 

The natural and easy way (right):

For each of the LEDs, make one state (T) green and the other (F) red and wire the booleans to the indicator terrminals.

 

The Rube Goldberg way (left):

  • Leave the LED terminals disconnected
  • Add four case structures and wire the four booleans to the selector.
  • Place red or green colorbox diagram constants (a total of 8!) in the respective cases.
  • bundle the colors into a cluster of two elements in four different places.
  • convert it into an cluster array with one element using built array in four different places
  • Create four "Colors[4]" property nodes, one for each boolean
  • Wire the color cluster array to the property node.

 

I guess you have to see it to believe it, so here's a picture (I have moved the terminals slightly to keep the image smaller)..

 

 

 

(And yes, even the calling VI has two LEDs that are "operated" in exactly the same fashion. That's like operating a traffic light by sending a painter up the pole every 30 seconds to change the colors. :D)

Message 1703 of 2,635
(11,625 Views)

Good question, Christian: Why not?
<sarcasm>
LabVIEW is a graphical programming environment, so adding some additional elements to the BD is an act of increasing its beauty.
And think of her/his boss: If this is the usual coding style there might be enough occasions to slay bugs. The boss can be happy to have employees that are capable in fixing these bugs quickly.
</sarcasm>
Lean and clean code is out.  Long live RG. 

Note: I have recently been passed a project that comes with a good amount of RG ;(

0 Kudos
Message 1704 of 2,635
(11,540 Views)

This is a little complex way to create an array results.

Rube Clean.png

 

Seen here: https://decibel.ni.com/content/docs/DOC-47313

Certified-LabVIEW-Architect_rgb.jpgCertified_TestStand_Architect_rgb.jpg


"I won't be wronged. I won't be insulted. I won't be laid a-hand on. I don't do these things to other people, and I require the same from them." John Bernard Books

Message 1705 of 2,635
(11,476 Views)

Hi Bsvare! Thanks for the correction! Sometimes when I stare at LabVIEW code all day I get a little woozy and the simple solutions slip under my nose. Brilliant solution.Robot Happy

0 Kudos
Message 1706 of 2,635
(11,470 Views)

Is it a Rube Goldberg when you spell a word with all the wrong letters?

 

"Collum"  ?   I guess that actually means "column".  Smiley Tongue

0 Kudos
Message 1707 of 2,635
(11,455 Views)

@RavensFan wrote:

Is it a Rube Goldberg when you spell a word with all the wrong letters?

 

"Collum"  ?   I guess that actually means "column".  Smiley Tongue


Depends on if you have a sudden urge to touch your code and mutter "My precious", or "Filthy local variables"

Josh
Software is never really finished, it's just an acceptable level of broken
Message 1708 of 2,635
(11,411 Views)

Original post.

You want to get the last value out of the loop? Enqueue it to a queue just waiting for the single element.

Checking to see if the first two elements of an array are what you want? Search the array for the two elements and make sure they are at indices 0 and 1.

 

Original code:

Enqueue.PNG

 

Simplified Code:

Nosearch.PNG

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Message 1709 of 2,635
(11,232 Views)

I just ran in to this gem while going through someone else's source code...  I actually had to drop probes before I realized what he was doing with all of the multiplication.

RG Time.png

Message 1710 of 2,635
(11,164 Views)