07-19-2011 12:02 PM
Hello!
I'm working on an OPC solution, and I'm wondering if there is a better way set up a method to adapt the data to a standard output. Here's the setup:
1. A configuration file is made that has several lines of information that details the name of the channel, data type (Integer/Double/etc), URL of OPC information, and a description of the data.
2. A VI takes this configuration file, and reads in all the OPC data, and puts it into arrays: The integers go into an integer array, the doubles go in to a double array etc
3. These arrays are put into a cluster and output from this VI.
4. Another VI, specific to the instrument, now reads in this cluster of arrays, and processes the information into the "standard output" for the rest of the system.
This is working as is, but the real task here is making step 4 easy, and here's the problem.
Currently, (as seen in the attached VI), you get to the data by indexing the arrays with a unique number. However, now this VI is constrained by these index numbers.. if I make a change to the configuration file and say, insert a new integer, I have to go in to this VI and push all the numbers down.
Now I must stress that the overall structure of the program has to remain the same, but I'm looking for suggestions on making this issue of indexing the array more manageable. I considered sending the "name" of each data channel along with the data itself, but it doesn't help me get it into the cluster any easier.
07-19-2011 12:40 PM
The VI is missing a bunch of subVIs. I think what you are describing is a perfect application for LVOOP with inheritance. I know you said you can not rearchitect this.
Here is one hint for you
07-19-2011 12:56 PM
Thanks for that tip and I'll read into LVOOP.
Yes the attached VI was just for show, it doesn't do anything useful without my main program anyway (which I can't post).
07-19-2011 01:06 PM
I don't know if you have any experience with OOP in general but anyway...
Keep in mind one thing when you are learning LVOOP. At it's core a class is really just a library containing one cluster and one or more VIs that have permission to unbundle and bundle the cluster.
If you think of a class as a typedef .ctl file, then an object is a place where you use that .ctl file in your program. Not exactly the same but close enough.
Here is an excellent webcast