Jump to content

XControl: Polymorphic?


Aitor Solar

Recommended Posts

QUOTE(Aitor Solar @ Feb 14 2007, 01:23 PM)

Let's say you make a XControl of a graph. Graphs are polymorphic (for example, a Waveform Graph can accept 1D or 2D-array data), but the XControl doesn't. Any workaround?

Saludos,

Aitor

Variant?

I don't think there is an easy work around since the datatype is defined with the data ability, which is a typedef, and the beauty of typedefs is that they restrict the data type.

Moreover you should be able to handle all kinds off data inside your facade VI, quite hard I can imagine!

Ton

Link to comment

QUOTE(Aristos Queue @ Feb 14 2007, 06:06 PM)

Passing different types of data isn't what makes the graph change. It's a compile time decision based on the data type provided. So, no, there is no workaround.

But you can detect the runtime type of an input. Based on this type you can choose one of different graphs, at runtime. Simply put multiple graphs of different type on a transparent tab control and select which tab to show based on the runtime type of the data.

Tomi

Link to comment

QUOTE(tcplomp @ Feb 14 2007, 07:19 PM)

This is not about the display of the XControl, but about the terminal and datatype of the XControl, and I think Aitor knows his way with Xnodes... Maybe this can be gold pot under the rainbow?

One thing that could work is to force a control on XNode generated front panel visible somehow. By default both the XNode generated code and the front panel elements are all hidden.

Tomi

Link to comment

QUOTE(Tomi Maila @ Feb 14 2007, 07:52 PM)

One thing that could work is to force a control on XNode generated front panel visible somehow. By default both the XNode generated code and the front panel elements are all hidden.

Tomi

Well now my sick twisted mind kicks in.....

What we need is an Xnodes\XControls twin....

It will be kind of hard, but let's handle the xnode do the polymorphism, and convert the data into the generic datatype you'd like to use and port that into the XControl, maybe together with a datatype changed? signalling boolean.

One other thought is just a normal polymorphic VI '1' (one) pixel wide stitched to the XControl, and have a merge VI contain both, maybe that is better, but true XControl polymorphism would be wonderfull!!!

Ton

Link to comment

Yes, using an XNode would be great, but we'd need a lot on info about them we still don't have. I've tried a simpler solution, an XControl that is replaced with another one if the input type changes, something very similar to a polymorphic VI. The example is limited to two cases: I32 and String input.

Create a new VI and put some of the provided XControls (Str_poly.xctl and I32_poly.xctl) in the front panel. Make them indicators and try to connect an I32 wire to the string XControls and strings to the I32 ones.

post-1450-1172153494.jpg?width=400

But is not a solution I really like 'cos it relies on a hidden daemon checking continuosly the XControls. We would need an event fired when something is connected to the XControl, but I think LV doesn't give us something like that :( .

BTW: Keep in mind this is just a proof of concept. Is not perfectly done (for example, if you save and reload a VI with these XControls, the polymorphism will be lost since is included in the init ability) and you'll probably end up with an unstable LV, so be careful.

Saludos,

Aitor

Link to comment

Nice work.

QUOTE(Aitor Solar @ Feb 22 2007, 06:18 AM)

BTW: Keep in mind this is just a proof of concept. Is not perfectly done (for example, if you save and reload a VI with these XControls, the polymorphism will be lost since is included in the init ability).

Saludos,

Aitor

Init Ability always runs when XControl instance is loaded. The problem is you put your code in the 0.0.0.0 frame. You need to put it in the default frame. Delete the 0.0.0.0 frame altogether.
Link to comment

QUOTE(Michael_Aivaliotis @ Feb 22 2007, 06:11 PM)

Init Ability always runs when XControl instance is loaded. The problem is you put your code in the 0.0.0.0 frame. You need to put it in the default frame. Delete the 0.0.0.0 frame altogether.

OK, stupid mistake. I have uploaded an updated version, more robust.

Saludos,

Aitor

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.