LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a type defined control refnum cluster?

Solved!
Go to solution

Hello -

 

Is it possible to create control refnums for front panel objects and make a type defined cluster out of them?  I don't seem to be having any luck, but I could swear I've seen it done before.

 

I am trying to pass a cluster of control references into sub-vis that will be called dynamically (using call by reference).  I want to create a standard cluster for use in all of the sub-vi's without having to go back and edit the cluster in every VI if anything is changed or added.

 

If not, is there a better way?

 

Thanks,

Mike

0 Kudos
Message 1 of 21
(7,171 Views)

I wrotethis Mini-Nugget to show how to that the easy way by taking advantage of the middle input of a bundle (not bundle by name).

 

Here is a preview of thatt Nugget.

 

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 21
(7,167 Views)

Thanks for your response, Ben.  I created the cluster in the way you've shown, but when I save it as a type defined cluster, then try to use it in a sub VI, I get an "Object reference is invalid" error.

 

I'm new at control refnums, so I may be doing something completely boneheaded - please bear with me.

0 Kudos
Message 3 of 21
(7,157 Views)

That is exactly what typedefs are for.

Start from a new blank VI.

 

  1. Create all the controls you need on the panel.
  2. Create a ref for each one on the diagram.
  3. Create a cluster constant on the diagram.
  4. Drag the refs into the cluster constant, in the order you want.
  5. Change the cluster constant into a control (or create one from it).
  6. COPY the front panel cluster.
  7. Make a NEW - CUSTOM CONTROL
  8. PASTE the control in the new CTL file.
  9. Arrange the elements if you need to.
  10. Change it to STRICT TYPEDEF
  11. Save it as MyFancyTypeDef.ctl, or some suitable name.
  12. Remember that the control on yyour scratch VI is NOT an instance of the typedef, it was created before the typedef existed.
  13. Enjoy!

 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 4 of 21
(7,153 Views)

when I save it as a type defined cluster, then try to use it in a sub VI, I get an "Object reference is invalid" error.

 

Remember that your typedef is just that, a TYPE DEFINITION.

 

You have to populate it with REAL REFERENCES to REAL CONTROLS. 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 5 of 21
(7,149 Views)

Steve -

 

When I create a cluster constant and try to drag the reference into it, it just ends up behind the cluster constant.

 

Mike

0 Kudos
Message 6 of 21
(7,149 Views)

I have created a cluster of refnums and set them as a type definition, I just can't seem to use them.

 

As a simple example, say I have a main VI with an LED on the front panel.  This main VI runs a subVI that needs to manipluate that LED in real-time, while the sub VI is running (which may run for 2 minutes and turn the LED on and off or change the color 5 times during that two minutes).

 

In my final application, there will be several controls and indicators being manipulated in the sub-vis, which is why I would like a type defined cluster.

0 Kudos
Message 7 of 21
(7,143 Views)

You're right - that's not doable (and I don't know why)

Try this procedure:

 

  • Create all the controls you need on the panel.
  • Create a ref for each one on the diagram.
  • Create a CONTROL from each reference 
  • Create a cluster constant on the PANEL.
  • Drag the REF CONTROL into the cluster, in the order you want.
  • COPY the front panel cluster.
  • Make a NEW - CUSTOM CONTROL
  • PASTE the control in the new CTL file.
  • Arrange the elements if you need to.
  • Change it to STRICT TYPEDEF
  • Save it as MyFancyTypeDef.ctl, or some suitable name.
  • Remember that the control on your scratch VI is NOT an instance of the typedef, it was created before the typedef existed.
  •  

    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com


    Blog for (mostly LabVIEW) programmers: Tips And Tricks

    0 Kudos
    Message 8 of 21
    (7,141 Views)
    Solution
    Accepted by topic author MB1

    Remember that the typedef is nothing but a placeholder.

    A cluster with two I32s in it is just a container.  

    If you want your values in it (rather than default zeroes), you have to put the values into the cluster.

     

    A cluster with two CONTROL REFS in it is likewise just a container.

    If you want references to REAL controls in it (rather than default NILs), you have to put them into the cluster.

    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com


    Blog for (mostly LabVIEW) programmers: Tips And Tricks

    0 Kudos
    Message 9 of 21
    (7,138 Views)

    Once I created that type def (look at my Mini Nugget to see how I did that) the type def was used as shown below to update control from a sub-VI.

     

    I had an app with hundereds of controls and indicators that needed updated.

     

     

    So I bundled refes for all of the control into logical groups.

     

     

    Then passed these refs to the sub-VI

     

     

    And the sub-VI used those named refs to do the updates.

     

     

     

    I hope that help,

     

    Ben

    Message Edited by Ben on 03-25-2009 10:41 AM
    Message Edited by Ben on 03-25-2009 10:43 AM
    Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
    Download All
    0 Kudos
    Message 10 of 21
    (7,133 Views)