08-27-2007 01:46 AM
@Gabi1 wrote:
btw, for those who still like to use : make current value defaults, thats how it might be done:
You should note that this method will not work in an executable , because the run-time engine cannot save VIs.
For enums, i generally never let the user update them directly, but always trough an external vi, that saves both the string and the value.
It's also important to note that the problem here is with the programmer changing the typedef enum. If the programmer is only adding elements at the end, then you have no problem. The problem is that you can't rely on the programmer doing that. You have to account for that somehow, either by throwing an error if the value was not found or by using a default value (probably throw an error because you wouldn't want the values changing behind your back).
It is true that users should not usually see enums on the front panel, but have a ring with some sort of translation from the ring values to the enum values.
08-27-2007 02:06 AM - edited 08-27-2007 02:06 AM
Message Edited by shoneill on 08-27-2007 09:11 AM
Message Edited by shoneill on 08-27-2007 09:12 AM
08-27-2007 03:14 AM
@shoneill wrote:
Regarding tricks stopping to work. I'm pretty pragmatic on this one. NI may or may not change a whole boat-load of things in future versions. I'd rather not try to second-guess their future moves but rather concentrate my efforts on the best current method available. I also don't think they're going to get rid of variants completely (or radically change them) without having something else with similar (or better) functionality available. Heck, maybe NI will give us a function to exactly what Ben's describing here, thus negating the need for this discussion.....
I generally would agree, as long as the trick seems encapsulated and sound enough.
I had a look at the tool in the GetType.llb, but I don't think this works. LV stores the array sizes as -1 since LV has dynamic sized arrays. The Type Descriptor therefore does NOT store the actual size of the array. At least it didn't in LV 6.1. I just checked, and this is true for 8.2.1 also. It's NOT possible to get the array size this way (unless always getting -1 is of any use). Wire up an array and check it out. This why "tricks" are required to get the array size.
I see you missed it again.
GetType.llb is what 7.x had.
8.x has a new folder with VIs which do return the dimension sizes.
In the OpenG code, the dimension sizes are extracted from the TD of the variant, not of the array itself.
08-27-2007 04:58 AM - edited 08-27-2007 04:58 AM
PS a further correction : The OPenG versions do not get the sizes from the TD, they use the TD and the flattened data of the entire array. Only using the TD, this is not possible.
Message Edited by shoneill on 08-27-2007 11:58 AM
Message Edited by shoneill on 08-27-2007 12:04 PM
08-27-2007 05:08 AM
08-27-2007 06:12 AM
Thanks for all of the comments!
I can only address some of the issues at the moment.
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.
I'll look for the libraries you mentioned tst. They may be just the ticket.
If the example Shane posted is the same one I saw off-line, his method is perferable to my fat-fingered approach.
Thank you Shane!
Run in the UI thread?
Yep! The top level VI's are configured to run in the UI thread rather than forcing thread swaps for every other node.
Gabs,
You sound like you are running in the same track as me. Everytime I sat down to write a new "save-Restore" I was motivated to figure out how to do it once and forget about it.
I re-read the mreplies again and post back latter.
Have Fun!
Ben
08-27-2007 06:21 AM
08-27-2007 06:33 AM
@Ben wrote:
I'll look for the libraries you mentioned tst. They may be just the ticket.
Maybe, but I believe I was thinking of the VI in the image Shane posted. Either I didn't test it (quite possible) or I was thinking of another VI (unlikely) or it only started working in 8.5, but I can't check at the moment.
Shane, I only had a quick look, but it looks like the OpenG code takes advantage of the fact that the array data is saved flat and simply uses that with some dark magic TD manipulation to generate a 1D array of variants (see the attached).
08-27-2007 06:40 AM
08-27-2007 08:05 AM
In the last post I was only refering to the conversion of an array to a 1D array of variants. The actual dimension sizes are determined by analyzing the TD of the variant holding the array (the VI in the left side of the internal case structure). As you say, it requires duplicating the array itself by converting it to a variant.
BTW, your image wasn't attached.