06-22-2015 06:43 PM
I've got a system that uses shared variables for data communcation where the shared variables are of type 'variant'. The server will typecast its data (generally a cluster) to a variant before writing to the SV and the client will typecast the variant data back via the 'Variant to Data' VI using a pre-defined typedef control. The client reading the SV is using the 'Read Variable with Timeout' from the PSP API. I would like to create a wrapper VI that encapsulates both the 'Read Variable with Timeout' as well the 'Variant to Data' VI but my implementation does not seem to be working. I was hoping that passing in a typedef constant into the 'type' control of the SubVI would allow the output 'data' to be polymorphic and adapt but it does not. Therefore I am concluding my inent does not seem possible or at the very least all that easy to do.
I have a striking feeling this would be a good application for LVOOP but other than knowing how to create a LV class, I'm pretty much at a loss here on how to go about it. Any help would be appreciated.
Thanks!
06-22-2015 07:14 PM - edited 06-22-2015 07:19 PM
@SeanDonner wrote:
I've got a system that uses shared variables for data communcation where the shared variables are of type 'variant'. The server will typecast its data (generally a cluster) to a variant before writing to the SV and the client will typecast the variant data back via the 'Variant to Data' VI using a pre-defined typedef control. The client reading the SV is using the 'Read Variable with Timeout' from the PSP API. I would like to create a wrapper VI that encapsulates both the 'Read Variable with Timeout' as well the 'Variant to Data' VI but my implementation does not seem to be working. I was hoping that passing in a typedef constant into the 'type' control of the SubVI would allow the output 'data' to be polymorphic and adapt but it does not. Therefore I am concluding my inent does not seem possible or at the very least all that easy to do.
I have a striking feeling this would be a good application for LVOOP but other than knowing how to create a LV class, I'm pretty much at a loss here on how to go about it. Any help would be appreciated.
Thanks!
You're right, this isn't easily possible. LabVIEW needs to know the interface types on the connector pane in order to perform static testing at compilation. Polymorphic VIs themselves are simply 'tricks' that give the compiler an option to select the right type from a list provided by the developer.
The easiest way to do this is create your own poly VI that contains a VI for each output data type you need, including your typedef. You could use LVOOP to accomplish a similar goal but either way you are declaring static types. Either way you need to know the type in advance so it wouldn't be possible for an adpative solution.
XNodes are what you are ideally after but they are not supported by NI. Looking around the forums or LAVA could help but I personally think you are better staying away from any unsupported tech.
06-23-2015 01:40 PM
Thank you for confirming what I thought to be true. I've always wanted to dabble in Xnodes with the known caveat that they are not supported, perhaps this will be the reason I needed to dive in head first.
06-23-2015 03:55 PM
I made a suggestion for this, but it was declined.
06-23-2015 04:25 PM
@SeanDonner wrote:
Thank you for confirming what I thought to be true. I've always wanted to dabble in Xnodes with the known caveat that they are not supported, perhaps this will be the reason I needed to dive in head first.
Well it could be. Or you might have a library already written with XNodes that might help.
https://lavag.org/files/file/248-variant-repository/
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord