LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

event structure type code for C++

Does anyone know if it is possible, in C++, to make code that operates like the event structure?? Not having to waste resources scanning button changes?? Or could I make a labview vi that could be called by the C++ program. This is out of my league and is for some software that I beta test.
0 Kudos
Message 1 of 6
(4,182 Views)
Generically, in C, you have signal() and kill() that can be used to interrupt program execution to jump to a separate routine. In Visual C++, you set up events associated with each control in the form of member methods of the class that defines the form (front panel).

As for calling LabVIEW with C++ programs, VIs can be compiled into DLLs instead of exe via the Build Application of Shared Library (DLL) menu option on LabVIEW. Is the builder to define your C interface and link into that from your C++ app.

0 Kudos
Message 2 of 6
(4,166 Views)
If you are using Windows, you can use Windows Event functions.
Such as CreateEvent, SetEvent, ResumeEvent, etc.
 
 
George Zou
George Zou
0 Kudos
Message 3 of 6
(4,155 Views)
Unclebump,

Perhaps you could illuminate us a bit more on what, exactly, you are trying to do, and on what OS.

How, exactly, you accomplish event driven programs depends slightly on your windowing system (assuming that it is window events that you are interested in, I suppose). Kcaero's suggestion about VC's member methods, etc., is essentially a wrapper around the basic structure of a Windows program. This structure has a "message pump" somewhere at the bottom which gets messages from a message queue, and then dispatches them to the appropriate handler function, which is typically associated with the window or ancestor of the window that generated the event.

So, if its that aspect that you're interested in, and you're working on windows, check out the following windows functions:

GetMessage
TranslateMessage
DispatchMessage


These events are generated by the OS itself, so you don't have to waste resources scanning. Hopefully, the OS is also being efficient about it as well 🙂

CreateEvent, and other forms of signalling are probably not what you are interested in unless you are trying to both generate and process the events. The only reason to not let the OS handle the event generation is if you are creating your own events. At least that's the only reason I can think of off hand.
0 Kudos
Message 4 of 6
(4,132 Views)
This is for an opengl cad program. In 3D view, the frames per second increased by 25% when the toolbars were turned off. I think the operating system was sending messages all of the time. I wanted to see if it was possible to mimic the labview event structure to process the buttons. Trying to minimize the messages being sent by the OS. Programming is being done on winXP, but the program runs on anything from win98 to present, maybe even some mac's running emulators. I think he is using VC6 for programming environment.
0 Kudos
Message 5 of 6
(4,124 Views)
I doubt that the program is polling the buttons. Windows programs are inherently event driven, so it would actually take work to make it poll. It's possible that the toolbar is talkative, but even that isn't generally a problem. My best guess (knowing very little about it) is that the toolbar is somehow causing more paint messages, either of itself or of the main window. That would certainly be a time sink. It's also possible that they've managed to set up some sort of infinite message loop that only shows up when the toolbar does.

In any case, based on the information given, I would classify the problem as a bug, not as a design flaw.

Jason
0 Kudos
Message 6 of 6
(4,116 Views)