Quantcast
Channel: NI TestStand topics
Viewing all articles
Browse latest Browse all 6524

I can't get Engine.NewExecution to run my sequence

$
0
0

I'm trying to use the 'NationalInstruments.TestStand.Interop.API' to run a sequence from Visual Studio 2017 using some C#.  What I want to do is write some code that when executed will do act exactly the TestStand application does when I load a sequence and execute a single pass test.

 

As I understand it, I should be able to create an engine object, use 'GetSequenceFileEx' to get a sequence object and then use the 'NewExecution' method to run the sequence. Here's the code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using NationalInstruments.TestStand.Interop.API;

namespace TestStandBridge
{
    public class TSBridge
    {
        public TSBridge()
        {
            // Instantiate the Engine for TS
            engine = new Engine();
        }

        ~TSBridge()
        {
            GC.Collect();
        }

        internal Engine engine;

        public Execution StartSequence(string sequenceFilename, string resultDir)
        {
            Execution exec = null;

            try
            {
                User admin = engine.GetUser("administrator");
                engine.CurrentUser = admin;
                
                SequenceFile seqFileModel = null;
                
                int flags = 107; 
                SequenceFile seqFile = engine.GetSequenceFileEx(sequenceFilename, flags, TypeConflictHandlerTypes.ConflictHandler_Error);

                bool modelExists;
                string modelPath = seqFile.GetModelAbsolutePath(out modelExists);
                seqFileModel = engine.GetSequenceFileEx(modelPath, GetSeqFileOptions.GetSeqFile_NoOptions, TypeConflictHandlerTypes.ConflictHandler_Error);
                                
                exec = engine.NewExecution(seqFile, "Single Pass", seqFileModel, false, 0);
                exec.Report.Location = resultDir;
                                            
                engine.ReleaseSequenceFileEx(seqFile);
                engine.ReleaseSequenceFileEx(seqFileModel);
            }
            catch (Exception)
            {
                throw;
            }

            return exec;
        }
    }
}

 

However, when I instantiate this class from a console application, my sequence isn't executed. I don't get any errors thrown and when I debug it, I can see that it spends ~20seconds doing the 'NewExecution' method and then just continues. I'm fairly sure my sequence isn't actually executing as it should take several minutes and it's not interacting with any of the hardware it normally would do when I run a single pass from TestStand.

 

The SequenceFile & seqFileModel do go to valid file locations, if I change them then the code will throw an error. As it's not throwing an error, I'm not sure what I'm doing wrong. Any ideas?

 

Thanks very much.


Viewing all articles
Browse latest Browse all 6524

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>