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.
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.
07-25-2016 10:04 AM - edited 07-25-2016 10:17 AM
Hi All,
I'm developping CVI instrument wrapper for Tektronix Logic Analyzer, TLA7012.
For now, I was able to implement client connection using the *.dll assembly and *.config files, and now I just can't figure out how to impliment remote system events subscribtion.
As far as I know, I have to create a delegate function that is going to represent my event handler. After that, using an event handler, I will run the some assembly _add function, in order to "listen"-and-handle specific events.
What functions/methods should I use in order to create my event handler?
I am using CVI2015 and CPP example attached (contains TlaNeInterfaces.dll)
Thanks in advance for your help.
Solved! Go to Solution.
07-26-2016 05:17 PM
Hi ArtB83
Have you seen this forum post? This at least talks about how to handle .NET delegates and where to find examples on how to handle .NET objects.
If this doesn't help you, what event are you trying to register? Which function are you looking to create a delegate for? And what do you mean when you say
After that, using an event handler, I will run the some assembly _add function, in order to "listen"-and-handle specific events.
07-27-2016 03:54 AM - edited 07-27-2016 04:05 AM
Hi Andy,
Thanks for your reply.
I am trying to subscribe to hardware events, that signal when the run state of logic analyzer changes.
Yes, I saw that post, that you've mentioned and I saw the timer example. As I understood the post and the example, the flow is prety simple when using standart .NET library from CVI - the flow is different when I use the assembly file only in order to create objects and manipulate them. Mostly, because of types and different operators/constructors/handlers/overloading that implemented in my assembly.
I rely on C# example that come with the assembly file, and I am trying to recreate the following
// Subscribe to ITlaRunControl.RunStarted.
m_runStartHandler = EventRemoter.Create(new EventHandler(OnRunStarted));
m_system.RunControl.RunStarted += m_runStartHandler;
/********************************************************************************/
I will put some details of my understanding, that I have right now.
From observing the class, m_runStartHandle - is a data member, of type EventHandler.
And probably this is some kind of descriptor of previously declared type.
So, I need some way to create that type, initialize that descriptor and to ensure that it has correct functionality. I can't clearly figure out how to do that using my assembly file. My assembly file has class - Event_Remoter - but the class has no way of creating EventHandler. Some other class, has method of creating the Handler, but it has no way(that visible to me) of subsribing.
If we take a look to methods and member functions.
The EventRemoter.Create - probably declares the event handler descriptor.
The (new EventHandler(OnRunStarted)) - is the decriptor init operation, and the delegate itself is OnRunStarted. How do I declare some function as delegate, using my assembly?
Now, m_system.RunControl.RunStarted += m_runStartHandler;
m_system - my MAIN SYSTEM CLIENT object.
RunControl - type of event that m_system "listens" to.
RunStarted - the EVENT itself (there is also RunComplete).
Operator += performs the subscription using initialized event descriptor.
And again, I observe classes in my assembly, and just can't find these methods or appropriate types that required to implement my subscription.
I have a class ITla_Runcontrol - it has a method ITla_Runcontrol_add (probably +=)
It requires as argument a handle representing a .NET object of type: Tektronix.LogicAnalyzer.TpiNet.ITlaRunControl - that probably represents the descriptor, but I don't have a CREATE method in order to create such handle of ITlaRunControl type.
This is the whole picture in details. May be I use the assembly in some incorrect way, if so please let me know.
In my 1st post, I have accidentaly uploaded CPP example, here is C#.
Kind Regards
07-28-2016 03:56 PM
Hi ArtB83,
I noticed that the assembly was written in C# (and C++ above). It seems like it would be easier to use this assembly in a .NET environment. What were your thoughts behind using LabWindows™/CVI™ for this project?
I would suggest talking with Tektronix about using their assembly in an ANSI C environment. They may not have designed their assembly to be called in C, and if that is the case, some methods and properties may not translate nicely. They may have included some documentation with their assembly that you can look through, and if nothing else, they would probably be of more help in using their driver in ANSI C.
07-28-2016 06:08 PM
07-29-2016 05:49 PM - edited 07-29-2016 05:50 PM
Hi ArtB83,
The implementation in LabVIEW is slightly different because LabVIEW uses an object-oriented language (G). Because ANSI C is not object-oriented, using .NET assembly files is a bit trickier. Once you hear back from Tektronix, feel free to post your findings on the forum, and we can work from there!
08-05-2016 07:45 AM - edited 08-05-2016 07:48 AM
Hello again,
I have been waiting for a week to get an answer from Tektronix, but I didn't get anything. Meanwhile, I am trying to solve my problem from enother perspective.
I tried to investigate the wrapper code in order to extract the root of my problems.
My wrapper function signature is:
int CVIFUNC TLA_TpiNet_ITlaRunControl_add_RunStarted(
TLA_TpiNet_ITlaRunControl __instance,
System_EventHandler value,
CDotNetHandle * __exception);
Looks like my major problem is declaring an instance of type/class - System_EventHandler and initialize it with function pointer which makes it a "delegate".
How do I make that "delegate"?
08-08-2016 11:44 AM
Hi ArtB83,
After doing a little digging, I've found a function called CDotNetCreateDelegate that you should be able to use for your project. I haven't used this function myself, but I have linked the help here. If you have any questions on how to use this function, feel free to reply back on this thread!
08-10-2016 03:57 AM
Hi Andy,
I think I found the solution after digging in Tektronix C++ sample codes. They use the mscorlib library to emplement simple events. I thoght that the System_EventHandler type belongs to their own dll, but it actually comes from the framework itself (or the OS) .
So I added the mscorlib.fp to my project, and vualla - I have a class and a method - System_EventHandler__Create 🙂
08-10-2016 04:34 PM
Hi ArtB83,
That's exciting news! I'm glad you were able to get your Tektronix dll working in LabWindows™/CVI™! If you want to mark your answer as correct, it would boost your stats on the forum and allow others who find this thread to skip to the solution.
Thanks for posting your answer on the forum!