📄 form1.vb
字号:
'Update list
Sub UpdateCircuitListCtrl()
Dim szNewStat As String = "" '[100];
Dim szOldStat As String = "" '[100];
Dim nIndex As Int32
Dim i As Int32
nIndex = 0
For i = 0 To nMaxCic - 1
'Display the state of the monitored circuit
Select Case (CicState(i).nCicState)
Case EnumCicState.CIRCUIT_IDLE
szNewStat = "Idle"
Case EnumCicState.CIRCUIT_RCV_PHONUM
szNewStat = "Receiving Phone number"
Case EnumCicState.CIRCUIT_RINGING
szNewStat = "Ringing"
Case EnumCicState.CIRCUIT_TALKING
szNewStat = "Talking"
End Select
szOldStat = m_CicList.get_TextMatrix(nIndex + 1, 1)
If (szOldStat.Equals(szNewStat) = False) Then
m_CicList.set_TextMatrix(nIndex + 1, 1, szNewStat)
End If
'Display calling party number
szOldStat = m_CicList.get_TextMatrix(nIndex + 1, 2)
If (szOldStat.Equals(CicState(i).szCallerId.ToString()) = False) Then
m_CicList.set_TextMatrix(nIndex + 1, 2, CicState(i).szCallerId.ToString())
End If
'Display called party number
szOldStat = m_CicList.get_TextMatrix(nIndex + 1, 3)
If (szOldStat.Equals(CicState(i).szCalleeId.ToString()) = False) Then
m_CicList.set_TextMatrix(nIndex + 1, 3, CicState(i).szCalleeId.ToString())
End If
'Display incoming channel and received DTMFs in the channel
szNewStat = CicState(i).nCallInCh.ToString() + ":" + CicState(i).szCallInDtmf
szOldStat = m_CicList.get_TextMatrix(nIndex + 1, 4)
If (szOldStat.Equals(szNewStat) = False) Then
m_CicList.set_TextMatrix(nIndex + 1, 4, szNewStat)
End If
'Display outgoing channel and received DTMFs in the channel
szNewStat = CicState(i).nCallOutCh.ToString() + ":" + CicState(i).szCallOutDtmf
szOldStat = m_CicList.get_TextMatrix(nIndex + 1, 5)
If (szOldStat.Equals(szNewStat) = False) Then
m_CicList.set_TextMatrix(nIndex + 1, 5, szNewStat)
End If
nIndex = nIndex + 1
Next i
End Sub
Protected Overrides Sub WndProc(ByRef uMsg As System.Windows.Forms.Message)
Dim nCic As Int32
Dim nCh As Int32
Dim cNewDtmf As Char
Dim nEventCode As Int32
Dim nNewState As Int32
Dim nDtmf As Int32
'message = uMsg.Msg
'Adopt windows message mechanism
' windows message code:event code + 0x7000(WM_USER)
If (uMsg.Msg > WM_USER) Then
nEventCode = uMsg.Msg - WM_USER
'Event notifying the state change of the monitored circuit
If (nEventCode = ShEvent.E_CHG_SpyState) Then
nCic = uMsg.WParam.ToInt32
nNewState = (uMsg.LParam.ToInt32() And &HFFFF&)
If (nCic >= 0 And nCic < 1000) Then
Select Case (nNewState)
'Idle state
Case ChState.S_SPY_STANDBY
If (CicState(nCic).nCicState = EnumCicState.CIRCUIT_TALKING) Then
'Call the function with circuit number as its parameter
If (m_nCallFnMode = 0) Then
'stop recording
If (SpyStopRecToFile(nCic) = -1) Then
'MessageBox.Show("Fail to call SpyStopRecToFile")
End If
'Call the function with channel number as its parameter
Else
If (CicState(nCic).wRecDirection = EnumRecDir.CALL_IN_RECORD) Then
If (SsmStopRecToFile(CicState(nCic).nCallInCh) = -1) Then
'MessageBox.Show("Fail to call SsmStopRecToFile")
End If
ElseIf (CicState(nCic).wRecDirection = EnumRecDir.CALL_OUT_RECORD) Then
If (SsmStopRecToFile(CicState(nCic).nCallOutCh) = -1) Then
'MessageBox.Show("Fail to call SsmStopRecToFile")
End If
Else
If (SsmSetRecMixer(CicState(nCic).nCallInCh, False, 0) = -1) Then 'Turn off the record mixer
'MessageBox.Show("Fail to call SsmSetRecMixer")
End If
If (SsmStopLinkFrom(CicState(nCic).nCallOutCh, CicState(nCic).nCallInCh) = -1) Then 'Cut off the bus connect from outgoing channel to incoming channel
'Dim stbTemp As New System.Text.StringBuilder(500)
'SsmGetLastErrMsg(stbTemp)
'MessageBox.Show(stbTemp.ToString())
'MessageBox.Show("Fail to call SsmStopLinkFrom")
End If
If (SsmStopRecToFile(CicState(nCic).nCallInCh) = -1) Then 'Stop recording
'MessageBox.Show("Fail to call SsmStopRecToFile")
End If
End If
End If
End If
CicState(nCic).nCicState = EnumCicState.CIRCUIT_IDLE
CicState(nCic).nCallInIndex = 0
CicState(nCic).nCallOutIndex = 0
CicState(nCic).szCallInDtmf = ""
CicState(nCic).szCallOutDtmf = ""
'Receiving phone number
Case ChState.S_SPY_RCVPHONUM
If (CicState(nCic).nCicState = EnumCicState.CIRCUIT_IDLE) Then
CicState(nCic).nCicState = EnumCicState.CIRCUIT_RCV_PHONUM
End If
'Ringing
Case ChState.S_SPY_RINGING
CicState(nCic).nCicState = EnumCicState.CIRCUIT_RINGING
CicState(nCic).szCallerId.Remove(0, CicState(nCic).szCallerId.Length)
CicState(nCic).szCalleeId.Remove(0, CicState(nCic).szCalleeId.Length)
If (SpyGetCallerId(nCic, CicState(nCic).szCallerId) = -1) Then 'Get calling party number
MessageBox.Show("Fail to call SpyGetCallerId")
End If
If (SpyGetCalleeId(nCic, CicState(nCic).szCalleeId) = -1) Then 'Get called party number
MessageBox.Show("Fail to call SpyGetCalleeId")
End If
'Talking
Case ChState.S_SPY_TALKING
If (CicState(nCic).nCicState = EnumCicState.CIRCUIT_RCV_PHONUM) Then
CicState(nCic).szCallerId.Remove(0, CicState(nCic).szCallerId.Length)
CicState(nCic).szCalleeId.Remove(0, CicState(nCic).szCalleeId.Length)
If (SpyGetCallerId(nCic, CicState(nCic).szCallerId) = -1) Then
MessageBox.Show("Fail to call SpyGetCallerId")
End If
If (SpyGetCalleeId(nCic, CicState(nCic).szCalleeId) = -1) Then
MessageBox.Show("Fail to call SpyGetCalleeId")
End If
End If
CicState(nCic).nCallInCh = SpyGetCallInCh(nCic)
If (CicState(nCic).nCallInCh = -1) Then 'Get the number of incoming channel
MessageBox.Show("Fail to call SpyGetCallInCh")
End If
CicState(nCic).nCallOutCh = SpyGetCallOutCh(nCic)
If (CicState(nCic).nCallOutCh = -1) Then 'Get the number of outgoing channel
MessageBox.Show("Fail to call SpyGetCallOutCh")
End If
CicState(nCic).nCicState = EnumCicState.CIRCUIT_TALKING
'Start recording
'Record file name + Monitored circuit number + Time(hour-minute-second)
'CString strRecFile;
'SYSTEMTIME st;
'char szTemp[50];
'GetLocalTime(&st);
'strRecFile.Format("Rec%d-%d-%d-%d.wav", nCic, st.wHour, st.wMinute, st.wSecond);
'strcpy(szTemp, strRecFile.GetBuffer(strRecFile.GetLength()));
'strRecFile.ReleaseBuffer();
Dim szTemp As String
Dim dt As DateTime = DateTime.Now
szTemp = "Rec" + nCic.ToString() + "-" + dt.Hour.ToString() + "-" + dt.Minute.ToString() + "-" + dt.Second.ToString() + ".wav"
If (m_nCallFnMode = 0) Then 'Call the function with circuit number as its parameter
If (SpyRecToFile(nCic, CicState(nCic).wRecDirection, szTemp, -1, 0L, -1, -1, 0) = -1) Then
'MessageBox.Show("Fail to call SpyRecToFile")
End If
Else 'Call the function with channel number as its parameter
If (CicState(nCic).wRecDirection = EnumRecDir.CALL_IN_RECORD) Then
If (SsmRecToFile(CicState(nCic).nCallInCh, szTemp, -1, 0L, -1, -1, 0) = -1) Then
'MessageBox.Show("Fail to call SsmRecToFile")
End If
ElseIf (CicState(nCic).wRecDirection = EnumRecDir.CALL_OUT_RECORD) Then
If (SsmRecToFile(CicState(nCic).nCallOutCh, szTemp, -1, 0L, -1, -1, 0) = -1) Then
'MessageBox.Show("Fail to call SsmRecToFile")
End If
Else
If (SsmLinkFrom(CicState(nCic).nCallOutCh, CicState(nCic).nCallInCh) = -1) Then 'Connect the bus from outgoing channel to incoming channel
'MessageBox.Show("Fail to call SsmLinkFrom")
End If
If (SsmSetRecMixer(CicState(nCic).nCallInCh, True, 0) = -1) Then 'Turn on the record mixer
'MessageBox.Show("Fail to call SsmSetRecMixer")
End If
If (SsmRecToFile(CicState(nCic).nCallInCh, szTemp, -1, 0L, -1, -1, 0) = -1) Then 'Recording
'MessageBox.Show("Fail to call SsmRecToFile")
End If
End If
End If
End Select
End If
'Event generated by the driver when DTMF is received
ElseIf (nEventCode = ShEvent.E_CHG_RcvDTMF) Then
nCh = uMsg.WParam.ToInt32()
'Switching from channel number to circuit number
nCic = SpyChToCic(nCh)
If (nCic = -1) Then
MessageBox.Show("Fail to call SpyChToCic")
End If
If (nCic <> -1) Then
Dim NTEM As Int32 = CicState(nCic).nCicState
If (CicState(nCic).nCicState = EnumCicState.CIRCUIT_TALKING) Then
nDtmf = &HFFFF& And uMsg.LParam.ToInt32()
cNewDtmf = Chr(nDtmf) 'Newly received DTMF
If (nCh = CicState(nCic).nCallInCh) Then
CicState(nCic).szCallInDtmf = CicState(nCic).szCallInDtmf + cNewDtmf
'CicState(nCic).szCallInDtmf(CicState(nCic).nCallInIndex) = cNewDtmf
CicState(nCic).nCallInIndex = CicState(nCic).nCallInIndex + 1
ElseIf (nCh = CicState(nCic).nCallOutCh) Then
CicState(nCic).szCallOutDtmf = CicState(nCic).szCallOutDtmf + cNewDtmf
'CicState(nCic).szCallOutDtmf(CicState(nCic).nCallOutIndex) = cNewDtmf
CicState(nCic).nCallOutIndex = CicState(nCic).nCallOutIndex + 1
End If
End If
End If
End If
UpdateCircuitListCtrl()
End If
MyBase.WndProc(uMsg)
End Sub
Private Sub m_bCallFnMode_Cic_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles m_bCallFnMode_Cic.CheckedChanged
If (Me.m_bCallFnMode_Cic.Checked = True) Then
m_nCallFnMode = 0
End If
End Sub
Private Sub m_bCallFnMode_Ch_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles m_bCallFnMode_Ch.CheckedChanged
If (Me.m_bCallFnMode_Ch.Checked = True) Then
m_nCallFnMode = 1
End If
End Sub
Private Sub m_bRecFormat_In_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles m_bRecFormat_In.CheckedChanged
If (Me.m_bRecFormat_In.Checked = True) Then
Dim nCurLine As Int32
Dim sz As String = m_cmbCic.Text '.SelectedText
If sz = "" Then
Return
End If
nCurLine = Int32.Parse(sz)
CicState(nCurLine).wRecDirection = EnumRecDir.CALL_IN_RECORD
End If
End Sub
Private Sub m_bRecFormat_Out_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles m_bRecFormat_Out.CheckedChanged
If (Me.m_bRecFormat_Out.Checked = True) Then
Dim nCurLine As Int32
Dim sz As String = m_cmbCic.Text '.SelectedText
If sz = "" Then
Return
End If
nCurLine = Int32.Parse(sz)
CicState(nCurLine).wRecDirection = EnumRecDir.CALL_OUT_RECORD
End If
End Sub
Private Sub m_bRecFormat_Mix_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles m_bRecFormat_Mix.CheckedChanged
If (Me.m_bRecFormat_Mix.Checked = True) Then
Dim nCurLine As Int32
Dim sz As String = m_cmbCic.Text '.SelectedText
If sz = "" Then
Return
End If
nCurLine = Int32.Parse(sz)
CicState(nCurLine).wRecDirection = EnumRecDir.MIX_RECORD
End If
End Sub
Private Sub m_cmbCic_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles m_cmbCic.SelectedIndexChanged
Dim nCurLine As Int32
Dim sz As String = m_cmbCic.Text '.SelectedText
nCurLine = Int32.Parse(sz)
Select Case (CicState(nCurLine).wRecDirection)
Case EnumRecDir.CALL_IN_RECORD
m_bRecFormat_In.Checked = True 'm_nRecFormat = 0
Case EnumRecDir.CALL_OUT_RECORD
m_bRecFormat_Out.Checked = True 'm_nRecFormat = 1
Case EnumRecDir.MIX_RECORD
m_bRecFormat_Mix.Checked = True 'm_nRecFormat = 2
End Select
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -