NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Teststand Operator Interface and C++ MFC interface

Solved!
Go to solution

Hi,

I am customizing the Teststand Operator Interface based on my project requirements.

Now I want to display the Current system and Date information in the bottom pane of the operator interface along with other information like User, Model etc. I am using below code to display the current date and time but is not working. 

mExecutionViewMgr->GetCaptionText(CaptionSource_Date, false, "");
mExecutionViewMgr->GetCaptionText(CaptionSource_Time, false, "");

Where mExecutionViewMgr is my pointer to Execution view manager.

Please guide how to display current date and time as I could not get this anywhere in internet or forum.

Thanks in advance.

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

Building the connection is the first important step on displaying that information. However, i do recommend you to use the ApplicationMgr in case you want to display the information all the time.

 

You  missed the second step to actually display the accoring pane(s). You can configure this in the ShowAppropriateStatusBarPanes method (at least this is the name in C# as i do not work with C++ anymore). Note that the panes are referred to per name in that method.

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

Hi Norbert,

 

Thanks for the reply.

I have replaced 'mExecutionViewMgr' with 'mApplicationMgr' (again a pointer to ApplicationMgr). However I still don't get the date and time information.

 

About ShowAppropriateStatusBarPanes:

Below code snippet was available in the C++(MFC) example code for Operator Interface. It is used to show information like User, Model etc on the selected tab control.

 

void CTestExecDlg::ShowAppropriateStatusBarPanes()
{
  if (m_tabCtrl.GetCurSel() >= 0)
  {
  if (mListBar->GetCurrentPage() == SEQUENCE_FILES_PAGE_INDEX) // if only the files    tab is visible
  mStatusBar->ShowPanes(_T("User, EngineEnvironment, FileModel, FileSelectedSteps,   FileNumberOfSteps"));
  else
  if (m_tabCtrl.GetCurSel() == 0) // execution tab is selected
  mStatusBar->ShowPanes(_T("User, EngineEnvironment, ExecutionModel,     ExecutionSelectedSteps, ExecutionNumberOfSteps, ProgressText, ProgressPercent"));
 else // report tab is selected
  mStatusBar->ShowPanes(_T("User, EngineEnvironment, ExecutionModel,     ReportLocation, ReportModel, ProgressText, ProgressPercent"));
  }
}

 

In the above ShowAppropriateStatusBarPanes(), how can I include date and time information as GetCaptionText() does not have the 'uiObj' parameter.

PS: The parameters inside ShowPanes() in the above code snippet are the 'uiObj' for each connection established.

 

Appreciate any help!

0 Kudos
Message 3 of 13
(4,836 Views)

As mentioned, the panes are referred to by name.



  mStatusBar->ShowPanes(_T("User, EngineEnvironment, FileModel, FileSelectedSteps,   FileNumberOfSteps, <MyPaneName>"));
 

I hope above part points you to a working solution...

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

Hi Norbert,

 

I understand that I should list <MyPaneName> in the parameters list of ShowPanes().

But, analyzing the current parameters of ShowPanes(), for example 'User', this is the uiObj parameter of the below code snippet. used for connection.

 

mApplicationMgr->ConnectCaption(panes->GetItem("User"), CaptionSource_UserName, false);

 

'uiObj' is the first parameter of the function ConnectCaption() which is used to connect this caption (i.e. 'User')

However for date and time, I am using GetCaptionText() and this function does not have uiObj parameter. I tried using ConnectCaption() for date and time but when I launch my .exe, it says invalid pane probably because no such pane exists. Is GetCaptionText() the correct function to use?

If yes, what would be <MyPaneName> I should be passing to ShowPanes().

If No, what should be the function used instead of GetCaptionText() ?

0 Kudos
Message 5 of 13
(4,828 Views)
Solution
Accepted by topic author Divyaa

@Divyaa wrote:
[...]

But, analyzing the current parameters of ShowPanes(), for example 'User', this is the uiObj

[...]


That part underlined in your text above is incorrect. ShowPanes works with the name.

That is why you need


@Divyaa wrote:
[...]
mApplicationMgr->ConnectCaption(panes->GetItem("User"), CaptionSource_UserName, false);

[...]


This code connects the item with the name "User" to the application manager. You can see this because it calls the GetItem method.

When looking at the parameters of ShowPanes, you won't see the GetItem method call....

 

The name is whatever you provided as name for the pane in the ActiveX property dialog.

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

It Worked! Thanks a lot Norbert.

 

I am pasting the code below for someone in need.

 

First insert two panes with names 'Date' and 'Time' as below.

panes->Insert("Date",4);
panes->Insert("Time", 5);

where 'panes' is of type StatusBarPanesPtr.

4 and 5 is the position of the panes.

 

Then connect these panes as below:

mApplicationMgr->ConnectCaption(panes->GetItem("Date"), CaptionSource_Date, false);
mApplicationMgr->ConnectCaption(panes->GetItem("Time"), CaptionSource_Time, false);

 

Upon passing 'Date' and 'Time' in ShowPanes() of ShowAppropriateStatusBarPanes() function. This brings both date and time information to the status bar.

0 Kudos
Message 7 of 13
(4,821 Views)

This is working fine and displaying the current date and time correctly. Now, how to give a label to them as 'Date:' and 'Time:' so that when they look like 'Date:dd/mm/yyyy' and 'Time: hh:mm:ss'? 

Now it is just 'dd/mm/yyyy' and 'hh:mm:ss'

0 Kudos
Message 8 of 13
(4,812 Views)

You have to extend your connection to allow custom formatting.

To do so, you can modify the connection command area to somthing like this (C#):

CaptionConnection TimeConn;

TimeConn = this.axApplicationMgr.ConnectCaption(panes["Time"], CaptionSources.CaptionSource_Time, false);

TimeConn.FormatExpression = "\"Time: %1\"";

 

%1 is replaced with the text of the caption source once an update is done.

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

Got it working. Thanks a lot!

0 Kudos
Message 10 of 13
(4,795 Views)