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

📄 demodlg.cpp

📁 美国Solartron测量设备的演示程序,带数据库和图形显示功能
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// DemoDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Demo.h"
#include "DemoDlg.h"
#include "DlgProxy.h"
#include "orbitcom.h"
#include "AddModule.h"
#include "conio.h"
#include "AccessDlg.h"


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

	IOrbitServer m_OrbitServer;
	IOrbitNetworks m_OrbitNetworks;
	IOrbitNetwork m_OrbitNetwork;
	IOrbitModules m_OrbitModules;
	IOrbitModule m_OrbitModule;
	static long m_lBase,realnum;

/////////////////////////////////////////////////////////////////////////////
// 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)
	//}}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()

/////////////////////////////////////////////////////////////////////////////
// CDemoDlg dialog

IMPLEMENT_DYNAMIC(CDemoDlg, CDialog);

CDemoDlg::CDemoDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CDemoDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDemoDlg)
	m_strRealValue = _T("");
	m_strTempValue = _T("");
	m_strZeroBase = _T("");
	m_strModuleID = _T("");
	m_strModuleName = _T("");
	m_iModulesNumber = 0;
	m_strModuleType = _T("");
	m_strNetworkDescription = _T("");
	m_strNetworkType = _T("");
	m_strProbeStroke = _T("");
	m_iScale = 0;
	m_strSWVersion = _T("");
	m_fUpLimit = 2.5f;
	m_strHWVersion = _T("");
	m_fDownLimit = -2.5f;
	m_strDeviceType = _T("");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
	m_pAutoProxy = NULL;
}

CDemoDlg::~CDemoDlg()
{
	// If there is an automation proxy for this dialog, set
	//  its back pointer to this dialog to NULL, so it knows
	//  the dialog has been deleted.
	if (m_pAutoProxy != NULL)
		m_pAutoProxy->m_pDialog = NULL;
}

void CDemoDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDemoDlg)
	DDX_Text(pDX, IDC_RealValue, m_strRealValue);
	DDX_Text(pDX, IDC_TempValue, m_strTempValue);
	DDX_Text(pDX, IDC_ZeroBase, m_strZeroBase);
	DDX_Text(pDX, IDC_ModuleID, m_strModuleID);
	DDX_Text(pDX, IDC_ModuleName, m_strModuleName);
	DDX_Text(pDX, IDC_ModulesNumber, m_iModulesNumber);
	DDX_Text(pDX, IDC_ModuleType, m_strModuleType);
	DDX_Text(pDX, IDC_NetworkDescription, m_strNetworkDescription);
	DDX_Text(pDX, IDC_NetworkType, m_strNetworkType);
	DDX_Text(pDX, IDC_ProbeStroke, m_strProbeStroke);
	DDX_Text(pDX, IDC_Scale, m_iScale);
	DDX_Text(pDX, IDC_SWVerison, m_strSWVersion);
	DDX_Text(pDX, IDC_UpLimit, m_fUpLimit);
	DDX_Text(pDX, IDC_HWVersion, m_strHWVersion);
	DDX_Text(pDX, IDC_DownLimit, m_fDownLimit);
	DDX_Text(pDX, IDC_DeviceType, m_strDeviceType);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CDemoDlg, CDialog)
	//{{AFX_MSG_MAP(CDemoDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_WM_CLOSE()
	ON_BN_CLICKED(ID_Exit, OnExit)
	ON_BN_CLICKED(IDC_ConnectToNetwork, OnConnectToNetwork)
	ON_BN_CLICKED(IDC_NotifyAndAdd, OnNotifyAndAdd)
	ON_BN_CLICKED(IDC_OneCollect, OnOneCollect)
	ON_BN_CLICKED(IDC_SetBase, OnSetBase)
	ON_BN_CLICKED(IDC_Collect1000, OnCollect1000)
	ON_BN_CLICKED(IDC_Scan, OnScan)
	ON_BN_CLICKED(IDC_OpenAccess, OnOpenAccess)
	ON_WM_TIMER()
	ON_BN_CLICKED(IDC_EmptyAccess, OnEmptyAccess)
	ON_WM_DESTROY()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDemoDlg message handlers

BOOL CDemoDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here
	
	CRect rect;
	rect.bottom=682;
	rect.top=0;
	rect.left=0;
	rect.right=1006;
	MoveWindow(&rect,true);

	
	m_lBase=0;
	m_strZeroBase.Format("%d",m_lBase);

	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CDemoDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CDemoDlg::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	if (IsIconic())
	{
		
		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}

/*
	CRect rectWave,rect;
	GetClientRect(&rect);

	COLORREF m_colorRed,m_colorGreen,m_colorWhite;
	m_colorWhite=RGB(255,255,255);
	m_colorRed=RGB(255,0,0);
	m_colorGreen=RGB(0,255,0);

	rectWave.bottom=rect.bottom;
	rectWave.right=rect.right;
	rectWave.left=0;
	rectWave.top=rect.bottom-410;

	dc.FillSolidRect(rectWave,m_colorWhite);
*/


	
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CDemoDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

// Automation servers should not exit when a user closes the UI
//  if a controller still holds on to one of its objects.  These
//  message handlers make sure that if the proxy is still in use,
//  then the UI is hidden but the dialog remains around if it
//  is dismissed.

void CDemoDlg::OnClose() 
{
	if (CanExit())
		CDialog::OnOK();
}

void CDemoDlg::OnOK() 
{
//	if (CanExit())
//		CDialog::OnOK();
}

void CDemoDlg::OnCancel() 
{
//	if (CanExit())
//		CDialog::OnCancel();
}

BOOL CDemoDlg::CanExit()
{
	// If the proxy object is still around, then the automation
	//  controller is still holding on to this application.  Leave
	//  the dialog around, but hide its UI.

	if (m_pAutoProxy != NULL)
	{
		ShowWindow(SW_HIDE);
		return FALSE;
	}

	return TRUE;
}

void CDemoDlg::OnExit() 
{
	

	KillTimer(1);

	CDialog::OnOK();

//	if(CanExit())
//		CDialog::OnOK();

}

void CDemoDlg::OnConnectToNetwork() 
{
	UpdateData(true);

	if(m_fUpLimit==m_fDownLimit)
		MessageBox("Please reset limit specification!");
	else
	{
	if(m_OrbitServer.CreateDispatch("OrbitCOM.OrbitServer")!=NULL)
	{
		if(!m_OrbitServer.GetConnected())
			m_OrbitServer.Connect();
	}

	if(m_OrbitServer.GetNumNetworks()>0)
	{
		COleVariant V0;
		m_OrbitNetworks=m_OrbitServer.GetNetworks();
		V0=(long)0;
		m_OrbitNetwork=m_OrbitNetworks.GetItem(V0);
	
	}

	m_OrbitModules=m_OrbitNetwork.GetModules();
	m_strNetworkDescription=m_OrbitNetwork.GetNetDescription();
	m_strNetworkType.Format("%d",m_OrbitNetwork.GetNetType());
	m_iModulesNumber=m_OrbitNetwork.GetNumModulesOnNW();

	UpdateData(false);
	}

}

void CDemoDlg::OnNotifyAndAdd() 
{
	CAddModule AddModule;
	if(AddModule.DoModal()==IDOK)
	{
		UpdateData(true);

		
			do
			{
				m_OrbitModule=m_OrbitModules.NotifyAndAdd(AddModule.m_strModuleName);
				m_strModuleID=m_OrbitModule.GetModuleID();
			}while(m_strModuleID.GetLength()!=10);
		

		m_strModuleName=m_OrbitModule.GetModuleName();
		m_strModuleType=m_OrbitModule.GetModuleType();
		m_strProbeStroke.Format("%d",m_OrbitModule.GetStroke());
		m_strProbeStroke+="  mm";
		m_strDeviceType=m_OrbitModule.GetDeviceType();
		m_strSWVersion=m_OrbitModule.GetSWVersion();
		m_strHWVersion.Format("%d",m_OrbitModule.GetHWType());
		m_iScale=m_OrbitModule.GetScale();
		m_iModulesNumber=m_OrbitNetwork.GetNumModulesOnNW();

		UpdateData(false);

	}

		
}
	

void CDemoDlg::OnOneCollect() 
{
	static long m=0;
	long reading,n;
	double realreading;
    for(int i=0;i<10;i++)

⌨️ 快捷键说明

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