06-12-2014 08:57 AM
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,
06-12-2014 09:07 AM - edited 06-12-2014 09:30 AM
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.
06-12-2014 09:12 AM
06-12-2014 09:26 AM - edited 06-12-2014 09:27 AM
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
06-16-2014 02:54 AM