NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

I would like to make calls to CallFrontEndCallbackEx from a .Net object that was created by an Action Step...

Hey guys,
 
I am probably missing just one little tidbit to make this work, but here is what I am doing, and what is happening when I do it:
 
1. I have a "FrontEndCallbacks.seq" located in "C:\Program Files\National Instruments\TestStand 4.0\Components\User\Callbacks\FrontEnd", in which I have placed a sequence called "Startup".
 
2. The "Startup" sequence creates an instance of a .Net class called "TitleBar", and then calls the "Startup" method inside that object, which looks like this:
 
   Public Sub Startup(ByRef seqContext as SequenceContext)
     

Public Sub Startup(ByRef seqContext As SequenceContext)

Try

'Show the titlebar form

Me.Show()

'Keep a ref to the TS engine

tsEngine = seqContext.Engine

Catch ex As COMException

End Try

End Sub

0 Kudos
Message 1 of 6
(3,692 Views)

Whoops, this thing took off on me before I finished the question:

Anyway, the problem I'm having is this:

When I call any of my sequences in my FrontEndCallbacks.seq from the sample operator interface, all seems to work just fine.

So I thought I would instantiate a .Net object from an Action step inside one of my FrontEndCallback sequences, and the .Net object gets an Engine reference from the sequenceContext that I pass on the call.

The .Net object creates a Form, and I can click on object on the form, and the form can use the saved Engine reference to make a call to DisplayMessageBox(), and that seems to work fine.

But, if the .Net object trys to make a call to CallFrontEndCallbackEx() with the name of one of my sequences in FrontEndCallbacks.seq, I end up with a hung TestStand....

So my question is this: can I only make calls to CallFrontEndCallbackEx() from the same object that started the TestStand engine (in this case, the operator interface), or am I just making a simple mistake in how I am trying to use the call?

I have attached the .Net code for my simple attempt to make this work (I know, it's missing all the good stuff in the Catch clauses, but I'm just trying to get a simple example to work!).

Thanks!

Download All
0 Kudos
Message 2 of 6
(3,691 Views)
Hi Larry,

I have been looking at your issue, and I think it is more of a question of how these objects are going to be interacting.

The operator interface is calling the FrontEndCallbackex, which is what it does by default.  Then the sequence in the Frontend callback calles teh same FrontEndCallbackex.  I assume you are calling seperate sequences, but you are in a sense having a function call itself.  I am going to set this up here, and verify, but it seems like that is just an endless loop.

Looking through everything it seems

Operator Interface calls Startup, .Net object created by startup calls startup, Back to Startup.  creating the .Netobject, which calls startup again.

You could probably fix this by adding another sequence.

A simple fix would be to move the sequences being called by the .NET object to another sequence file and then execute the sequences from there as well.

Let me know if this doesn't change things, but it really seems like you are creating an endless loop.  I have to get a test machine to try out your code on, but i will let you know if I find a problem with TestStand, and not just the logic of the code.

Michael D
Applications Engineering


0 Kudos
Message 3 of 6
(3,672 Views)
Michael,

I should have given more detail in the sequence of events area of my post.

What I am doing is this:

1. Operator Interface code -> CallFrontEndCallbackEx("Startup")

2. TestStand -> FrontEndCallback.Startup creates a .Net object called "TitleBar", and calls "TitleBar.Startup(seqContext)"

3. The reference to the TitleBar .Net object is kept in a station global variable

4. TitleBar.Startup(seqContext) shows its form, then saves a ref to the TestStand engine in "tsEngine"

5. TitleBar.Startup(seqContext) then returns to the FrontEndcallback.Startup sequence, which then returns to OI code

6. Later on, I click on an image in the TitleBar form.

7. TitleBar.pictureBox1_Click() event handler code then performs tsEngine.CallFrontEndCallbackEx("TitleBarClick")

8. TestStand -> FrontEndCallback.TitleBarClick should then display a message box

Step 1 works fine, and the TitleBar form appears on the screen. When I click on the titlebar, the event handler locks up TestStand.

If I change the code in TitleBar.pictureBox1_Click() to display a message using tsEngine.DisplayMessageBox(), it works fine.

If I make the same CallFrontEndCallbackEx() calls from the OI code (instead of from the .Net code that has a ref to Engine), it works fine.

The end game for me is to be able to call FrontEndCallbackEx() from any .Net object in my system, including objects that I create as a result of running scripts....
0 Kudos
Message 4 of 6
(3,667 Views)

Hey Michael,

I just tried the same idea out, but I wrote an ActiveX EXE server to perform the same kind of functionality.

From the FrontEndCallbacks.seq, I called the "Startup" entry point of the ActiveX EXE and passed the sequenceContext as a parameter.

The "Startup" routine in the ActiveX EXE stores a reference to the TestStand engine.

The FrontEndCallback sequence completed, and I was left with a form that was being displayed by the ActiveX EXE, just like my .Net example.

When I click on the image on the form, the ActiveX EXE uses the TestStand engine reference to make a "CallFrontEndCallbackEx()" call, and the front end callback sequence runs as desired.

So, the ActiveX Server works fine, but the .Net example does not....

Maybe this will give you more to go on, I don't know....

 

0 Kudos
Message 5 of 6
(3,636 Views)
Hi Larry,

I have been looking into this issue.

I am seeing simialar behavior, and when I get a nice easy to reproduce consistent hang from the event handler I will make sure to get corrective action request created for the issue.  To help you continue with development though it would be much faster to create a workaround to the problematic behavior we are currently seeing.

I am talking with R&D and other TestStand users and I am sure there is a way we can get the functionality you are looking for without calling FrontEndCallbackEx from the .NET objects you are creating.  I assume that you included these sequences in a frontend callback file, because the convenience that FrontEndCallbackEx provided.

I am pretty sure we can achieve the same result using UI messages, to create calls to a sequence file that is not a frontend callback file.  I am investigating this, but if you could just verify the exact goal of your application.

It seems you want to have a User Interface that Brings up .NET forms.  Then these forms can be clicked on to execute other sequences in TestStand.  I assume the forms do other things as well. 

Are we going to want to have multiple forms open at once?  If so is there some maximum number we are looking to have.
  If the .NET object can execute a different set of calls than the FrontEndCallbackEx and execute a sequence stored in a file, then will that meet your needs?

I don't think the way you have tried to set it up will work and I am working to find out why and if it is unexpected or not.  I just want to make sure that I am also helping you by trying to find a workaround that will allow you to move forward.

Please give me an idea of the functionality your application needs to have and I we will come up with a way to achieve that, which does not hang your system.

Have a great day,

Michael D
Applications Engineering
National Instruments
0 Kudos
Message 6 of 6
(3,635 Views)