NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Run TestStand Sequence Silently in C# with Report

Solved!
Go to solution

Hello,

 

I'm using TestStand 2012 SP1 and Visual Studio 2010.

I want to run a TestStand sequence silently in my C# software.

 

I saw on this web site how to do to run a TestStand sequence (https://decibel.ni.com/content/docs/DOC-29585).

This example is really interresting to know how to run it using the .NET interop API.


The problem I can't solve is that no report is created when running the sequence although I added a step to setup the ReportOptions.

 

You will found here, the class I use to start the TestStand sequence :

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

            try
            {
                User admin = Engine.GetUser("administrator");
                Engine.CurrentUser = admin;

                SequenceFile seqFileModel = null;
                StationOptions stationOptions = Engine.StationOptions;
                stationOptions.DisableResults = false;
                stationOptions.AllowOtherModels = true;

                int flags = 107; // GetSeqFileOptions.GetSeqFile_OperatorInterfaceFlags;
                seqFile = Engine.GetSequenceFileEx(sequenceFilename, flags, TypeConflictHandlerTypes.ConflictHandler_Prompt);

                bool modelExists;
                string modelPath = seqFile.GetModelAbsolutePath(out modelExists);
                seqFileModel = Engine.GetSequenceFileEx(modelPath, GetSeqFileOptions.GetSeqFile_NoOptions, TypeConflictHandlerTypes.ConflictHandler_Prompt);

                // Setup the report options
                int reportOptionCallbackIndex = seqFile.GetSequenceIndex(DefaultModelCallbacks.DefModCback_ReportOptions);
                if (reportOptionCallbackIndex > -1)
                {
                    seqFile.DeleteSequence(reportOptionCallbackIndex);
                }
                Sequence reportGenCallback = seqFile.CreateCallbackOverrideSequence(DefaultModelCallbacks.DefModCback_ReportOptions, false);
                InsertStatementStep(reportGenCallback,
                    "Parameters.ReportOptions.DisableReportGeneration=False,\n" +
                    "Parameters.ReportOptions.GeneratePath=False,\n" +
                    string.Format("Parameters.ReportOptions.ReportFilePath=\"{0}\",\n", GenerateReportFilename(resultDir, sequenceFilename)) +
                    "Parameters.ReportOptions.UseOnTheFlyReporting=True,\n" +
                    "Parameters.ReportOptions.PurgeOnTheFlyResults=True");

                exec = Engine.NewExecution(seqFile, "Single Pass", seqFileModel, false, 0, null, null, null);
                exec.Report.Location = resultDir;
            }
            catch (Exception)
            {
                throw;
            }

            return exec;
        }

 

 

What's wrong with my code and what should I do to get a report associated to the single pass ?

 

I hope someone will help me

Best Regards,

 

CFOE

0 Kudos
Message 1 of 4
(5,791 Views)

Hi,

 

The process model creates the report. Does the Engine.NewExecution( ... seqFileModel...) call refer to a valid process model? Does your sequence file have a model option specified in the sequence file properties?

 

cc

0 Kudos
Message 2 of 4
(5,753 Views)

Hi,

 

as far I could see while debugging, the process model associated to the sequence file is the SequentialModel and as far as I know, the SequentialModel can create a report.

I get the sequence file model using the command seqFile.GetModelAbsolutePath.

 

Best Regards,

CFOE

0 Kudos
Message 3 of 4
(5,746 Views)
Solution
Accepted by topic author cfoe

Hi,

 

This code works fine I just forgot to manage the Execution messages by polling.

 

Best Regards,

CFOE

Message 4 of 4
(5,720 Views)