Jump to content

+create Polymorphic VI programmatically


i2dx

Recommended Posts

Hi,

has anyone ever tried to create a polymorphic VI with VI-Scripting ? or does anyone know a way to do this ?

thx,

CB

2510[/snapback]

Hmmm, curiouser and curiouser...

(LV7.1) Calling the 'New VI ' primitive with the 'vi type' input set to 'Polymorphic VI' (so far, this seems like what we want to do, right?) generates an error and no valid VI ref. Not ready for prime time.

OK, let's try this:

Create a new polyVI (using the conventional approach). Save it with a .vit extension. NOW call the 'New VI' primitive, specifying the path to the .vit file as the 'template' input, but specify the 'vi type' as a standard VI.

When I run this, I get a history dialog asking me to add a comment (I have this option turned on in my prefs, YMMV). The save operation is on a VI named:

<long-random-digits>.tmp

When done, I have a valid VI reference. If I do FP.Open on this ref, I have an 'Untitled' polyVI that says it's never been saved (no path to disk).

That's all for now... more testing needs to be done. Like, where is there a scripting method to add a VI to a polyVI's list of instances...? I think this is a dead end for the moment.

Best regards,

Dave

Link to comment
  • 5 weeks later...
Hmmm, curiouser and curiouser...

[...]  I think this is a dead end for the moment.

Best regards,

Dave

2559[/snapback]

sad but true ...i did not find a solution, too

but, that was not really a problem, because building a poly-VI with 800 instances would have not been a really good idea ;-)

i found a way to solve the problem on a more "low level" way.

by the way: waiting 4 LV8 will last longer than usually. the beta version is expected in august 2005

best regards

cb

Link to comment
  • 6 months later...

I never found the need to use poly VI's, even though my professional version allows for creating them.

I _always_ use Variants as control for those VI's and add as many "Variant to Data" VI's as needed with the different constants wired to them. The one that does not return an error, got the right data.

Never failed for me :-)

Link to comment

sorry, but this doesn't sound like a good idea to me. if you just stick with variants, you better become a visual basic programmer. there are many positive aspects with strict typing and so on :headbang:

Link to comment
Hi,

has anyone ever tried to create a polymorphic VI with VI-Scripting ? or does anyone know a way to do this ?

thx,

CB

2510[/snapback]

Hi all

I forgot about that thread, but since it resurfaced I realized I made such a tool.

post-121-1119739299.png?width=400

The Attached tool will allow you to get 90% there. At the end, you just have to add the polymorphic instances to the polymorphic VI.

Enjoy

PJM

Note: I forgot to mentioned, attached file is in LV7.1

Download File:post-121-1119739386.llb

Link to comment
  • 11 months later...
  • 3 weeks later...
  • 1 month later...
I found a way to create polymorphic VIs. Works only in LabVIEW 8, but the code can be created with LV 7.1.

post-4014-1149860532.png?width=400

-jimi-

LV scripting programmer since Wednesday this week :P

Combining this with PJM's method of creating a new Polymorphic VI in 7.1 (clever, clever :thumbup: ) one can create polymorphic VI's programmatically even in 7.1, even with the Full Development System.

I kept PJM's original code, adding the following:

Attaching generated instances to the new polymorphic VI

If selected control is an array, the element data is replaced (not the entire array)

David Saunders

Download File:post-1519-1156806400.llb

Link to comment
  • 3 weeks later...
I kept PJM's original code, adding the following:

Attaching generated instances to the new polymorphic VI

If selected control is an array, the element data is replaced (not the entire array)

Download File:post-1519-1156806400.llb

Nice work :worship: Polymorphism over array dimensions (from scalars to N-dimensional arrays) combined with different data types is still on my wish list. As an example:

DBL scalar, SGL scalar, Bool scalar

DBL 1d, SGL 1d, Bool 1d

DBL 2d, SGL 2d, Bool 2d

...

DBL Nd, SGL Nd, Bool Nd

If I ever have extra time, I'll modify to code or write a tool to include polymorphism over both type and dimension.

Tip: Today I needed to create polymorphic dynamic LVOOP methods. This requires to create first a number of dynamic methods (one for each polymorphic type), then create for each dynamic method a static method that calls the dynamic method. In the end the static methods can be added to polymorphic VI. When the polymorphic VI is called, it first calls static VI of correct type, which then calls dynamic VI of the same type which is dynamically dispatched to the correct decendent class. Complicated but it works...

Link to comment
  • 1 month later...

Thanks for your help :thumbup: , but that's don't run. :headbang:

At start it's ok, but when i push "generate" there is an error message,who tell me that " Can't open the ref of vi in creatPolymorphism Instances(stingSM)___....

(reason: this VI is in more new version than your labview version"

And when i look at working folder, i see a VI(POLY).Vi creat, but in 7.1 format.

I look at code and I think it's in the Empty Polymorphic VI.vi template who is write for 7.1

Do you know if it's possible ,and how, modify this template to be compatible with 7.0 ?

Regards Eric :yes:

Link to comment

Hi again

In fact there is always a bug.

Now Ican create a Polymorphic Vi , i can place it on new Vi, Place Wire on it.

But if i right click on it, labview stop and close immediately, without any error message (big crash).

I send you a copie of my polymorphic Vi to see if you have same problem.

I have test that on 2 PC and see same things.

Regards

Eric

:headbang:

Download File:post-5178-1162980110.zip

Link to comment
Now I can create a Polymorphic Vi , i can place it on new Vi, Place Wire on it.

But if i right click on it, labview stop and close immediately, without any error message (big crash). :headbang:

Hi,

I've tested your "Essai multi1 (Poly).vi" in LV 7.1.1f2 FDS and didn't have a problem with it (right-click to select the instance was also OK),

so maybe it's because you are using LV 7.0 ??

One strange thing in your "Essai multi1 (Poly).vi" is that you've included "Essai multi2 (Boolean).vi", I've had to browse for it when opening the toplevel polymorph vi.

Good luck with creating polymorphic vi's in LV FDS (instead of PDS) ...

TNT

Link to comment
  • 2 years later...

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.