04-04-2013 01:25 PM
Hello All,
I've been trying to find a way to create a cluster automatically based off of imported format data, but have not had any luck. The number of elements is quite large, and there are several different data types, so I would prefer to not have to build the cluster manually. I searched the discussions forums, and there have been other people that have asked about this same function, and the answer has always been "there is no good way". However, most of the posts have been from several years (and several Labview versions) ago, so I thought I would resubmit the question. Has there been any new features added recently, or any new development done related to this?
-I am already aware of the non-supported scripting tools (that may or may not still be valid).
-I am aware of the possibility of obtaining a "scripting license" from NI, but do not consider this an option.
-The format data is in a .csv type of format, so I cannot use the "Shared Library Wizard" like if it were in a .dll or header file.
-The import does not need to happen at runtime, it will only be used to configure the software tool prior to use.
-I am working with Labview 2012, but have access to other versions.
Thanks much.
GSinMN
Solved! Go to Solution.
04-04-2013 01:41 PM
What exactly do you mean by automatically bundle? Do you mean you will try to read some data from a file and just dump it into a cluster and at the same time have varied formats for the data? This is not possible and more than likely will never be possible. Will a single execution only deal with one particular data type? If so look at LVOOP and dynamic dispatch. If you need to use different data types at run time you can still use dynamic dispatch but you will need to know what type to invoke. Your code will require a case structure to choose the right processing the particular data type.
04-04-2013 01:58 PM
Mark, I think the title is confusing. The point is to create the cluster in the first place.
There is a good way and it is indeed scripting. You don't need any special license. Since LV 2010 scripting is officially supported in LV and you can enable it in the VI Server page in the options dialog.
You will need to write a parser for your data and use that to create a cluster and then create the various elements with the cluster as their owner. There should be some examples in the example finder (Help>>Find Examples) and online (the LV APIs group in the communities is a good place to look). The code should be fairly simple, assuming you don't need complicated parsing.
04-04-2013 02:32 PM
Hello Mark,
Thanks for the quick response. To clarify my situation, the .csv data I want to import defines the structure of a datagram that I will receive over UDP. Each datagram contains several messages, and each message contains several different data types, including such things as strings that define headers, integers that define size, and enums that define commands, plus many others. I need to use this information to "unpack " the UDP string. The messages are not all the same size, and they do not even include the same data types. Each message is unique. I do not have control over how the messages are structured, only access to the document that defines that structure.
Additional options I am investigating are converting the imported data into something that Labview may find more easily useable, and using type descriptors in combination with variant data to accomplish the task.
Thanks again,
GSinMN
04-04-2013 02:48 PM
Hello tst,
Thanks for the response, and congratulations on the recent Knighthood. Sounds like the question was indeed worth asking, in that the scripting has matured in recent years to be fully supported. I have indeed already created a parser to extract the info that is applicable to the structure (plenty there that isn't applicable). I'll start checking into the scripting features. Sounds like it should be a good solution.
Thanks again,
GSinMN
04-04-2013 03:04 PM
One scripting subtlety you will probably run into - to create a cluster, you will need to create the cluster and the objects inside it. The easiest way to do this is to create the cluster and use its reference as the owner for creating the objects inside it. Alternately, you can create everything, then move the cluster items into it.
One more - you cannot create control terminals on the block diagram. You need to create controls on the front panel, which creates the control terminals on the block diagram.
Good luck and welcome to the world of scripting!