LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the data type inside a User Event?

Hi,

 

While developing some malleable VIs to deal with user events, I suddenly hit a brick wall:

There is no way (that I know of) to get the data type inside a user event!

When I say get the data type, I don't want to get it as a variant, but as a strict type through data type propagation.

 

You can easily get the contained data type for most strictly-typed reference types (here for example with a contained boolean):

 

raphschru_3-1755102155124.png

 

...but trying a similar approach with user events seems impossible in the general case.

 

Here it works if the user event contains a scalar named exactly "Data":

raphschru_6-1755102981067.png

...but it fails if the element is named differently.

 

It is even harder if the user event contains a cluster:

raphschru_0-1755104165803.png

Since the event data node automatically unbundles top-level cluster elements, it seems impossible to have a code that works for all data types.

 

Any idea on this?

 

Regards,

Raphaël.

0 Kudos
Message 1 of 10
(605 Views)

Maybe this thread will give you some ideas.

0 Kudos
Message 2 of 10
(565 Views)

The only thing I can think of is to make an XNode instead of a malleable (but you probably don't want to do that).

0 Kudos
Message 3 of 10
(544 Views)

@mcduff wrote:

Maybe this thread will give you some ideas.


Very interesting thread about the early days of malleable VIs!

0 Kudos
Message 4 of 10
(500 Views)

@paul_a_cardinale wrote:

The only thing I can think of is to make an XNode instead of a malleable (but you probably don't want to do that).


Yeah, but not enough time at the moment to dive back into XNodes, plus the fact that they cannot be placed in malleable/inline VIs is still an annoying drawback for me.

 

My original idea was to have a malleable VI that takes a cluster of user events (refnums can be invalid, they are just used to get the data types), then creates the user event refnums appropriately and outputs the same cluster with the newly created references filled in.

 

I guess I'll give it a try when I have more time...

 

Regards,

Raphaël.

0 Kudos
Message 5 of 10
(493 Views)

@raphschru wrote:

@paul_a_cardinale wrote:

The only thing I can think of is to make an XNode instead of a malleable (but you probably don't want to do that).


Yeah, but not enough time at the moment to dive back into XNodes, plus the fact that they cannot be placed in malleable/inline VIs is still an annoying drawback for me.

 

My original idea was to have a malleable VI that takes a cluster of user events (refnums can be invalid, they are just used to get the data types), then creates the user event refnums appropriately and outputs the same cluster with the newly created references filled in.

 

I guess I'll give it a try when I have more time...

 

Regards,

Raphaël.


I think that the only thing that's going to work is to forget using a malleable, and put all of the functionality inside an XNode.

0 Kudos
Message 6 of 10
(460 Views)

Here's another possibility (but it's a bit kludgy):

In your project's buildspec, set up a pre-build action that finds all instances of your .vim and fixes them up.

0 Kudos
Message 7 of 10
(398 Views)

Just adding some design test VIs here for the associated idea I posted, since it is not possible to attach files in the Idea Exchange:

https://forums.ni.com/t5/LabVIEW-Idea-Exchange/New-primitive-to-get-the-contained-data-type-of-a-str...

 

Regards,

Raphaël.

Message 8 of 10
(254 Views)

Here's an XNode that will do it.

Message 9 of 10
(117 Views)

@raphschru wrote:

@mcduff wrote:

Maybe this thread will give you some ideas.


Very interesting thread about the early days of malleable VIs!


It really was.  Back then they were VI Macros, and it wasn't it's own thing, it was just an XNode that had some temple like function to it. You provided the VI to a XNode, and it would use the block diagram contents, inlineing it, and then having the type propagation that XNodes do already. I think it was after the beta that VIMs were no longer XNodes, but a more native features that didn't rely on that technology.  The type specialized structure being a hidden drop, in only the Mac and Linux releases was a fun find. I had to download it, and extract all the pieces to get to the VIM so I could pull out the structure and mess around. I was able to make a few bullet points, and then have a demo for my NI Week presentation. I basically had "2 days" to get the structure, play around, and get something ready.  It made for a fun time for sure.  And I think I was presenting in the advance user track, at the same time Stephen (AQ) was right next door. Both of our presentations were packed.  At NI Week that year I talked to Stephen saying how I thought it was crazy that Jeff just dropped this VIM, with this new undocumented structure, in the user.lib on the 2016 release.  He had no idea.  It sounded like Jeff went around several best practices for releasing code to get it in there.  Good times.

0 Kudos
Message 10 of 10
(72 Views)