03-21-2007 06:43 AM
We want to retreive all messages (simple strings), or in other words, we want to listen if messages arrives.
2 questions:
1.) What s the typical way to program this in C# with Visa 4.0, .Net 2.0,
which methodes, delegations, events are normally used, are methodes used in threads...?
2) We would prefer to create an event handler which starts every time a callback function,
when a messages retrieves.
In the documuntation we found:
stat = viOpen(dfltRM, "VXI0::16::INSTR", VI_NULL, VI_NULL, sesn)
stat = viEnableEvent(sesn, VI_EVENT_VXI_SIGP, VI_QUEUE, VI_NULL)
stat = viWaitOnEvent(sesn, VI_EVENT_VXI_SIGP, 5000, eType, eData)
When we use:
mbSession.EnableEvent(MessageBasedSessionEventType.AllEnabledEvents,EventMechanism.Handler);
we get the error:
Specified event type is not supported by the resource. VISA error code -1073807322 (0xBFFF0026), ErrorInvalidEvent
03-23-2007 01:34 PM
03-25-2007 04:39 PM - edited 10-18-2010 03:12 PM
Hey Jason W,
at the moment I have skiing holidays,
so sorry that I am not able to answer detailed
(no access to visa docu).
We are using TCP-socket connection,
and I think I tried to find infos in...
Next week I will proof it again.
Can you please post me an example how to enable an event.
Best regards
Axel
03-27-2007 05:25 PM
04-02-2007 05:48 AM
04-03-2007 03:36 PM
04-04-2007 03:16 PM
Hi AxelF,
When you use the VISA .NET API, you will be working with Session objects and the Session-derived classes (GpibSession, VxiSession, TcpipSession, etc). The Session-derived classes have .NET event members in which you can register a delegate with a .NET event to receive notification of when the event occurs. Check out the examples in the <National Instruments>\MeasurementStudioVS2005\DotNET\Examples\Visa directory (I would start with VxiInterruptHandler since it appears that what your working with) to see how to set up the delegate and event handler.
So for example, if you had a vxiSession object already created, to register an event handler for VmeInterruptEvent and enable event, you would say
vxiSession.VxiVmeInterrupt += new VxiSessionVxiVmeInterruptEventHandler(OnVxiVmeInterrupt);
vxiSession.EnableEvent(VxiSessionEventType.VxiVmeInterrupt, EventMechanism.Handler);
04-04-2007 03:16 PM
Continued....
I would check out the VISA .NET 2.0 API help (Start >> Programs >> National Instruments >> Visa >> Documentation >> NI-VISA .NET 2.0 Framework Help) then navigate to NI Measurement Studio Help >> NI Measurement Studio .NET Class Library >> Using the Measurement Studio .NET Class Libraries >> Using the Measurement Studio VisaNS .NET Library. This should give you some to start with.
Several of the other examples in the Visa directory I mentioned earlier show off using events for other Session-derived classes.
One tip to remember (which is stated in the help for AllEnabledEvents) is that all currently enabled events for DisableEvent, DiscardEvent, and WaitOnEvent must be operated on. For EnableEvent, all previously enable events must be operated on.
Hope this helps!
Best Regards,
04-05-2007 06:05 AM
Hello Jonathan N , Brandon V,
thank you for your answers.
I know and understand event handling and delegations in C#.
Also I read the documentation of NI-VISA
But I am not able to enable events in NI-VISA.
We use a TCP/IP based session,
we use C# and .NET2.0,
and we want to enable 2 events:
1.) when message received
2.) when serviceRequest received
What I have to do, please dont refer to NI documentation,
I have read it. Maybe you can send me some code lines, I think to enable
this events not more then 10 lines are neccessary.
Best regards AxelF
04-06-2007 11:29 AM