Jump to content

Type casting


Recommended Posts

I'm stuck right now, so I thought give it a try.

This is what I want to achieve:

I have one Vi to inside another Vi. Lets call the first one "inner" and the second one "outer". The "inner" Vi is a Vi which communicates to a python server (tcp-connection). The protocol is already implemented and works for sending over strings which are provided by the "outer" Vi. The procotol is designed in such a way that not only strings should be transmited, but also boolean and numbers.

Now the problem rised. The outer Vi provides a value of a certain type. The inner Vi should figure out which value and type is provided by the outer vi, so that it can fit it into the protocol. In other words, the inner Vi should be made more general in accepting values and data types. In this way it can act as a blackbox to which an value is given.

I hope someone can help me out.

Link to comment

Hi FSVZ:

Try searching LabView help on "Variant" data types and "Polymorphic" vis. I'm pretty sure what you want to do can be done & from the way you form the question sounds like you'll be able to get a good start-- if not the whole answer-- searching on those terms.

Good luck, keep us posted. If you run into difficulties some of us (not me unfortunately :( ) know quite a bit about how to impliment these things.

Best Regards, Louis

Link to comment
Try searching LabView help on "Variant" data types and "Polymorphic" vis. I'm pretty sure what you want to do can be done & from the way you form the question sounds like you'll be able to get a good start-- if not the whole answer-- searching on those terms.

Regarding the "poymorphic", check the ini-file functions in your palette. You don't have to use the full complexity, but it gives the idea. Have separate vi's for opening and closing the port, and a set of vi's (grouped into a polymorphic vi) that do the transmission for a specific datatype. This way you can add a new vi with a new datatype when need rises.

If you prefer the variant datatype, check OpenG. There you'll get (by installing OpenG commander and downloading the packages) a whole set of vi's to work with variants.

Didier

Link to comment
Regarding the "poymorphic", check the ini-file functions in your palette. You don't have to use the full complexity, but it gives the idea. Have separate vi's for opening and closing the port, and a set of vi's (grouped into a polymorphic vi) that do the transmission for a specific datatype. This way you can add a new vi with a new datatype when need rises.

If you prefer the variant datatype, check OpenG. There you'll get (by installing OpenG commander and downloading the packages) a whole set of vi's to work with variants.

Didier

I'm fairly new to labview and I'm the only one using it for my thesis. Anyway I created a Polymorphic Vi and I can now connect all the wanted data types I want to it. :D

However to create a connector (to another Vi) a control is needed. But when I create a connecter the type is bound and a polymorphic vi turns into a static Vi. So if there exists a "polymoric" control my problem is solved ;)

If anyone has an idea for this, your welcome to post. ;)

Gr FSVZ

Link to comment
However to create a connector (to another Vi) a control is needed. But when I create a connecter the type is bound and a polymorphic vi turns into a static Vi. So if there exists a "polymoric" control my problem is solved ;)

It is normal that the poly-vi is turned into a static vi. LV is datatype bound and so your "outer vi" supplies a value of a known datatype. LV recognizes it an on a double-click on the "innner vi" opens the correct "static" vi.

That's the reason why you make poly-vi's. They are just a container for a collection of similar vi's (same operations, same connector panes, but different datatypes as input/output). While plopping a poly-vi onto the block diagram, it recognizes the needed datatype and places the correct collection member on the block diagram.

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
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.