LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reg event callback in .NET don't work

Solved!
Go to solution
Hi all

The Falcon Driver Library is the library based high performance DCOM for Windows from KNX. I have a very simple example in C # that works perfectly registering an event on Falcon API library. I'm trying to replicate this example in Labview, I got everything working properly without errors, but it seems that the event does not work. I tried everything but can not get it to work.
I've uploaded the programs in C # and Labview.

I would need some help please.

Thanks in advance

Carlos
 
 
 

 


 

0 Kudos
Message 1 of 11
(6,648 Views)

What event are you trying to register ? I do not have the API...

 

event.png

 

I do not see you unregister, so try to restart labview before next attempt.

0 Kudos
Message 2 of 11
(6,641 Views)

Hi Bublina

 

Thanks for your fast response. The event that I try to register is:

vi.jpg

If you want to try the API or you are interested, can be downloaded from the website:

 

http://www.knx.org/uk/knx-tools/falcon/downloads/

 

I think unregister event is not the problem, because at least work the first time, right?. If I can get to shoot and stop the execution of the main VI then I'll unregister the event.

I've never gotten that the event works fine in Labview, But always work perfectly in C #

 

 

Thank you for your answers and I appreciate any help you can give.

Regards

Carlos

0 Kudos
Message 3 of 11
(6,631 Views)

I cannot make it work, I probably need some USB or RS232 / KNX converter and some KNX bus that is working.

 

That event you are handling "GroupDataIndicationWrite" should occur once somebody on the bus writes the GroupData ?

 

If yes, how do you know that it really happened. Are you running another VI and using the

 

write.png

 

to send a messagee ? And get no error.

 

Once you make it work, I suggest to use "Generate user event" and pass the event refnum to that referenced VI through the user parameter.

 

 

0 Kudos
Message 4 of 11
(6,624 Views)

Yes, you're right, you need a USB or RS232 converter to make it work completely.

I'll explain my setup: I have a KNX installation working with two USB-KNX converters. One of them is connected to a PC with ETS (ETS is the program with which you can develop and test the KNX instalations) and it is monitoring the bus activity. The other is connected to another different PC with LabView.

The event that I am handling, occurs when any device on the bus, write a message in it.

For now just try to monitor what happens on the bus (replicate the ETS monitor functionality).

The problem is that when I see a message on the monitor bus via the ETS, it executes the callback in C # without problems. But when the Labview is running does not occur this Callback.

 

I tried to use "Create user event" in the main VI and pass the event refnum to the callback VI through the user parameter and generate the user event within. I used the event structure for attend the event. But the result is the same, the event callback don't occur.

 

MAIN VI:
vi.jpg

CALLBACK VI:

vi2.jpg

I'm very intrigued that the call works fine  in C # an

 

Thank you for your help and I appreciate any help you can give.

0 Kudos
Message 5 of 11
(6,614 Views)

When I first try to set up a callback VI I like to make it as simple as possible: I put a one-button dialog box in it.  If the callback works, you get a dialog.  Don't even worry about the user event at first.

 

Have you tried wiring the error clusters through, and monitoring whether there's an error with probes or execution highlighting?  Do you get any errors out of the callback registration?

0 Kudos
Message 6 of 11
(6,605 Views)

Hi nathan

 

Thanks for your help, Sorry for the delay in my reply I had a very busy day.

 

Yes, I did the same at first, put only a one-button dialog box in the Callback VI, but as not working, I was adding the other elements.

 

As for the errors, everything is OK, all calls return no error (code 0).

 

Thank you for your help and I appreciate any help you can give.

 

Carlos

0 Kudos
Message 7 of 11
(6,588 Views)

Hi Carlos,

 

Try out the attached example. I had a bit of trouble creating one of these from scratch a while back!

 

Register for Events Snippet.png

 

/*
* ---------------------------------------------------------------------
* This C# code programmatically fires an event when an internal value
* is changed. Using LabVIEW, this event can be registered via the use
* of the Register for Events node. NI-UK 2011
* ---------------------------------------------------------------------
*/
// Make use of generic System library calls in this code.
using System;
// Define the namespace for the following classes.
namespace NETEvents
{
//Delegates allow us to pass methods between classes. Using parameters
public delegate void ChangedEventMethodHandler(object sender, EventArgs e);
// ProduceMyEvent is a class that will fire the event.
public class ProduceMyEvent
{
       //Create an internal event reference based on the original delegate method ChangedEventMethodHandler.
       public event ChangedEventMethodHandler EventReference;
       //Declare an internal variable. We will use this to fire events upon a changed value.
       //Note that this value is private to the ProduceMyEvent class.
       private int x;
       //Create a method to be called when an event is to be fired.
       public virtual void ValueChanged(EventArgs e)
       {              
       // Call the EventReference, if there is an event to be fired.
       if (EventReference != null)
       {
              //Fire the event.
                   EventReference(this, e);
           }
     }
    // Fire the event when the value of x changes.
    public int xValue
           {
           //Get the value of x.
           get { return x; }
           //Set x to be the new value and fire off the new event!
           set { x = value; ValueChanged(EventArgs.Empty); }
           }
     }
}

 

 

I hope this helps.


Alex Thomas, University of Manchester School of EEE LabVIEW Ambassador (CLAD)

0 Kudos
Message 8 of 11
(6,567 Views)

Hi Alex

 

Thank you very much, for your example. 

 

This weekend I was trying to find what is the problem in my callback, but do not see it. With the help of your example I will continue to check what is wrong. The only problem is that I have not access to the source code of the dll.

If I can not fix it, I'll try to generate an user event from within the DCOM event with an intermediate dll in NET

 

Thank you for your help and I appreciate any help you can give.

 

Carlos

0 Kudos
Message 9 of 11
(6,542 Views)
Solution
Accepted by topic author carlosp29

Certainly could be the issue. The main reason I had trouble getting these events to be captured in LabVIEW when I was developing that example was because the event I was firing was carrying a null parameter. This means that events that appeared to be launched within the DLL were occurring as expected, but they weren't being recognised within LabVIEW.

 

An intermediate .NET event is a good approach; this way we'll have absolute control over the format of the event that's fired. Best of luck!


Alex Thomas, University of Manchester School of EEE LabVIEW Ambassador (CLAD)

0 Kudos
Message 10 of 11
(6,535 Views)