?? testapiview.cpp
字號:
// TestAPIView.cpp : implementation of the CTestAPIView class
//
#include "stdafx.h"
#include "TestAPI.h"
#include "TestAPIDoc.h"
#include "TestAPIView.h"
#include "FlashDSOAPI.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTestAPIView
IMPLEMENT_DYNCREATE(CTestAPIView, CView)
BEGIN_MESSAGE_MAP(CTestAPIView, CView)
//{{AFX_MSG_MAP(CTestAPIView)
ON_WM_TIMER()
ON_COMMAND(IDM_200K, On200k)
ON_COMMAND(IDM_20K, On20k)
ON_COMMAND(IDM_20M, On20m)
ON_COMMAND(IDM_2M, On2m)
ON_COMMAND(IDM_400K, On400k)
ON_COMMAND(IDM_40K, On40k)
ON_COMMAND(IDM_40M, On40m)
ON_COMMAND(IDM_4M, On4m)
ON_COMMAND(IDM_800K, On800k)
ON_COMMAND(IDM_80K, On80k)
ON_COMMAND(IDM_8M, On8m)
ON_COMMAND(IDM_AC, OnAc)
ON_COMMAND(IDM_DC, OnDc)
ON_COMMAND(IDM_END, OnEnd)
ON_COMMAND(IDM_GAIN_1, OnGain1)
ON_COMMAND(IDM_GAIN_10, OnGain10)
ON_COMMAND(IDM_GAIN_20, OnGain20)
ON_COMMAND(IDM_START, OnStart)
ON_COMMAND(IDM_VERSION, OnVersion)
ON_WM_DESTROY()
ON_COMMAND(IDM_RISING, OnRising)
ON_COMMAND(IDM_FALLING, OnFalling)
ON_COMMAND(IDM_AUTO, OnAuto)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTestAPIView construction/destruction
CTestAPIView::CTestAPIView()
{
// TODO: add construction code here
iComPort = GetPort();
memset(szComPort,0x00,sizeof(szComPort));
sprintf(szComPort,"COM%d",iComPort);
iClockType = VA_TIMEBASE_0;
memset(szClock,0x00,sizeof(szClock));
sprintf(szClock,"40M HZ");
iGainType = VA_OP_X0;
memset(szGain,0x00,sizeof(szGain));
sprintf(szGain,"1:1");
memset(szAcDc,0x00,sizeof(szAcDc));
sprintf(szAcDc,"交流");
memset(szTriger,0x00,sizeof(szTriger));
sprintf(szTriger,"自動");
}
CTestAPIView::~CTestAPIView()
{
}
BOOL CTestAPIView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CTestAPIView drawing
void CTestAPIView::OnDraw(CDC* pDC)
{
CTestAPIDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
int x;
int y;
int i;
//ch1
x = 1;
y = 280 - (int)ChannelData1[0];;
pDC->MoveTo(x,y);
for ( i = 0 ; i < BUFFER_LENGTH; i++)
pDC->LineTo(x+i,280-(int)ChannelData1[i]);
//ch2
x = 1;
y = 480 - (int)ChannelData2[0];
pDC->MoveTo(x,y);
for ( i = 0 ; i < BUFFER_LENGTH; i++)
pDC->LineTo(x+i,480-(int)ChannelData2[i]);
//Status Title
char szTemp[128];
sprintf(szTemp,"采樣頻率 = %s, 藕合方式 = %s, 衰減比例 = %s, 通訊端口 = %s, 觸發(fā)模式 = %s",
szClock,szAcDc,szGain,szComPort,szTriger);
pDC->TextOut(1,1,szTemp);
}
/////////////////////////////////////////////////////////////////////////////
// CTestAPIView printing
BOOL CTestAPIView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CTestAPIView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CTestAPIView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CTestAPIView diagnostics
#ifdef _DEBUG
void CTestAPIView::AssertValid() const
{
CView::AssertValid();
}
void CTestAPIView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CTestAPIDoc* CTestAPIView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTestAPIDoc)));
return (CTestAPIDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CTestAPIView message handlers
void CTestAPIView::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
StartDSO();
ReadDSOData(&ChannelData1[0],&ChannelData2[0]);
this->Invalidate(TRUE);
CView::OnTimer(nIDEvent);
}
void CTestAPIView::On40m()
{
iClockType = VA_TIMEBASE_0;
memset(szClock,0x00,sizeof(szClock));
sprintf(szClock,"40M HZ");
SetClock(iClockType);
this->Invalidate(TRUE);
}
void CTestAPIView::On20m()
{
iClockType = VA_TIMEBASE_1;
memset(szClock,0x00,sizeof(szClock));
sprintf(szClock,"20M HZ");
SetClock(iClockType);
this->Invalidate(TRUE);
}
void CTestAPIView::On8m()
{
// TODO: Add your command handler code here
iClockType = VA_TIMEBASE_2;
memset(szClock,0x00,sizeof(szClock));
sprintf(szClock,"8M HZ");
SetClock(iClockType);
this->Invalidate(TRUE);
}
void CTestAPIView::On4m()
{
// TODO: Add your command handler code here
iClockType = VA_TIMEBASE_3;
memset(szClock,0x00,sizeof(szClock));
sprintf(szClock,"4M HZ");
SetClock(iClockType);
this->Invalidate(TRUE);
}
void CTestAPIView::On2m()
{
// TODO: Add your command handler code here
iClockType = VA_TIMEBASE_4;
memset(szClock,0x00,sizeof(szClock));
sprintf(szClock,"2M HZ");
SetClock(iClockType);
this->Invalidate(TRUE);
}
void CTestAPIView::On800k()
{
// TODO: Add your command handler code here
iClockType = VA_TIMEBASE_5;
memset(szClock,0x00,sizeof(szClock));
sprintf(szClock,"800K HZ");
SetClock(iClockType);
this->Invalidate(TRUE);
}
void CTestAPIView::On400k()
{
// TODO: Add your command handler code here
iClockType = VA_TIMEBASE_6;
memset(szClock,0x00,sizeof(szClock));
sprintf(szClock,"400K HZ");
SetClock(iClockType);
this->Invalidate(TRUE);
}
void CTestAPIView::On200k()
{
// TODO: Add your command handler code here
iClockType = VA_TIMEBASE_7;
memset(szClock,0x00,sizeof(szClock));
sprintf(szClock,"200K HZ");
SetClock(iClockType);
this->Invalidate(TRUE);
}
void CTestAPIView::On80k()
{
// TODO: Add your command handler code here
iClockType = VA_TIMEBASE_8;
memset(szClock,0x00,sizeof(szClock));
sprintf(szClock,"80K HZ");
SetClock(iClockType);
this->Invalidate(TRUE);
}
void CTestAPIView::On40k()
{
// TODO: Add your command handler code here
iClockType = VA_TIMEBASE_9;
memset(szClock,0x00,sizeof(szClock));
sprintf(szClock,"40K HZ");
SetClock(iClockType);
this->Invalidate(TRUE);
}
void CTestAPIView::On20k()
{
// TODO: Add your command handler code here
iClockType = VA_TIMEBASE_10;
memset(szClock,0x00,sizeof(szClock));
sprintf(szClock,"20K HZ");
SetClock(iClockType);
this->Invalidate(TRUE);
}
void CTestAPIView::OnAc()
{
// TODO: Add your command handler code here
memset(szAcDc,0x00,sizeof(szAcDc));
sprintf(szAcDc,"交流");
SetAC();
this->Invalidate(TRUE);
}
void CTestAPIView::OnDc()
{
// TODO: Add your command handler code here
memset(szAcDc,0x00,sizeof(szAcDc));
sprintf(szAcDc,"直流");
SetDC();
this->Invalidate(TRUE);
}
void CTestAPIView::OnGain1()
{
// TODO: Add your command handler code here
iGainType = VA_OP_X0;
memset(szGain,0x00,sizeof(szGain));
sprintf(szGain,"1:1");
SetGain(iGainType);
this->Invalidate(TRUE);
}
void CTestAPIView::OnGain10()
{
// TODO: Add your command handler code here
iGainType = VA_OP_X1;
memset(szGain,0x00,sizeof(szGain));
sprintf(szGain,"1:10");
SetGain(iGainType);
this->Invalidate(TRUE);
}
void CTestAPIView::OnGain20()
{
// TODO: Add your command handler code here
iGainType = VA_OP_X2;
memset(szGain,0x00,sizeof(szGain));
sprintf(szGain,"1:20");
SetGain(iGainType);
this->Invalidate(TRUE);
}
void CTestAPIView::OnStart()
{
OpenDSO(iComPort);
SetAutoTriger();
SetAC();
SetClock(iClockType);
SetGain(iGainType);
SetTimer(1,50,NULL);
}
void CTestAPIView::OnEnd()
{
KillTimer(1);
ShutDSO();
}
void CTestAPIView::OnVersion()
{
// TODO: Add your command handler code here
char szTemp[9];
memset(szTemp,0x00,sizeof(szTemp));
GetVersion(szTemp);
AfxMessageBox(szTemp);
}
void CTestAPIView::OnDestroy()
{
CView::OnDestroy();
// TODO: Add your message handler code here
OnEnd();
}
void CTestAPIView::OnRising()
{
// TODO: Add your command handler code here
memset(szTriger,0x00,sizeof(szTriger));
sprintf(szTriger,"上升沿");
SetRiseTriger();
this->Invalidate(TRUE);
}
void CTestAPIView::OnFalling()
{
// TODO: Add your command handler code here
memset(szTriger,0x00,sizeof(szTriger));
sprintf(szTriger,"下降沿");
SetFallTriger();
this->Invalidate(TRUE);
}
void CTestAPIView::OnAuto()
{
// TODO: Add your command handler code here
memset(szTriger,0x00,sizeof(szTriger));
sprintf(szTriger,"自動");
SetAutoTriger();
this->Invalidate(TRUE);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -