01-26-2016 09:34 AM
Hey everybody,
I want to use CVTs instead of a variable to transfer data from some parallel loops to another. The data can be lossy since I only need the most current value. I have read this thread whitepapter: CVTs
I see that they behave similar to global variables, but what is the advantage or difference between them. Do they have higher performance or use less memory?
kind regards
Slev1n
Solved! Go to Solution.
01-26-2016 09:44 AM - edited 01-26-2016 09:46 AM
The main idea behind CVT is that it's dynamic - whereas you normally need to define your global variables up front (unless it's just a variant), you can dynamically add/update data to the CVT. This makes it very useful when you have a very modular/flexible application (e.g. loading in different hardware, custom variables etc.).
For example, you could have a DAQ module which is configured by the user to configure any number of DAQ tasks/channels - the data from these goes into the CVT. You could then write a common user interface which uses the API to list the current signals from the CVT and select which ones you want to log/display. If you change the DAQ task (or add another...e.g. to read from an instrument), you wouldn't need to modify your logging / display components.
I've written my own version of the CVT library - it's essentially the same principle but it has some extra features (e.g. storing additional attributes about a signal, generating a user event on data update etc.)/performance considerations (storing the variant in a DVR).
01-26-2016 09:46 AM
Hi Slev1n,
The answer is Here.
Regards.
01-26-2016 11:00 AM
I should mention that the Global Variable will be a little faster and use less memory than the CVT. But, as already said, they are set in stone. Globals must be defined and then specifically called where they are used.
CVT is dynamic. You can create variable names on the fly and get/set the value.