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

📄 volumedlg.cpp

📁 代码为windows下的无线猫的应用程序(对AT指令的操作)。
💻 CPP
字号:
// VolumeDlg.cpp : implementation file
//

#include "stdafx.h"
#include "SIMTOOL.h"
#include "VolumeDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CVolumeDlg dialog
extern CSIMTOOLApp theApp;

CVolumeDlg::CVolumeDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CVolumeDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CVolumeDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CVolumeDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CVolumeDlg)
	DDX_Control(pDX, IDC_VOLUME, m_Vol);
	DDX_Control(pDX, IDC_SLIDER, m_Slid);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CVolumeDlg, CDialog)
	//{{AFX_MSG_MAP(CVolumeDlg)
	ON_NOTIFY(NM_CUSTOMDRAW, IDC_SLIDER, OnCustomdrawSlider)
	ON_BN_CLICKED(IDC_APPBTN, OnAppbtn)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CVolumeDlg message handlers

BOOL CVolumeDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	int iLevel;
	char cText[100], comm[20], cLevel[5];
	CString RetInfo, sDevComm, sStatus, sAppComm;

	memset(comm, 0, 20);
	memset(cText, 0, 100);
	memset(cLevel, 0, 5);

	m_Slid.SetRange(0, 255);

	sAppComm = theApp.GetAppComm();
	sprintf(comm, "%s", sAppComm);
	theApp.SetStatusText("正在寻找GPRS无线网络设备,请稍后...");
	theApp.SetDevText("");
	sDevComm = theApp.OpenDev(comm, 9600);
	if (sDevComm.GetLength() == 0)
	{
		theApp.SetStatusText("设备未被找到或端口未被初始化,正在尝试初始化...");
		sDevComm = theApp.MultiBautOpenDev(comm);
		if (sDevComm.GetLength() == 0)
		{
			theApp.mobile.CloseComm();
			theApp.SetStatusText("没有找到设备或端口波特率不匹配,请确定设备是否连接...");
			MessageBox("没有找到设备或端口波特率不匹配!", "AWS");
			return FALSE;
		}
		else
		{
			theApp.SetStatusText("端口初始化完成,正在打开端口...");
			sDevComm = theApp.OpenDev(comm, 9600);
		}
	}

	if (theApp.GetDevType() == "WAVECOM")
	{
		theApp.SetStatusText("");
		sprintf(cText, "ADBON GPRS MODEM : %s/%d", sDevComm, 9600);
		theApp.SetDevText(cText);
		iLevel = GetVolume();
		theApp.mobile.CloseComm();
	}

	if (theApp.GetDevType() == "BENQ")
	{
		theApp.SetStatusText("");
		sprintf(cText, "ADBON GPRS MODEM : %s/%d", sDevComm, 9600);
		theApp.SetDevText(cText);
		iLevel = GetVolume();
		theApp.mobile.CloseComm();
		sprintf(cLevel, "%d", iLevel);
		m_Vol.SetWindowText(cLevel);
		m_Slid.SetPos(iLevel);
	}

	if (theApp.GetDevType() == "SAGEM MO1xx")
	{
		theApp.mobile.SetModuleType("SAGEM MO1xx");
		MessageBox("SAGEM MO1xx", "AWS");
	}

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

int CVolumeDlg::GetVolume()
{
	int iRet;
	CString strRet, strTmp1, strTmp2;
	char buf[10];

	memset(buf, 0, 10);

	theApp.mobile.QCLVL();
	Sleep(10);
	strRet = theApp.mobile.ReceiveInfo();
	strTmp1 = strRet.Left(strRet.Find("OK")-1);
	strTmp2 = strTmp1.Right(strTmp1.GetLength()-strTmp1.Find(":")-2);
	sprintf(buf, "%s", strTmp2);
	iRet = atoi(buf);

	return iRet;
}

void CVolumeDlg::OnCustomdrawSlider(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	int iPos;
	char buf[10];

	memset(buf, 0, 10);

	iPos = m_Slid.GetPos();
	sprintf(buf, "%d", iPos);
	m_Vol.SetWindowText(buf);

	*pResult = 0;
}

void CVolumeDlg::OnAppbtn() 
{
	// TODO: Add your control notification handler code here
	char buf[10], cText[100], comm[20], cVolume[5];
	CString RetInfo, sDevComm, sStatus, sAppComm;
	int iLevel;

	memset(buf, 0, 10);
	memset(comm, 0, 20);
	memset(cText, 0, 100);
	memset(cVolume, 0, 5);
	m_Vol.GetWindowText(buf, 10);
	
	iLevel = atoi(buf);

	sAppComm = theApp.GetAppComm();
	sprintf(comm, "%s", sAppComm);
	theApp.SetStatusText("正在寻找GPRS无线网络设备,请稍后...");
	theApp.SetDevText("");
	sDevComm = theApp.OpenDev(comm, 9600);
	if (sDevComm.GetLength() == 0)
	{
		theApp.SetStatusText("设备未被找到或端口未被初始化,正在尝试初始化...");
		sDevComm = theApp.MultiBautOpenDev(comm);
		if (sDevComm.GetLength() == 0)
		{
			theApp.mobile.CloseComm();
			theApp.SetStatusText("没有找到设备或端口波特率不匹配,请确定设备是否连接...");
			MessageBox("没有找到设备或端口波特率不匹配!", "AWS");
			return;
		}
		else
		{
			theApp.SetStatusText("端口初始化完成,正在打开端口...");
			sDevComm = theApp.OpenDev(comm, 9600);
		}
	}

	if (theApp.GetDevType() == "WAVECOM")
	{
		theApp.SetStatusText("");
		sprintf(cText, "ADBON GPRS MODEM : %s/%d", sDevComm, 9600);
		theApp.SetDevText(cText);
		sprintf(cVolume, "%d", iLevel);
		theApp.SetVolume(cVolume);
		theApp.mobile.CLVL(iLevel);
		theApp.mobile.CloseComm();
	}

	if (theApp.GetDevType() == "BENQ")
	{
		theApp.SetStatusText("");
		sprintf(cText, "ADBON GPRS MODEM : %s/%d", sDevComm, 9600);
		theApp.SetDevText(cText);
		sprintf(cVolume, "%d", iLevel);
		theApp.SetVolume(cVolume);
		theApp.mobile.CLVL(iLevel);
		theApp.mobile.CloseComm();
	}

	if (theApp.GetDevType() == "SAGEM MO1xx")
	{
		theApp.mobile.SetModuleType("SAGEM MO1xx");
		MessageBox("SAGEM MO1xx", "AWS");
	}
}

⌨️ 快捷键说明

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