LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW Style Challenge - Error Wires

Tom McQuillan and I are gearing up for a fierce LabVIEW style debate at GDevCon in September and wanted to reach out to the LabVIEW community to learn the your style quirks and preferences.

Style Challenge
Download the attached file, an incomplete simple subVI that reads from an ini file, and sends values to a queue and a event.
Complete this code such that it is not broken, and it shows your best coding style practices.

hunter_jki_2-1691592454046.png

 

 

Once complete upload a screenshot of your block diagram below.

Bonus Questions
What are your biggest coding style pet peeves?
What, if any, style practices do you enforce militantly?

Message 1 of 147
(2,405 Views)
0 Kudos
Message 2 of 147
(2,390 Views)
Can you upload for 2016 or older?
0 Kudos
Message 3 of 147
(2,355 Views)

Here you go, the VI in LV2012

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.

Finding it hard to source NI hardware? Try NI Trading Post
Message 4 of 147
(2,340 Views)

Could you also include a typical ini file?

 

I guess the main challenge is to decide on error handling because queue and event should be able to fail independently. (Removing all the duplicate code is easy 😉 )

Message 5 of 147
(2,333 Views)

Going with the assumption that Enqueueing and Generating Event need to happen one after the other:

 

BertMcMahan_0-1691596292269.png

 

This also assumes that you want any upstream errors to prevent any further actions from happening. For example, if I wanted to generate the user event even if the Enqueue failed, then I'd handle it differently:

 

BertMcMahan_1-1691596525606.png

 

Bonus questions:

 

1- Biggest pet peeve is when two VI's that are generally adjacent to each other have different conpanes that make the wire bend. For example, the INI file VI's have the config refnum chained between each VI. I've run across examples before where a 4-terminal output conpane goes to a 5-terminal input conpane, meaning you have to have a tiny little bend in the wire somewhere.

 

2- All objects that are near each other have to be justified to each other, even if they don't interact. For example:

BertMcMahan_2-1691596909781.png

 

(I guess number 2 is also a pet peeve 😁)

 

 

 

Message 6 of 147
(2,327 Views)

Here is mine.

 

Taggart_0-1691597686664.png

 

Sam Taggart
CLA, CPI, CTD, LabVIEW Champion
DQMH Trusted Advisor
Read about my thoughts on Software Development at sasworkshops.com/blog
GCentral
Message 7 of 147
(2,316 Views)

Here is me:

With some assumptions about the code

Design Challenge.png


1) Pet Peeves: No escape from wires crossing like in the second for loop. There will be some bends and some crossing.
2) I like to group the operation and try to execute them by group if possible like shown in the snippet.

Message 8 of 147
(2,296 Views)

@hunter_jki wrote:

Tom McQuillan and I are gearing up for a fierce LabVIEW style debate at GDevCon in September and wanted to reach out to the LabVIEW community to learn the your style quirks and preferences.

Style Challenge
Download the attached file, an incomplete simple subVI that reads from an ini file, and sends values to a queue and a event.
Complete this code such that it is not broken, and it shows your best coding style practices.

hunter_jki_2-1691592454046.png

 

 

Once complete upload a screenshot of your block diagram below.

Bonus Questions
What are your biggest coding style pet peeves?
What, if any, style practices do you enforce militantly?


The heck I would complete that code!  I'd advise strongly against it!

 

I MIGHT pass that Configuration Data to a User Event where the Data itself is exposed on the Left Event Case Node for Every Event Structure registered for the Event.   A 1:n Data Process.  Then have each Responsible Event Structure pass the Data along to the Event Customer that the specific Event Structure is serving (along with some Command information to tell each Data customer what to DO with the configuration Data.)

 

But, I think that passing configuration Data directly to ANOTHER Queue is just a bit silly since, it is already stored in a queue internally.  Moreover, it just isn't scalable with more than one Data Customer and you will beg to find race conditions between the configuration Data Queue (a writeable object) and the NEW Queue.

 

Better, Fire a User Event and Operate on the configuration Data Queue (Read/Write) in the Event Case and serve the Data Client from the Event. I.e. fire User Event "Config XYZ" (Datatype config file refnum) then Do Something.  You could even get Values for the same Key for each Section that you write P-C (Events) plugin for while registering different Event Structures for each of the config parameters it is designed to use.  

 

Yep, an Event driven Actor.class is exactly what I mean if taken all the way to LVOOP.


"Should be" isn't "Is" -Jay
0 Kudos
Message 10 of 147
(2,279 Views)