Oxynos Posted November 6, 2013 Report Posted November 6, 2013 Hi guys! I'd like to have my XNode to behave differently when the input is a (strict) typedef but also differently according to the typedef path (or name) if any. In a regular VI, this is easily done by extracting the path of the typedef: Terminal>Control>TypedefPath, but in Xnodes it's another story! So far I managed to get the regular type in the 'AdaptToInputs' ability (which is the common use of this ability!) and to see if it is a typedef or not by reading the properties of the control in the 'GenerateCode' ability. But in this last ability VI, an error occurs when I try to obtain the TypedefPath (Error 7). This error apparently occurs in Xnodes and especially Express VIs when "one of the internal paths is hard coded incorrectly" Is there a limitation due to the XNode or else? I guess that I could get around the problem by scripting the owning VI and retrieve the typedef of the control connected to the XNode directly but it would be quite cumbersome and ugly. Any thoughts on the subject? Quote
Jon Kokott Posted November 7, 2013 Report Posted November 7, 2013 I think its because your terminal on the xnode isn't really a typedef but just an adapted terminal. Maybe try opening the typedef itself (by using the string of the actual name) and then getting the path. So somethign like: control -> Value-> Strip out typedef name from variant -> open vi reference (with the string name in same application ref) -> then get path. ~Jon Quote
Oxynos Posted November 7, 2013 Author Report Posted November 7, 2013 Nicely done, I didn't think about extracting the type from the variant! Based on your idea, I used GetTypedefPath.vi which is in the vi.lib folder and it works perfectly in the 'AdaptToInputs' ability without scripting the XNode reference. Thanks! UPDATE: For the challenge, I also tried to get the type of the control by following wires from the XNode back to the control/constant source of the type (since I didn't manage to get it from the XNode control before the solution of Jon) and it works also. It is a lot more complicated (and stupid?) but it works. Quote
Jon Kokott Posted November 7, 2013 Report Posted November 7, 2013 Good luck with those Xnodes, they're pretty tricky. I used some tools available on this forum that were pretty helpful, I just never had the confidence to put one in a project someone paid me for. ~Jon Quote
Oxynos Posted November 8, 2013 Author Report Posted November 8, 2013 Thanks Jon! Yes, debugging XNodes and figuring their behavior behind the scene can sometimes be a pain in the butt! It is true that because of the lack of support from NI, stability of XNodes and compatibility are not guaranteed. That said, in my case clients always require the source code but rarely modify it themselves, so I was thinking that replacing all XNodes by their generated code in the release version could be interesting... (I would then continue the development using XNodes from my private version or replace back the generated code parts by their XNodes for the development of following releases) If we do not use abilities like "OnFontChange", etc. (abilities that depend on the platform), it would be seamless to the user/client... Of course it would not work if the client wants to modify also the code generated by these XNodes! Quote
Jon Kokott Posted November 8, 2013 Report Posted November 8, 2013 For the only Xnodes I created/actually used, I created a method where you could right click on the Xnode and replace the Xnode with a subVI containing whatever the xnode created. Its really straightforward to implement, I'll try to dig it up but its been a while and I haven't been maintaining it. Quote
Oxynos Posted November 8, 2013 Author Report Posted November 8, 2013 Nice, that would be a neat feature for my XNodes too. Did you use the "ReplaceSelf" ability to do that? Quote
o u a d j i Posted November 23, 2013 Report Posted November 23, 2013 (edited) This code replaces the XNode with a SubVI and rewires it as before the change.(ReplaceSelf Ability) Trigger this function via SelectMenu (and BuildMenu) ReplaceSelf (SubVI from XNode and rewire) LV2011.zip Edited November 23, 2013 by o u a d j i 1 Quote
Oxynos Posted November 25, 2013 Author Report Posted November 25, 2013 Thanks for this useful VI Ouadji! Quote
o u a d j i Posted December 12, 2013 Report Posted December 12, 2013 (edited) my last version. (Ver2) SubVI from XNode (ReplaceSelf) Ver2 LV2011.vi Edited December 12, 2013 by o u a d j i Quote
o u a d j i Posted December 28, 2013 Report Posted December 28, 2013 Ver3 (ReplaceSelf - Convert XNode to SubVI) unzip --> run TESTER.vi --> XNode / right-click --> convert pattern 4833 (LV2011) (comments and feedback are welcome) xnode_to_subvi_ver3.zip Quote
Oxynos Posted January 23, 2014 Author Report Posted January 23, 2014 Thanks for the Updated version Ouadji! (and Sorry for the late comment) Quote
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.