LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Recursive ActiveX register event callback VI

Hi!

 

I am trying to control a motor in LV2013 using the ActiveX concept. When I use a "register event callback VI" function, can I call the same VI that calls a VI (with the "stop rule" controlled be the user data terminal, of course, inside)? By default, callback Vis that one can create for this are all reentrant (preallocated clone) and synchronious (according to help). However, both when I use the "server VI reference" ("This VI") and when I create a reference and browse for the same file - "register event callback" shows me a broken wire.

0 Kudos
Message 1 of 11
(3,594 Views)

Obviously, attaching of a picture may clarify the issue.Issue.PNG

0 Kudos
Message 2 of 11
(3,586 Views)

Ok, I am sorry, it is solved. The problem was, that one has to right-click the terminal from the "Static VI reference" and choose there "Strictly typed". I hope it works as it seems to now.

0 Kudos
Message 3 of 11
(3,581 Views)

the reference has to be strictly typed, so you have to right click on the reference and select that.

 

What are you wanting to accomplish? On the surface this doesn't seem like a good idea, not least because its hard to keep track of the reregistrations and therefore the code as shown will have a horrible memory leak. 

 

I also notice you have a 'callback queue' where you are checking a value out and then back in again. I'd recommend first that you add the queue reference to your user parameter input. This means you don't have to relocate the queue every time the callback fires. Second this could be a race condition as you're checking the value out and then back in again. This would be OK if you never write to it from any other event, as I believe activeX events are synchronous. Oh, and the code as shown should almost never throw an error, but it may hang your program.

0 Kudos
Message 4 of 11
(3,577 Views)

Hi Thank you for revision of this preliminary VIs. The idea behind is to handle movements of the rotational stage, which may be undequal in time despite that they are equal in distance. Every time the single move is completed the event is fired and an action for another device has to be performed. As far as I understood, putting a  movement method in the loop will not give any result, so I tought in the direction of the recursive callback. However, I found this post. Would you in general agree that the callback VI cannot be recursive? I attach my code in LV13 (if you need me to convert, I will), which hangs after homing and performing a first 5-deg step (so HomeCompleteString.vi executes). I also don't know why it hangs if I did unregister for event... Seems that my cycle is endless, but this must not be the case - the step size is equal to the position being checked in the loop.

Download All
0 Kudos
Message 5 of 11
(3,448 Views)

@_Basil_ wrote:

As far as I understood, putting a  movement method in the loop will not give any result, so I tought in the direction of the recursive callback. However, I found this post. Would you in general agree that the callback VI cannot be recursive? I attach my code in LV13 (if you need me to convert, I will)


Sorry, I'm still on LabVIEW 2012 here, so can't look at your VIs. I don't understand your comments in these sentences though. What do you mean by putting a movement method in a loop will not give any result? And why would you ever want a recursive callback? The callback is called each time the event occurs. There's no sense in making it recursive, nor would you want to re-register for a callback on an event inside a callback VI. Normally a callback should contain very little logic; it should primarily pass some piece of information (through a queue, user event, etc) back to the main thread and let the main logic handle it.

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

what's the difference in using register event callback and using the case structure?

0 Kudos
Message 7 of 11
(3,312 Views)

@Stavrosyt wrote:

what's the difference in using register event callback and using the case structure?


They aren't the same thing at all. Does your question relate to the topic of this post, and if so, can you elaborate on exactly what you're asking?

0 Kudos
Message 8 of 11
(3,292 Views)

Sure. It relate to the topic. I am automatizating a laser machine. I used the same MG17 motors also in another program for the same computer.

But not I want to make a program only for the Laser using also ActiveX control.

 

The problem is that I can't make it works. I have a example in C#, that works fine, and I translated to labview, but I don't know how to debugged the program because I can only create my program in another computer, and then with an stand-alone executable used it in the other isolated computer connected to the laser.

 

Because I have no debugging ideas, I thought on start using first manual commands instead of waiting to receive events (laser is on, laser is waiting, laser stopped).

 

So instead of waiting of events I want to use buttons, which I will pressed simulating the events, in that case I should use case structures.

 

So then I get a little confused about the control of it, if I should wait for events triggered by reg event callback, or wait until a signal is introduced in a case structure.

0 Kudos
Message 9 of 11
(3,272 Views)

Stavros, I'm going to have to call you up on a minor point of forum etiquette.

 

Please don't scatter your questions all over the place (I've seen at least two versions of this same question posted recently).

 

Please stick to a single location or post a new question with a link to one of the other threads you think might be relevant, but do not post the same question multiple times.

 

Regarding the question itself, I have not understood your problem exactly so you're going to have to show some code to let us know what the problem is.  Without knowing the problem, finding solutions is pure luck.

0 Kudos
Message 10 of 11
(3,260 Views)