NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with 'CloseAllSequenceFiles' and 'OpenSequenceFile'

Simple Code - Difficult TestStand Question
 

private

void axApplicationMgr_UIMessageEvent(object sender, NationalInstruments.TestStand.Interop.UI.Ax._ApplicationMgrEvents_UIMessageEventEvent e)

{

switch (e.uiMsg.Event)

{

case (UIMessageCodes) 31001: // TPS Load

axApplicationMgr.CloseAllSequenceFiles();

axApplicationMgr.OpenSequenceFile(e.uiMsg.StringData);

break;

case (UIMessageCodes) 31002: // Close All Sequence Files

axApplicationMgr.CloseAllSequenceFiles();

break;

}

}

Pretty simple.... It even works most of the time; until the TestStand Engine detects a change in the sequence file. Then the first popup happens; Select "Yes" from the TestStand Dialog the second popup occurs. Try to exit or do anything else look out there's your exception.

Thanks in advanced for your help,

Steve

0 Kudos
Message 1 of 18
(4,852 Views)
To Update the Community,
 
I spoke on the phone with Steve and the first message is coming up because he is saving a sequence file programmatically in the sequence that is sending the UI Message.  That first message comes up anytime the change is made outside the environment (such as in a sequence) and so when the message is up, it can't open a new sequence file.  The solution is to send a UI message to close all sequence files before programmatically saving the sequence file, this will not cause the message to popup, and then he would be able to open the sequence file with a different UI message. 
 
The other thing to mention here is that you usually want to use the UserMessageEvent event instead of the UIMessageEvent for your custom UI messages as all UIMessages are sent to this particular event handler.  This causes each UI Message to have to go through this code before being handled by the appropriate Manager control.
 
If anyone has any questions about this, please let me know.
0 Kudos
Message 2 of 18
(4,819 Views)
Adam:
 
I went ahead and did as you suggested and it helped a lot but I still am getting another popup (See attached file). The engine seems to think the sequence file is in use. I have even added an engine method (UnloadAllModules) after the UI message event that calls CloseAllSequenceFiles.
 
Any other Ideas?
 
Thanks,
Steve
0 Kudos
Message 3 of 18
(4,801 Views)
Steve,
 
Let me make sure that i have your order of events correct.  You start with no executions running.  You then run your execution entry point (which is not computer.seq?), which sends a UI Message which just calls the CloseAllSequenceFiles method of the ApplicationMgr, which throws this error.  Is this correct?  Your hope would be that it closes correctly, then you can load your sequence file from the network and then open this sequence file using another UI Message. If this is the case then the message that you're getting really doesn't seem to make sense. Could the message be thrown after you reopen the sequence file?  I would say that you should try to close all executions in your call back as well.  However, this will try to close the executing entry point as well.
 
I just did some testing on my end and created 2 UI Messages.  One that only calls CloseAllSequenceFiles and on that only calls OpenSequenceFile with the string data as a parameter (I did this in LabVIEW, I can recreate in C# if need be).  I then created a Configuration Entry point that called the first and then the second.  Even when the sequence file being opened in step two is opened at the start, everything works perfectly.  Does it sound like I'm doing anything differently (besides using LabVIEW).  Let me know.
 
Thanks and have a good one.
0 Kudos
Message 4 of 18
(4,757 Views)

Order is a follows:

 

1.) Configuration entry point starts execution.

2.) PostUIMessage fires and RTOI responds by calling 'CloseAllSequenceFiles'.

3.) All Sequences files close OK.

4.) A sequence file is downloaded that is different but has the same name.

5.) PostUIMessage fires and RTOI responds by calling 'OpenSequenceFile'

6.) Error message occurs.

0 Kudos
Message 5 of 18
(4,746 Views)

Hi Steve,

