08-27-2007 08:12 AM
@Gabi1 wrote:
btw, for those who still like to use : make current value defaults, thats how it might be done:
Hi Gabi1,
I stay away from relying on default values for front panel objects. It is too simple to make unwanted values default. There are a couple of approaches to avoid that. One is using X-Controls, but you need the appropriate LV package for these. The other is to read those values from a known source (usually static), such as an ini file. Which is where this approach is useful.
Although I have been try to get this code running since LV 6.1 i only assembled all of the right "tricks" in LV 7.1 were i did most of my testing.
Ben & tst,
I did the "testing" with LV8.2. I did not observe any strange behaviour.
@tst wrote:
I generally would agree, as long as the trick seems encapsulated and sound enough.
Now if this approach covered all angles, I'm sure Ben would release it as an OpenG tool.. 😉
.... maybe I shouldn't be giving him any ideas... 😄 Sometimes these "tricks" are needed to provide a more "robust (?)" - not exactly the word I was looking for... "predictable???)"
As I explained to Gabi1, you do not want to rely on default values to initialize front panel controls accessible to the Operator. Plus, maybe you want to change their state.. An automatic "save as default" tool is dangerous... I see it in people's code when I am called to debug or implement features to existing code -- sigh -- 😞 Using X-Controls is not a solution for everyone.. So we need to consider something else.. such as using configuration file. However, I have seen configuration files that are just completely crazy (can't post an example).. The client spends 1/2 day just modifying config files to create new variants of test. Now, with this tool, it is so much easier to do so.. You configure the controls for the test and this approach takes care of saving it for you. Now on your front panel, if you save the settings by name, they can be later recalled "by name", thus providing you with the ability to try out various configuratuions and then even running them as a script (provide a list of "names" to recall is set order). I see an application for an existing client that would need this approach. Especially when the LV programmer spends more time editing config files than writing code... 🙂 The approach was actually legacy code left by someone else...
So.. maybe there are tricks... But the real trick is how to deal with ever-changing configurations without getting your hands too dirty.. 😉 ... or going insane... ... or did Ben already pass that threashold 😄 LOL!!
Concerning the 3D array (post 6).. I can't imagine why someone would need that. I'm trying to mentally picture it... *** no... can't see it *** 🙂
@unclebump wrote:
I guess we know what Ben and JLV do in their spare time!!!
U.N.C.L.E.,
*** spare time!!???!!! *** 😉
08-27-2007 08:16 AM - edited 08-27-2007 08:16 AM
Message Edited by shoneill on 08-27-2007 03:16 PM
08-27-2007 08:24 AM - edited 08-27-2007 08:24 AM
Message Edited by shoneill on 08-27-2007 03:25 PM
08-27-2007 08:55 AM
@shoneill wrote:
We see that the sizes are indeed being ripped from the flattened string data of the array. Not only the TD.
Oh dear, that's twice you've got me in one thread. For some reason I didn't actually look at what was happening inside the case.
Can I attribute this to jet lag from NIWeek (I did return from S.F. which is a 10 hour difference)?
Yes, I can. It's jet lag from NIWeek.
08-27-2007 09:08 AM
08-27-2007 09:28 AM
08-27-2007 09:33 AM
You should note that this saves and loads a typedef, not controls. It simply does it by using control references.
@DFGray wrote:
Although I can see the utility of this sort of automatic state caching, I have never run into it as a use case. I have always stored my internal state variables, not the state of a front panel. This is probably just a comment on my coding style.
08-27-2007 09:39 AM - edited 08-27-2007 09:39 AM
Message Edited by shoneill on 08-27-2007 04:41 PM
08-27-2007 10:35 AM
Wow great thoughts all!
First, lets not overlook JLV's contribution. He had to read this Nugget a half dozen times and re-edit when I was doing one of those "What the he#@ is he talking about?" things.
Shane,
Hijack away! You carrying this Nugget virtually without my help.
tst and Dr Grey,
You are doing what I hoped.
So by my read we are down to two options for getting the array size. My hack and Shanes version.
Q1:
Wouldn't it be nice if there was an X-node that did the scripting required to accomplish this "trick" without resorting to control ref?
Idea:
If you thow out my file I/O stuff and shuffled things a little, code based on these concept could be used to repack a cluster of one order into a cluster with a different order.
Q2:
Has anyone tried this in LV 8.5 yet? (Ben covvers his head and hopes.)
BTW: I really do not like my "copy till it grows" method. I'm glad we agree on that point.
RE: the class of the control for parsing
The stability of the class ID has only recently come to light.
Keep them issues coming.
I love it!
Ben
08-27-2007 11:58 AM
Thanks Ben! You did most of the work.. Cheers go to you! 😄
...They don't have much hierarchy (unless you use XML, but that is whole level of complexity higher)...
As a result, I usually use HDF5 (a hierarchical, binary file format) for my configuration files. I
Hi DFGray,
I agree with you... Unfortunately, you were not involved in action before posting this Nugget... All I can say is that I totally agree with you on the text-based configuration.... and that I was about to open a big can of worm with Ben on the subject of XML.... (I won't do that here either, but again... I agree with you). We could have another Nugget to discuss xml as config file. (Are you busy, Ben?) 😉
The "unfortunate" part is that in Ben & my case, we deal with requirements from our clients/customers. Although I cannot speak for Ben, I'm sure he faces similar situations. Most customers WANT a text-based configuration file. They want it completely readable.. They want to look at it and they want to be able to edit it. (where's they sigh icon...??? )
The test-based config file is in most cases "a customer requirement". Either that or we have to deal with legacy code (I promisse I won't oopen a can of worms based on ... euh... existing customer legacy code)
I am like Shoneil, I have not yet used HDF5. To my knowledge, the recommended (NI) approach to config files is XML. However, I am willing to try other formats, including HDF5 as long as there is long-term support for it. The challenge (in my case) is to "sell" the idea to clients who feel more comfortable with "proven" -cough- methods such as the good ol' text-based ini file...