NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing container argument to sequence through API

Hello,

 

I'm trying to pass an argument to a sequence using the teststand API and the "Engine.NewExecution" method. A container to be more accurate. I've managed to pass strings, numbers... but not containers, well, that's not true, I've passed empty container successfully.

 

I'm using python to do this but the API works the same as if I'd use VB. This is my code snippet :

 

    # New property object of tye container containing sequence params
    sequenceParams = self.tsEngine.NewPropertyObject(0x00, False, "", 0)
    sequenceParams.SetValString("TestValue", 0x01, "Hello")
    
    # Create new property object corresponding to TapData container then add it to sequenceParams
    tapData = self.tsEngine.NewPropertyObject(0x00, False, "", 0)
    tapData.SetValString("TapTest", 0x01, "Hello")
    sequenceParams.InsertSubProperty("TapData", 0x01, 0, tapData)
    
    
    seqExec = self.tsEngine.NewExecution(seqFile, "MainSequence", None, False, 0, sequenceParams)

 

 


Sorry about those configuration constants. I know I'm using the raw values instead of their names, but I havent figured out a way to include them in my python script yet.

 

This is the sequence parameters :

image.png

 

 

 

 

 

I get the following error (which is a bit ambiguous):

 

    seqExec = self.tsEngine.NewExecution(seqFile, "MainSequence", None, False, 0, sequenceParams)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\nharel.ext\AppData\Local\Temp\gen_py\3.11\B2794EF3-C0B6-11D0-939C-0020AF68E893x0x1x0.py", line 3638, in NewExecution
    ret = self._oleobj_.InvokeTypes(110, LCID, 1, (9, 0), ((9, 1), (8, 1), (9, 1), (11, 1), (3, 1), (12, 17), (12, 17), (12, 17)),sequenceFileParam
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'TSAPI', "Error calling sequence MainSequence.\nType of argument is incompatible with parameter 'TapData'. Expected Container, found Container.", None, 0, -17332), None)

 

 

 

Expected Container, found Container ? Anyone have any idea what I'm doing wrong, if I'm doing something wrong ?

 

Thank you, have a nice day.

0 Kudos
Message 1 of 7
(1,167 Views)

Nothing ?

 

I'm guessing this is not a normal behaviour from Teststand...

0 Kudos
Message 2 of 7
(1,125 Views)

Bumping this one last time.

0 Kudos
Message 3 of 7
(1,105 Views)

Not sure about the bad error message. Does TapData in the parameters have a type?

 

Have you tried right-clicking on the sequence parameter and unchecking the Check Type option?

0 Kudos
Message 4 of 7
(1,091 Views)

Hello James,

 

TapData was a container. The fields inside this container were just a bunch of integers, but I've also tried with strings, and tested pretty much everything. Always had the same error. The only thing that "works" is passing empty containers.

 

Anyway, we ended up deleting all our container params and replacing them with "classic" types. Not optimal at all, really dirty, but it works.

 

I haven't tried disabling the type check in Teststand.

0 Kudos
Message 5 of 7
(1,040 Views)

Hello everyone,

I'm still quite new to TestStand, so I'm not sure if this will be helpful.

 

I encountered the error message "Expected Container, found Container." when I used a container as a parameter.

 

The problem was that the elements in the container did not have the same names as the elements in the container in the sequence that was called. Unlike an array, the order in a container can be rearranged with drag and drop, but to identify them correctly, the names must be identical.

 

I hope this helps.

Message 6 of 7
(396 Views)

Names are used to identify container elements. Otherwise it would be hard to tell two or more elements of the same type apart.

 

BTW…. Probably consider using typedefs for containers 

0 Kudos
Message 7 of 7
(380 Views)