NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

C# Creating sequence file with steps

Solved!
Go to solution

I'm trying to use the C# API in order to create a sequence file that can be loaded into TestStand. When I try to create a step, i'm given the error:

 

Additional information: Step type 'Action' not found in type list

I'm using the following:

class Teststand
    {
        Engine engine;
        SequenceFile file;

        public Teststand()
        {
            engine = new Engine();
        }

        public void new_sequence()
        {
            file = engine.NewSequenceFile();

            Sequence seq = engine.NewSequence();
            seq.Name = "Example";

            Step step = engine.NewStep( "None Adapter", "Action" );
            step.Name = "Step Test";

            save_sequence_file( @"C:\Users\me\Desktop\output.seq" );
        }

        public void save_sequence_file(string file_path)
        {
            file.Save(file_path);
        }
    }
}

I know that I'm not adding the step to the sequence file just yet, but surely that wouldn't be the cause of the issue? Why can't it find the step type? I've tried multiple types and even tried 

StepTypes.StepType_Action

Which just gives me the same idea.

 

I'm very confused as to how to specify the type correctly, can anyone help?

0 Kudos
Message 1 of 3
(4,410 Views)
Solution
Accepted by topic author adam_

Hi adam_,

 

It is recommended that you add the new Step to the TypeUsageList of the Sequence File it is being inserted into:

 

class Teststand
    {
        Engine engine;
        SequenceFile file;

        public Teststand()
        {
            engine = new Engine();
            engine.LoadTypePaletteFilesEx(TypeConflictHandlerTypes.ConflictHandler_Prompt, 0);
        }

        public void new_sequence()
        {
            file = engine.NewSequenceFile();

            Sequence seq = engine.NewSequence();
            seq.Name = "Example";
            file.InsertSequenceEx(file.NumSequences, seq);

            Step step = engine.NewStep("None Adapter", "Action");
            step.Name = "Step Test";
            file.AsPropertyObjectFile().TypeUsageList.AddUsedTypes(step.AsPropertyObject());
            seq.InsertStep(step, 0, StepGroups.StepGroup_Main);

            save_sequence_file(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\output.seq");
        }

        public void save_sequence_file(string file_path)
        {
            file.Save(file_path);
        }
    }
}

Here are the things that I have added to your code:

  1. Engine.LoadTypePaletteFilesEx
  2. SequenceFile.InsertSequenceEx
  3. TypeUsageList.AddUsedTypes
  4. Sequence.InsertStep
  5. Environment.GetFolderPath(Environment.SpecialFolder)

 

Regards,

 

Jeff

Message 2 of 3
(4,396 Views)

Thanks for your detailed response! I've now managed to get it working however with some slight changes. I thought it'd be worth posting what I changed in case another forum user has the same issue. With the code provided the step wasn't being inserted, however after looking through the example code provided in the TestStand installation folder I found that you need to insert your step into 'MainSequence' like so:

 

file = engine.NewSequenceFile();
Sequence seq = file.GetSequenceByName("MainSequence");

Thanks again for your help!

0 Kudos
Message 3 of 3
(4,368 Views)