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

📄 yykcsdlg.cpp

📁 170话费催交系统
💻 CPP
字号:
// yykcsDlg.cpp : implementation file
//

#include "stdafx.h"
#include "yykcs.h"
#include "yykcsDlg.h"

#include <srllib.h>
#include <dxxxlib.h>
#include <dtilib.h>
#include <sctools.h>
#include "myyyk.h"

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

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

/////////////////////////////////////////////////////////////////////////////
// CYykcsDlg dialog

CYykcsDlg::CYykcsDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CYykcsDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CYykcsDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CYykcsDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CYykcsDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CYykcsDlg, CDialog)
	//{{AFX_MSG_MAP(CYykcsDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CYykcsDlg message handlers

BOOL CYykcsDlg::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
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CYykcsDlg::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 CYykcsDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

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

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

void CYykcsDlg::OnOK() 
{
	// TODO: Add extra validation here
	
	CDialog::OnOK();
}

/************************************************************
 *        NAME: WinPrintf()
 * DESCRIPTION: Popup error message box for cases where
 *              no child windows exist.
 ************************************************************/
void WinPrintf(char *szFormat, ...)
{
   char szBuffer[256];
   va_list pArguments;


   va_start(pArguments,szFormat);
   vsprintf(szBuffer, szFormat, pArguments);
   MessageBox(hwndFrame, szBuffer, "Program message...", MB_SYSTEMMODAL | MB_OK);
}

/***************************************************************************
 *        NAME: void sysinit()
 * DESCRIPTION: Start System  设备初始化
 ***************************************************************************/
void sysinit(void)
{
	int mode;
	int i;
   /* Set the Device to Polled Mode  设置语音卡为轮询问模式*/
   mode = SR_POLLMODE;
   if (sr_setparm(SRL_DEVICE,SR_MODEID,&mode )==-1) {  //sr_setparm( ) function allows the application to set 
   							//the value of an SRL(Standard Runtime Library) parameter
		WinPrintf("sr_setparm()");
		return;
   }
	promptfh=dx_fileopen("sample.vox",O_RDONLY|O_BINARY);
	if(promptfh<=0){
		WinPrintf("File SAMPLE.VOX not found, please  copy it to the current directory.");
		return;
	}
	for (i = 0; i < MAXCHAN; i++) {
		//打开语音卡端口
		strcpy(dev[i].voxname,voxchannels[i]);		
		if ((dev[i].vox = dx_open(dev[i].voxname, 0)) == -1) {
			WinPrintf("%s: Error opening this channel",dev[i].voxname);
			return;
		}
		//打开中继卡端口
		strcpy(dev[i].dtiname,dtichannels[i]);
		if ((dev[i].dti = dt_open(dev[i].dtiname, 0)) == -1) {
			WinPrintf("%s: Error opening this channel",dev[i].dtiname);
			return;
		}
		//
		//连接语音卡和中继卡两种设备。这里涉及到 SCBus,SCBus是Dialogic公司的一种硬件
		//技术,用于连接不同的DEVICE. D300/SC-E1卡其实就是用SCBus连接一个30路语音卡
		//和一个30口中继卡为一体的产品。
		// nr_nr_scunroute()函数的作用在于断开 dit 和 voice之间的连接。
		if(nr_scunroute(dev[i].dti,SC_DTI,dev[i].vox,SC_VOX,SC_FULLDUP)==-1){
			WinPrintf("%s <=== UnRoute Failed ===> %s",dev[i].voxname,dev[i].dtiname);
			return;
		}
		//重建 dti 和voice之间的连接。(全双工连接)
		if(nr_scroute(dev[i].dti,SC_DTI,dev[i].vox,SC_VOX,SC_FULLDUP)==-1){
			WinPrintf("%s <=== Route Failed ===> %s",dev[i].voxname,dev[i].dtiname);
			return;
		}
		//语音卡要监听来自交换机的前向信号( R2MF, forward signal),必须调用 r2_createfsig
		//建立一个模板(template),指定监听哪些signal, dx_deltons()则是清除这个template.
		if(dx_deltones(dev[i].vox)==-1){
			WinPrintf("%s: dx_deltones()",dev[i].voxname);
			return;
		}
		//重建template,指定端口监听所有的(forward signal)
		if(r2_creatfsig(dev[i].vox,R2_ALLFSIG)==-1){
			WinPrintf("%s: r2_creatfsig()",dev[i].voxname);
			return;
		}
		//数字设备上有一个传输信号字节Bitmask,用于表示事件,其bitmask有如下
		/* DTB_AON - "A" signaling bit on 
		   DTB_AOFF - "A" signaling bit off 
		   DTB_BON - "B" signaling bit on 
		   DTB_BOFF - "B" signaling bit off 
		   DTB_CON - "C" signaling bit on (E-1 only) 
		   DTB_COFF - "C" signaling bit off (E-1 only) 
		   DTB_DON - "D" signaling bit on (E-1 only) 
		   DTB_DOFF - "D" signaling bit off (E-1 only) */		   
		if(dt_settssigsim(dev[i].dti,DTB_AON|DTB_BOFF|DTB_CON|DTB_DON)==-1){
			WinPrintf("dt_settssig() in dt_onhook(1)");
			return;
		}
		
		chan_init(i);
		/*chan_init(){
			if(DEBUG) printf("%s: In chan_init()\n",dev[i].voxname);
			strcpy(dev[i].dnis,"");
			strcpy(dev[i].ani,"");
			dev[i].number=0;
			dev[i].state=ST_SZ_ACK;
			dt_settssigsim(dev[i].dti,DTB_AON|DTB_BOFF|DTB_CON|DTB_DON);
		}
		*/
		//接收信号事件,对于SC设备 AON和AOFF同时要设置。
		if(dt_setevtmsk(dev[i].dti,DTG_SIGEVT,DTMM_AON|DTMM_AOFF,DTA_SETMSK)==-1){
			WinPrintf("%s: dt_setevtmsk()",dev[i].dtiname);
			return;
		}	
	}
	WinPrintf("All Channels opened, dial in now.");
}

⌨️ 快捷键说明

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