NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

access FileGlobals

I'm trying to access a File Global from TestExec that is a .NET Object Reference. I have no problem getting numeric or string values. I've tried

GetValIDispatch and  GetValInterface. Anyone been able to accomplish this?

 
0 Kudos
Message 1 of 13
(4,349 Views)

You have to do it as a property object: http://forums.ni.com/ni/board/message?board.id=330&message.id=18398&requireLogin=False

Hope that helps.  Funny how Ray answers questions even when he doesn't post.  🙂

If you could post a snippet of code it would help a little as well.  What datatype do you want to retrieve?



Message Edited by ~jiggawax~ on 04-29-2008 02:18 PM
jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 2 of 13
(4,340 Views)
Thanks jigg,
   But, I've read that post and it doesn't address my issue. I can get the PropertyObject with no problem. My issue is one of my File Globals is a .NET Object Reference and I can't pull that out of the PropertyObject. As I said, getting numbers, bools, or strings is no problem. I haven't seen any examples that show how to get an Object Reference and all the ways I've tried throw an exception. I step through my sequence to verify my MyObjRefVal is a valid .NET Object Reference before I jump to this TestExec code.
 
//--------------------------------------------------------
.....
.....
.....
MyClass mc=new MyClass();

PropertyObject po = SeqCont.AsPropertyObject().GetPropertyObject("FileGlobals", 0);

double x = po.GetValNumber("MyNumVal", 0); //no problem

bool y = po.GetValBoolean("MyBoolVal", 0); //no problem

string s= po.GetValString("MyStrVal", 0); //no problem

mc = po.GetValInterface("MyObjRefVal", 0); //NOT!! Exception

mc = po.GetValIDispatch("MyObjRefVal", 0); //NOT!! Exception

//------------------------------------------------------------------------------------

I'v tried A bunch of things with Variant types too and nothing works. I am able to assign it to a base object but I can do anything with it if i can't cast it to an object of my class type.

 

0 Kudos
Message 3 of 13
(4,336 Views)
Hey John,
 
What about:
 
MyClass mc=new MyClass();

PropertyObject po = SeqCont.AsPropertyObject();

mc = po.GetPropertyObject("FileGlobals.MyObjRefVal", 0);

?

I don't have a .net editor or I'd mess around with it.

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 4 of 13
(4,325 Views)
Hi John
 
Please post a small example (best as hole a visual studio project file) of your code and sequnce,
 
I assume that this is a little bit difficult and is a task of your NI-Guys here.
I have done some test and realized that i have to use a class derived from MarshalByRefObject
but it it is not working good. Another solution could be object serialization
 
So lets see what your NI fiends are saying
 
Greetings
 
juergen
--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 5 of 13
(4,310 Views)

jigg,

  Yea, I tried that too...same result.

 

j_dodek,

   What I posted before was my code. The Only thing I didn't include is the function name. In my sequence I'm using PostUIMessageEX and passing "ThisContext" as the ActiveX parameter. In my code I override UIMessageEvent of the Application Manager component. Here is the whole function directly from my code:

private void axApplicationMgr_UIMessageEvent(object sender, NationalInstruments.TestStand.Interop.UI.Ax._ApplicationMgrEvents_UIMessageEventEvent e)

{

if

(e.uiMsg.Event == NationalInstruments.TestStand.Interop.API.UIMessageCodes.UIMsg_UserMessageBase + 100)

{

MyClass mc=new MyClass();

SequenceContext sc = (SequenceContext)e.uiMsg.ActiveXData;

PropertyObject objStepProperty = sc.AsPropertyObject().GetPropertyObject("FileGlobals", 0);

double x = objStepProperty.GetValNumber("MyNumVal", 0);

bool y = objStepProperty.GetValBoolean("MyBoolVal", 0);

string s = objStepProperty.GetValString("MyStrVal", 0);

mc = (

MyClass)objStepProperty.GetValIDispatch("MyObjRefVal", 0);

}

}

 

BTW, I also tried to bypass dealing with the Sequence Context, Property Objects, FileGlobals, etc... and directly pass the .NET Object Reference as the ActiveX parameter but that doesn't work either.


0 Kudos
Message 6 of 13
(4,284 Views)
One more thing just in case anyone wnats to know...Passing an Object Reference from a sequence to .NET code works fine, I do it all the time. It just seems to be something with doing it via a Post Message and the ActiveX parameter.
0 Kudos
Message 7 of 13
(4,283 Views)

Hi John,

I know that that you have posted your code. But posting the hole stuff as a zip-file makes it more easier to test your code because there is no need for creating a
VS project and SequenceFile.

In your case you have at the one hand your UserInterface and on the other the execution. If you take a look into the task-manager you will that there are 2 processes.
You have to do interprocess communications. Maybe you will find this Thread interresting.


http://forums.ni.com/ni/board/message?board.id=330&message.id=18696&query.id=74382#M18696

greetings

juergen

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 8 of 13
(4,269 Views)

juergen,

   First off, thanks for the responses. I guess I didn't explicitly state this but I am just using the C# TestExec that ships with TestStand. So, since you have Test Stand on your machine I'm assuming you already have the code on your machine. There are probably some paths and dependencies etc... in the project that would make it a little burdensome to just zip it up and send it. Anyway...depending on the version (Mine is 4.0), the path is:

C:\Program Files\National Instruments\TestStand 4.0\UserInterfaces\NI\Full-Featured\CSharp

The only other thing I've done is overridden UIMessageEvent which I've included. So you should be able to open project and test it in literally a minute or two.

 

Regarding the interprocess communications…not sure if I could accomplish what I am trying this way or not. I’ll look into it.

 

I just assumed there was an easy way to access all variable types via the use of PropertyObject but apparently this is not the case with Object Reference types.

 

Thanks again

 

0 Kudos
Message 9 of 13
(4,260 Views)

John,

Just like to point out, that changing the code in the NI folder is not wise. It is recommended that you copy the NI folder to the USER folder then change the code in the USER folder.

eg not use this folder

C:\Program Files\National Instruments\TestStand 4.0\UserInterfaces\NI\Full-Featured\CSharp

but use the following folder

C:\Program Files\National Instruments\TestStand 4.0\UserInterfaces\USER\Full-Featured\CSharp

Regards

Ray Farmer

Regards
Ray Farmer
0 Kudos
Message 10 of 13
(4,245 Views)