BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Rube Goldberg Code


t06afre wrote:

This weekend I picked up this golden nugget from the Labview forum.


Ouch! I somehow missed that. No wonder I stayed out of that thread. 😄

 

I would guess we have about 98.5% too much code.

 

  • Near identical subVIs, just differing in a diagram constant and name.
  • Wait loops that check the tick count every nanosecond, consuming all CPU in the process. (He knows the wait function, because it is used two frames later in the same flat sequence).
  • "one iteration" while loops.
  • "code only" VIs (e.g. "select picture.vi") that are set to "show front panel when called"
  • Completely useless property nodes and methods (e.g. s+presentation.vi" is already set to open when called and close afterwards, so closing the FP in the last frame and then reading the setting without ever using the output of the node seems pointless.)
  • Warping of pane origin and button positions..
  • ....

 

I would guess a single small toplevel VI state machine some logic, and the four picture VIs are all that's really needed.

 

It does not really take any brains to disassembe this monstrosity, just a gigantic monitor, paper and pencil and a huge amount of free time, which I unfortunately don't have.

 

It would be much cheaper to get the detailed specs and code it from scratch. 😄 Shouldn't take more that 10 minutes.

Message 391 of 2,635
(13,011 Views)

The "referenceophils" way of programming:

 

  • Place all terminals disconnected inside the first sequence frame.
  • In the next sequence frame place static references.
  • Do everyting (everything!!!) with value reference nodes connected to the reference wires.

 

Here's how we simulate latch action booleans, e.g. "quit" (but there are many more).

 

 

(spotted here)

Message Edited by altenbach on 12-08-2008 11:58 AM
Message 392 of 2,635
(12,928 Views)
I have not been using Labview 8. For so long time. But anyway, this day I needed the function called “file dialog”. At first I could not find it. But then I saw the express VI named File dialog. OK so far so good. I placed it in my block diagram. And since I am a curious person I opened the front panel. Just to find another sub VI just to discover no functions but a new sub VI. Taking a dive into this sub VI I found the old File Dialog function, which they have removed from the palette. Besides creating Rude Goldberg code. I see no use in this. From my point of view I think many of the express VIs have the same symptom as many people in the western world. They suffer from overweight. Covering all ranges from moderate to super heavySmiley Very Happy


Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
Message 393 of 2,635
(12,852 Views)

To retrieve an I16 from a 4 chars string received on a serial port, you can convert the string to an U8 array, chop off the last two elements, index explicitely the two remaining elements, convert each one to I16s, shift-left the first one and logical-or-e the result with the second.

Or you could typecast the string...

as found here
Chilly Charly    (aka CC)
Message 394 of 2,635
(12,765 Views)

I love the cast function and i use it a lot. But has not your solution a smal flaw. 4 chars is 32 bytes or 2 I16. So the type input (in the type cast function) should have been connected to an array. Your solution will only convert the 2 first bytes to an I16. But this person needed the 2 last char converted to a number. Smiley Wink



Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 395 of 2,635
(12,759 Views)

Correct.  You need to cast to a cluster of 2 i16, and select the second one.  A bit more complicated, but still much easier than the original code.

 

Shane.

Message Edited by Intaris on 12-17-2008 05:59 AM
0 Kudos
Message 396 of 2,635
(12,756 Views)

Intaris wrote:

Correct.  You need to cast to a cluster of 2 i16, and select the second one.  A bit more complicated, but still much easier than the original code.


Assuming we are not interested in the first two bytes at all and we know we only get four bytes in the string, we only need to convert the correct string subset as follows.

 

 

Message Edited by altenbach on 12-17-2008 10:15 AM
Message 397 of 2,635
(12,721 Views)

Seems that you all missed the same point : the guy was just interest by the two first bytes (the last ones were CR LF)... 🙂

In the original solution, remove elements was completely useless...

Message Edité par chilly charly le 12-18-2008 05:23 AM
Chilly Charly    (aka CC)
Message 398 of 2,635
(12,685 Views)
Ah, yes. Looking at your code picture I mistook the "delete from array" as "array subset", which would have been a more natural choice here. 🙂
0 Kudos
Message 399 of 2,635
(12,674 Views)

That's a "Delete from Array"? Would have never noticed that since I never really use it.  I "saw" "Array Subset" too. :smileysurprised:

 

OK, then the operation in the original code is totally pointless.

 

Shane.

0 Kudos
Message 400 of 2,635
(12,635 Views)