LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to interface a user created .Net DLL to a VI

Solved!
Go to solution

hi -- I've written some C# code that interaces to an embedded controller using a USB link. I can turn this around into a dll so that i can use the dll to encapsulate the driver to the embedded board. i'm looking for some best practices to show me how to do this so that i can cleanly interface this to a LV application.

 

thanks,

Jim

0 Kudos
Message 1 of 7
(3,663 Views)

 

 

Use ' Constructor ' to load that C# DLL which is found in Fuctions >> Connectivity >> .Net palette in the LabVIEW. Afterwards you can use the Propery and Invoke nodes to call the properties and  methods present in the C# DLL.

 

 

 

AshwiN,

0 Kudos
Message 2 of 7
(3,637 Views)

 

A Snippet...

 

 

 

 

AshwiN,

0 Kudos
Message 3 of 7
(3,630 Views)

ok -- thanks. but now i need to conditionalize the call to the method (ie the invoke node). there doesnt' appear to be any easy way to do that. any suggestons?

Jim

0 Kudos
Message 4 of 7
(3,602 Views)

Jim:

 

Probably my lack of text-based background speaking here, but I don't quite follow.

 

Are we trying to use a specific condition/output from the .NET constructor to change the method we invoke?

Caleb Harris

National Instruments | http://www.ni.com/support
0 Kudos
Message 5 of 7
(3,581 Views)

no -- my presentation of the problem has made it overly complicated. in C#, if i have a method, for example int SDO_Write(some arguments) that returns an int, i can write a couple lines of code that look like this:

 

int testValue = 0;

if (condition)

{

     testValue = SDO_Write(arg 1, arg2, etc);

}

 

so that, if the condition is true, the method is called. now, if the method is one that is exposed in the dll, can i conditionalize my calling it from within my labview application? the issue is that the calls are to a driver that i want to control how much loading occurs.

0 Kudos
Message 6 of 7
(3,576 Views)
Solution
Accepted by topic author djcoburn

Jim:

 

We  cancertainly use something simple like a case structure to conditionalize what method or arguments we call. If we know what method we'll be writing, we can wire our condition to the conditional terminal of the case structure and put our method inside. If we know we'll be writing anyway, but we need to switch commands, we can simply put our write constant inside the case structure and pass it to the method.

 

18621i174D1C674E60033D

Caleb Harris

National Instruments | http://www.ni.com/support
0 Kudos
Message 7 of 7
(3,539 Views)