Just wanted to update you on my progress.  I've continued to look at this and have now added steps in my Configuration Entry point to GetSequenceFileEx from one directory and then do a Save method to my "working" directory between my two UI Messages.  Everything is still working for me in the LabVIEW Operator Interface.  I'm now going into my C# Operator Interface and recreate things there to see if somehow the environment change is the cause for this problem.  As soon as I have this working (or not working), I'll post it up here to see if we can see what is being done differently.  I'll repost before the end of the day.  Thanks.

0 Kudos
Message 6 of 18
(4,727 Views)

Steve,

OK, so I still haven't gotten the exact same message that you did, but I am getting some different error messages (in both LabVIEW and C#).  They referred to the fact that a sequence file of the same name was still in memory.  This makes sense, because when we are using the TestStand API, even though we close the sequence files using the CloseSequenceFiles method, we still have access to the sequence file in the API, and we actually have to release the sequence file.  I got my code to work repeatedly with this C# code:

switch(e.uiMsg.Event)

{

case(UIMessageCodes)(10000):

Engine engReference = axApplicationMgr.GetEngine();

int count = axApplicationMgr.SequenceFiles.Count;

for (int i = 0; i < count; i++)

{

engReference.ReleaseSequenceFileEx(axApplicationMgr.SequenceFiles[i], 0);

}

axApplicationMgr.CloseAllSequenceFiles();

break;

case(UIMessageCodes)(10001):

axApplicationMgr.OpenSequenceFile(e.uiMsg.StringData);

break;

}

This traverses all of the sequence files loaded in memory and releases them.  This allowed my code to run over and over again with no errors.  Give this a try and let me know if you continue to get errors.  Thanks and have a great one.

Message Edited by Adam B. on 09-15-2005 10:58 AM

0 Kudos
Message 7 of 18
(4,721 Views)

Hi Steve,

One more little piece for you.  I'm not sure exactly how you are moving the files from the network to the working directory so I've attached my process model to show you how I'm doing it that works with the code pasted above.  The configuration entry point is called "Download and Open File".  I have two local variables for the network directory and the working directory and I have included a message popup so that the user can specify which sequence file to download and open.  There are probably better ways to determine which file to use, but the ActiveX calls being made should work for you.  Let me know if you have any questions about this or the code above.  Thanks and have a good one.

0 Kudos
Message 8 of 18
(4,715 Views)

Adam:

This didn't fix anything. In order to simplify what the system is doing I've removed some steps from your "Download and Open File" configuration entry sequence and added one break point. If you change the string parameter in the "Open the working directory sequence file" step as required and follow through the steps as listed below you'll be able to recreate the problem I've been seeing.

1.) Copy a sequence file to your local directory

2.) Copy the sequence file in your local dirtectory to your network directory (Do not change the sequence file name)

3.) Open the sequence file in your network directory in the sequence editor and add a couple of statements steps to the sequence and save the sequence file (Do not change the sequence file name)

4.) Close the sequence editor and start the RTOI

5.) Copy sequence file from local directory to TestStand/bin directory

6.) Open sequence file in the TestStand/bin directory with the RTOI and start your configuration entry sequence

7.) Sequence file closes and execution pauses after hitting break point.

8.) Copy sequence file from network directory to TestStand/bin directory

9.) Resume execution which attempts to load the sequence file with the same name from the same directory and error message occurs.

If you have any questions please feel free to contact me.

 

Thanks,

Steve

 

 

0 Kudos
Message 9 of 18
(4,673 Views)


@Adam B. wrote:

This makes sense, because when we are using the TestStand API, even though we close the sequence files using the CloseSequenceFiles method, we still have access to the sequence file in the API, and we actually have to release the sequence file.



This is actually incorrect.  You only need to call Engine.ReleaseSequenceFileEx on Sequence Files that have been opened directly from the Engine.  The TestStand UI Controls will call Engine.ReleaseSequenceFileEx on any Sequence Files on its own.

Allen P.

TestStand R&D

0 Kudos
Message 10 of 18
(4,641 Views)