NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

postuimessage array activexparam

Solved!
Go to solution

Hi.  So I am on an academic venture.  Trying to learn how to make a custom user interface that interacts with Teststand.  I am learning.  I have an array that I am passing from teststand to a custom OI interface I created from the simple Ui interface example that ships with Teststand. I want to update the an arrray indicator I have on the OI with the array I am passing from teststand. What I have read so far on the internet and forums is that a good way to do this is by passing the array variable from TestStand via a PostUiMessage.  Specifically via the activexparam component of the PostUiMessage.  This seems easy enough to do... so I did that.

 

On the OI side, I am able to detect the eventcode that I set in the PostUIMessage I created in TestStand.  However, I am not sure how to exactly extract the array from the activexdata portion of the UiMessage on the OI side.  I think it is passing me a reference which is essentially just a memory location .... I think.   I think it is a pointer to the array.  I just can't figure out how to actually turn the activexdata back into an array on the OI side and how to put that into my array indicator on the my OI front panel.

 

If you can help, I would appreciate it.  More specific, the better. 

0 Kudos
Message 1 of 9
(5,633 Views)
Solution
Accepted by topic author DN_Eng1

The value stored in the ActiveXdata parameter is a PropertyObject that is the array. Use the TestStand PropertyObject API to access it. If you are using LabVIEW there is also a wrapper VI (in the teststand palette. VIs are called "Get Property Value"/"Set Property Value") to convert to and from a labview array.

 

Hope this helps,

-Doug

0 Kudos
Message 2 of 9
(5,607 Views)

Doug,

 

I'm a newbie.  So be gentle :).  I put down a TestStand Get property vi.  But still can't figure out how to convert my ActiveXData property into an array using the GetProperty vi.  The get property is asking for a Sequence Context in.  I can get one from the Ctrl Ref, but I am not sure if that is the correct thing to do.  Basically, I want to set a array in my OI vi to the the array my ActiveXData property is suppose to represent.  I attached my code if you feel like reveiwing and manipulating it to show me what to do.  I am trying to make a custom User Interface (based from the simple user interface shipped from NI) for my teststand sequence.  The code I am sending you is a control VI that gets fired off from the user interface based on an event from TestStand.  I was able to succussfully get a string value from teststand and set a label on my userinterface with the same methodology, but having trouble doing the same type of thing with an array.  Again, I am new so it could very well be that I have no idea what I am doing at this point.  So any help you can provide would be appreciated. 

0 Kudos
Message 3 of 9
(5,592 Views)

You are correct, that wrapper VI is assuming a property off of the sequence context, which is not what you have. Sorry, I forgot. If you look at the diagram for that VI though, you can see what it does and do something similar for your PropertyObject that is an array directly. For example, here is the diagram for the numeric array version of that wrapper VI:

 

forum.png

 

 

You can make a similar VI, but instead of using the sequence context and lookupstring, just call GetValVariant() directly on your PropertyObject from the activeXdata, and pass an empty string for the lookupstring. Also you might want to do the Close Reference at a different location rather than right after the call to GetValVariant, basically close it when you are done with it.

 

Hope this helps,

-Doug

Message 4 of 9
(5,582 Views)

Doug,

 

Thanks for the response.  Unfortunately, I am still stuck.  I have thought about this quite a bit and now have come to the realization that I need a code example from anyone who has ever successfully passed an array from TestStand to a User Interface and was able to successfully display array data on the front panel of the user interface vi.

 

I need a real example.  Not just someone talking about how to do it.  But an actual real example of it being done.  Yes.  I am at that point.  🙂

 

Anyone?  Anyone?  Doug? Anyone.  Real working example?  That runs without error?

0 Kudos
Message 5 of 9
(5,567 Views)

Hey DN_Eng, 

 

There is an example that ships with TestStand 2014 that you can use as a starting point to get something functional. It's located in the TestStand Public Directory:

 

