Jump to content

Recommended Posts

Hi, I want to implement the SSL Begin Read method in LabVIEW with the System DLL using the .net construtor nodes.I am successful in doing so for the synchronous Read method. But when I am trying to modify my code with the Asynchronous methods, it asks me to wire reference for a Asynchronous Callback node. I haven't worked with Event Callbacks in .net before , so I dont have much clue about the dataflow and other things.Can anyone please help me regarding creating callbacks in this particular case.Regards,Runjhun.

Share this post


Link to post
Share on other sites

I can't give a solution for your specific problem, but .net callbacks are easy to understand:

- Place the Register Event Callback node from the .NET palette into your VI

- Wire the .NET class reference to the Event input (the third connector from top-left! not the first!) -> Now you can select an event from the drop-down box where all available Events are listed

- Once you've selected your event, rightclick the VI Ref terminal and select Create Callback VI

- Do whatever you want in the callback VI (like trigger a LabVIEW event)

 

Now whenever the event is fired, your callback VI is called... Try it with a message window ;)

 

Hint: Wire some data to the User Parameter input of the Register Event Callback node and re-create the callback VI. This is how you could send a LabVIEW event refnum (or any type of data) into a callback VI.

 

Hope that helps. Upload your VI if you need help for your specific solution.

 

EDIT:

Ehem, I hate to post links but:


http://zone.ni.com/reference/en-XX/help/371361J-01/lvcomm/reg_event_callback/

https://decibel.ni.com/content/docs/DOC-9161

 

:shifty:

Edited by LogMAN

Share this post


Link to post
Share on other sites

Hi,

 

I have gone through the basic working of Event Callbacks but I have found examples that are related to UI events.

In my case, I am reading some data from TCP socket and I want to generate event from that using the callback, so that it becomes an Asynchronous operation.

 

The code that I am trying to convert to LabVIEW is the SSL Stream Begin Read method.

"http://msdn.microsoft.com/en-us/library/system.net.security.sslstream.beginread(v=vs.100).aspx"

 

I have posted my VI as well but as of now its broken because there's nothing wired to the callback function.

Async Read.vi

Share this post


Link to post
Share on other sites

Interesting task, some VIs are missing though (from your user.lib), but I get the critical part now.

 

As far as I know there is no way to pass a delegate from LabVIEW to a function (as there are no raw delegates in LabVIEW). Also, even though the parameter is called 'asyncCallback', it is not an event callback, but just a parameter you could pass (any?) delegate to. The delegate could be registered as an event by the caller. I searched the internet and found a similar topic:

http://forums.ni.com/t5/LabVIEW/How-do-I-configure-NET-SOAPSender-AsyncCallback-in-LabVIEW/td-p/284364

 

The first answer states:

 

LabVIEW 8 introduced support for .NET events but we don't have support for raw delegates (the AsyncCallback parameter)...

 

I think this is still true. The only option I see for this is to write your own wrapper that internally handles the delegate and provides an event for LabVIEW to register to. Of course you would also have to wrap the method you want to call in order to provide a method without the delegate parameter.

 

I'm quite sure I've seen a similar topic here before... I guess...

  • Like 1

Share this post


Link to post
Share on other sites

Yes. So I am trying to build my own callback but the problem is the callback function has an argument of type 'IAsyncResult'.

But when I am selecting the consturtor node for this class, I get the message as 'There are no public constructors for this class'.

 

What to do in this case ?

Share this post


Link to post
Share on other sites

IAsyncResult is an interface, not a concrete class, so there is no constructor for it. You need a class that implements that interface.

  • Like 1

Share this post


Link to post
Share on other sites

ned, can you please elaborate on this. May be with an example.

I understand Asynchronous calls are difficult implementation in .net as well as LabVIEW but in my project I am not seeing any way out here for that.

I have to implement few methods as asynchronous only.

 

Can you please help here ?

 

Runjhun :)

Share this post


Link to post
Share on other sites

In what language are you trying to write your callback? You cannot do it in LabVIEW. In C# you need to create a class that implements the correct interface, and call the constructor for that class.

Share this post


Link to post
Share on other sites

I found the solution to my problem. I had to write a .net application that was triggering an event whenever bytes were received on a socket.

And as LogMan specified earlier, I used Regiter for .net Event node and passed the socket reference to it.

With that whatever events were related to that class, they were populating in that list. So, I created a Callback VI, that would generate a Value Signaling event to an inetger array that would give me the bytes read from the socket.

 

Appreciate everyone for their suggestions.

 

Regards,

Runjhun.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Similar Content

    • By William Hofmeister
      I need to access Aerotech A3200 data with LabView. The Digital Scope in the A3200 software has the capability to record data at 1kHz for 8 seconds in dedicated batches. We use LabView for all functions surrounding the motion control and have the Aerotech LabView package. Using the LabView vis we can only access data a single data point per call and I don't see how to set up a FIFO to Windows LabView. Someone must have looked at this problem lately. Can anyone steer me in the right direction?  Thanks!!
    • By LogMAN
      So this just happened to me and I'm quite confused by it. As it turns out, the .NET Constructor Node not only provides terminals for error in, error out and the reference, but actually two more "hidden" terminals:

      Notice: I left the error terminals untouched and none of the wires are connected (try it yourself). This never occurred to me. Only now, while hunting a null reference exception I found the constructor node looked "off", like this:

      The strange part is that the terminal doesn't actually carry the reference (which is why I receive the null exception). It only specifies the type. The upper left terminal is a void type input, so the wire is always broken.
      Does anyone know why these extra terminals exist? They don't seem to be part of the specification as far as I can tell.
      Any fancy things we can do with this?
    • By ATE-ENGE
      Edit: I'm asking primarily if there is a reason why/when I should/shouldn't use .net functions in my LabVIEW development. The example below is just to demonstrate a case of my question.
      _________________________________________________________________________________________________________________________________________________________
       
      I recently found a custom library that calculates SHA256 hash algorithms However, in this post I see that the same thing can be done with .net 
       
      My main question is: Is there any reason to build or use a custom library for something where .net functionality already exists? Are there any disadvantages to offloading work to .net ? 
    • By Gribo
      Hello, I am trying to copy multiple cells in LibreOffice, using the UNO API. I encountered an issue in the XCellRangeData object.
      The object's method returns an array of array of any() type. it seems LV can't compile this, even though the wire appears not to be broken. If I try to parse the array of array into a single dimension and then rebuild, the code is broken. See the attached files. Is there a solution for this issue? The alternative would be to copy cells one by one, which is a much slower solution.


    • By P.Carpentier
      Hi Everyone,
      Most of the time I am able to find solutions to my issues just by reading this forum but I wasn't that lucky this time.
      So, i got an issue when i'm trying to install my build.
      I got the following message: "This distribution is built with an older version of winMIF that is not compatible with .NET 4.6.2 upgrade to 17.0"
      When googling this error message or even "winMIF" i can't find anything that match my request
      I tried to uninstall the .NET framework and then reinstall the 4.0 (and 3.5) and I got the same issue. (Exactly the same error even if it's .NET 4.0 or 3.5 ...)

      The computer used to build is a Win7Pro with Labview 16.
      The target computer is a WES7 (but I got the same issue on my dev computer ...)

      In advance thank you, 

      Piet
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.