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

📄 testsys.cpp

📁 百色电信中继电话录音系统,是对于电话会议接入到本中继系统进行电话录音
💻 CPP
字号:
// TestSys.cpp : implementation file
//

#include "stdafx.h"
#include "recsys.h"
//#include "TestSys.h"

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

/////////////////////////////////////////////////////////////////////////////
// CTestSys

IMPLEMENT_DYNCREATE(CTestSys, CWinThread)

CTestSys::CTestSys()
{

}

CTestSys::~CTestSys()
{
}

BOOL CTestSys::InitInstance()
{
	// TODO:  perform and per-thread initialization here
	for(int i=0;i<240;i++)
	{
		trks[i].state=0;
		memset(trks[i].filename,0,255);
		memset(trks[i].callee,0,20);
		memset(trks[i].caller,0,20);
		trks[i].tcount=0;
		trks[i].state_sp=ramdig(50,100);
	}
	SetTimer(NULL,0,100,NULL);
	return TRUE;
	
}

int CTestSys::ExitInstance()
{
	// TODO:  perform any per-thread cleanup here
	return CWinThread::ExitInstance();
}

BEGIN_MESSAGE_MAP(CTestSys, CWinThread)
	//{{AFX_MSG_MAP(CTestSys)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//	ON_WM_TIMER()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTestSys message handlers

int CTestSys::SsmPickup(int ch)
{
	trks[ch].state=3;	//voice
	trks[ch].state_sp=ramdig(100,200);
	return 1;
}
int CTestSys::SsmHangup(int ch)
{
	trks[ch].state=0;	//idle
	trks[ch].tcount=0;
	trks[ch].state_sp=ramdig(50,100);
	return 1;
}
int CTestSys::SsmAutoDial(int ch, LPSTR szPhoNum)
{
	trks[ch].state=2;	//acm
	trks[ch].tcount=0;
	trks[ch].state_sp=ramdig(20,50);
	return 1;
}
int CTestSys::SsmChkAutoDial(int ch)
{
//	trks[ch].tcount=0;
	if(trks[ch].state==2)
		return 2;
	else if(trks[ch].state==3)
		return 7; 
	else return 0;
}
int CTestSys::SsmGetAutoDialFailureReason(int ch)
{
	return 99;
}
int CTestSys::SsmGetChState(int ch)
{
	return trks[ch].state;
}
int CTestSys::SsmSearchIdleCallOutCh(WORD wSearchMode, DWORD dwPrecedence,int ch)
{
	return ch+120;
}
int CTestSys::SsmSetAutoCallDirection(int ch, BOOL bEnAutoCall, int nDirection)
{
	return 1;
}
int CTestSys::SsmGetPhoNumStr(int ch, LPSTR pszPhoNum)
{
	strcpy(pszPhoNum,trks[ch].callee);
	return 1;
}
int CTestSys::SsmSetKB(int ch, BYTE btSigKB)
{
	trks[ch].state=2;
	return 1;
}
int CTestSys::SsmTalkWith(int ch1,int ch2)
{
	return 1;
}
int CTestSys::SsmStopTalkWith(int ch1,int ch2)
{
	return 1;
}
int CTestSys::SsmRecToFile(int ch, LPSTR pszFileName, int nFormat, DWORD dwStartPos, DWORD dwBytes, DWORD dwTime, int nMask)
{
	CFile myfile;
	myfile.Open(pszFileName,CFile::modeCreate|CFile::modeWrite,NULL);
	char strtmp[1024];
	sprintf(strtmp,"通道%d:正在录音,文件名:%s。-------录音结束!",ch,pszFileName);
	myfile.Write(strtmp,1000);
	myfile.Close();
	return 1;
}
int CTestSys::SsmStopRecToFile(int ch)
{
	return 1;
}
int CTestSys::SsmSetRecMixer(int ch, BOOL bEnRecMixer, int nMixerVolume)
{
	return 1;
}
int CTestSys::SsmSetRecVolume(int ch, int nVolume)
{
	return 1;
}
int CTestSys::SsmGetCallerId(int ch, LPSTR szCallerId)
{
	sprintf(szCallerId,trks[ch].caller);
	return 1;
}
int CTestSys::SsmSetTxCallerId(int ch, LPSTR pszTxCallerId)
{
	sprintf(trks[ch].caller,pszTxCallerId);
	return 1;
}
void CTestSys::SsmGetLastErrMsg(LPSTR szErrMsgBuf)
{
	sprintf(szErrMsgBuf,"处于测试模块,请与黄宇联系!");
}

void CTestSys::OnTimer()
{
	simulate();
}

void CTestSys::simulate()
{
	for(int i=0;i<240;i++)
	{
		if(i<120)
		{
			switch(trks[i].state) 
			{
			case 0	://主叫,空闲时
				{
					if(trks[i].tcount>trks[i].state_sp)	//空闲时间超过3秒,进入呼入状态
					{
						trks[i].tcount=0;
						trks[i].state=7;
						sprintf(trks[i].caller,"570%04d",i);
						sprintf(trks[i].callee,"123570%04d",i*2+1);
					}
					else
						trks[i].tcount++;
				}
				break;
			case 3:		//主叫方,通话状态
				{
					if(trks[i].tcount>trks[i].state_sp)	//通话时间超过3秒,挂机
					{
						trks[i].tcount=0;
						trks[i].state=0;
						memset(trks[i].callee,0,20);
						memset(trks[i].caller,0,20);
					}
					else
						trks[i].tcount++;
				}
				break;
			default:
				break;
			}
		}
		else
		{
			switch(trks[i].state) 
			{
			case 2:	//被叫处于振铃状态
				{
					if(trks[i].tcount>trks[i].state_sp)	//振铃时间超过3秒,被叫摘机
					{
						trks[i].tcount=0;
						trks[i].state=3;
						trks[i].state_sp=ramdig(100,200);
					}
					else
						trks[i].tcount++;
				}
				break;
			default:
				break;
			}
		}
	}
}

long CTestSys::ramdig(long min, long max)
{
	return ((long)((rand()*(max-min))/RAND_MAX)+min);
}

BOOL CTestSys::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class
	switch(pMsg->message) {
	case WM_TIMER:
		{
			OnTimer();
		}
		break;
	default:	;
	}	
	return CWinThread::PreTranslateMessage(pMsg);
}

⌨️ 快捷键说明

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