📄 screenview.cpp
字号:
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
nDecNum = str[i] - '0';
break;
default:
return 0;
}
tmp += nDecNum*pow(16,len-i -1);
}
return tmp;
}
UINT CScreenView::sendProc(LPVOID pParam)
{
CWnd* pMainWnd=AfxGetApp()->m_pMainWnd;
CMainFrame* pMainFrame=(CMainFrame*)pMainWnd;
CScreenView* pVw=(CScreenView*)pParam;
int begin,end;
if(pVw->downloadmode==0)
{
begin=0;
end=pVw->m_PageListBox.GetCount();
}
else
{
begin=pVw->downloadmode-1;
end=begin+1;
}
BYTE buf[1];
buf[0]=0xbb;
// pVw->pComm->SendBlock(buf,1);
/* pVw->bAck=FALSE;
unsigned char programheader[18]={0x1B,0x24,0x4C,0x59,0x54,0x45,0x43,0x00,0x31,0x00,0x05,0x41,0x0F,0x0A,0x0F,0x0A,0x5A,0x63 }; //发送当前图片
unsigned char programTab1[18]={0x1B,0x24,0x4C,0x59,0x54,0x45,0x43,0x00,0x31,0x00,0x05,0x51,0x2F,0x01,0x00,0x02,0x8,0xb0};
BYTE num=5;
WORD CRCValue=0;
programTab1[15]=end;
pVw->funCRC(&CRCValue,(num)>>8);
pVw->funCRC(&CRCValue,(num)&0xff);
for(int i=11;i<11+num;++i)
{
pVw->funCRC(&CRCValue,programTab1[i]);
}
programTab1[16]=CRCValue>>8;
programTab1[17]=CRCValue&0x0ff;
//发送头
pVw->readindex=0;
pVw->pComm->SendBlock(programheader,18);
CString s11;
CString s22;
while(pVw->readindex<18)
{
;
}
for(int iu=0;iu<18;iu++)
{
s22.Format("%02x ",pVw->datread[iu]);
s11+=s22;
}
TRACE(s11);
//if(pVw->datread[7]=='O' && pVw->datread[8]=='K' )
{
//发送节目表1
pVw->readindex=0;
pVw->pComm->SendBlock(programTab1,18);
while(pVw->readindex<9)
{
;
}
s11="";
for(int iu=0;iu<9;iu++)
{
s22.Format("%02x ",pVw->datread[iu]);
s11+=s22;
}
TRACE(s11);
if(pVw->datread[7]!='O' && pVw->datread[8]!='K' )
return 0;
}
*/
//AfxMessageBox("ok le");
for(int xx=begin;xx<end;xx++)
{
::SendMessage(pMainFrame->m_hWnd,MYWM_PROGRESS,0,0);
DWORD starttime,endtime;
// if(pVw->bAck==FALSE)
{
pVw->DownLoad2(xx);
starttime=GetTickCount();
}
/* if(pVw->bAck==TRUE)
{
endtime=GetTickCount();
if(pVw->datread[0]==0xaa)
{
pVw->bAck=FALSE;
xx++;
}
if((endtime-starttime)>5000)
{
break;
}
}*/
::SendMessage(pMainFrame->m_hWnd,MYWM_PROGRESS,10,10);
}
/*
unsigned char programtab3[18]={0x1B,0x24,0x4C,0x59,0x54,0x45,0x43,0x00,0x31,0x00,0x05,0x51,0x21,0x01,0x01,0x02,0x99,0xdb };
unsigned char programTab2[3*91]={
0x1B,0x24,0x4C,0x59,0x54,0x45,0x43,0x00,0x31,0x01,0x04,0x52,0x0F,0xF3,0x01,0x00,0x00,0x05,0x00,0xFE,0x00,0x00,0x23,0x59,0x00,0x00,0x00,0x01,0x00,0x05,0x00,0xFE,0x00,0x00,0x23,0x59,0x00,0x00,0x00,0xB0,0x16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x48,0x00,0x4D,0x01,0x64,0xD6,0x92,0x7C,0xEA,0xA6,0x80,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x64,0xDD,0x12,0x00,0x0E,0xA7,0x80,0x7C,0x00,0x00,0x00,0x00,0x94,0xFA,0x12,0x00,0x00,0x00,0x00,0x00,0x88,0xE2,0x92,0x7C,0x75,0x18,0x80,0x7C,0x1C,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0xDD,0x12,0x00,0x84,0xE8,0x12,0x00,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x98,0x18,0x80,0x7C,0x94,0xFA,0x12,0x00,0x94,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x94,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x48,0x00,0x4D,0x01,0x02,0x00,0x00,0x00,0x48,0x00,0x4D,0x01,0x56,0x26,0x36,0x01,0x86,0xE8,0x12,0x00,0x30,0xDE,0x12,0x00,0x06,0x00,0x00,0x00,0x48,0x00,0x4D,0x01,0xFC,0xF8,0x12,0x00,0x89,0x35,0x36,0x01,0x43,0xE8,0x12,0x00,0x09,0x00,0x00,0x00,0x94,0x42,0x00,0x00,0xC4,0x35,0x36,0x01,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x48,0x00,0x4D,0x01,0x01,0x40,0x6C,0x74,0x59,0xEC,0x46,0x00,0xBC,0xDE,0x12,0x00,0x07,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x94,0x37,0x37,0x04,0xCB,0x8E
} ;
//发送头
pVw->readindex=0;
pVw->pComm->SendBlock(programTab2,3*91);
while(pVw->readindex<9)
{
;
}
s11="";
for( iu=0;iu<9;iu++)
{
s22.Format("%02x ",pVw->datread[iu]);
s11+=s22;
}
TRACE(s11);
if(pVw->datread[7]=='O' && pVw->datread[8]=='K' )
{
num=5;
CRCValue=0;
programtab3[15]=end;
pVw->funCRC(&CRCValue,(num)>>8);
pVw->funCRC(&CRCValue,(num)&0xff);
for(i=11;i<11+num;++i)
{
pVw->funCRC(&CRCValue,programtab3[i]);
}
programtab3[16]=CRCValue>>8;
programtab3[17]=CRCValue&0x0ff;
pVw->readindex=0;
pVw->pComm->SendBlock(programtab3,18);
while(pVw->readindex<9)
{
;
}
s11="";
for( iu=0;iu<9;iu++)
{
s22.Format("%02x ",pVw->datread[iu]);
s11+=s22;
}
TRACE(s11);
}
::SendMessage(pMainFrame->m_hWnd,MYWM_PROGRESS,0,0);
return 1;*/
pVw->Invalidate();
return 1;
}
UINT CScreenView::GetInfoProc(LPVOID pParam)
{
CScreenView* pVw=(CScreenView*)pParam;
// COleDateTime dt;
CWnd* pMainWnd=AfxGetApp()->m_pMainWnd;
CMainFrame* pMainFrame=(CMainFrame*)pMainWnd;
MSG msg;
int commnuationsucess;
DWORD tStart,tEnd;
static BOOL bSend=FALSE;
for(;;)
{
if(!bSend)
{
BYTE buf[1];
buf[0]=0x66;
// buf[1]=0x02;
pVw->readindex=0;
for(int t=0;t<3;t++)
pVw->datread[t]=0x00;
try
{
pVw->pComm->SendBlock(buf,1);
}
catch(...){
}
tStart=GetTickCount();
commnuationsucess=FALSE;
bSend=TRUE;
}
else
{
int tp=1;
for(int m=0;m<3;m++)
{
tp*=pVw->datread[m];
}
if(tp!=0x00)
{
commnuationsucess=TRUE;
pVw->GetScreenInfo();
/* pVw->pagenum=pVw->datread[0];
CString str;
str.Format("%d",pVw->datread[1]);
pMainFrame->m_wndToolBarDraw.m_screenHeight.SetWindowText(str);
str.Format("%d",pVw->datread[2]);
pMainFrame->m_wndToolBarDraw.m_screenWidth.SetWindowText(str);
AfxMessageBox("dslf");
*/
break;
}
tEnd=GetTickCount();
if((tEnd-tStart)>3000)
{
AfxMessageBox("与下位机通讯失败!");
::SendMessage(NULL,WM_QUIT,0,0);
AfxEndThread(0,0);
exit(0);
break;
}
}
Sleep(1);
}
return 1;
}
/////////////////////////////////////////////////////////////////////////////
// CScreenView printing
BOOL CScreenView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CScreenView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CScreenView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
void CScreenView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
{
// TODO: add customized printing code here
}
/////////////////////////////////////////////////////////////////////////////
// CScreenView diagnostics
#ifdef _DEBUG
void CScreenView::AssertValid() const
{
CFormView::AssertValid();
}
void CScreenView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
CScreenDoc* CScreenView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CScreenDoc)));
return (CScreenDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CScreenView message handlers
void CScreenView::OnUpdateImport(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
}
void CScreenView::OnSize(UINT nType, int cx, int cy)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -