LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I Reprogram Cow-Orkers?

One of my cow-orkers needed to convert an array of 4 elements into a cluster of 4 elements.

He tried the "Array to Cluster" function, but it didn't work (because he hadn't set the cluster size).

So instead of looking up the help for the function, he just hacked away, ending up with this:

c.png  Not terrible, but not nearly as clean as it ought to be.

The problem is when you multiply this by every time any of them writes any piece of code.

Does anybody have any ideas on how to re-program cow-orkers so that they actually try to make good code?

"If you weren't supposed to push it, it wouldn't be a button."
Message 1 of 10
(2,379 Views)

Well, the here advantage is that the resulting cluster correctly corresponds to the typedef cluster, while a plain array to cluster would give you a generic naming scheme.

 

My cluster contents are almost never of homogenous datatype, so I would actually use a bundle by name and pick the elements that need to be replaced with the values from the array. "by name" cluster functions are beautifully self-documenting (as long as the elements have good naming 😉 ).

0 Kudos
Message 2 of 10
(2,373 Views)

Maybe the "array to cluster" should have an optional cluster input on top, which, when wired, would define the size and datatype and break the wire if the array does not match in datatype or if the cluster is of mixed type. Maybe a similar idea already exists...

 

Note that if the array has 4 DBLs and the cluster typedef also has 4 DBLs, a simple typecast will do the trick, properly naming the output elements:

 

altenbach_0-1629909473646.png

 

Message 3 of 10
(2,364 Views)

@paul_cardinale wrote:

One of my cow-orkers needed to convert an array of 4 elements into a cluster of 4 elements.

He tried the "Array to Cluster" function, but it didn't work (because he hadn't set the cluster size).

So instead of looking up the help for the function, he just hacked away, ending up with this:

c.png  Not terrible, but not nearly as clean as it ought to be.

The problem is when you multiply this by every time any of them writes any piece of code.

Does anybody have any ideas on how to re-program cow-orkers so that they actually try to make good code?


I actually like this because it is pretty explicit in its conversion, but that's besides the point.  I think that experience is probably the best teacher here.  We all have moments when we do something a little Rube-ish because we are not aware there is a much simpler way to do this.

 

This is where you come in.  Unfortunately, this is a problem probably only an experienced LV programmer like yourself can remedy.  Simply put, every time you see something like that, you'll have to show him there is a better way to do it, so he can learn from your experience.  I wish I had someone like that, but I am one of the most experienced LV programmers where I work, so nobody helps me; I end up helping everyone else (when I can).  I suspect there are better ways to do some stuff than I am currently doing, but there's no one to turn to for me.

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.
0 Kudos
Message 4 of 10
(2,363 Views)

@altenbach wrote:

Maybe the "array to cluster" should have an optional cluster input on top, which, when wired, would define the size and datatype and break the wire if the array does not match in datatype or if the cluster is of mixed type. Maybe a similar idea already exists...

 

Note that if the array has 4 DBLs and the cluster typedef also has 4 DBLs, a simple typecast will do the trick, properly naming the output elements:

 

altenbach_0-1629909473646.png

 


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

i would prefer if they made "Array to Cluster" smarter so then when you wire the output, it looks at it an adjusts its size.

"If you weren't supposed to push it, it wouldn't be a button."
Message 5 of 10
(2,336 Views)

Not really helping your concern here, just voicing my thoughts on alternative implementation,

 

Since the cluster contents are all numeric and it just simple as named elements, I would have approached this with an array of numeric and a string array containing the corresponding channel name/label for the numeric array. I do agree that every time you need to get a specific element data, you need to look up its position on the string array and then index it from the numeric array.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution
0 Kudos
Message 6 of 10
(2,306 Views)

@paul_cardinale wrote:

i would prefer if they made "Array to Cluster" smarter so then when you wire the output, it looks at it an adjusts its size.

I've voiced that thought before - but it's been pointed out that clusters dont change size at runtime, arrays can - so I too use the typecast (it's elegant beautiful and easy to read, I plan my cluster structures to use this too if they are going to be big).
As for re-programming Cow-orkers, I'm sure sometimes they'd like to reprogram you to give them training instead of moan, and to let them know when they've done something right. (I'm sure you do really Paul, just looks like you're going through a tough patch at the moment 😉)

James

CLD; LabVIEW since 8.0, Currently have LabVIEW 2015 SP1, 2018SP1 & 2020 installed
0 Kudos
Message 7 of 10
(2,291 Views)

I would say proper training and regular code reviews. Array to Cluster is a fairly basic primitive, to have a coworker working on production software who has never used that before... the thought kind of irks me, not gonna lie.

 

BUT, then again, take another super common primitive, Compound Arithmetic. I just learned a couple weeks ago that you can invert the inputs. I know I have code out there that would look way cleaner had I known this from the get-go. It never came up when I got trained, or in any code reviews, or by looking over legacy code. I never even noticed it when skimming the right-click menu to change the mode. I only learned about that from this forum. Was looking at an uploaded VI for a completely different thing, and saw it and was like "hoooooold up..."

 

Both myself and your coworker would have been fine if we had just read the Detailed Help for the function the first time we used it. In that regard, we both could use a lesson in RTFM, you could say.

 

Bottom line, you don't know something until you do. Hopefully now that it's come up, your coworker 100% knows how to set up Array to Cluster.

Redhawk
Test Engineer at Moog Inc.

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

0 Kudos
Message 8 of 10
(2,289 Views)

In regards to the Array To Cluster mess...Go give this idea a kudos: Allow Array to Cluster Type.  In the comments, AristosQueue recommends just using Coerce To Type.



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 9 of 10
(2,275 Views)

@crossrulz wrote:

In regards to the Array To Cluster mess...Go give this idea a kudos: Allow Array to Cluster Type.  In the comments, AristosQueue recommends just using Coerce To Type.


I could make an XNode that does that.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 10 of 10
(2,249 Views)