NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I dynamically create StationGlobals variables that are LabVIEWIOControl

Solved!
Go to solution

I am looking for a way to dynamically create StationGlobals variables that are LabVIEWIOControl.  I know how to create variables through "PropertyObject/SetValXXX", however I am having difficualty creating variables that are custom data types.

 

Thanks,

Bryon

0 Kudos
Message 1 of 10
(6,850 Views)
Solution
Accepted by topic author blthom124

Bryon,

 

You can use an expression like the following:

 

StationGlobals.NewSubProperty("MyVariable",PropValType_NamedType,False,"LabVIEWIOControl",0)

 

Hope this helps!

Message 2 of 10
(6,848 Views)

That's awesome! I was just going to ask similar question, but found this topic! In my case, it works for FileGlobals, via TestStand API from LabVIEW. Thanks!

0 Kudos
Message 3 of 10
(5,978 Views)

Related question on a similar setup (in LV/TS 2012):
When I just tried (from within LV)

SequenceContext - StationGlobals - SetValInterface("MyVar", PropOption_InsertIfMissing, [Some .NET-object])

with "MyVar" not existing absolutely nothing happened: No creation of the variable, no error message.

The same when I used "PropOption_NoOptions": Especially the error I'd expect was missing.

The same when the variable was already existing.

Also the same with SetValIDispatch...

But:

SetValNumeric worked as expected in the same setup.

 

I can live with the command not working on StationGlobals or from within LV but why is there no error? What am I missing?

0 Kudos
Message 4 of 10
(4,896 Views)

What value are you trying to set MyVar to? Does the value exist in memory before calling SetValInterface?

Dale S.
RF Systems Engineer - NI
0 Kudos
Message 5 of 10
(4,881 Views)

Hi Dale,

the value is a .NET-Object. I just have to get it from one call and pass it a little later into the next. I have nothing to do with the handling of the data itself.

Meanwhile I got the stuff running by using SetValVariant on an already existing "MyVar" (here: DataSetLabView). See my testcode below.

SetVal-Object-.png

But what still puzzels me:

I tried all combinations of
- "MyVar" already existing and "MyVar" not existing before
- "SetValIDispatch" and "SetValInterface"
- "PropOption_InsertIfMissing" and "PropOption_NoOptions"
and always got neither an error coming up nor the data set or even the propery created.

In contrast - "SetValVariant" with "PropOption_InsertIfMissing" gave me a nice, clear error. I can work with that.

0 Kudos
Message 6 of 10
(4,876 Views)

Are you running this code from TestStand? If you do not create an error out connection to the connector pane, TestStand will not know that the LabVIEW code has errored out. Although this makes me wonder why you are seeing an error when using a different function. What is the error that you are getting when using SetValVariant and how are you handling errors?

 

Could you also give me some additional information on the value that you are writing? Does it have a custom data type, or is it something more simple like a string or a numeric?

Dale S.
RF Systems Engineer - NI
0 Kudos
Message 7 of 10
(4,852 Views)

Hi Dale,

thanks for the reply.

I'll try to stich together an example code which contains a commonly available datatype or .NET-object and which shows the same behaviour. Should be easy - I did it before:

The screenshot above is already not my original case. That code would have been a bit too huge... In my original code the .NET object contained a custom data type which conveys statistical data. I don't know the exact structure because I'm just the messenger. The testcode in the screenshot was a reference to a random .NET-written database connection-type code. I took the first reference I got my hands on. It showed exactly the same behaviour as the original code.

Of course I'm running the code from TS as I need the SequenceContext and because the code remote controls TS...

The error cluster was connected but even If it wasn't I'd seen any error on the LV frontpanel.

 

Sören

0 Kudos
Message 8 of 10
(4,846 Views)

Here is the code.

You'll have to relink the VI to the TS-sequence but I hope I selected a enough common .NET thingy.

I placed breakpoints so the state of the memory can be easily checked.

 

Sören

Download All
0 Kudos
Message 9 of 10
(4,842 Views)

Hi Dave,

ARGH!

I just saw what you meant with the unconnected error cluster.
STUPID ME! Sorry.

I made the tests in the original code which had the Error Cluster connected. Plus I checked the Frontpanel. The code in the screenshot was only created for that screenshot...

 

The example code I just posted also shows the behaviour I described.

0 Kudos
Message 10 of 10
(4,839 Views)