📄 fax_polling_vcdlg.cpp
字号:
m_TrkChList.GetItemText(nIndex, 4, szOldStat, 29);
if(strcmp(szNewStat, szOldStat) != 0)
{
m_TrkChList.SetItemText(nIndex, 4, szNewStat);
}
//Chinese: 显示出错信息
//display error messages
m_TrkChList.GetItemText(nIndex, 5, szOldStat, 60);
if(strcmp(m_TrkCh[i].szChErrMsg, szOldStat) != 0)
{
m_TrkChList.SetItemText(nIndex, 5, m_TrkCh[i].szChErrMsg);
}
nIndex++;
}
}
//Chinese: 搜索空闲传真通道
//English: search for idle fax channel
int CFax_Polling_VCDlg::FindAnIdleFaxCh()
{
int nCheck;
for(int i = 0; i < m_nTotalCh; i++)
{
nCheck = SsmGetChType(i);
if(nCheck == -1)
WriteLog("Fail to call SsmGetChType");
else if((nCheck == FAX_CH || nCheck == SOFTFAX_CH)
&& m_FaxCh[i].nStep == FAX_IDLE && m_FaxCh[i].bUseful == FALSE)
return i;
}
return -1;
}
//Chinese: 搜索空闲中继通道
//English: search for idle trunk channel
int CFax_Polling_VCDlg::FindAnIdleTrunkCh()
{
for(int i = 0; i < m_nTotalCh; i++)
{
if(m_TrkCh[i].bEnCalled == TRUE && m_TrkCh[i].bUseful == FALSE
&& m_TrkCh[i].nStep == TRK_IDLE)
return i;
}
return -1;
}
void CFax_Polling_VCDlg::OnSelchangeComboTrkch()
{
// TODO: Add your control notification handler code here
char sz[50];
m_cmbTrkChNo.GetLBText(m_cmbTrkChNo.GetCurSel(), sz);
int n = atoi(sz);
m_nAutoOrNot = m_TrkCh[n].nAutoOrNot;
UpdateData(FALSE);
}
//Chinese: 设置传真ID
//English: set ID of fax machine
void CFax_Polling_VCDlg::OnButtonSetId()
{
// TODO: Add your control notification handler code here
char sz[50];
char str[50];
m_cmbFaxCh.GetLBText(m_cmbFaxCh.GetCurSel(), sz);
int n = atoi(sz);
strcpy(str, m_strSetId.GetBuffer(m_strSetId.GetLength()));
m_strSetId.ReleaseBuffer();
if(SsmFaxSetID(n, str) == -1)
WriteLog("Fail to call SsmFaxSetID");
}
void CFax_Polling_VCDlg::OnChangeEditSetId()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
UpdateData(TRUE);
}
void CFax_Polling_VCDlg::OnDestroy()
{
CDialog::OnDestroy();
// TODO: Add your message handler code here
//Chinese: 卸载已经装载到内存的语音片段数据
//English: unload speech data loaded in the memory
SsmFreeIndexData(1);
SsmFreeIndexData(2);
//close board drivers
if(SsmCloseCti() == -1)
WriteLog("Failed to call SsmCloseCti");
}
//LRESULT CFax_Polling_VCDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
//{
// TODO: Add your specialized code here and/or call the base class
/*
int nEventCode; //event ID
int nCh; //channel ID
int nCheck;
if(message > WM_USER)
{
nEventCode = message - WM_USER;
if(nEventCode == E_SYS_TIMEOUT)
{
//Chinese: 根据定时器标识号辨别通道号
//English: identify the channel number according to the flag 'timer'
for(int i = 0; i < m_nTotalCh; i++)
{
if(wParam == (WPARAM)(m_TrkCh[i].nTimer))
{
nCh = i;
break;
}
}
}
else
nCh = wParam;
nCheck = SsmGetChType(nCh);
if(nCheck == -1)
{
WriteLog("Fail to call SsmGetChType");
}
else if(nCheck == FAX_CH || nCheck == SOFTFAX_CH)
{
FaxProc(nEventCode, nCh, lParam);
}
else
{
if(m_TrkCh[nCh].bEnCalled == TRUE)
{
TrunkProc(nEventCode, nCh, lParam);
}
}
UpdateFaxChListCtrl();
UpdateTrunkChListCtrl();
}
*/
// return CDialog::WindowProc(message, wParam, lParam);
//}
void CFax_Polling_VCDlg::TrunkProc(UINT event, WPARAM wParam, LPARAM lParam)
{
int nCh;
int nChannel;
char szRecFile[250];
DWORD dwDtmf;
DWORD dwToneAnalyze;
int i;
char temp[1];
int nNewState;
nCh = wParam;
switch(event)
{
case E_CHG_ChState:
{
nNewState = (int)(lParam & 0xFFFF); //new state
if(nNewState == S_CALL_RINGING) //ring detected
{
if(m_TrkCh[nCh].nStep == TRK_IDLE)
{
m_TrkCh[nCh].bUseful = TRUE;
if(SsmPickup(nCh) == -1) //pick up
WriteLog("Fail to call SsmPickup");
m_TrkCh[nCh].nCallFlag = 0;
sprintf(szRecFile,"channel%d.pcm", nCh);
if(m_TrkCh[nCh].bRecord)
{
if(SsmRecToFile(nCh, szRecFile, -1, 0, -1, -1, 0) == -1) //record
WriteLog("Fail to call SsmRecToFile");
//Chinese: 打开混音器开关
//English: turn on record mixer
if(SsmSetRecMixer(nCh, 1, 0) == -1)
WriteLog("Fail to call SsmSetRecMixer");
}
if(SsmGetCallerId(nCh, m_TrkCh[nCh].szCallerId) == -1)
WriteLog("Fail to call SsmGetCallerId");
CString str;
m_SecondDlg.m_cmbFaxCh.GetWindowText(str);
if(str == "None")
nChannel = -1;
else
nChannel = atoi(str);
if(nChannel != -1)
{
if(m_FaxCh[nChannel].nStep != FAX_IDLE || m_FaxCh[nChannel].bUseful == TRUE)
{
if((nChannel = FindAnIdleFaxCh()) == -1)
{
//Chinese: 无空闲传真通道
//English: idle fax channel is unavailable
Hangup(nCh);
break;
}
}
}
else
{
if((nChannel = FindAnIdleFaxCh()) == -1)
{
//Chinese: 无空闲传真通道
//English: idle fax channel is unavailable
Hangup(nCh);
break;
}
}
//Chinese: 有空闲传真通道
//English: idle fax channel is available
m_FaxCh[nChannel].bUseful = TRUE;
//Chinese: 提示传真收发
//English: manual
if(m_TrkCh[nCh].nAutoOrNot)
{
m_TrkCh[nCh].nStep = TRK_PLAY_VOC1;
m_TrkCh[nCh].nToFaxCh = nChannel;
m_TrkCh[nCh].bLinked = TRUE;
m_FaxCh[nChannel].nTrunkCh = nCh;
//Chinese: 打开通道的抢拨开关
//English: turn on 'DTMF_stop_play' switch
if(SsmSetDtmfStopPlay(nCh, 1) == -1)
WriteLog("Fail to call SsmSetDtmfStopPlay");
if(SsmPlayIndexString(nCh, "1") == -1) //play voice 1
WriteLog("Fail to call SsmPlayIndexString");
if(SsmClearRxDtmfBuf(nCh) == -1) //Clear buffer
WriteLog("Fail to call SsmClearRxDtmfBuf");
//Chinese: 开启定时器
//English: turn on timer
if((m_TrkCh[nCh].nTimer = SsmStartTimer(15000, 1)) == -1)
WriteLog("Fail to call SsmStartTimer");
}
//Chinese: 自动收发
//English: automatic
else
{
m_TrkCh[nCh].nToFaxCh = nChannel;
m_TrkCh[nCh].bLinked = TRUE;
m_FaxCh[nChannel].nDirection = C_RECEIVE_FAX; //receive
m_FaxCh[nChannel].nTrunkCh = nCh;
m_TrkCh[nCh].nStep = TRK_FAXING;
//Chinese: 建立传真通道与中继通道的总线连接
//English: set up bus connection between fax and trunk channel
if(SsmTalkWith(nCh, nChannel) == -1)
WriteLog("Fail to call SsmTalkWith");
FaxProc(E_MSG_RCV_FAX, nChannel, nCh);
// SendMessage(WM_USER+E_MSG_RCV_FAX, nChannel, nCh);
}
}
}
//Chinese: 远端挂机
//English: remote hungup
else if(nNewState == S_CALL_PENDING)
{
if(m_TrkCh[nCh].nStep == TRK_PLAY_VOC1)
{
//Chinese: 关闭定时器
//English: turn off timer
if(SsmStopTimer(m_TrkCh[nCh].nTimer) == -1)
WriteLog("Fail to call SsmStopTimer");
m_TrkCh[nCh].nTimer = -1;
if(SsmStopPlayIndex(nCh) == -1)
WriteLog("Fail to call SsmStopPlayIndex");
}
else if(m_TrkCh[nCh].nStep == TRK_PLAY_VOC2)
{
if(SsmStopPlayIndex(nCh) == -1)
WriteLog("Fail to call SsmStopPlayIndex");
}
else if(m_TrkCh[nCh].nStep == TRK_FAXING)
{
//Chinese: 断开传真通道与中继通道的总线连接
//English: tear down bus connection between fax and trunk channel
if(SsmStopTalkWith(nCh, m_TrkCh[nCh].nToFaxCh) == -1)
WriteLog("Fail to call SsmStopTalkWith");
FaxProc(E_MSG_OFFLINE, m_TrkCh[nCh].nToFaxCh, NULL);
// SendMessage(WM_USER+E_MSG_OFFLINE, m_TrkCh[nCh].nToFaxCh, NULL);
}
Hangup(nCh);
}
}
break;
//Chinese: 收到DTMF码之事件
//English: event generated by the driver when DTMF is received
case E_CHG_RcvDTMF:
{
dwDtmf = lParam & 0xFFFF; //the latest DTMF received
*temp = (char)dwDtmf;
m_TrkCh[nCh].szDtmf[m_TrkCh[nCh].nIndex++] = *temp;
if(m_TrkCh[nCh].nIndex >= 99)
{
m_TrkCh[nCh].nIndex = 0;
}
m_TrkCh[nCh].szDtmf[m_TrkCh[nCh].nIndex] = 0;
if((*temp) == '1' || (*temp) == '2')
{
if(m_TrkCh[nCh].nStep == TRK_PLAY_VOC1)
{
m_TrkCh[nCh].nFirstDtmf++;
if(m_TrkCh[nCh].nFirstDtmf == 1)
{
*m_TrkCh[nCh].szDtmfChose = *temp;
if(SsmPlayIndexString(nCh, "2") == -1) //play voice 2
WriteLog("Fail to call SsmPlayIndexString");
if(SsmStopTimer(m_TrkCh[nCh].nTimer) == -1)
WriteLog("Fail to call SsmStopTimer");
m_TrkCh[nCh].nTimer = -1;
m_TrkCh[nCh].nStep = TRK_PLAY_VOC2;
}
}
}
}
break;
//Chinese: 定时器超时事件
//English: event generated by the driver when the timer is overtime
case E_SYS_TIMEOUT:
{
if(SsmStopTimer(m_TrkCh[nCh].nTimer) == -1)
WriteLog("Fail to call SsmStopTimer");
m_TrkCh[nCh].nTimer = -1;
Hangup(nCh);
}
//Chinese: 信号音分析结果变化事件
//English: event generated by the driver when the result of tone analysis changes
case E_CHG_ToneAnalyze:
{
dwToneAnalyze = lParam & 0xFFFF; //the result of tone analysis
i = dwToneAnalyze;
if(i == 7) //F1 tone
{
if(m_TrkCh[nCh].nStep == TRK_PLAY_VOC1
|| m_TrkCh[nCh].nStep == TRK_PLAY_VOC2)
{
if(m_TrkCh[nCh].nStep == TRK_PLAY_VOC1)
{
if(SsmStopTimer(m_TrkCh[nCh].nTimer) == -1)
WriteLog("Fail to call SsmStopTimer");
m_TrkCh[nCh].nTimer = -1;
}
m_FaxCh[m_TrkCh[nCh].nToFaxCh].nDirection = C_RECEIVE_FAX; //receive
if(SsmStopPlayIndex(nCh) == -1) //stop playing
WriteLog("Fail to call SsmStopPlayIndex");
if(SsmTalkWith(nCh, m_TrkCh[nCh].nToFaxCh) == -1)
WriteLog("Fail to call SsmTalkWith");
m_FaxCh[m_TrkCh[nCh].nToFaxCh].nAnswered = 1;
m_TrkCh[nCh].nStep = TRK_FAXING;
FaxProc(E_MSG_RCV_FAX, m_TrkCh[nCh].nToFaxCh, nCh);
// SendMessage(WM_USER+E_MSG_RCV_FAX, m_TrkCh[nCh].nToFaxCh, nCh);
}
else if(m_TrkCh[nCh].nStep == TRK_FAXING)
{
m_FaxCh[m_TrkCh[nCh].nToFaxCh].nAnswered = 1;
}
}
else if(i == 8) //F2 tone
{
if(m_TrkCh[nCh].nStep == TRK_PLAY_VOC1
|| m_TrkCh[nCh].nStep == TRK_PLAY_VOC2)
{
if(m_TrkCh[nCh].nStep == TRK_PLAY_VOC1)
{
if(SsmStopTimer(m_TrkCh[nCh].nTimer) == -1)
WriteLog("Fail to call SsmStopTimer");
m_TrkCh[nCh].nTimer = -1;
}
m_FaxCh[nCh].nDirection = C_SEND_FAX; //send
if(SsmStopPlayIndex(i) == -1) //stop playing
WriteLog("Fail to call SsmStopPlayIndex");
if(SsmTalkWith(i, nCh) == -1)
WriteLog("Fail to call SsmTalkWith");
m_FaxCh[nCh].nAnswered = 1;
m_TrkCh[i].nStep = TRK_FAXING;
FaxProc(E_MSG_SEND_FAX, m_TrkCh[nCh].nToFaxCh, nCh);
// SendMessage(WM_USER+E_MSG_SEND_FAX, m_TrkCh[nCh].nToFaxCh, nCh);
}
else if(m_TrkCh[nCh].nStep == TRK_FAXING)
{
m_FaxCh[m_TrkCh[nCh].nToFaxCh].nAnswered = 1;
}
}
}
break;
//Chinese: 放音结束事件
//English: event generated by the driver when the playing stops
case E_PROC_PlayEnd:
{
if(m_TrkCh[nCh].nStep == TRK_PLAY_VOC2)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -