11-17-2025 01:47 PM - edited 11-17-2025 02:26 PM
Dear Paul,
I have never heard of XNode before, so I just dragged and dropped it into the code from the folder, but it did not work.
I found this website and was able to run it successfully: https://lv.qizhen.xyz/en/oop_xnode.
It seems that, for the first time, with your solution it is mandatory to maintain the order of the cluster elements and also the enum list elements order too.
11-17-2025 01:58 PM
Thanks for the lot of ideas. I have tested @PhillipDBrooks’ solution, and it seems that it will work for me, keeping in mind that converting to string and back is not a cheap thing.
With this solution, I like that it can be loaded back even when the order of the items in the enum is different from before.
@Andrey_Dmitriev: you are totally right. I need this because I am loading settings from before, and I have to maintain backward compatibility.
@paul_a_cardinale: Currently, the Xnode solution doesn’t work for me, but it would be quite elegant.
11-17-2025 05:35 PM
Keep in mind that the conversion to string using the JSONText library does NOT preserve bit-by-bit values for single precision numbers. It's quite good, but for your example you need bit-perfect values, which this does NOT have. The author has a bit of discussion on this here:
https://bitbucket.org/drjdpowell/jsontext/issues/13/ni-json-number-of-digits-bug
Example:
For some values of floats you do get perfect retransmission, but for arbitrary "it's not actually a float it's a bitfield" values you will NOT get what you need, and it'll fail randomly depending on what your original bitfield was!
You may be able to make a custom serializer to do this, or maybe you could make some sort of pre-processing function that takes Floats and flattens them to a U8 array or string, then go to JSON and back, but that seems like a lot of work to avoid rearchitecting something into "the right way" (which is to store bitstreams as either a string or U8 array). It sounds like you're not using typedefs, which sucks, but going through it once will take a while... but fixing the bugs from this decision will likely bite you in the long run. Nobody here can make that call for you though... I'm sure we've all been in the "just get it going you don't have budget to fix it" spot before 🙂
11-17-2025 07:14 PM
@denesdomjan wrote:
Dear Paul,
I have never heard of XNode before, so I just dragged and dropped it into the code from the folder, but it did not work.
I found this website and was able to run it successfully: https://lv.qizhen.xyz/en/oop_xnode.
It seems that, for the first time, with your solution it is mandatory to maintain the order of the cluster elements and also the enum list elements order too.
That's a bug. I'll fix it.
11-17-2025 09:46 PM
Here's the fix. Just replace the one VI (located in ,,, \Support\Merge Clusters).
Not really the proper way to make changes to an XNode, but as long as you first delete all the instances of the XNode on BDs, it should be OK.
(The problem was a race condition inside a property node.
Needs to be this: , not this:
)
11-18-2025 01:31 AM - edited 11-18-2025 01:39 AM
Works well, thanks a lot to you and everyone who commented! 🙂
11-18-2025 02:21 AM
@denesdomjan wrote:
@Andrey_Dmitriev: you are totally right. I need this because I am loading settings from before, and I have to maintain backward compatibility.
If your goal is to save and load settings and you don't need to map old values using some logic (e.g. this element's name was changed) then you can simply use something like JSONtext as suggested or the OpenG Variant Configuration VIs or the MGI Read/Write Anything VIs. These should all allow you to convert a cluster to text format and then take that text and convert it back to the cluster. If the cluster has elements which don't exist in the text, then the default value from the cluster will be used for those elements. That way the conversion from the text to the new version of the cluster is done automatically.
11-19-2025 07:24 AM
I have had a need for something similar to this in the past, but I just ended up writing a normal VI with type def clusters so it wasn't reusable. In my case I had a cluster with a set of limits in it. It was things like "Maximum Allowed Voltage", "Minimum Allowed Voltage", "Maximum Allowed Current", "Minimum Allowed Current" etc. This cluster would be settings that the "System" could support. The system might support 0V to 1000V range. Then we would have the limits that the DUT would want, so it would have it's own set of "Maximum Allowed Voltage", and "Minimum Allowed Voltage" which could be more restrictive like 20V to 80V. The "System" would have a cluster of limits, and the "DUT" would have the same type def cluster of limits that could be more, or less restrictive. The VI I made needed to merge these two clusters finding the most restrictive set of limits. If a limit was NaN then it wouldn't add any restriction on the existing limit. There was also a third cluster set for the "Sequence" being ran. It could have a "Maximum Allowed Voltage" which would need to be merged with the existing limits. In practice the "Sequence" limits were usually NaN using whatever limits the System and DUT came up with.
Sorry for such a long explanation. All of that is to say I could see an XNode of this type, or a similar kind, being useful in the past for merging sets of limits from various sources.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord