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

📄 dsotest.cpp

📁 最新的USB示波器源码?可直接编译生成可执行程序,需要硬件支持
💻 CPP
字号:
// DSOTEST.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "DSOTEST.h"

#include "MainFrm.h"
#include "DSOTESTDoc.h"
#include "DSOTESTView.h"

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

CH_PARAM cha_param;
CH_PARAM chb_param;
MATH_OPERATION math_operation;
RUNNING_CONTROL run_ctrl;
TIME_BASE time_base;
TRIGGER trigger;
TRIGGER_VIDEO trigger_video;
ACQUIRE acquire;
DISPLAY display;
/////////////////////////////////////////////////////////////////////////////
// CDSOTESTApp

BEGIN_MESSAGE_MAP(CDSOTESTApp, CWinApp)
	//{{AFX_MSG_MAP(CDSOTESTApp)
	ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
	// Standard file based document commands
	ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
	ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
	// Standard print setup command
	ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDSOTESTApp construction

CDSOTESTApp::CDSOTESTApp()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CDSOTESTApp object

CDSOTESTApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CDSOTESTApp initialization

BOOL CDSOTESTApp::InitInstance()
{
	AfxEnableControlContainer();

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

	// Change the registry key under which our settings are stored.
	// TODO: You should modify this string to be something appropriate
	// such as the name of your company or organization.
	SetRegistryKey(_T("Local AppWizard-Generated Applications"));

	LoadStdProfileSettings();  // Load standard INI file options (including MRU)

   cha_param.bw_limit =false;
   cha_param.couping =1;
   cha_param.display =true;
   cha_param.probe =10; //10X
   cha_param.reversal =false;
   cha_param.vlot_d =10000; //10000mv 10V 通道衰减100db
   cha_param.y_offset =DISHEIGHT/2;
   
   chb_param.bw_limit =false;
   chb_param.couping =1; //AC
   chb_param.display =false;
   chb_param.probe =10; //10X
   chb_param.reversal =false;
   chb_param.vlot_d =10000; //10000mv 10V 通道衰减100db
   chb_param.y_offset =DISHEIGHT*3/4;

   math_operation.operation =0;
   math_operation.reversal =false;
   math_operation.soure_a =0;
   math_operation.soure_b =1;
   
   run_ctrl.auto_set =false;
   run_ctrl.force_trigger =false;
   run_ctrl.run =false;
   run_ctrl.setTrigto_50 =false;
//"10s + + 1s + + 0.1s + + 10ms + + 1ms + + 0.1ms + + 10us + + 1us + + 0.1us + + 10ns");
//水平参数
   time_base.time_d =2;
   time_base.x_step=1;
   time_base.delay =0;
   time_base.format =0;//Y_T
   time_base.memory_offset =(SAMPLE_DEPTH-DISWIDTH)/2;
   time_base.memory_size =SAMPLE_DEPTH;
   time_base.trigger_offset=SAMPLE_DEPTH/2;
   
   trigger.display =true;
   trigger.coupling =0;  // 0 AC、1 DC、2 HF、3 LF 触发藕合方式
   trigger.method =0; //0 :edge 边沿方式 1: video 对标准视频信号进行场或行视频触发 2: 脉宽触发
   trigger.mode =0;// 0 AUTO、1 NORMAL、2 SINGLE 触发模式
   trigger.slope=0; //0: prising 上升沿触发 1:falling 下降沿触发 2:双沿触发
   trigger.source=0; //触发源选择0: CH1、1: CH2、2: EXT
   trigger.level=128;
   trigger.disp_counter=0;
   /* if(trigger.source==0)
    trigger.level=cha_param.y_offset;
	else
		if(trigger.source==1)
            trigger.level=chb_param.y_offset;
		else
			trigger.level=0;

*/

   trigger_video.level=DISHEIGHT/2;
   trigger_video.nios_rejection =false; //1 on 0 off 高频抑制
   trigger_video.polarity=0; ////0 -|_|-,  1 _|-|_ 黑色电平边沿选择
   trigger_video.source=0;//0: CH1,1: CH2,2: EXT,3: EXT/5 
   trigger_video.sync=0;  //line 行同步触发 ,field1 视频场1触发,field2 视频场2触发  

   acquire.acquire_freq=0; //采样频率 0:25M ,1:50M,2:125M,3:250M
   acquire.acquisition =0;  //0 NORMAL 普通采样, 1 AVERAGE 平均采样方式,2 ENVELOPE 峰值采样方式
   acquire.averages=2;  //平均采样次数 2~256 次
   acquire.fast_trigger=1;   //ON 打开快速触发 OFF 关闭快速触发
   acquire.persistence=10;  // //10ms 25ms 30ms ...500ms 设置余辉时间
   acquire.sampling_mode=0; //0:REAL_TIME 实时采样 ,1:EQU_TIME 等效采样
   acquire.counter=0;
   
   display.type=true; //1:vect 矢量方式,0:dot 直接显示采样点
   display.persist=false;//0:OFF 关闭波形保持功能,1:ON 记录点一直保持
   display.grid_on=true;//1 ON 显示屏幕背景网格 OFF 关闭屏幕背景网格
   display.freq_on_ch1=false; //频率
   display.vlot_on_ch1=false; //电压
   display.freq_on_ch2=false;
   display.vlot_on_ch2=false;

	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views.

	CSingleDocTemplate* pDocTemplate;
	pDocTemplate = new CSingleDocTemplate(
		IDR_MAINFRAME,
		RUNTIME_CLASS(CDSOTESTDoc),
		RUNTIME_CLASS(CMainFrame),       // main SDI frame window
		RUNTIME_CLASS(CDSOTESTView));
	AddDocTemplate(pDocTemplate);

	// Parse command line for standard shell commands, DDE, file open
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	// Dispatch commands specified on the command line
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;

	// The one and only window has been initialized, so show and update it.
	m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);
	m_pMainWnd->UpdateWindow();

	return TRUE;
}


/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
		// No message handlers
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

// App command to run the dialog
void CDSOTESTApp::OnAppAbout()
{
	CAboutDlg aboutDlg;
	aboutDlg.DoModal();
}

/////////////////////////////////////////////////////////////////////////////
// CDSOTESTApp message handlers

⌨️ 快捷键说明

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