BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Control

Hi Thought I would post this in here as it is not really a problem but something I was musing over today.

 

I have come across the situation where I have a type def'd Enum on the GUI of my Application.  I use this Enum throughout my code (Case statements etc etc and in one particular place i use it to index a 1D string array constant on the block diagram.  I do not like this Idea as if the Enum is updated, the String array must also be updated.  Thus to get around this i have put the required string info into the Enum under brackets so that i can pull this information out and the Enum can be easliy updated through the Type Def and thus the code should not get out of Sync.  However this is not as attractive to the User on the Front Panel.

 

I know you could probably create a custm cluster etc and make it look like an Enum.  But i was just thinking how powerfull it would be to be able to add fields / parameters under the Enums "Edit Items" menu.

 

Anyone know how to achieve a similar goal for future refernce?   

 

Thought id share the food for thought.

 

Craig

LabVIEW 2012
0 Kudos
Message 1 of 11
(9,413 Views)
What do you think about this method ? You still need to show the altitude in the enum and to take care about the exact syntax. But it is less ugly and easily maintainable !
Message Edité par JB le 05-08-2009 03:16 PM
Message 2 of 11
(9,403 Views)

HI JB

 

Like the thinking, however The example i made is not really representative of my real life situation, where the Enum will already have spaces in it such as "Initial Assembly Test" etc etc.  Just seems a shame that there no fields behind the Enum to modify 😉 was just one of those Hmmm i wish this control did that type of scenario

 

craigc

LabVIEW 2012
0 Kudos
Message 3 of 11
(9,380 Views)

This question really belongs in the LabVIEW forum ...

 

but, I'll provide a reply here since I'm already here. Smiley Wink

 

Place the information in the description for the enum. To enter linefeeds in the description box use Shift-Enter.

 

 

Then, you just need to do this:

  

Be sure to make the enum a typedef, but I think you said you already had that. 

 

Obviously, if you're already using the description for documentation like a good little programmer, you can always chop out what you need from it.  Smiley Wink

Message Edited by smercurio_fc on 05-08-2009 01:35 PM
Download All
Message 4 of 11
(9,377 Views)

Could you use Tags, as described by Darren here ?

 

You could place the information you need into a set of tags that are applied to your type def. The tags could be identified by a string representation of the enum index (such as "01", "02" etc.), and the actual value could then contain "8848m" and "8861m", then all you have to do is format your enum index into a suitable tag identifier and extract the info.

 

Because the Tag info is embedded within the object, it will always remain. What I haven't tested here is creating a type-def from the enum, and then checking new controls based on that type-def for user tag info. The tag info may get stripped out?

 

Attached is my idea in LV 8.6

 

 

Update: Tried creating a type-def from the enum with the tags in, and the new control also had the tag info! So all new controls that are associated with the type-def get the tag info as well. Now to test changing the tag info to see if the associated controls update too...

Message Edited by Thoric on 05-08-2009 11:18 PM
Thoric (CLA, CLED, CTD and LabVIEW Champion)


Message 5 of 11
(9,361 Views)

A quick follow up: there's a weakness. I cannot see a way to edit the tags of the type-def control Smiley Sad

 

Therefore, once you've created your custom control from a standard control, the embedded tags cannot be changed. The User Tags functions only allow us to change the tags of either controls (by reference) or vis (by reference). A type-def is a .ctl file, and this does seem to report back those tags associated within the control inside it. Therefore presumably one cannot change them.

 

Maybe Darren can throw a little wisdom on all this?

Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 6 of 11
(9,357 Views)

Thoric wrote:

 

Therefore, once you've created your custom control from a standard control, the embedded tags cannot be changed.


 

A typedef control is treated as a VI. I can't check this at the moment, but you can open a reference to it using the Open VI Reference primitive and then try to use that reference to modify the tags.

I'm guessing you will need to use the FP.Control[] property to get the actual control, but I didn't try this recently.


___________________
Try to take over the world!
0 Kudos
Message 7 of 11
(9,324 Views)

A typedef control is treated as a VI. I can't check this at the moment, but you can open a reference to it using the Open VI Reference primitive and then try to use that reference to modify the tags.

I'm guessing you will need to use the FP.Control[] property to get the actual control, but I didn't try this recently.


Yes, you are correct. I've just tried this, and by accessing FP.Control[0] I can get a reference to the type-def enum and change it's user tag details programmatically! Smiley Happy

The downside is, programmatic changes don't get flagged up in the type-def as changes, so they are not propagated down to any associated vi controls. To force this I had to make a simple cosmetic change (I moved it a couple of pixels), which enabled the "File>Apply Changes" menu item. Doing this on a Strict Type Def works brilliantly, but user tag changes are not propagated back for ordinary type defs Smiley Indifferent

 

So, craigc,  to use user tags one would need to force the type def into a strict form and also be prepared to programmatically make the modifications as user tags can't be edited through the ordinary "properties" window, unlike smercurio's Description text suggestion - which sounds a lot easier Smiley Happy

Message Edited by Thoric on 05-09-2009 10:22 PM
Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 8 of 11
(9,313 Views)

Would it be acceptable to use a ring instead of an enum ? This type allows to set non sequential values. This may be a solution if, like in your example, the values are integers.

 

 

 

 

Message Edité par JB le 05-11-2009 09:32 AM
Download All
Message 9 of 11
(9,286 Views)

Hi All,

 

Thanks for all the suggestions 🙂  I finally went with JB's solution 🙂

 

The thing is that it would still be nice if the enum would be able to have "properties"  of some sort attached to it, however the ring is a nice solution as it is probably the most obvious to other people what has been done.

 

Would an X control enable you to create a custom enum with properties attached?  (I have no Exp or clue how to do an xcontrol)

Craig

LabVIEW 2012
0 Kudos
Message 10 of 11
(9,213 Views)