⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainfrm.cpp

📁 一个amccs5933芯片的驱动程序开发源程序和部分文档
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//

#include "stdafx.h"
#include "testmenu.h"

#include "maskedBitmap.h"
#include "DialogSelectTest.h"

#include "testmenuDoc.h"
#include "testmenuView.h"

#include "MainFrm.h"
// #include "comemDevice.h"
// #include "comemdrv.h"

#include "drive42.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


//  Globals (This is really bad form, but is fast and produces simpler code.)
PROPERTIES	g_properties;		// Global properties that apply to the entire application


/////////////////////////////////////////////////////////////////////////////
// CMainFrame

IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
	//{{AFX_MSG_MAP(CMainFrame)
	ON_WM_CREATE()
	ON_COMMAND(ID_TESTS_SELECTTESTS, OnTestsSelecttests)
    ON_MESSAGE (WM_USER, OnWM_User)
    ON_WM_TIMER ()
//    ON_WM_PAINT ()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

static UINT indicators[] =
{
	ID_SEPARATOR,           // status line indicator
	ID_INDICATOR_CAPS,
	ID_INDICATOR_NUM,
	ID_INDICATOR_SCRL,
};



int CPath::getLastIx (void)
{
	return (m_lastIx);
}

CPoint CPath::getFirstPoint(void)
{
	m_curIx = 0;
	return m_point[m_curIx];
}

CPoint CPath::getLastPoint(void)
{
	m_curIx = getLastIx();
	return m_point[m_curIx];
}

CPoint CPath::getNextPoint(void)
{
	m_curIx++;
	if (m_curIx > getLastIx())
		m_curIx = 0;
	return m_point[m_curIx];
}

CPoint CPath::getPrevPoint(void)
{
	m_curIx--;
	if (m_curIx < 0)
		m_curIx = getLastIx();
	return m_point[m_curIx];
}

void CPath::initPath (int path)
{
	int x;
	int xinc;
	int y;
	int yinc;
	int i;
	
	switch (path)
	{

    case 0:
		x = 323;
		xinc = 22;
		y = 763;
		yinc = 24;
		
		for (i = 0 ; i < 3  ; i++)
		{
			m_point[i].x = x;    m_point[i].y = y;
			y -= 16;
		}
		
		y = 586;
		for (         ; i < 5  ; i++)
		{
			m_point[i].x = x;    m_point[i].y = y;
			y -= 19;
		}
		
		for (         ; i < 12 ; i++)
		{
			m_point[i].x = x;    m_point[i].y = y;
			x -= xinc;
		}
		
		for (         ; i < 15 ; i++)
		{
			m_point[i].x = x;    m_point[i].y = y;
			y -= yinc;
		}
		
		m_lastIx = i - 1;

		// m_point[i].x = farOut;  m_point[i].y = farOut;   // Means 'end of path'
		
		break;

	case 1:
		x = 249;
		xinc = 17;
		y = 594;
		yinc = 16;
		
		for (i = 0 ; i < 2  ; i++)
		{
			m_point[i].x = x;    m_point[i].y = y;
			y -= yinc;
		}
		
		y = 429;
		for (         ; i < 3  ; i++)
		{
			m_point[i].x = x;    m_point[i].y = y;
			y -= yinc;
		}
		
		for (         ; i < 10 ; i++)
		{
			m_point[i].x = x;    m_point[i].y = y;
			x += xinc;
		}
		
		for (         ; i < 12 ; i++)
		{
			m_point[i].x = x;    m_point[i].y = y;
			y -= yinc;
		}
		
		m_lastIx = i - 1;

		// m_point[i].x = farOut;  m_point[i].y = farOut;   // Means 'end of path'
		
		break;

	default:
		break;
	}
	
}
void CMainFrame::setPathAndDirection (int passedTestNum)
{
	switch (passedTestNum)
	{
	case IDC_RADIO2:
		m_direction = fromSysMem;
		m_curpath = 0;
		break;
		
	case IDC_RADIO3:
		m_direction = toSysMem;
		m_curpath = 0;
		break;
		
	case IDC_RADIO4:
		m_direction = fromSysMem;
		m_curpath = 1;
		break;
		
	case IDC_RADIO5:
		m_direction = toSysMem;
		m_curpath = 1;
		break;
		
	default:
		break;
	}

	if (m_direction != toSysMem)
		m_currentPt = m_path[m_curpath].getFirstPoint();
	else
		m_currentPt = m_path[m_curpath].getLastPoint();
	
}

/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction

