Jump to content

Data Access on the cheap and easy


torekp

Recommended Posts

First off, thank all y'all for schooling me on Data Access Best Practices and FGVs, Action Engines and DVRs.  Now let's dumb it down a bit.  I want to ask about good(?) old-fashioned native Labview globals.

 

Here's a use case:  A control program for an industrial process has 10-20 adjustable parameters (numerics and booleans) on its GUI.  These parameters are written once at program start based on values in an INI file, and then an arbitrary number of times thereafter when the user changes them.  It is not critical for the process to update the user-changed value at the exact millisecond.  So: globals?  Or what?

 

How lazy can I be, before the expected value of time and effort goes negative?  Let's assume that the control program is subject to revisions such as adding more adjustable parameters.  The additional parameters could represent new hardware that has been added, or simply taking advantage of more functions (that we had thought we could just set and forget) of existing hardware.

Link to comment

I'm somewhat biased but I'd use CVT (https://decibel.ni.com/content/docs/DOC-36858) or any of the numerous similar tools out in the world for that. Since the number and composition of the variables can also be loaded from the file alongside the data, it makes it easy to add new fields. Performance is slightly slower than a global, but not by all that much. Plus we already have a nice-ish library for copying data across the network so an HMI can update it (https://decibel.ni.com/content/docs/DOC-37226).

 

I'd use a global if the data I'm changing were more fixed, like a stop (except I'd use notifiers for that) or maybe some timing information.

 

For your specific situation, where the count is small and timing is really not critical, honestly shared variables would probably be OK. Probably. SVs can also be referenced programmatically, so all you'd need is some VI that reads your INI file, translates the token names into variable names, and writes the appropriate value into the SV.

Link to comment

It's really a risk calculation. You have to anticipate what are the odds that down the road you'll want some feature (programmatic access? in place editing?) that globals can't easily provide. If you think you have a 10% chance you'll need that and it would take your 40 hours to pull out all your global and put in a better data type, you'd need to save 4 hours of development time to justify using a global. Maybe you should put in a fudge factor for unknown unknowns. So you'll want to save 40 hours of dev time to justify their use.

Link to comment

It's really a risk calculation. You have to anticipate what are the odds that down the road you'll want some feature (programmatic access? in place editing?) that globals can't easily provide. If you think you have a 10% chance you'll need that and it would take your 40 hours to pull out all your global and put in a better data type, you'd need to save 4 hours of development time to justify using a global. Maybe you should put in a fudge factor for unknown unknowns. So you'll want to save 40 hours of dev time to justify their use.

For the use he described, what would be the superior alternative? I'm on board with what you're saying, generally, but in this case...

Link to comment

Thanks for the input.  I already had installed CVT from reading those threads I mentioned, but I did not think to use it for this relatively simple case.  Now that I'm looking at it, it does seem very easy to use.  The only downside is the XML files.  Usually I put my initialization info into an MGI_Read_Anything type file.  The MGI format is much easier for a non-programmer to read (and modify).

 

The obvious solution is, I could write a few little VIs to use the MGI format.  I think I will.

Link to comment

Yeah, XML was just a convenience but for some reason a lot of people get hung up on that. Sometimes I think it would have been better to include no serialization at all. I don't think I've ever used the XML format for anything. If I were selecting all over again in 2013, I'd pick the json parser instead (even if it is a bit of a pain to use for no real reason <_<).

 

Anyway, the MGI files look nice, simple enough format. Good luck with the rest of the CVT.

Link to comment
  • 2 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.