LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating own datatypes/handles

Hello!

 

I have a C library which has differents functions that expect various handles (uint32) as parameters. Calling these functions from within LabVIEW is not a problem. What I want to do is make these handles avaible to the outside, accessible through a SubVI connector, somehow comparable to the "Tasks" in DAQmx functions. I can without problem give them as uint32, however this way different types of handles can easily get mixed up as they all appear as blue lines and look like some integers and are not typechecked at all.

 

Is there a possibility to create own datatypes in LabVIEW that basically can be translated to a simple uint32 in order to pass them to a DLL but to avoid mixing up different types of handles outside of the SubVI. It would be comparable to some C "typedef" with additional typechecking when they are passed to a SubVI. This would simplify the use of the VIs I am creating siginificantly as errors with mixed up handles are very hard to spot and cause major run-time errors. Additionally it would be very helpful if it was able to create its own coloring/design for the lines and connectors to make the block diagram look cleaner.

 

I am using LabVIEW 8.5.1.  

 

Best regards! 

0 Kudos
Message 1 of 5
(3,181 Views)

Two ideas come to mind.

 

Type cast your U32 as an datalog reference. That will only give you the option for a green wire. But its traditional and has been around for a long time.

 

LVOOP lets you define the appearence of the wires used by a class. So wrapping your dll inside a privat method in its class will give you custom wires.

 

 

 

Ben

Message Edited by Ben on 03-12-2009 01:07 PM
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 5
(3,167 Views)

For the wire appearance you will need to use LVOOP. If you don't care that much about the appearance, you can use the datalog type as Ben suggested, but with a twist -

  1. Create a U32 typedef with the name of your data.
  2. Create another  control typedef (for your wire type) and place a datalog refnum into it.
  3. Drag the U32 typedef into the refnum.  

I believe this should generate a unique wire type which will break when wired with other wires (even of the same type), although I can't check to make sure.


___________________
Try to take over the world!
Message 3 of 5
(3,143 Views)

tst wrote:

For the wire appearance you will need to use LVOOP. If you don't care that much about the appearance, you can use the datalog type as Ben suggested, but with a twist -

  1. Create a U32 typedef with the name of your data.
  2. Create another  control typedef (for your wire type) and place a datalog refnum into it.
  3. Drag the U32 typedef into the refnum.  

I believe this should generate a unique wire type which will break when wired with other wires (even of the same type), although I can't check to make sure.


I have not confirmed that is the proper proceedure but that sounds like what I wanted to say.

 

Thank you Yair!

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 4 of 5
(3,134 Views)

OK, I looked into it and I was wrong. You get a coercion, but not a break.

 

What you actually need is a different data type. The easiest way to do this is to create a U32 enum (which doesn't even have to be a typedef) and populate it with a single element which will make it unique (e.g. the name of the wire type). You can then place it into the datalog file refnum (a typedef) and use that as your reference. Typecasting the reference to and from U32 works correctly.


___________________
Try to take over the world!
Message 5 of 5
(3,114 Views)