05-21-2009 07:35 AM - edited 05-21-2009 07:36 AM
Well it turns out I had a copy on one of my old machines at work, so I may be the first person to post LV scripting code to the NI fourm without it being pulled down.
This works in LV 7.1 just fine.
A) A new VI is created.
B) An empty cluster is inserted on the FP.
C) is an array of enums that determine what types of controls get dropped in the cluster.
D) The For loop insertes each control and set their position inside the cluster.
The code is attached.
I do not know if this will run on more recent versions.
Please don't use this in a real app.
Ben
05-21-2009 10:09 AM
Ben,
This solution is perfect and really helps! Thank you so much for helping me on this! Not only did you help me on the problem of creating a cluster based off an array, you also answered my earlier question from a few weeks ago about how to autogenerate a cluster.
Thanks again!
Phil
05-22-2009 12:15 PM
So... I was playing around with this solution and came across, what is hopefully, a small obstacle. The VI uses an enumerated array value to select which control to place in the cluster. For a numeric control, the user would have to select "Digital Control" or "Digital Control 1". However, this control defaults to the Double representation.
Is there any way to change the representation of the numeric control before it is placed in the cluster?
Ideally, I would like to have a text file like this....
U32 numX
I16 numY
DBL numZ
The VI would have a case statement that would recognize that the user is looking for a numeric control (named numX, etc...) to be placed in the cluster. It would then create that numeric control and set its representation to U32, etc...
05-22-2009 12:35 PM
05-22-2009 12:41 PM
05-26-2009 12:14 PM
smercurio_fc wrote:
As a follow-up: Let's not forget the whole reason for this, which is what you described way back in post #10. The crux of your issue is that you are trying to feed data into a Simulink DLL. I contend that it will be a whole lot easier and more robust to write a wrapper DLL to provide the data translation between LabVIEW and Simulink. You will not have to rely on scripting (which may or may not be available and at the very least requires you to write the code in LabVIEW 7.1 for right now) and you don't have to create a cluster with 2000+ elements which I think is simply silly.
True... This would be ideal. However, I think you'd still run into the same problem this way. If I created a wrapper DLL to translate the data, I would still be translating between a LabView array (variable length) to a Simulink array (fixed length). I believe this conversion problem would simply be removed from the step DLL and placed in the wrapper DLL.
05-26-2009 12:37 PM
05-26-2009 12:39 PM
05-26-2009 01:01 PM
My apologizes… I often forget that I discuss issues under different posts. Here is my detailed post on the array issue.
http://forums.ni.com/ni/board/message?board.id=170&message.id=408616#M408616
Please note that I made a mistake in the explanation. Turns out, there is no “good” or “working” solution. Because I didn’t do anything but pass my array through the Simulink model, I didn’t catch the fact that the resulting indicator array isn’t updated at all by the model.
05-26-2009 03:36 PM
If I were able to get a copy of 7.1, would I even be able to change the representation? I have a feeling that the numeric control always defaults to Double representation. I've noticed in 8.6 that there is no Invoke Node or Property node that has anything to do with representation. This makes me believe that even if I got 7.1, there would be no way for me to modify the above VI to create a numeric control inside a cluster with a specific representation. Am I wrong? I suspect the only way change the representation is by right-clicking the control and changing the representation by hand.