📄 mainfrm.cpp
字号:
}
/*
// Is the 860 is alive?
// Put some dummy task number. putWORD() times out if the 860 is dead.
if (putWORD (555, g_properties.n3042ComemID) == NO_ERROR)
{
g_properties.e860Status = OPENEDok;
}
else
{
g_properties.e860Status = BAD;
MessageBox("860 is not running.",
NULL,
MB_ICONEXCLAMATION );
}
*/
// Act like the user pushed a radio button to start the test indicated in nTestNum.
OnWM_User(0, g_properties.nTestNum);
// Must start timer at the end, else Windows will start calling OnTimer before the initialization is complete!!!
if (!SetTimer (ID_TIMER_CLOCK, 50, NULL))
{
MessageBox ("SetTimer failed", "Error", MB_ICONSTOP | MB_OK);
return -1;
}
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
cs.style &= ~FWS_ADDTOTITLE; // Strip the document name (Untitled) from the Window title.
// cs.lpszName = "CO-MEM Lite (AN3042) Performance Workbench";
cs.lpszName = "PCI-DP DMA Performance Demonstration";
return CFrameWnd::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
void CMainFrame::OnTestsSelecttests()
{
// TODO: Add your command handler code here
if (pDialogSelectTest != NULL)
{
pDialogSelectTest->SetFocus();
return;
}
else
{
pDialogSelectTest = new CDialogSelectTest;
pDialogSelectTest->Create (IDD_DIALOG1, this);
}
}
// Displays the bandwidth and the DMA size.
void CMainFrame::display_bandwidth (double bw, int DMAsize, CClientDC &dc)
{
// if (bw > (double)10) // Don't display bw less than 10 MB/sec. (caused when switching tests).
{
char buf[50];
dc.SetTextColor (RGB (255,0 ,0));
dc.SelectObject (&m_font1);
int bwlen = sprintf (buf, "%6.1lf MB/s", bw); // That's an 'ell' f to convert a double!
if (bwlen <= 13) // Skip update if a very long string (caused when the HLDATA wraps around).
dc.TextOut (20, 20, buf);
sprintf (buf, " Sustained!");
dc.TextOut (40, 20 + m_cyChar1*75/100, buf);
dc.SelectObject (&m_font2);
sprintf (buf, "DMA Size");
dc.TextOut (40, 150, buf);
int DMAsizelen = sprintf (buf, "%5.0d", DMAsize);
dc.TextOut (70, 150 + m_cyChar2*75/100, buf);
}
}
void CMainFrame::OnTimer (UINT nTimerID)
{
#define NUMsecsBTWNchanges 10
if (g_properties.eTestRunning == TRANSITIONING)
return;
_ftime( &m_tstruct ); // Get the time, including milliseconds
if ( (g_properties.eMainMode == AUTOMATIC) &&
(m_bChangeSecondPassed) // Can't attempt to change test num automatically for a few seconds.
)
{
if ((m_tstruct.time % NUMsecsBTWNchanges) == 0)
{
m_bChangeSecondPassed = FALSE; // We just started the 'Change Second'!
g_properties.nTestNum++; // Change to next test...
if (g_properties.nTestNum > IDC_RADIO5)
g_properties.nTestNum = IDC_RADIO3; // ...but loop around if past the last test number.
// Act like the user pushed a radio button to start the test indicated in nTestNum.
OnWM_User(0, g_properties.nTestNum);
return; // And let it get started before we do any display updates.
}
}
if ((m_tstruct.time % NUMsecsBTWNchanges) != 0)
m_bChangeSecondPassed = TRUE; // The 'Change Second' has now passed.
CClientDC dc (this);
dc.SetBkColor (RGB (0xff, 0xff, 0x88)); // Puke yellow.
// CFont* pOldFont = dc.SelectObject (&m_font1);
if (g_properties.eTestRunning == IDLE)
{
dc.SelectObject (&m_font1);
dc.SetTextColor (RGB (255,0 ,0));
char buf[50];
sprintf (buf, " Idle ");
dc.TextOut (20, 20, buf);
sprintf (buf, " ");
dc.TextOut (20, 20 + m_cyChar1*75/100, buf);
// Blit grey blob at last location to 'erase' the red blob.
CPen pengrey (PS_SOLID, m_penSize, RGB (200, 200, 200) ) ;
CPen* poldPen = dc.SelectObject (&pengrey);
CPoint point (m_currentPt.x, m_currentPt.y);
dc.MoveTo (point);
dc.LineTo (point);
dc.SelectObject (poldPen);
}
else
{
switch (g_properties.nTestNum)
{
case IDC_RADIO4:
if (g_properties.e3042Status != BAD)
{
if (m_tstruct.time != m_lasttime) // Did the seconds roll over, hence time to do our one-second update?
{
// Compute and update the bandwidth text.
int innerPasses = g_properties.nCount3042; // Read the total innerPasses reported by the 3041
int deltaPasses = innerPasses - m_lastInnerPasses;
m_floattime = (double)m_tstruct.time + ( ((double)m_tstruct.millitm) / 1000 );
double elapsedfloat = m_floattime - m_lastfloattime;
double bw;
int pktSize = g_properties.nPktSz;
if (elapsedfloat != 0) // Protect against divide by zero.
bw = ((pktSize * (double)deltaPasses) / elapsedfloat) / 1000000;
else
bw = ((pktSize * (double)deltaPasses))/ 1000000; // If elapsed float == 0, assume 1 second passed (a fudge).
display_bandwidth (bw, pktSize, dc);
m_lasttime = m_tstruct.time;
m_lastfloattime = m_floattime;
m_lastInnerPasses = innerPasses;
}
}
break;
case IDC_RADIO5:
if (g_properties.e3042Status != BAD)
{
if (m_tstruct.time != m_lasttime) // Did the seconds roll over, hence time to do our one-second update?
{
// Compute and update the bandwidth text.
int innerPasses = g_properties.nCount3042; // Read the total innerPasses reported by the 3041
int deltaPasses = innerPasses - m_lastInnerPasses;
m_floattime = (double)m_tstruct.time + ( ((double)m_tstruct.millitm) / 1000 );
double elapsedfloat = m_floattime - m_lastfloattime;
double bw;
int pktSize = g_properties.nPktSz;
if (elapsedfloat != 0) // Protect against divide by zero.
bw = ((pktSize * (double)deltaPasses) / elapsedfloat) / 1000000;
else
bw = ((pktSize * (double)deltaPasses))/ 1000000; // If elapsed float == 0, assume 1 second passed (a fudge).
display_bandwidth (bw, pktSize, dc);
m_lasttime = m_tstruct.time;
m_lastfloattime = m_floattime;
m_lastInnerPasses = innerPasses;
}
}
break;
default:
break;
} // end switch
// Blit grey blob at last location to 'erase' the red blob.
CPen pengrey (PS_SOLID, m_penSize, RGB (200, 200, 200) ) ;
CPen* poldPen = dc.SelectObject (&pengrey);
CPoint point (m_currentPt.x, m_currentPt.y);
dc.MoveTo (point);
dc.LineTo (point);
dc.SelectObject (poldPen);
if (m_direction != toSysMem)
m_currentPt = m_path[m_curpath].getNextPoint();
else
m_currentPt = m_path[m_curpath].getPrevPoint();
// blit RED blob at coords
CPen penRed (PS_SOLID, m_penSize, RGB (255, 0, 0) );
poldPen = dc.SelectObject (&penRed);
dc.MoveTo (m_currentPt);
dc.LineTo (m_currentPt);
dc.SelectObject (poldPen);
}
m_timerTicks++;
// dc.SelectObject (pOldFont);
} // end CMainWindow::OnTimer
// Called whenever we are starting the first test, or some entity in the system (the dialog box or the auto controller)
// wants to start (or restart) a test.
LONG CMainFrame::OnWM_User (UINT wParam, LONG lParam)
{
// Shut down the old test (???, if any???)...
g_properties.eTestRunning = TRANSITIONING; // Because of the way OnIdle is coded, this
// is sufficient to stop any running 3042 tests.
// ... and start up the new test.
switch (lParam)
{
case IDC_RADIO3:
g_properties.nTestNum = lParam; // Change the test number.
g_properties.eTestRunning = IDLE;
break;
case IDC_RADIO4:
case IDC_RADIO5:
g_properties.nTestNum = lParam; // Change the test number.
if ((g_properties.e3042Status == OPENEDok) || (g_properties.e3042Status == OK))
{
g_properties.e3042Status = OK;
g_properties.eTestRunning = RUNNING;
g_properties.nCount3042 = 0;
}
else
{
g_properties.e3042Status = BAD;
g_properties.eTestRunning = IDLE;
MessageBox("Since the 3042 wasn't opened OK, can't run any 3042 tests.",
NULL,
MB_ICONEXCLAMATION );
}
break;
case IDC_CHECK1:
case IDC_CHECK2:
if ( (g_properties.e3042Status == OPENEDok) || (g_properties.e3042Status == OK) )
{
g_properties.e3042Status = OK;
g_properties.eTestRunning = RUNNING;
g_properties.nCount3042 = 0;
}
else
{
g_properties.e3042Status = BAD;
g_properties.eTestRunning = IDLE;
MessageBox("Since the PCI-DP wasn't opened OK, can't run any PCI-DP tests.",
NULL,
MB_ICONEXCLAMATION );
}
break;
break;
default:
break;
} // end switch
m_lastInnerPasses = 0;
setPathAndDirection (g_properties.nTestNum);
// Invalidate ();
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -