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

📄 yhjk.cpp

📁 实现智能大厦自动报警系统主要是通过串口通信来实现的。计算机对数模转换设备发送到端口的数据进行处理
💻 CPP
字号:
// yhjk.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "yhjk.h"
#include "DBegin.h"
#include "RxADO.h"
#include "math.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "DllHeader.h"
/////////////////////////////////////////////////////////////////////////////
// CMyApp

BEGIN_MESSAGE_MAP(CMyApp, CWinApp)
	//{{AFX_MSG_MAP(CMyApp)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG
	ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyApp construction

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

/////////////////////////////////////////////////////////////////////////////
// The one and only CMyApp object
HINSTANCE hInstance;
CMyApp theApp;
RxADO ado;
CString m_Coding[30][30];
 

        
TAXIS Taxis(TAXIS Ts)
{
	int nMax=0;
	while ((Ts.Taxis[nMax]!=0 && Ts.Taxis[nMax]!=-858993460) && nMax<99)
	{
		nMax++;
	}
	int memNum;
	for(int i=0;i<nMax;i++)
	{
		for(int n=i;n<nMax;n++)
		{
			if(Ts.Taxis[i]==Ts.Taxis[n+1])//如果相等
				Ts.Taxis[n+1]=-858993460;
			if(Ts.Taxis[i]<Ts.Taxis[n+1])//交换位置
			{	
				memNum=Ts.Taxis[n+1];
				Ts.Taxis[n+1]=Ts.Taxis[i];
				Ts.Taxis[i]=memNum;
			}
		}
	}
	return Ts;
}
int TwoToTen(CString sTwoNumber)
{
	int nLength=sTwoNumber.GetLength(); 
	CString sOneNumber;
	int nTenValue=0;
	int nValue=0;
	for(int i=0;i<nLength;i++)
	{
		sOneNumber=sTwoNumber.Mid(i,1);
		nTenValue=atoi(sOneNumber)*pow(2,(nLength-i-1));
		nValue=nValue+nTenValue;
	}
	return nValue;

}
CString TenToTwo(int nTenNumber)
{
	CString sSixteenNumber;
	sSixteenNumber.Format("%x",nTenNumber);
	CString sNum;
	CString sTwoNum;
	CString sReturn;
	for(int l=1;l<=sSixteenNumber.GetLength();l++)
	{	
		sNum=sSixteenNumber.Mid(l-1,1);
		if(sNum=="0")
			sTwoNum="0000";
		if(sNum=="1")
			sTwoNum="0001";
		if(sNum=="2")
			sTwoNum="0010";
		if(sNum=="3")
			sTwoNum="0011";
		if(sNum=="4")
			sTwoNum="0100";
		if(sNum=="5")
			sTwoNum="0101";
		if(sNum=="6")
			sTwoNum="0110";
		if(sNum=="7")
			sTwoNum="0111";
		if(sNum=="8")
			sTwoNum="1000";
		if(sNum=="9")
			sTwoNum="1001";
		if(sNum=="a")
			sTwoNum="1010";
		if(sNum=="b")
			sTwoNum="1011";
		if(sNum=="c")
			sTwoNum="1100";
		if(sNum=="d")
			sTwoNum="1101";
		if(sNum=="e")
			sTwoNum="1110";
		if(sNum=="f")
			sTwoNum="1111";
		sReturn=sReturn+sTwoNum;
	}
	return sReturn;
}
/////////////////////////////////////////////////////////////////////////////
// CMyApp initialization

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

	//载入动态库
	hInstance =LoadLibrary("RxDLL.dll");
	
	//载入RXDLL中的函数
	MoneyToChineseCode=(_MoneyToChineseCode*)GetProcAddress(hInstance,"MoneyToChineseCode");
	CTimeToCString=(_CTimeToCString*)GetProcAddress(hInstance,"CTimeToCString");
	CStringTOCTime=(_CStringTOCTime*)GetProcAddress(hInstance,"CStringTOCTime");
	Padl=(_Padl*)GetProcAddress(hInstance,"Padl");
	CharToLetterCode=(_CharToLetterCode*)GetProcAddress(hInstance,"CharToLetterCode");

  if(ado.SetConnection("uid=admin;pwd=111;DRIVER={Microsoft Access Driver (*.mdb)};DBQ=zndsdb.mdb;")==false)
		return false;
	cnn=ado.GetConnection();

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



	CDBegin dlg;
	m_pMainWnd = &dlg;
	int nResponse = dlg.DoModal();
	return FALSE;
}

int CMyApp::ExitInstance() 
{
	FreeLibrary(hInstance);	
	
	return CWinApp::ExitInstance();
}

⌨️ 快捷键说明

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