C:\Users\Public\Documents\National Instruments\TestStand 2014 (32-bit)\Examples\Modifying User Interfaces\Handling UI Messages\

 

The user interfaces are located in their respective directories.

 

There is a small modification I made to one of the cases in the example. In the "Register event Callbacks" case in the Main Event Loop of the example, there is a Callback VI that is was added to handle a specific event that you added. There are two possible ways to get the information you need:

 

1) You can do what Doug was saying, which is get the ActiveXData and cast it as the type you need and then set your TestStand UI Data that corresponds with your numeric array. 

 

getval by variant.PNG

 

2) You can get a reference to the thread in the UI Message and then call the GetSequenceContext method on it. From there, you get the value of a particular array and set the value. This takes a few more calls but it is more clear what you are doing.

 

get value from user event prop nodes.PNG

 

I suggest trying the first method because it is closest to what your first response was about and it is the most general.

Kurt P
Automated Test Software R&D
Message 6 of 9
(5,522 Views)

Kurt, Doug,  I am prepared to give you a billion kudos for your efforts to help me so far.  However, I haven't crossed the finish line and am still stuck.  I basically need someone to produce the actual task I am trying to do and send me the code.  Yes.  I am at the point where I basically need some spoon feeding.  I am very new and learning.  However, I have been churning this for days now and just can't figure it out.  So here is the task...

 

1. Create a two dimensional array of type string in TestStand.  Somehow.  Anyway you want to create it.  Let it have some values.

2. Pass the 2D array from TestStand to the "Simple User Interface" shipped with TestStand 2014 via the PostUIMessageEx via the activeXDataParam.

3. I am trying to make a custom user interface.  So I moved stuff around on the front panel of the simple user interface and put a 2D array of string type on the front panel for the user to see. 

4. When I run the TestStand sequence from my user interface.  I want to see the 2D string array that I created in TestStand populate the 2D array of string on my front panel of my user interface.

 

Or do it anyway you want.  I just want to display a 2D array on my user interface front panel pass from teststand.  This is driving me crazy. If you have the time to show me working code, I would extremely appreciate it.

 

best regards,

 

DN

 

0 Kudos
Message 7 of 9
(5,507 Views)

Hey DN_Eng1,

 

First I just want to mention that I had a mistake in my first post on this thread; I incorrectly cast the parameter from a Variant to an array of doubles. The correct way to do this was demonstrated by dug9000 in his post. That is, cast the ActiveXData as a property object and then calling GetValVariant on that object and casting that as the data type that you need. 

 

I created a callback to perform this action. I modified the UserMessage Event Callback.vi from the UI Message Example and added two cases:

 

1) I added case 10123. It uses the ActiveXData parameter.

2) I added case 10343. It gets the sequence context and then uses a Lookup String to get the variable and updates it. Note, in the sequence file we do not need to set the ActiveXData Parameter because we are getting our variable through the sequence context. I did not use the TestStand VI Set Property Value because it does not have a case for multidimensional arrays. 

 

Both methods work and accomplish the exact same functionality but you probably want to use case 10123. It is cleaner for your application. 

 

I mentioned in my previous post to demonstrate how you could accomplish both methods that I posted about. The only difference is that I did not use the Set Property Value TestStand VI because it does not have a case for multidimensional arrays so I just accessed the TestStand API directly with invoke nodes. I also attached the sequence file I used to post the UI messages.

 

Best Regards,

 

KP

Kurt P
Automated Test Software R&D
Message 8 of 9
(5,480 Views)

Kurt and Doug,

 

That worked!!!  Thank you soooo much.  Like I said, I am just a beginner and am learning.  I tried and tried to do this myself but couldn't.  Normally, I don't like to ask someone to just "do" it (write code) for me, but in this case, I just had to ask.  You writing some code for me really is helpful and hopefully will spring board me into better understanding.  Thanks alot!!!!  I am trying to self teach myself labview.  Thanks again.

 

David

0 Kudos
Message 9 of 9
(5,451 Views)