From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using labview to control C# application

Hello my name is David Charlot and I am new to C# programming but have been using labview for a while. I have to develop a C# application to control a digital camera. I also need to have complete control over this application via labview. The program consists of two boolean buttons that control the cameras acquisition type. I however would like two know how I can have labview control the toggling of the two buttons. In other words i would like a mouse down event on a button in labview correspond to a mouse down event in the C# application. Any help with this would be great.

David Charlot
UCSD Grad Student
0 Kudos
Message 1 of 5
(3,361 Views)
David,

i asume that you have a working assemlby for your cams. If so, it is quite easy, since the assembly should supply you with the appropriate functions. Just include the assembly by using the "constructor node" from the .NET-palette in LV. Then you can call methods (invoke node) or change properties (property node) from the assembly. So you have to include the fitting invoke nodes of your assembly into an event structure which handles the buttons.

hope this helps,
Norbert B.
Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 5
(3,358 Views)
Thankyou for your response, but I don't understand what you mean by assembly. Is the application itself the assembly? If so, Labview will be able to automatically detect the functions I have declared in the assembly code? I'm new to this type of stuff. Thanks


David Charlot.
0 Kudos
Message 3 of 5
(3,357 Views)


@dcharlot wrote:
Is the application itself the assembly?



Yes, that true. Weather you can access certain functions/properties from LV depends on your classdefinition within C#. Private methods/properties are not accessable, public shoud be.

Norbert
Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 4 of 5
(3,353 Views)

I think the easiest solution is to create the C# code as a "C# Class Library" - you should see that as an option in Visual Studio when you go to create the project type. This doesn't create an application (.EXE), but a library (.DLL) kind of assembly. The term assembly is simply the name for the binary packaging of .NET code...it's actually a bit more than that, but it'll get you started 🙂

You then create the actually EXE application with LabVIEW, using the front panels to create your user interface. Then, rather than trying to get a mouse action in LV to become a mouse action in .NET (non-trivial in the extreme), you simply call the .NET code from LabVIEW.

If you go to examples\comm\dotnet\Calculator.llb, you'll get a good understanding of what I'm saying. It's a trivial example, but the calculator functions (add, subtract, etc) are written in C# and then compiled into a class library assembly (calculator.dll). The calculator UI is created in LabVIEW, and when you click the buttons, it calls down to .NET via the constructor/invoke/property nodes...

Let me know what questions you have after looking at that.

0 Kudos
Message 5 of 5
(3,337 Views)