码迷,mamicode.com
首页 > 其他好文 > 详细

一套基于模板匹配的语音识别技术 提取语音的特征,并建立模板库 可以将语音识别技术应用于机器人

时间:2018-12-23 18:02:39      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:ons   ifd   run   class   取数据   nec   rgb   记忆   debug   

  1. 视图类,废话少说,看看带注释的源码
  2. #include "stdafx.h"    
  3. #include "robot.h"    
  4. #include"Label.h"    
  5.    
  6. #include "robotDoc.h"    
  7. #include "robotView.h"    
  8.    
  9. #ifdef _DEBUG    
  10. #define new DEBUG_NEW    
  11. #undef THIS_FILE    
  12. static char THIS_FILE[] = __FILE__;   
  13. #endif    
  14.    
  15. /////////////////////////////////////////////////////////////////////////////    
  16. // CRobotView    
  17.    
  18. IMPLEMENT_DYNCREATE(CRobotView, CFormView)   
  19.    
  20. BEGIN_MESSAGE_MAP(CRobotView, CFormView)   
  21.     //{{AFX_MSG_MAP(CRobotView)    
  22.     ON_WM_CTLCOLOR()   
  23.     ON_WM_TIMER()   
  24.     //}}AFX_MSG_MAP    
  25.     ON_MESSAGE(WM_COMMNOTIFY, OnCommNotify)   
  26. END_MESSAGE_MAP()   
  27.    
  28. /////////////////////////////////////////////////////////////////////////////    
  29. // CRobotView construction/destruction    
  30.    
  31. CRobotView::CRobotView()   
  32.     : CFormView(CRobotView::IDD)   
  33. {   
  34.     //{{AFX_DATA_INIT(CRobotView)    
  35.     //}}AFX_DATA_INIT    
  36.     // TODO: add construction code here    
  37.     m_ncomand1=10;   
  38.     m_bflag=0;   
  39.     m_nsudu=1;   
  40.     m_ngzq=0;   
  41.     m_nguanjie;   
  42.     m_nfangxiang;   
  43.     m_nmsg[0]=0;   
  44.     m_njishu=0;   
  45.     m_nmsg[1]=0;   
  46.     m_nmsg[2]=0;   
  47.     m_nmsg[3]=0;   
  48.     m_nmsg[4]=0;   
  49.     m_nsum=0;   
  50.     m_ndelay=0;   
  51.     nLength=0;   
  52.     m_recflag=1;   
  53.     m_failflag=1;   
  54.     m_brush.CreateSolidBrush(RGB(40,98,122)); // 生成一绿色刷子     
  55.    
  56. }   
  57.    
  58. CRobotView::~CRobotView()   
  59. {   
  60. }   
  61.    
  62. void CRobotView::DoDataExchange(CDataExchange* pDX)   
  63. {   
  64.     CFormView::DoDataExchange(pDX);   
  65.     //{{AFX_DATA_MAP(CRobotView)    
  66.     //DDX_Control(pDX, IDC_EDIT1, m_edit1);    
  67.     DDX_Control(pDX, IDC_STATIC_LINK, m_link);   
  68.     DDX_Control(pDX, IDC_STATIC_1, m_ml);   
  69.     DDX_Control(pDX, IDC_STATIC_4, m_workpart);   
  70.     DDX_Control(pDX, IDC_STATIC_COMMAND, m_command);   
  71.     DDX_Control(pDX, IDC_STATIC_STATUS, m_static);   
  72.     DDX_Control(pDX, IDC_STATIC_BUCHANG, m_buchangshu);   
  73.     DDX_Control(pDX, IDC_STATIC_5, m_buchang);   
  74.     DDX_Control(pDX, IDC_STATIC_3, m_sudu);   
  75.     DDX_Control(pDX, IDC_STATIC_2, m_zhuangtai);   
  76.     //}}AFX_DATA_MAP    
  77. }   
  78.    
  79. BOOL CRobotView::PreCreateWindow(CREATESTRUCT& cs)   
  80. {   
  81.     // TODO: Modify the Window class or styles here by modifying    
  82.     //  the CREATESTRUCT cs    
  83.    
  84.     return CFormView::PreCreateWindow(cs);   
  85. }   
  86.    
  87.    
  88.    
  89. /////////////////////////////////////////////////////////////////////////////    
  90. // CRobotView diagnostics    
  91.    
  92. #ifdef _DEBUG    
  93. void CRobotView::AssertValid() const   
  94. {   
  95.     CFormView::AssertValid();   
  96. }   
  97.    
  98. void CRobotView::Dump(CDumpContext& dc) const   
  99. {   
  100.     CFormView::Dump(dc);   
  101. }   
  102.    
  103. CRobotDoc* CRobotView::GetDocument() // non-debug version is inline    
  104. {   
  105.     ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CRobotDoc)));   
  106.     return (CRobotDoc*)m_pDocument;   
  107. }   
  108. #endif //_DEBUG    
  109.    
  110. /////////////////////////////////////////////////////////////////////////////    
  111. // CRobotView message handlers    
  112.    
  113. void CRobotView::OnDraw(CDC* pDC)    
  114. {   
  115.     // TODO: Add your specialized code here and/or call the base class    
  116.     SuduDisplay(m_nsudu);   
  117.     GzqDisplay(m_ngzq);   
  118. }   
  119.    
  120. void CRobotView::OnInitialUpdate()    
  121. {   
  122.     CFormView::OnInitialUpdate();   
  123.        
  124.     // TODO: Add your specialized code here and/or call the base class    
  125.     m_link.SetLink(TRUE)   
  126.         .SetTextColor(RGB(0,0,255))   
  127.         .SetFontUnderline(TRUE)   
  128.         .SetLinkCursor(AfxGetApp()->LoadCursor(IDC_ICON1));   
  129.     m_command.SetFontSize(24)   
  130.         .SetFontName("Terminal")   
  131.               .SetTextColor(RGB(240,240,40));   
  132.     m_static.SetFontSize(24)   
  133.               .SetTextColor(RGB(240,240,40));   
  134.     m_workpart.SetFontSize(24)   
  135.         .SetFontBold(TRUE)   
  136.               .SetTextColor(RGB(0,240,0));   
  137.     m_buchangshu.SetFontSize(24)   
  138.               .SetTextColor(RGB(240,240,40));   
  139.     m_buchang.SetFontSize(24)   
  140.             .SetFontBold(TRUE)   
  141.               .SetTextColor(RGB(0,240,0));   
  142.     m_sudu.SetFontSize(24)   
  143.             .SetFontBold(TRUE)   
  144.               .SetTextColor(RGB(0,240,0));   
  145.     m_zhuangtai.SetFontSize(24)   
  146.             .SetFontBold(TRUE)   
  147.               .SetTextColor(RGB(0,240,0));   
  148.     m_ml.SetFontSize(24)   
  149.             .SetLinkCursor(AfxGetApp()->LoadCursor(IDC_ICON1))   
  150.             .SetFontBold(TRUE)   
  151.              .SetTextColor(RGB(0,240,0));   
  152.     GetParentFrame()->RecalcLayout();   
  153.     ResizeParentToFit();   
  154. }   
  155.    
  156. LRESULT CRobotView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)    
  157. {   
  158.     // TODO: Add your specialized code here and/or call the base class    
  159.     if(message == (WM_USER + 1002))   
  160.         ProcessMessage(wParam, lParam);   
  161.     else if(message==(WM_USER+1003))   
  162.         ProcessMyMessage();   
  163.     return CFormView::WindowProc(message, wParam, lParam);   
  164. }   
  165. void CRobotView::ProcessMessage(WPARAM wParam, LPARAM lParam)   
  166. {   
  167.        
  168.     CRobotDoc* pDoc=GetDocument();   
  169.     char* l[57] = {"零","一","二",///012    
  170.         "三","四","五","六","七","八","九","执行","各关节归零","大臂正转",///12    
  171.         "大臂反转","小臂正转","小臂反转","手腕正转","手腕反转","手爪张开","手爪闭合","上升","下降","大臂运行",///13--22    
  172.         "大臂负运行","小臂运行","小臂负运行","手腕运行","手腕负运行","手爪运行","手爪负运行","升降运行",////23---30    
  173.         "升降负运行","大臂归零","小臂归零","手腕归零","手爪归零","升降归零","速度加","原点记忆",///31---38    
  174.         "系统复位","示教盒","","","回原点","速度减","区号加","区号减","单步再现","周期再现",///39---48    
  175.         "连续再现","返回","继续","数据记忆","读取数据","设置串口","打开串口","关闭串口"};      
  176.     CString    strcomand;   
  177.     CString    strstatus;   
  178.     m_recflag=1;   
  179.     if(!pDoc->m_bConnected)   
  180.     {   
  181.         KillTimer(1);   
  182.         MessageBox("请先打开串口");   
  183.         return;   
  184.     }   
  185.     if(wParam==100)   
  186.     {   
  187.         KillTimer(1);   
  188.         if(!m_failflag)   
  189.             {   
  190.                     CWnd* pWnd=GetDlgItem(IDC_STATIC_5);   
  191.                     pWnd->SetWindowText("");   
  192.                     pWnd=GetDlgItem(IDC_STATIC_BUCHANG);   
  193.                     pWnd->SetWindowText("");   
  194.                     pWnd=GetDlgItem(IDC_STATIC_COMMAND);   
  195.                     pWnd->SetWindowText("请输入新的命令");   
  196.                     pWnd=GetDlgItem(IDC_STATIC_STATUS);   
  197.                     pWnd->SetWindowText("执行完毕");   
  198.                     m_ncomand1=0;   
  199.                        
  200.                 }   
  201.                 else   
  202.                     MessageBox("请检查连线是否正确或下位机是否打开","通信失败",MB_ICONWARNING);   
  203.                 }   
  204.     else if(wParam>=11&&wParam<=56)   
  205.     {   
  206.         m_bflag=0;   
  207.         m_ncomand1=wParam;   
  208.         strcomand=l[m_ncomand1];   
  209.         CWnd* pWnd=GetDlgItem(IDC_STATIC_COMMAND);   
  210.         pWnd->SetWindowText(strcomand);   
  211.         pWnd=GetDlgItem(IDC_STATIC_STATUS);   
  212.         pWnd->SetWindowText("");   
  213.         pWnd=GetDlgItem(IDC_STATIC_5);   
  214.         pWnd->SetWindowText("");   
  215.         pWnd=GetDlgItem(IDC_STATIC_BUCHANG);   
  216.         pWnd->SetWindowText("");   
  217.         m_nsum=0;   
  218.         m_njishu=0;   
  219.     }   
  220.     else if(wParam>=0&&wParam<=9)   
  221.     {      
  222.         if(m_ncomand1>=12&&m_ncomand1<=21)           
  223.         {   
  224.             m_bflag=1;   
  225.             m_nmsg[m_njishu]=wParam;   
  226.            //pWnd=GetDlgItem(IDC_STATIC_COMMAND);    
  227.             //pWnd->SetWindowText(strcomand);    
  228.             CWnd* pWnd=GetDlgItem(IDC_STATIC_5);   
  229.             pWnd->SetWindowText("步长:");   
  230.             ++m_njishu;   
  231.             if(m_njishu==1)   
  232.             {   
  233.                 CString m_stemp;   
  234.                 m_nsum=m_nmsg[0];   
  235.                 m_stemp.Format("%d",m_nsum);   
  236.                 pWnd=GetDlgItem(IDC_STATIC_BUCHANG);   
  237.                 pWnd->SetWindowText(m_stemp);   
  238.             }   
  239.             if(m_njishu==2)   
  240.             {   
  241.                 CString m_stemp;   
  242.                 m_nsum=m_nmsg[0]*10+m_nmsg[1];   
  243.                 m_stemp.Format("%d",m_nsum);   
  244.                 pWnd=GetDlgItem(IDC_STATIC_BUCHANG);   
  245.                 pWnd->SetWindowText(m_stemp);   
  246.             }   
  247.             if(m_njishu==3)   
  248.             {   
  249.                 CString m_stemp;   
  250.                 m_nsum=m_nmsg[0]*100+m_nmsg[1]*10+m_nmsg[2];   
  251.                 //m_nmsg[0]=0;    
  252.                 //m_nmsg[1]=0    
  253.                 //  m_nmsg[2]=0;    
  254.                 //  m_njishu=0;    
  255.                 m_stemp.Format("%d",m_nsum);   
  256.                 pWnd=GetDlgItem(IDC_STATIC_BUCHANG);   
  257.                 pWnd->SetWindowText(m_stemp);   
  258.             }   
  259.             if(m_njishu==4)   
  260.             {   
  261.                 CString m_stemp;   
  262.                 m_nsum=m_nmsg[0]*1000+m_nmsg[1]*100+m_nmsg[2]*10+m_nmsg[3];   
  263.                 m_stemp.Format("%d",m_nsum);   
  264.                 pWnd=GetDlgItem(IDC_STATIC_BUCHANG);   
  265.                 pWnd->SetWindowText(m_stemp);   
  266.             }   
  267.             if(m_njishu>4)   
  268.             {   
  269.                 m_njishu=1;   
  270.                 m_nmsg[0]=m_nmsg[4];   
  271.                 CString m_stemp;   
  272.                 m_nsum=m_nmsg[0];   
  273.                 m_stemp.Format("%d",m_nsum);   
  274.                 pWnd=GetDlgItem(IDC_STATIC_BUCHANG);   
  275.                 pWnd->SetWindowText(m_stemp);   
  276.                 m_nmsg[1]=0;   
  277.                 m_nmsg[2]=0;   
  278.                 m_nmsg[3]=0;   
  279.             }   
  280.         }          
  281.         else   
  282.             ;   //MessageBox("清先输入运动步数命令");    
  283.     }   
  284.     else if(wParam=10)   
  285.     {    SetTimer(1,500,NULL);   
  286.         if(m_ncomand1>=11&&m_ncomand1<=56)   
  287.         {   
  288.             if(!m_bflag)   
  289.             {   
  290.                 strstatus="正在执行命令,请稍后.....";   
  291.                 CWnd* pWnd=GetDlgItem(IDC_STATIC_STATUS);   
  292.                 pWnd->SetWindowText(strstatus);   
  293.                 Execute(m_ncomand1);   
  294.                
  295.             }      
  296.             else //if(m_ncomand1>=12&&m_ncomand1<=21)    
  297.             {   
  298.                 unsigned char m_uhi,m_ulo;   
  299.                 m_nmsg[0]=0;   
  300.                 m_nmsg[1]=0;   
  301.                 m_nmsg[2]=0;   
  302.                 m_nmsg[3]=0;   
  303.                 m_njishu=0;   
  304.             /// CWnd* pWnd=GetDlgItem(IDC_STATIC_STATUS);    
  305.                /// pWnd->SetWindowText("正在执行命令,请稍后.....");    
  306.                 switch(m_ncomand1)   
  307.                 {   
  308.                 case(12):   
  309.                     m_nguanjie=01;   
  310.                     m_nfangxiang=00;   
  311.                     m_uhi=(unsigned char)(m_nsum/256);   
  312.                     m_ulo=(unsigned char)(m_nsum-m_uhi*256);   
  313.                     m_ndelay=(m_nsum+500)/m_nsudu;   
  314.                     Execute_1(m_nguanjie,m_nfangxiang,m_uhi,m_ulo,m_ndelay);   
  315.                     break;   
  316.                     case(13):   
  317.                     m_nguanjie=0x01;   
  318.                     m_nfangxiang=0xff;   
  319.                     m_uhi=(unsigned char)(m_nsum/256);   
  320.                     m_ulo=(unsigned char)(m_nsum-m_uhi*256);   
  321.                     m_ndelay=(m_nsum+500)/m_nsudu;   
  322.                     Execute_1(m_nguanjie,m_nfangxiang,m_uhi,m_ulo,m_ndelay);   
  323.                     break;   
  324.                     case(14):   
  325.                     m_nguanjie=0x02;   
  326.                     m_nfangxiang=0x00;   
  327.                     m_uhi=(unsigned char)(m_nsum/256);   
  328.                     m_ulo=(unsigned char)(m_nsum-m_uhi*256);   
  329.                     m_ndelay=(m_nsum)/(m_nsudu*3);   
  330.                     Execute_1(m_nguanjie,m_nfangxiang,m_uhi,m_ulo,m_ndelay);   
  331.                     break;   
  332.                     case(15):   
  333.                     m_nguanjie=0x02;   
  334.                     m_nfangxiang=0xff;   
  335.                     m_uhi=(unsigned char)(m_nsum/256);   
  336.                     m_ulo=(unsigned char)(m_nsum-m_uhi*256);   
  337.                     m_ndelay=(m_nsum)/(m_nsudu*3);   
  338.                     Execute_1(m_nguanjie,m_nfangxiang,m_uhi,m_ulo,m_ndelay);   
  339.                     break;   
  340.                     case(16):   
  341.                     m_nguanjie=0x04;   
  342.                     m_nfangxiang=0x00;   
  343.                     m_uhi=(unsigned char)(m_nsum/256);   
  344.                     m_ulo=(unsigned char)(m_nsum-m_uhi*256);   
  345.                     m_ndelay=(m_nsum+500)/m_nsudu;   
  346.                     Execute_1(m_nguanjie,m_nfangxiang,m_uhi,m_ulo,m_ndelay);   
  347.                     break;   
  348.                     case(17):   
  349.                     m_nguanjie=0x04;   
  350.                     m_nfangxiang=0xff;   
  351.                     m_uhi=(unsigned char)(m_nsum/256);   
  352.                     m_ulo=(unsigned char)(m_nsum-m_uhi*256);   
  353.                     m_ndelay=(m_nsum+500)/m_nsudu;   
  354.                     Execute_1(m_nguanjie,m_nfangxiang,m_uhi,m_ulo,m_ndelay);   
  355.                     break;   
  356.                     case(18):   
  357.                     m_nguanjie=0x05;   
  358.                     m_nfangxiang=0x00;   
  359.                     m_uhi=(unsigned char)(m_nsum/256);   
  360.                     m_ulo=(unsigned char)(m_nsum-m_uhi*256);   
  361.                     m_ndelay=(m_nsum+500)/m_nsudu;   
  362.                     Execute_1(m_nguanjie,m_nfangxiang,m_uhi,m_ulo,m_ndelay);   
  363.                     break;   
  364.                     case(19):   
  365.                     m_nguanjie=0x05;   
  366.                     m_nfangxiang=0xff;   
  367.                     m_uhi=(unsigned char)(m_nsum/256);   
  368.                     m_ulo=(unsigned char)(m_nsum-m_uhi*256);   
  369.                     m_ndelay=(m_nsum+500)/m_nsudu;   
  370.                     Execute_1(m_nguanjie,m_nfangxiang,m_uhi,m_ulo,m_ndelay);   
  371.                     break;   
  372.                     case(20):   
  373.                     m_nguanjie=0x03;   
  374.                     m_nfangxiang=0x00;   
  375.                     m_uhi=(unsigned char)(m_nsum/256);   
  376.                     m_ulo=(unsigned char)(m_nsum-m_uhi*256);   
  377.                     m_ndelay=(m_nsum+500)/(m_nsudu*2);   
  378.                     Execute_1(m_nguanjie,m_nfangxiang,m_uhi,m_ulo,m_ndelay);   
  379.                     break;   
  380.                     case(21):   
  381.                     m_nguanjie=0x03;   
  382.                     m_nfangxiang=0xff;   
  383.                     m_uhi=(unsigned char)(m_nsum/256);   
  384.                     m_ulo=(unsigned char)(m_nsum-m_uhi*256);   
  385.                     m_ndelay=(m_nsum+500)/(m_nsudu*2);   
  386.                     Execute_1(m_nguanjie,m_nfangxiang,m_uhi,m_ulo,m_ndelay);   
  387.                     break;   
  388.                 }   
  389.                    
  390.            }   
  391.             m_failflag=1;}   
  392.        else   
  393.            MessageBox("清先输入命令");   
  394.      }   
  395.      else   
  396.          MessageBox("不能识别,请重新输入命令");   
  397. }   
  398. void CRobotView::ProcessMyMessage()   
  399. {   
  400.     CDC *PDc=GetDC();   
  401.     m_failflag=0;   
  402.         switch(m_ncomand1)   
  403.         {   
  404.         case(37):   
  405.             {   
  406.                 m_nsudu++;   
  407.                 if(m_nsudu==6)   
  408.                     m_nsudu=1;   
  409.                 OnDraw(PDc);   
  410.             }   
  411.             break;   
  412.         case(44):   
  413.             {   
  414.                 m_nsudu--;   
  415.                 if(m_nsudu==0)   
  416.                     m_nsudu=5;   
  417.                 OnDraw(PDc);   
  418.             }   
  419.             break;   
  420.         case(45):   
  421.             {   
  422.                 m_ngzq++;   
  423.                 if(m_ngzq==8)   
  424.                     m_ngzq=0;   
  425.                 OnDraw(PDc);   
  426.             }   
  427.             break;   
  428.         case(46):   
  429.             {   
  430.                 m_ngzq--;   
  431.                 if(m_ngzq==-1)   
  432.                     m_ngzq=7;   
  433.                 OnDraw(PDc);   
  434.             }   
  435.             break;   
  436.         }   
  437.         CWnd* pWnd=GetDlgItem(IDC_STATIC_COMMAND);   
  438.         pWnd->SetWindowText("请输入新的命令");   
  439.         pWnd=GetDlgItem(IDC_STATIC_STATUS);   
  440.         pWnd->SetWindowText("执行完毕");   
  441.         m_ncomand1=0;   
  442.     //}    
  443.     //else    
  444.     //  MessageBox("请检查连线是否正确或下位机是否打开","通信失败",MB_ICONWARNING);    
  445. }   
  446. void CRobotView::SuduDisplay(int n)   
  447. {   
  448.     CWnd* pWnd=GetDlgItem(IDC_STATIC_SUDU);   
  449.     CDC* pControlDC=pWnd->GetDC();   
  450.     pWnd->Invalidate();   
  451.     pWnd->UpdateWindow();   
  452.     pControlDC->SelectStockObject(BLACK_BRUSH);   
  453.     CBitmap mBit;   
  454.     CDC MemDC;   
  455.     MemDC.CreateCompatibleDC(NULL);   
  456.     switch(n)   
  457.     {   
  458.     case 0:   
  459.     mBit.LoadBitmap(IDB_BMP10);   
  460.     break;   
  461.     case 1:   
  462.     mBit.LoadBitmap(IDB_BMP11);   
  463.     break;   
  464.     case 2:   
  465.     mBit.LoadBitmap(IDB_BMP12);   
  466.     break;   
  467.     case 3:   
  468.     mBit.LoadBitmap(IDB_BMP13);   
  469.     break;   
  470.     case 4:   
  471.     mBit.LoadBitmap(IDB_BMP14);   
  472.     break;   
  473.     case 5:   
  474.     mBit.LoadBitmap(IDB_BMP15);   
  475.     break;   
  476.     default:   
  477.         //mBit.LoadBitmap(IDB_BMP0);    
  478.         MessageBox("error");   
  479.     }   
  480.     CBitmap *pOldBit=MemDC.SelectObject(&mBit);   
  481.     pControlDC->BitBlt(0,0,900,700,&MemDC,0,0,SRCCOPY);   
  482.     MemDC.SelectObject(pOldBit);   
  483. }   
  484. void CRobotView::GzqDisplay(int n)   
  485. {   
  486.     CWnd* pWnd=GetDlgItem(IDC_STATIC_GONGZUOQU);   
  487.     CDC* pControlDC=pWnd->GetDC();   
  488.     pWnd->Invalidate();   
  489.     pWnd->UpdateWindow();   
  490.     pControlDC->SelectStockObject(BLACK_BRUSH);   
  491.     CBitmap mBit;   
  492.     CDC MemDC;   
  493.     MemDC.CreateCompatibleDC(NULL);   
  494.     switch(n)   
  495.     {   
  496.     case 0:   
  497.     mBit.LoadBitmap(IDB_BMP10);   
  498.     break;   
  499.     case 1:   
  500.     mBit.LoadBitmap(IDB_BMP11);   
  501.     break;   
  502.     case 2:   
  503.     mBit.LoadBitmap(IDB_BMP12);   
  504.     break;   
  505.     case 3:   
  506.     mBit.LoadBitmap(IDB_BMP13);   
  507.     break;   
  508.     case 4:   
  509.     mBit.LoadBitmap(IDB_BMP14);   
  510.     break;   
  511.     case 5:   
  512.     mBit.LoadBitmap(IDB_BMP15);   
  513.     break;   
  514.     case 6:   
  515.     mBit.LoadBitmap(IDB_BMP16);   
  516.     break;   
  517.     case 7:   
  518.     mBit.LoadBitmap(IDB_BMP17);   
  519.     break;   
  520.     default:   
  521.         //mBit.LoadBitmap(IDB_BMP0);    
  522.         MessageBox("error");   
  523.     }   
  524.     CBitmap *pOldBit=MemDC.SelectObject(&mBit);   
  525.     pControlDC->BitBlt(0,0,900,700,&MemDC,0,0,SRCCOPY);   
  526.     MemDC.SelectObject(pOldBit);   
  527. }   
  528. void CRobotView::Execute(int n)   
  529. {   
  530.     CRobotDoc* pDoc=GetDocument();   
  531.    
  532.     unsigned char send1;   
  533.    
  534.     switch(n)   
  535.     {   
  536.     case(11):   
  537.         home();   
  538.         break;   
  539.     case(12):   
  540.         {//大臂正传    
  541.         unsigned char send[6]={0x53,0x01,0x00,0x00,0x07,0x18};   
  542.     for(int i=0;i<=5;i++)   
  543.     pDoc->WriteComm(&send[i],1);   
  544.     Sleep(2000/m_nsudu);   
  545.     break;   
  546.             }   
  547.     case(13):   
  548.         {   
  549.     unsigned char send[6]={0x53,0x01,0xff,0x00,0x07,0x18};   
  550.     for(int i=0;i<=5;i++)   
  551.     pDoc->WriteComm(&send[i],1);   
  552. //  pDoc->ReadComm(&buf,1);    
  553. //  if(nLength)    
  554. ////    {    
  555. //      str.Format("%d",buf);    
  556. //      m_edit1.SetSel(-1, 0);    
  557. //      m_edit1.ReplaceSel(str); // 向编辑视图中插入收到的字符    
  558. //  }    
  559. //  else    
  560. //  MessageBox("fjdklfjsdklgjsdfkl");    
  561.     Sleep(2000/m_nsudu);   
  562.     break;   
  563.         }   
  564.     case(14)://xiaobizhengzhuan    
  565.         {   
  566.         unsigned char send[6]={0x53,0x02,0x00,0x00,0x0f,0xe3};   
  567.     for(int i=0;i<=5;i++)   
  568.     pDoc->WriteComm(&send[i],1);   
  569.     Sleep(2000/m_nsudu);   
  570.             break;   
  571.         }   
  572.        
  573.     case(15)://小臂反转    
  574.         {   
  575.         unsigned char send[6]={0x53,0x02,0xff,0x00,0x0f,0xe3};   
  576.     for(int i=0;i<=5;i++)   
  577.     pDoc->WriteComm(&send[i],1);   
  578.     Sleep(2000/m_nsudu);   
  579.     break;     
  580.         }      
  581.     case(16)://手腕正转    
  582.             {   
  583.         unsigned char send[6]={0x53,0x04,0x00,0x00,0x00,0xff};   
  584.     for(int i=0;i<=5;i++)   
  585.     pDoc->WriteComm(&send[i],1);   
  586.     Sleep(1000/m_nsudu);   
  587.     break;   
  588.             }   
  589.     case(17)://shouwanfanzhuan    
  590.         {   
  591.         unsigned char send[6]={0x53,0x04,0xff,0x00,0x00,0xff};   
  592.     for(int i=0;i<=5;i++)   
  593.     pDoc->WriteComm(&send[i],1);   
  594.     Sleep(1000/m_nsudu);   
  595.         }   
  596.         break;   
  597.     case(18)://shouzhuazhangkai    
  598.             {   
  599.         unsigned char send[6]={0x53,0x05,0x00,0x00,0x00,0x43};   
  600.     for(int i=0;i<=5;i++)   
  601.     pDoc->WriteComm(&send[i],1);   
  602.     Sleep(2000/m_nsudu);   
  603.         }   
  604.         break;   
  605.     case(19):   
  606.         {   
  607.         unsigned char send[6]={0x53,0x05,0xff,0x00,0x00,0xf3};   
  608.     for(int i=0;i<=5;i++)   
  609.     pDoc->WriteComm(&send[i],1);   
  610.     Sleep(2000/m_nsudu);   
  611.         }   
  612.         break;   
  613.     case(20)://shangsheng    
  614.             {   
  615.         unsigned char send[6]={0x53,0x03,0x00,0x00,0x02,0xe3};   
  616.     for(int i=0;i<=5;i++)   
  617.     pDoc->WriteComm(&send[i],1);   
  618.     Sleep(1000/m_nsudu);   
  619.         }   
  620.         break;   
  621.     case(21):   
  622.         {   
  623.         unsigned char send[6]={0x53,0x03,0xff,0x00,0x02,0xe3};   
  624.     for(int i=0;i<=5;i++)   
  625.     pDoc->WriteComm(&send[i],1);   
  626.     Sleep(1000/m_nsudu);   
  627.         }   
  628.         break;   
  629. /*  case(22)://dabiyunxing  
  630.         {  
  631.         unsigned char send[3]={0x63,0x01,0x00};  
  632.     for(int i=0;i<=2;i++)  
  633.     pDoc->WriteComm(&send[i],1);  
  634.     Sleep(2000);  
  635.         }  
  636.         break;  
  637.     case(23):  
  638.             {  
  639.         unsigned char send[3]={0x63,0x01,0xff};  
  640.     for(int i=0;i<=2;i++)  
  641.     pDoc->WriteComm(&send[i],1);  
  642.     Sleep(2000);  
  643.         }  
  644.         break;  
  645.     case(24)://xiaobiyunxing  
  646.         {  
  647.         unsigned char send[3]={0x63,0x02,0x00};  
  648.     for(int i=0;i<=2;i++)  
  649.     pDoc->WriteComm(&send[i],1);  
  650.     Sleep(2000);  
  651.         }  
  652.         break;  
  653.     case(25):  
  654.         {  
  655.         unsigned char send[3]={0x63,0x02,0xff};  
  656.     for(int i=0;i<=2;i++)  
  657.     pDoc->WriteComm(&send[i],1);  
  658.     Sleep(2000);  
  659.         }  
  660.         break;  
  661.     case(26)://shouwanyunxing  
  662.         {  
  663.         unsigned char send[3]={0x63,0x04,0x00};  
  664.     for(int i=0;i<=2;i++)  
  665.     pDoc->WriteComm(&send[i],1);  
  666.     Sleep(2000);  
  667.         }  
  668.         break;  
  669.     case(27):  
  670.         {  
  671.         unsigned char send[3]={0x63,0x04,0xff};  
  672.     for(int i=0;i<=2;i++)  
  673.     pDoc->WriteComm(&send[i],1);  
  674.     Sleep(2000);  
  675.         }  
  676.         break;  
  677.     case(28)://shouzhuayunxing  
  678.         {  
  679.         unsigned char send[3]={0x63,0x05,0x00};  
  680.     for(int i=0;i<=2;i++)  
  681.     pDoc->WriteComm(&send[i],1);  
  682.     Sleep(2000);  
  683.         }  
  684.         break;  
  685.     case(29):  
  686.             {  
  687.         unsigned char send[3]={0x63,0x05,0xff};  
  688.     for(int i=0;i<=2;i++)  
  689.     pDoc->WriteComm(&send[i],1);  
  690.     Sleep(2000);  
  691.         }  
  692.         break;  
  693.     case(30)://shengjiangyunxing  
  694.             {  
  695.         unsigned char send[3]={0x63,0x03,0x00};  
  696.     for(int i=0;i<=2;i++)  
  697.     pDoc->WriteComm(&send[i],1);  
  698.     Sleep(2000);  
  699.         }  
  700.         break;  
  701.     case(31):  
  702.             {  
  703.         unsigned char send[3]={0x63,0x05,0xff};  
  704.     for(int i=0;i<=2;i++)  
  705.     pDoc->WriteComm(&send[i],1);  
  706.     Sleep(2000);  
  707.         }  
  708.         break;  
  709. */   
  710.     case(32)://dabiguiling    
  711.             {   
  712.         unsigned char send[2]={0xa3,0x01};   
  713.     for(int i=0;i<=1;i++)   
  714.     pDoc->WriteComm(&send[i],1);   
  715.     Sleep(18000);   
  716.         }   
  717.         break再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://www.cnblogs.com/captainbed

一套基于模板匹配的语音识别技术 提取语音的特征,并建立模板库 可以将语音识别技术应用于机器人

标签:ons   ifd   run   class   取数据   nec   rgb   记忆   debug   

原文地址:https://www.cnblogs.com/wicnwicnwh/p/10164766.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!