Graeme Posted December 31, 2006 Report Share Posted December 31, 2006 Hi everyone, Without boring you all with the tedious details I have a requirement to programmatically clear (set to their default value) front panel indicators (e.g. string and Boolean). There may be many indicators (~100) on the front panel so addressing each individually (via property nodes, say) is not a practical option. A catch-all solution, such as the "Clear indicators when called" VI property (but programmatically), is required. The idea is to create a sub-VI that will do this and that can be re-used in many different applications to carry out this action. Now, I have come up with a few solutions to this, ranging from very clunky to just about acceptable. However, I would be most interested to see how you LV gurus out there might go about the problem, as I'm always keen to find the neatest solution to such problems. I'd also be interested to know if this requirement is something that others have needed in the past. I'll post my solutions (well I call them solutions!) if anybody's interested. Happy New Year to you all. Best wishes. Quote Link to comment
Omar Mussa Posted December 31, 2006 Report Share Posted December 31, 2006 Hi everyone,Without boring you all with the tedious details I have a requirement to programmatically clear (set to their default value) front panel indicators (e.g. string and Boolean). There may be many indicators (~100) on the front panel so addressing each individually (via property nodes, say) is not a practical option. A catch-all solution, such as the "Clear indicators when called" VI property (but programmatically), is required. The idea is to create a sub-VI that will do this and that can be re-used in many different applications to carry out this action. Now, I have come up with a few solutions to this, ranging from very clunky to just about acceptable. However, I would be most interested to see how you LV gurus out there might go about the problem, as I'm always keen to find the neatest solution to such problems. I'd also be interested to know if this requirement is something that others have needed in the past. I'll post my solutions (well I call them solutions!) if anybody's interested. Happy New Year to you all. Best wishes. If you just have to re-initialize the controls to default, why not use the reinitialize to default method of the VI class. Quote Link to comment
Michael Aivaliotis Posted December 31, 2006 Report Share Posted December 31, 2006 You can get the references to all front panel controls and iterate over an array of them with a FOR loop. Use the property Panel reference then Controls []. You can select the controls you want by getting the label or caption text, or even the type. Quote Link to comment
Graeme Posted January 1, 2007 Report Share Posted January 1, 2007 Omar, thanks for the suggestion but I don't think that'll work for me. I want to clear my front panel indicators but leave my front panel controls with their current values. I think the VI property you suggest clears everything, both indicators and controls. Michael, your method is interesting. Didn't know it existed! However, I can't seem to create a valid reference for the Panel property node, always get the invalid object reference error when I run it (any suggestions because I like the sound of this technique?). However, if I use your suggestion but use a Pane property node I can get this to work along the lines that you suggest. To achieve what I want to date I've been using either of two similar methods, one based on the invoke nodes Contol Value: Get All [Flattened] and Contol Value: Set [Flattened], and the other based on the invoke nodes Contol Value: Get All [Variant] and Contol Value: Set [Variant]. These both give me the ability to return only indicator information and hence set only indicator values. Each has a potential problem though. The variant method returns no type descriptors. This means I have to adopt an ugly, brute force, inefficient approach. I have string and Boolean indicators that I want to clear. So I set ALL these indicators to an empty string then set ALL these indicators to a Boolean false. This works but of course generates errors: you can't set a string indicator to a Boolean false nor a Boolean indicator to an empty string. To avoid seeing the errors I break the error cluster wire appropriately and disable the sub-VI's automatic error handling. Yuck! The flattened method does return type descriptors. This means that I can see what type (string, Boolean etc.) the indicator is then clear it (set it to its default value) appropriately. What worries me here though is what if one day NI decide to change/re-assign LabVIEW's type descriptor values? My code won't work. Are the type descriptors liable to change or are they set in stone? Regards, Graeme. Quote Link to comment
Graeme Posted January 1, 2007 Report Share Posted January 1, 2007 Michael, I've got something working. Is the attached VI (IndicatorClearerPanel) the sort of thing you meant? I've also attached my "flattened" version of it to see if anyone has any comments. Certainly with your method (if I've got it right) it's much more obvious what's going on, quite intuitive really. It would be interesting to compare the execution speeds but I can't do this as I'm only running the Base Development system. Regards, Graeme. Download File:post-5820-1167657933.vi Download File:post-5820-1167657950.vi Quote Link to comment
crelf Posted January 1, 2007 Author Report Share Posted January 1, 2007 If the default value of the front panel element is what you want it to return to, then this is a more generic method that doesn't require a case for every data type: Download File:post-181-1167664213.vi Quote Link to comment
Graeme Posted January 1, 2007 Report Share Posted January 1, 2007 Hi crelf, I'm only running LV8.0 so can't open your 8.2 VI. You couldn't save it for the previous version and re-post, could you? Many thanks. Graeme. Quote Link to comment
Michael Aivaliotis Posted January 1, 2007 Report Share Posted January 1, 2007 Hi crelf,I'm only running LV8.0 so can't open your 8.2 VI. You couldn't save it for the previous version and re-post, could you? Many thanks. Graeme. Quote Link to comment
Graeme Posted January 1, 2007 Report Share Posted January 1, 2007 Hi again crelf, From your comments in your post I've deduced how your VI (probably) does it. What a beautifully simple solution. Many thanks to you and Michael for pointing me down this road. I think this is what I'm after. Graeme. Quote Link to comment
crelf Posted January 1, 2007 Author Report Share Posted January 1, 2007 Thanks Mike - I should have just put up the BD in the first place. Many thanks to you and Michael for pointing me down this road. No worries Graeme - sometimes it's just about hunting through the properties and methods until you find something that'll get the job done PS: you might want to check this out at around 11:30 tonight, London time... Download File:post-181-1167668503.vi Quote Link to comment
Graeme Posted January 1, 2007 Report Share Posted January 1, 2007 Ha ha, I like it crelf, very witty indeed. Fortunately I'm Scottish though, just happened to have lived in England most of my life, so not too fussed about the cricket (just as well). Soccer's a bitter pill to swallow though... Thanks again guys. Graeme. Quote Link to comment
crelf Posted January 2, 2007 Author Report Share Posted January 2, 2007 Ha ha, I like it crelf, very witty indeed. Fortunately I'm Scottish though, just happened to have lived in England most of my life, so not too fussed about the cricket (just as well). Soccer's a bitter pill to swallow though... No worries me old mate (you must be enjoying the Ashes series almost as much as I am then ) Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.