?? djcard.cpp
字號:
// DJCard.cpp: implementation of the CDJCard class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "query.h"
#include "DJCard.h"
#include "tc08a32.h"
#include "NewSig.h"
#include "djcvt.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CDJCard::CDJCard()
{
}
CDJCard::~CDJCard()
{
this->ReleaseCard();
}
BOOL CDJCard::InitCard()
{
int i;
if ( LoadDRV ( ) )
{
AfxMessageBox("Load driver FAIL", MB_OK,NULL );
return FALSE;
}
if ( EnableCard(8,1024*8) != (long)0)
{
FreeDRV();
AfxMessageBox ("Enable Card FAIL", MB_OK,NULL );
return FALSE;
}
SetBusyPara(350);
for(i=0;i<8;i++)
{
this->ResetChannel(i);
}
Sig_Init(0);
return TRUE;
}
VOID CDJCard::ChechState()
{
short int code;
PUSH_PLAY();
FeedSigFunc();
for(int i=0;i<8;i++)
{
(pDtmfChar+i)->recieve=FALSE;
(pDtmfChar+i)->dtmf=0;
if((*(pstrDuty+i))=="4"&&(!(*(pIsRecording+i))))//RECORDING FILE
{
(*(pIsRecording+i))=TRUE;
CString filename=CTime::GetCurrentTime().Format("r%Y%m%d%H%M%S.voc");
StartRecordFile((WORD)i,filename.GetBuffer(filename.GetLength()),1000000);
(*(pRecordFileName+i))=filename;
}
if((pChannelStatus+i)->used==0)
{
if(RingDetect(i))
{
InitDtmfBuf(i);
OffHook(i);
//play welcome and chang the steps
this->PlayFile(i,"inputcaller.voc");
(pChannelStatus+i)->step=1;
(pChannelStatus+i)->used=1;
}
}
else//this channel is in using!
{
if (Sig_CheckBusy(i))//user disconnect the query
{
if(CheckPlayEnd((WORD)i)==0)//end the play
StopPlayFile(i);
this->ResetChannel(i);
}
code=GetDtmfCode(i);
if(code!=-1)
{
if(CheckPlayEnd(i)==0)//end the play
StopPlayFile(i);
(pDtmfChar+i)->dtmf=ConvertDtmf(code);
(pDtmfChar+i)->recieve=TRUE;
}
}
}//end for
}
VOID CDJCard::ReleaseCard()
{
DisableCard();
FreeDRV();
}
char CDJCard::ConvertDtmf(int ch)
{
char c;
switch(ch)
{
case 10:
c = '0';
break;
case 11:
c = '*';
break;
case 12:
c = '#';
break;
case 13:
case 14:
case 15:
c=ch-13+'a';
break;
case 0:
c='d';
break;
default:
c = ch + '0';//轉換成ASCII碼
}
return c;
}
VOID CDJCard::PlayFile(int channel, CString filename)
{
StartPlayFile(channel,filename.GetBuffer(filename.GetLength()),0L);
}
VOID CDJCard::ResetChannel(int channel)
{
if((*(pIsRecording+channel))==TRUE)//is recording
{
StopRecordFile(channel);
CString tmp=(*(pRecordFileName+channel));
CString tmp1=tmp.Mid(0,tmp.GetLength()-4)+".wav";
PcmtoWave(tmp.GetBuffer(tmp.GetLength()),tmp1.GetBuffer(tmp.GetLength()));
}
StartSigCheck(channel);
HangUp(channel);
Sig_ResetCheck(channel);
//initialize the member of data for the input
(pChannelStatus+channel)->step=0;
(pChannelStatus+channel)->used=0;
(pDtmfChar+channel)->dtmf=0;
(pDtmfChar+channel)->recieve=FALSE;
(pCallerInfo+channel)->m_callerid="";
(pCallerInfo+channel)->m_password="";
*(pIsRecording+channel)=FALSE;
(this->pcosttype+channel)->Empty();
(this->pstrDuty+channel)->Empty();
(this->pstrRecDTMF+channel)->Empty();
(this->pstrenddate+channel)->Empty();
(this->pstrstartdate+channel)->Empty();
}
VOID CDJCard::ResetIndexPlay(int channel)
{
RsetIndexPlayFile((WORD)channel);
}
VOID CDJCard::StartIndexPlay(int channel)
{
StartIndexPlayFile( (WORD) channel);
}
VOID CDJCard::AddIndexPlay(int channel, CString filename)
{
AddIndexPlayFile((WORD)channel, filename.GetBuffer(filename.GetLength()));
}
BOOL CDJCard::CheckIndexPlay(int channel)
{
if(CheckIndexPlayFile((WORD) channel)==1)
return TRUE;
else
return FALSE;
}
VOID CDJCard::StopIndexPlay(int channel)
{
StopIndexPlayFile((WORD) channel);
}
VOID CDJCard::StopPlay(int channel)
{
StopPlayFile((WORD)channel);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -