04-29-2008 12:34 PM
GetValIDispatch and GetValInterface. Anyone been able to accomplish this?
04-29-2008 02:17 PM - edited 04-29-2008 02:18 PM
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?
04-29-2008 03:13 PM
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.
04-29-2008 04:53 PM
mc = po.GetPropertyObject("FileGlobals.MyObjRefVal", 0);
?
I don't have a .net editor or I'd mess around with it.
04-30-2008 01:20 AM
04-30-2008 10:26 AM
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.
04-30-2008 10:31 AM
04-30-2008 01:28 PM
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
04-30-2008 02:30 PM
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
05-01-2008 12:47 AM
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