Jump to content

Triggering user event from dynamic VI


Recommended Posts

I have a problem with a directory monitoring XControl, I thought I knew my share of XControl programming techniques but this is above my head:

I found on the NI website an XControl to monitor a directory. I thought the implementation was a bit clumsy so I decided to rewrite it.

Here's the basic layout:

I have two ActiveX callback VI, one for filechange events, and one for a filerename event.

I load these in the Init ability, and reload tem if needed (to my opinion), I sent a user event as a parameter to the callback VI. I register for the user event in the Facade ability.

Now when something happens in the directory I like to monitor the callback VI is called (I checked this with a pop-up, however a breakpoint isn't triggered), and if I check the user event I have exactly the same user event.

However the Facade ability isn't aware of this until the execution state changes.

So here's my problem how to get the user event triggered from the call-back VI?

In the attachment a zip including a lvproj with the XControl and all call-back VIs.

If you open the Test.vi, and run it the VI will show a pop-up for a directory, if you add items to that directory it isn't displayed. Now if you stop the Test.vi (with the stop button) the last event will be shown on the XControl.

Could someone verify this, and think of a work-around/reason.

Ton

EDIT: I notice I have the 'State Change' to False, setting this to true doesn't help.

Link to comment

QUOTE(tcplomp @ Nov 26 2007, 01:43 PM)

I have a problem with a directory monitoring XControl, I thought I knew my share of XControl programming techniques but this is above my head:

I found on the http://community.ni.com/examples/directory-event-monitor/' target="_blank">NI website an XControl to monitor a directory. I thought the implementation was a bit clumsy so I decided to rewrite it.

Here's the basic layout:

I have two ActiveX callback VI, one for filechange events, and one for a filerename event.

I load these in the Init ability, and reload tem if needed (to my opinion), I sent a user event as a parameter to the callback VI. I register for the user event in the Facade ability.

Now when something happens in the directory I like to monitor the callback VI is called (I checked this with a pop-up, however a breakpoint isn't triggered), and if I check the user event I have exactly the same user event.

However the Facade ability isn't aware of this until the execution state changes.

So here's my problem how to get the user event triggered from the call-back VI?

In the attachment a zip including a lvproj with the XControl and all call-back VIs.

If you open the Test.vi, and run it the VI will show a pop-up for a directory, if you add items to that directory it isn't displayed. Now if you stop the Test.vi (with the stop button) the last event will be shown on the XControl.

Could someone verify this, and think of a work-around/reason.

Ton

EDIT: I notice I have the 'State Change' to False, setting this to true doesn't help.

I don't think User Events are the best way to signal your XControl, at least not how it is set up currently. You are successfully firing and registering for the User Events, but the problem is that the XControl doesn't wake up automatically to handle the User Events. Remember that XControls are by definition NOT continuously running VIs. There's an external process of some sort that decides when to wake them up so they can run and handle their UI events, then go idle again. User Events don't wake them up apparently. They are getting successfully queued up, however, so as soon as some other event wakes your XControl up, it's ready to handle all the User Events at once.

There have been posts on this forum about how to successfully use User Events with XControls. Maybe someone figured out a good solution. I don't know of one, personally. I would encourage you to use some other communication mechanism for your XControl such as a Value Signaling property node for an internal/hidden control on the Facade VI. It's a little clumsy, but XControls definitely process those messages. Otherwise, you need some sort of way to ping the XControl periodically just so that it will wake up to handle any incoming messages from User Events. This sort of defeats the purpose of an event-based design, I realize...

Link to comment

QUOTE(ragglefrock @ Nov 27 2007, 12:43 AM)

There have been posts on this forum about how to successfully use User Events with XControls. Maybe someone figured out a good solution. I don't know of one, personally. I would encourage you to use some other communication mechanism for your XControl such as a Value Signaling property node for an internal/hidden control on the Facade VI. It's a little clumsy, but XControls definitely process those messages. Otherwise, you need some sort of way to ping the XControl periodically just so that it will wake up to handle any incoming messages from User Events. This sort of defeats the purpose of an event-based design, I realize...

Well if I export the user event to the owning VI (with the property Read User Event) I can queue user events which gets dequeued, maybe I have to turn the callback VI to the user thread.

Ton

Link to comment

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.

×
×
  • Create New...

Important Information

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