Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Create Events in derived class of CNi4882Device

Using VB and CW GPIB ActiveX control, we are able to do this:
CWGPIB1.NotifyMask = cwGPIBRQS
CWGPIB1.Notify
......
Private Sub CWGPIB1_OnGPIBNotify(ByVal mask As Integer)

In VC++, i have created a derived class from CNi4882Device. How do I add event capabilities to it and get the same callback mechanism as in the VB example?
0 Kudos
Message 1 of 5
(3,782 Views)
You will use the InstallEventHandler function. You can use it to install an event for any event mask that you want. Then you can just override the OnEvent virtual member of the class and handle the event however you like. You can also install an external (outside the class) function to handle the event, but since you are deriving from CNi4882Device, it would make more sense to override the virtual member OnEvent. See the online help for CNi4882::InstallEventHandler and CNi4882::OnEvent for more help.

Best Regards,

Chris Matthews
National Instruments
0 Kudos
Message 2 of 5
(3,782 Views)
i cannot find CNi4882::InstallEventHandler and CNi4882::OnEvent. Is this available in Measurement Studio 6.0? I am currently on Measurement Studio 1.0 or ComponentWorks++ 1.0
0 Kudos
Message 3 of 5
(3,782 Views)
This is available in Measurement Studio 1.0. Where are you looking? Look in the Tools->ComponentWorks++ Reference. You should find these functions discussed in this online help file. You can also find these functions declared in the Ni4882.h file.

Basically what you will want to do is to define the virtual function OnEvent in your derived class. Then call: yourDevice.InstallEventHandler(mask); where yourDevice is an instance of your derived class. Then when the event occurs, your class will run the OnEvent routine.

Best Regards,

Chris Matthews
National Instruments
0 Kudos
Message 4 of 5
(3,782 Views)
What is the value that OnEvent (or external function) should return? When this functon return 1 or 0 this will never call again. When my function return other value it sometimes don't work properly. Sometimes it is call when SRQ is not assert, other times it isn't reaction when SRQ is assert. Sorry for my english.
0 Kudos
Message 5 of 5
(3,782 Views)