LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating special control for enumerated string message (Controls and Datatype question)

Hello,

 

I've been stuck with an idea I had about two weeks ago. I tried reading about controls and XControls yet I still can't get it to work. I have a scenario which I will explain here so any help is appreciated.

 

I imagine a control that could store Enumerated and String (maybe even more) datatypes inside like an Enum control, binding the data inside as a datatype. It should look a bit like this:

pict1.png

 

So as you see... We have an enum type and a string type inside a control (this time a cluster). That would allow me to let the user pick only the command to run by enum (I would gray out or simply hide the string CMD data, using it programmaticaly and storing the ASCII based command to send inside. Less code in constants, less things to worry about.) Then as with enums it would have to be binding to the string command type. So Value 1 would be a constant Command 1, Value 2 would be Command 2 etc.

 

Oh, and the big arrows should be increment, decrement. Would be nice to have that so I could switch and checkup values.

 

This should allow me doing roughly something like this:

pict3.png

Easy, quite explanatory and each command pretty much only needs the constant. Eventually a valueToString using concat...

 

I even thought of allowing the control to pick up additional functionality. For easier answer purposes lets call it Control 2 or Advanced Control...

 

So the Advanced version would allow more modular use of commands, while leaving the enumerated command and string hidden. It would add values or enums or whatever like this:

pict2.png

So the lower part would allow user for example to pick a motor Axis X (which would actually use 3 commands for X axis, the Reset, Move and SetSpeed, as always this is only an example). The commands in ASCII are weird like MV_X_R_ etc... so... it is quite troublesome to modify it in code. So... it would be GREAT if control could pick the command from the Command Control based on the values in Enum Device and Enum Action.

 

I imagine even easier way than thispict4.png

 

I ask you, oh NI Warriors and Knights for your insight on the matter. I intend it to be a control because I often have to do something like this. So it would be nice to only have to edit control and have it done.

 

Edit: As I read it I pick up things to worry about. First of all it would be nice to let the control accept for example only enum or a cluster of enums as a basic value. This would only allow to get the string CMD by property. Would it be a good idea?

 

Seconldly. Remember, the data should be enumerated as a whole control. So Axis X, Command first, String CMD1. It is like enum. Second one is a different set of data alltogether.

 

Alas, could the easy version of the control be made without using XControl somehow? Seems a bit of an overkill for simply bound data?

 

Thank you in advance. Have a wonderful day.

 

0 Kudos
Message 1 of 6
(2,485 Views)

@Vitae wrote:

 Alas, could the easy version of the control be made without using XControl somehow? Seems a bit of an overkill for simply bound data?


Of course you can do that without an XControl (honestly, haven't memorized your entire list of requirements).

 

For me, using an XControl for anything\everything seems overkill... (Not a fan.)

 

I'd put it in a class, and let that class manage everything. Initialize the class with either a few references, or one to a cluster. If required, the class could start an actor to handle interactive stuff...

 

QControls might be useful... Haven't tried them jet, but the idea is pretty solid.

0 Kudos
Message 2 of 6
(2,440 Views)

Could you walk me through doing it without an XControl And QControls? Even to the easy Enum&String pattern. I can't for the life of me get the hang of understanding LabView control creation.

 

I cannot use QControls because at work I only have license for LV2013 and this addon requires 2015+> unfortunately. It does seem like a good addon though. Too bad my employer won't upgrade for now.

0 Kudos
Message 3 of 6
(2,420 Views)

@Vitae wrote:

Could you walk me through doing it without an XControl And QControls?


We can try. But there are several routes that can be taken, and which is the right one will depend on exact requirements, experience and taste.**

 


@Vitae wrote:

Even to the easy Enum&String pattern.


This might not be the easiest. Obviously, it can be much more complex.

 


@Vitae wrote:

I can't for the life of me get the hang of understanding LabView control creation.


There's control creation in LabVIEW?

 

You can customize controls, or put them together in a cluster. Or an XControl... That's about it.

 

For your purpose, XControl do fit. It might not be a terrible choice, it's just that my experiences with them aren't that good.

 

** So the easiest way to do something like this is to simply use an event structure. When the enum changes, catch the events and change the (disabled) string based on an array of strings. This is definitely the easiest way, but not very reusable. There's no 'module' of any sort that can be used OOTB...

 

It's hard to estimate what would be a good solution for you. We have no idea how you want to use it, and we don't want to saddle you up with a solution that you wouldn't be able to create yourself or understand. That's won't help you at all, AFAIC.

 

Do you have experience with OO, Callback VIs, VI Server, Dynamic VIs?

0 Kudos
Message 4 of 6
(2,405 Views)

@Vitae

If you don't want to use an XControl (good choice Smiley Wink) and can't use a QControl (too bad really Smiley Frustrated) then what it sounds like you need is a lookup table.  You can create a lookup table using variant attributes.  If you then package your lookup table in and Action Engine (AE, sometimes called a functional global variable) you can lookup the String CMD anywhere after the initialization it is needed.  (See the attached example.)

 

I did start a QControl for you but after I read you were stuck in 2013 I stopped and did it this way.

Quentin "Q" Alldredge

Chief LabVIEW Architect, Testeract | Owner, Q Software Innovations, LLC (QSI)
Director, GCentral | Admin, LabVIEW Wiki | Creator, The QControl Toolkit
Certified LabVIEW Architect | LabVIEW Champion | NI Alliance Partner



0 Kudos
Message 5 of 6
(2,277 Views)

As I see it, QControls fix a problem XControls have. You will get all properties of an existing control, and you can inherit your implementation from that, so you have those properties.

 

If you don't have QControls, you can still make a class that contains control reference(s). In the init, set the references, and simply make methods to deal with them. You'll lose all the properties that LabVIEW has, but I doubt it would matter in this case. Simply make methods for them.

0 Kudos
Message 6 of 6
(2,241 Views)