CMainFrame::CMainFrame()
{
	// TODO: add member initialization code here
	pDialogSelectTest = NULL;						// Inidicate that the Select Test dialog doesn't exist yet.

	g_properties.eMainMode		= MANUAL;
	g_properties.nTestNum       = IDC_RADIO4;
	g_properties.eTestRunning   = TRANSITIONING;
	g_properties.nPktSz         = DMAsizeMAX;
	g_properties.nCount3042     = 0;

    g_properties.nDMAszButton   = IDC_RADIO10;      // "Use Slider #1"

    g_properties.nSlider1       = g_properties.nPktSz;
    g_properties.nSlider2       = g_properties.nPktSz;

    g_properties.nEtoEto3042    = BST_UNCHECKED;
    g_properties.nEtoEfrom3042  = BST_UNCHECKED;
}

CMainFrame::~CMainFrame()
{
	int result;

	if (pDialogSelectTest)				// If the Select Tests dialog is still open (exists)
		delete pDialogSelectTest;
	
	g_properties.eTestRunning = IDLE;	// Shut down and clean up 3042.
	result = close3042(g_properties.n3042ComemID);
	VERIFY( result==NO_ERROR );
	
	//  KillTimer (ID_TIMER_CLOCK);		// !!! Need to turn this back on at some point!!!  Caused problem with a debug assertion failure.
}

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;

	if (!m_wndStatusBar.Create(this) ||
		!m_wndStatusBar.SetIndicators(indicators,
		  sizeof(indicators)/sizeof(UINT)))
	{
		TRACE0("Failed to create status bar\n");
		return -1;      // fail to create
	}

	
    {
        CClientDC dc (this);
        int nHeight = -((dc.GetDeviceCaps (LOGPIXELSY) * 8) / 72);
        nHeight *= 5;											// The font we create needs to be made larger.
        m_font1.CreateFont (nHeight, 0, 0, 0, FW_BOLD, 0, 0, 0,
            DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS,
            DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Courier New");
        
        CFont* pOldFont = dc.SelectObject (&m_font1);
        TEXTMETRIC tm;
        dc.GetTextMetrics (&tm);
        m_cxChar1 = tm.tmAveCharWidth;
        m_cyChar1 = tm.tmHeight;  // + tm.tmExternalLeading;
        dc.SelectObject (pOldFont);
    }
    
    
    {
        CClientDC dc (this);
        int nHeight = -((dc.GetDeviceCaps (LOGPIXELSY) * 8) / 72);
        nHeight *= 3;											// The font we create needs to be made larger.
        m_font2.CreateFont (nHeight, 0, 0, 0, FW_BOLD, 0, 0, 0,
            DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS,
            DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Courier New");
        
        CFont* pOldFont = dc.SelectObject (&m_font2);
        TEXTMETRIC tm;
        dc.GetTextMetrics (&tm);
        m_cxChar2 = tm.tmAveCharWidth;
        m_cyChar2 = tm.tmHeight;  // + tm.tmExternalLeading;
        dc.SelectObject (pOldFont);
    }
    
	
	m_penSize = 13;     // Size of the moving blob
	
	// A few inits to keep BoundsChecker happy...
	m_timerTicks = 0;
	m_lastfloattime = 0;
	m_lastInnerPasses = 0;

	// ... and some that BoundsChecker didn't find.
	m_bChangeSecondPassed = TRUE;				// Allow first Change Second if we switch to AUTOMATIC mode.

	// Set up the paths (so we can follow the dots)...
	m_path[0].initPath(0);
	m_path[1].initPath(1);

	setPathAndDirection (g_properties.nTestNum);
	
	_ftime( &m_tstruct );		// Get the time, including milliseconds
	m_lasttime = m_tstruct.time;

	g_properties.n3041ComemID = 0;
	g_properties.n3042ComemID = 0;

	/////////////////////////////////////////////////////////////////////////////////////
	// Init the device drivers, allocate physical pages, etc. for the 3041 and 3042.
	/////////////////////////////////////////////////////////////////////////////////////

	// 3041
	g_properties.e3041Status = BAD;
	
	// 3042
	if (init3042(g_properties.n3042ComemID) == NO_ERROR)
	{
		g_properties.e3042Status = OPENEDok;
	}
	else
	{
		g_properties.e3042Status = BAD;
		MessageBox("Can't open PCI-DP driver.\nMissing a PCI-DP device,\n.ini file, kernel driver, etc.", //FXN
			NULL, 
			MB_ICONEXCLAMATION );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -