NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Buttons on UI

Hi,

I'm developing a TestStand (2010 SP1) User Interface using LabVIEW (2011). I want to place a number of buttons on the UI to control a number of threads. I'm using the ConnectCommand (cmdKind CommandKind_Custom) to connect the button the IApplicationMgr. When a button is pressed, the PostCommandExec event is triggered and I can use this event to do my handling. However, I do not find a way to trace back which button had been pressed in this event. Any suggestions?

 

Thanks in advance,

Mark Vorage
Vision Engineer

Philips Technologie GmbH

View Mark Vorage's profile on LinkedIn
0 Kudos
Message 1 of 5
(4,731 Views)

Mark,

 

reading the help to CommandKind_Costume, you find this:

CommandKind_Custom–(Value: 3) Represents an action you define. You must set Command properties, such as the Command.Enabled and Command.Visible properties, to the values you require. Although this command does not perform an action when it executes, an application can perform an action when it receives the ApplicationMgr.PreCommandExecute or ApplicationMgr.PostCommandExecute event for the command. You can attach data you define to the command using the Command.UserObject and Command.UserData properties so the data is available to the application in the handlers for PreCommandExecute and PostCommandExecute events.

 

So it seems that the ApplicationMgr.PostCommandExecute Event does not know the source, so the specific command, it is called by. You can add the source by using the UserObject or UserData property for the Command in order to check the source in the callback function to this event.

 

Norbert

 

EDIT: Removed invalid hyperlinks from the quote from the TS help.

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 5
(4,730 Views)

Hi Norbert,

First of all thanks for the fast repsonse. Yeah, I also saw this. But how can I connect a button to a command. So, when the button is pressed the command is triggered (executed)?

Mark Vorage
Vision Engineer

Philips Technologie GmbH

View Mark Vorage's profile on LinkedIn
0 Kudos
Message 3 of 5
(4,725 Views)

Mark,

 

when trying to refer to the button itself, i would go for the UserObject.

I think you already saw this, and now we are in the situation that i never done that before myself 😉

 

That being said, it seems to me that it is working as following:

You have to configure a collection of commands (objects) for your custom commands. All these objects have their individual configuration, e.g. the reference to the button as UserObject (IUknown).

When connecting the CommandKind_Custom to a specific button, you select by index the command object from the command collection you want to work with. TestStand will call CommandExecute for this object automatically.

You can use the PostCommandExecution event callback to further add functionality in your UI to handle things connected to this control (button). This event callback gets the command object as parameter.

 

There is one predefined situation which is comparable to what you are working on:

CommandKind_ExecutionEntryPoints_Set: Using the index, you select which entry point you are actually going to execute once the button is pressed.

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 4 of 5
(4,721 Views)

Hi Norbert,

I just figured out that I was going completely into the wrong direction. For a custom action I don't need to connect a button to a command (i.e. CommandKind_Custom). I can just use the click event of the button itself.

 

Thanks!

Mark Vorage
Vision Engineer

Philips Technologie GmbH

View Mark Vorage's profile on LinkedIn
0 Kudos
Message 5 of 5
(4,666 Views)