BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Rube Goldberg Code

A unique class of Rube Goldberg Code involves the (ab)use of dynamic data. I thought It deserves its own thread. Feel free to contribute:

 

What's wrong with dynamic data?

 

(I was actually tempted to also include express VIs, but lets keep it narrowly focused for now)

0 Kudos
Message 1311 of 2,635
(11,008 Views)

These two examples are taken from the code posted here. There is plenty more weird stuff in there, but see for yourself).

 

What boggles my mind is trying to imagine how long it takes to write all this. Done right, it could all be done in five minutes. Even if this programmer would work at minumum wage, I could justify to ask for 100x minimum wage and the company would still be better off. :D)

 

(A) In order to read about 60 controls and write them to a tab delimited text file. We apparently need:

 

  • A 60 frame stacked sequence, reading one control at a time. Why does order matter here?
  • The outer flat sequence enforces an execution order that is already enforced by dataflow. Not needed!
  • Explicitely building the long tab delimited string (The next version will have 500 controls and the primitive will no longer fit on the screen!)
  • Making it into an array with one element
  • write it to a spreadsheet file.

All that's probably needed is "build array" and "write to spreadsheet" file to achieve exactly the same.

 


 

 

 


Moments later, we read the same data from the file again. This time we read it as a 2D array (even though it only has one row!) and use an index array primitive to get all values, one at a time. Then we write each value to an indicator terminal AND to a local variable of the same indicator terminal. Do that also about 60 time, filling the entire screen (here is a small section).

 

All we need is tap into the 1D output of "read from spreadsheet file"and use a single index array resized to the proper size and connect to all indicator terminals in order. The indices don't need to be wired. None of the local variables have any purpose.

 

 

Download All
0 Kudos
Message 1312 of 2,635
(10,937 Views)

@altenbach wrote:

These two examples are taken from the code posted here. There is plenty more weird stuff in there, but see for yourself).

 

What boggles my mind is trying to imagine how long it takes to write all this. Done right, it could all be done in five minutes. Even if this programmer would work at minumum wage, I could justify to ask for 100x minimum wage and the company would still be better off. :D)

 

(A) In order to read about 60 controls and write them to a tab delimited text file. We apparently need:

 

  • A 60 frame stacked sequence, reading one control at a time. Why does order matter here?
  • The outer flat sequence enforces an execution order that is already enforced by dataflow. Not needed!
  • Explicitely building the long tab delimited string (The next version will have 500 controls and the primitive will no longer fit on the screen!)
  • Making it into an array with one element
  • write it to a spreadsheet file.

All that's probably needed is "build array" and "write to spreadsheet" file to achieve exactly the same. 

 


So if he is really just looking to save and load control values you can just use the OpenG sub VI "Write Panel to INI" and "Read Panel From INI".  If OpenG is not an option then I would suggest not using the build array option, and instead get references to the controls using the "Traverse GObjects" to find all the string controls that match the pattern.  Then getting the values in a for loop using the references.  Then if you add a new control you don't need to change the code at all.  You can use this same method to set the control values using their references.

0 Kudos
Message 1313 of 2,635
(10,921 Views)

I wonder if he needs all those controls anyway....   Sounds like a typical use of controls as 'variables', in stead of the wires. 

 

And if he really needs those controls, then probably an array of those controls would have been sufficient.  

0 Kudos
Message 1314 of 2,635
(10,870 Views)

The 60 controls and the wires do seem to give some hypnosis effect.

Though, he should distributed them more evenly 😉

Kind Regards,
Thierry C - CLA, CTA - Senior R&D Engineer (Former Support Engineer) - National Instruments
If someone helped you, let them know. Mark as solved and/or give a kudo. 😉
0 Kudos
Message 1315 of 2,635
(10,863 Views)

@ThiCop wrote:

The 60 controls and the wires do seem to give some hypnosis effect.

Though, he should distributed them more evenly 😉


Ugh.  Why am I not more productive?  Becuase I'd have wasted 20 minutes getting all those wires perfectly spaced before I could continue.  Sometimes OCD is a real pain.

0 Kudos
Message 1316 of 2,635
(10,844 Views)

Intaris wrote:

Ugh.  Why am I not more productive?  Becuase I'd have wasted 20 minutes getting all those wires perfectly spaced before I could continue.  Sometimes OCD is a real pain.


That's why you use the Align and Distribute buttons on the wires.  I don't remember what version those started to work with wires, but I know it works in 2011 (and has saved me lots of time from my OCD).


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 1317 of 2,635
(10,827 Views)

I think that was irony from Intaris. 🙂

Kind Regards,
Thierry C - CLA, CTA - Senior R&D Engineer (Former Support Engineer) - National Instruments
If someone helped you, let them know. Mark as solved and/or give a kudo. 😉
Message 1318 of 2,635
(10,820 Views)

@ThiCop wrote:

I think that was irony from Intaris. 🙂


My guess as well.  OCD and RFC 2323 (FHM) compliance would just about drive a man insaneSmiley Wink


"Should be" isn't "Is" -Jay
Message 1319 of 2,635
(10,813 Views)

@ThiCop wrote:

I think that was irony from Intaris. 🙂


Yeah. Irony.  Completely.  Smiley Wink

 

Spoiler
It was only a joke.  I would have those wires aligned within 5 minutes or so..... Smiley Very Happy

I've been using versions of LV without the great new align wire functionality for so long, I can't get used to it being there.....

 

0 Kudos
Message 1320 of 2,635
(10,797 Views)