- 视图类,废话少说,看看带注释的源码
- #include "stdafx.h"
- #include "robot.h"
- #include"Label.h"
- #include "robotDoc.h"
- #include "robotView.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CRobotView
- IMPLEMENT_DYNCREATE(CRobotView, CFormView)
- BEGIN_MESSAGE_MAP(CRobotView, CFormView)
- //{ {AFX_MSG_MAP(CRobotView)
- ON_WM_CTLCOLOR()
- ON_WM_TIMER()
- //}}AFX_MSG_MAP
- ON_MESSAGE(WM_COMMNOTIFY, OnCommNotify)
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CRobotView construction/destruction
- CRobotView::CRobotView()
- : CFormView(CRobotView::IDD)
- {
- //{ {AFX_DATA_INIT(CRobotView)
- //}}AFX_DATA_INIT
- // TODO: add construction code here
- m_ncomand1=10;
- m_bflag=0;
- m_nsudu=1;
- m_ngzq=0;
- m_nguanjie;
- m_nfangxiang;
- m_nmsg[0]=0;
- m_njishu=0;
- m_nmsg[1]=0;
- m_nmsg[2]=0;
- m_nmsg[3]=0;
- m_nmsg[4]=0;
- m_nsum=0;
- m_ndelay=0;
- nLength=0;
- m_recflag=1;
- m_failflag=1;
- m_brush.CreateSolidBrush(RGB(40,98,122)); // 生成一绿色刷子
- }
- CRobotView::~CRobotView()
- {
- }
- void CRobotView::DoDataExchange(CDataExchange* pDX)
- {
- CFormView::DoDataExchange(pDX);
- //{ {AFX_DATA_MAP(CRobotView)
- //DDX_Control(pDX, IDC_EDIT1, m_edit1);
- DDX_Control(pDX, IDC_STATIC_LINK, m_link);
- DDX_Control(pDX, IDC_STATIC_1, m_ml);
- DDX_Control(pDX, IDC_STATIC_4, m_workpart);
- DDX_Control(pDX, IDC_STATIC_COMMAND, m_command);
- DDX_Control(pDX, IDC_STATIC_STATUS, m_static);
- DDX_Control(pDX, IDC_STATIC_BUCHANG, m_buchangshu);
- DDX_Control(pDX, IDC_STATIC_5, m_buchang);
- DDX_Control(pDX, IDC_STATIC_3, m_sudu);
- DDX_Control(pDX, IDC_STATIC_2, m_zhuangtai);
- //}}AFX_DATA_MAP
- }
- BOOL CRobotView::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return CFormView::PreCreateWindow(cs);
- }
- /////////////////////////////////////////////////////////////////////////////
- // CRobotView diagnostics
- #ifdef _DEBUG
- void CRobotView::AssertValid() const
- {
- CFormView::AssertValid();
- }
- void CRobotView::Dump(CDumpContext& dc) const
- {
- CFormView::Dump(dc);
- }
- CRobotDoc* CRobotView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CRobotDoc)));
- return (CRobotDoc*)m_pDocument;
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CRobotView message handlers
- void CRobotView::OnDraw(CDC* pDC)
- {
- // TODO: Add your specialized code here and/or call the base class
- SuduDisplay(m_nsudu);
- GzqDisplay(m_ngzq);
- }
- void CRobotView::OnInitialUpdate()
- {
- CFormView::OnInitialUpdate();
- // TODO: Add your specialized code here and/or call the base class
- m_link.SetLink(TRUE)
- .SetTextColor(RGB(0,0,255))
- .SetFontUnderline(TRUE)
- .SetLinkCursor(AfxGetApp()->LoadCursor(IDC_ICON1));
- m_command.SetFontSize(24)
- .SetFontName("Terminal")
- .SetTextColor(RGB(240,240,40));
- m_static.SetFontSize(24)
- .SetTextColor(RGB(240,240,40));
- m_workpart.SetFontSize(24)
- .SetFontBold(TRUE)
- .SetTextColor(RGB(0,240,0));
- m_buchangshu.SetFontSize(24)
- .SetTextColor(RGB(240,240,40));
- m_buchang.SetFontSize(24)
- .SetFontBold(TRUE)
- .SetTextColor(RGB(0,240,0));
- m_sudu.SetFontSize(24)
- .SetFontBold(TRUE)
- .SetTextColor(RGB(0,240,0));
- m_zhuangtai.SetFontSize(24)
- .SetFontBold(TRUE)
- .SetTextColor(RGB(0,240,0));
- m_ml.SetFontSize(24)
- .SetLinkCursor(AfxGetApp()->LoadCursor(IDC_ICON1))
- .SetFontBold(TRUE)
- .SetTextColor(RGB(0,240,0));
- GetParentFrame()->RecalcLayout();
- ResizeParentToFit();
- }
- LRESULT CRobotView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
- {
- // TODO: Add your specialized code here and/or call the base class
- if(message == (WM_USER + 1002))
- ProcessMessage(wParam, lParam);
- else if(message==(WM_USER+1003))
- ProcessMyMessage();
- return CFormView::WindowProc(message, wParam, lParam);
- }
- void CRobotView::ProcessMessage(WPARAM wParam, LPARAM lParam)
- {
- CRobotDoc* pDoc=GetDocument();
- char* l[57] = { "零","一","二",///012
- "三","四","五","六","七","八","九","执行","各关节归零","大臂正转",///12
- "大臂反转","小臂正转","小臂反转","手腕正转","手腕反转","手爪张开","手爪闭合","上升","下降","大臂运行",///13--22
- "大臂负运行","小臂运行","小臂负运行","手腕运行","手腕负运行","手爪运行","手爪负运行","升降运行",////23---30
- "升降负运行","大臂归零","小臂归零","手腕归零","手爪归零","升降归零","速度加","原点记忆",///31---38
- "系统复位","示教盒","","","回原点","速度减","区号加","区号减","单步再现","周期再现",///39---48
- "连续再现","返回","继续","数据记忆",
一套基于模板匹配的语音识别技术 提取语音的特征,并建立模板库 可以将语音识别技术应用于机器人
最新推荐文章于 2024-01-25 01:54:08 发布