05-01-2012 03:29 AM
Solved! Go to Solution.
05-01-2012 06:39 AM
What event are you trying to register ? I do not have the API...
I do not see you unregister, so try to restart labview before next attempt.
05-01-2012 10:18 AM
Hi Bublina
Thanks for your fast response. The event that I try to register is:
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
05-01-2012 11:11 AM - edited 05-01-2012 11:11 AM
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
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.
05-01-2012 01:26 PM
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:
CALLBACK VI:
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.
05-01-2012 04:11 PM
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?
05-02-2012 02:46 PM
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
05-04-2012 04:47 AM
Hi Carlos,
Try out the attached example. I had a bit of trouble creating one of these from scratch a while back!
/*
* ---------------------------------------------------------------------
* 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.
05-07-2012 02:08 PM
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
05-08-2012 02:44 AM - edited 05-08-2012 02:45 AM
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!