📄 form1.vb
字号:
ChannelState(i).IsListen = UNLISTEN 'UNLISTEN
ChannelState(i).IsRecord = UNRECORD 'Unrecord
ChannelState(i).pCallId = New Byte(MAX_CALLID_LEN) {} 'Phone number is null
ChannelState(i).Lcd = New Byte(MAX_LCD_LEN) {} 'LCD info is null
ChannelState(i).Dir = UNKNOWN 'Call direction is "UNKNOWN"
ComboBox1.Items.Add(i.ToString())
Else
ChannelState(i).WorkState = -1 'Off line state
ChannelState(i).IsListen = -1 'UNLISTEN
ChannelState(i).IsRecord = -1 'Unrecord
ChannelState(i).Dir = -1 'Call direction is "UNKNOWN"
End If
nChState = SsmGetChState(i) 'Get the state of current channel. -1:error
If (nChState = -1) Then
MsgBox(SsmGetLastErrMsgA())
End If
If (nChState = TRUNK_STATUS.S_CALL_OFFLINE) Then 'Off line state
ChannelState(i).WorkState = CH_OFFLINE
End If
Next
End Sub
Public Sub UpdateChannelState()
Dim nTemp As Int32
Dim str As String
Dim i As Int32
Dim lvi As ListViewItem
Dim lvsi As ListViewItem.ListViewSubItem
Me.ListView1.Items.Clear()
Me.ListView1.BeginUpdate()
For i = 0 To MaxLine - 1
nTemp = SsmGetChType(i)
If (nTemp = -1) Then
MessageBox.Show("Fail to call SsmGetChType")
ElseIf (nTemp = 12) Then
lvi = New ListViewItem
lvi.Text = i.ToString()
Select Case (ChannelState(i).WorkState)
Case CH_IDLE
str = "Idle"
Case CH_RING
str = "Ringing"
Case CH_ACTIVE
str = "Active"
Case CH_OFFLINE
str = "Offline"
Case CH_WAITFOR_ONHOOK
str = "WaitforOnhook"
End Select
lvsi = New ListViewItem.ListViewSubItem
lvsi.Text = str
lvi.SubItems.Add(lvsi)
str = ""
Select Case (ChannelState(i).IsListen)
Case LISTEN
str = "Listen"
Case UNLISTEN
str = "UNLISTEN"
End Select
lvsi = New ListViewItem.ListViewSubItem
lvsi.Text = str
lvi.SubItems.Add(lvsi)
str = ""
Select Case (ChannelState(i).IsRecord)
Case UNRECORD
str = "Unrecord"
Case RECORD
str = "Record"
End Select
lvsi = New ListViewItem.ListViewSubItem
lvsi.Text = str
lvi.SubItems.Add(lvsi)
lvsi = New ListViewItem.ListViewSubItem
str = ""
str = System.Text.Encoding.ASCII.GetString(ChannelState(i).pCallId)
lvsi.Text = str
lvi.SubItems.Add(lvsi)
lvsi = New ListViewItem.ListViewSubItem
str = ""
str = System.Text.Encoding.ASCII.GetString(ChannelState(i).Lcd)
lvsi.Text = str
lvi.SubItems.Add(lvsi)
str = ""
Select Case (ChannelState(i).Dir)
Case UNKNOWN
str = "Unknown"
Case UP
str = "Call out"
Case DOWN
str = "Call in"
End Select
lvsi = New ListViewItem.ListViewSubItem
lvsi.Text = str
lvi.SubItems.Add(lvsi)
Me.ListView1.Items.Add(lvi)
End If
Next
Me.ListView1.EndUpdate()
End Sub
Public Sub GetCallID(ByRef pEvent As SSM_EVENT)
Dim ch As Int32
Dim IDPos As Int32
Dim LCDPos As Int32
Dim NumStarPos As Int32
Dim NumStopPos As Int32
NumStarPos = 0
NumStopPos = 0
ch = pEvent.nReference
If (ChannelState(ch).LCDLen < 2) Then
Return
End If
LCDPos = ChannelState(ch).LCDLen - 1
IDPos = 0
'find the number's start position and end position in the LCD information;
Do While (LCDPos > 0)
If (NumStopPos = 0) Then
If (ChannelState(ch).Lcd(LCDPos) < &H39 And ChannelState(ch).Lcd(LCDPos) > &H30) Then
NumStopPos = LCDPos
End If
Else
If (ChannelState(ch).Lcd(LCDPos) > &H39 Or ChannelState(ch).Lcd(LCDPos) < &H30) Then
NumStarPos = LCDPos + 1
Exit Do
End If
End If
LCDPos = LCDPos - 1
Loop
If ((NumStarPos = 0) And (NumStopPos = 0) And (ChannelState(ch).Lcd(0) > &H39 And ChannelState(ch).Lcd(0) < &H30)) Then
Return ' not found any number;
End If
ChannelState(ch).CallIdLen = NumStopPos - NumStarPos + 1
For IDPos = 0 To ChannelState(ch).CallIdLen - 1
ChannelState(ch).pCallId(IDPos) = ChannelState(ch).Lcd(NumStarPos)
NumStarPos = NumStarPos + 1
Next
ChannelState(ch).pCallId(IDPos) = 0
End Sub
Public Sub ClearCallID(ByRef pEvent As SSM_EVENT)
Dim ch As Int32
ch = pEvent.nReference
ChannelState(ch).pCallId = New Byte(MAX_CALLID_LEN) {}
End Sub
Public Sub StartRecord(ByVal ch As Int32)
Dim recFile As String
recFile = "Test" + ch.ToString() + ".wav"
'Start the file sound recording task on the designates channel. -1:error
If (SsmRecToFile(ch, recFile, nRecFormat, 0, -1, 0, 0) = -1) Then
MsgBox(SsmGetLastErrMsgA())
End If
ChannelState(ch).IsRecord = RECORD
End Sub
Public Sub StopRecord(ByVal ch As Int32)
Dim nreChkRecToFile As Int32
ChannelState(ch).IsRecord = UNRECORD
'Obtains the situation of the file sound recording task. -1:error
nreChkRecToFile = SsmChkRecToFile(ch)
If (nreChkRecToFile = -1) Then
MsgBox(SsmGetLastErrMsgA())
End If
If (nreChkRecToFile = 1) Then '1:Recording
'Stop the file sound recording task. -1:error
If (SsmStopRecToFile(ch) = -1) Then
MsgBox(SsmGetLastErrMsgA())
End If
End If
End Sub
Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
UpdateChannelState()
End Sub
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
nRecFormat = -1
End Sub
Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
nRecFormat = 6
End Sub
Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
nRecFormat = 7
End Sub
Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged
nRecFormat = 17
End Sub
Private Sub RadioButton5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton5.CheckedChanged
nRecFormat = 131
End Sub
Private Sub RadioButton6_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton6.CheckedChanged
nRecFormat = &HFF83
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If (ComboBox1.Text = "") Then
Return
End If
Dim Cur_Line As Int32
Cur_Line = Convert.ToInt32(ComboBox1.Text)
If (ListenChannel <> Cur_Line) Then
If (ListenChannel < MaxLine) Then
If (SsmStopListenTo(ListenChannel, 0) = -1) Then 'Stop listen
MessageBox.Show(SsmGetLastErrMsgA())
Return
End If
ChannelState(ListenChannel).IsListen = UNLISTEN
End If
If (SsmListenTo(Cur_Line, 0) = -1) Then 'Listen
MessageBox.Show(SsmGetLastErrMsgA())
Return
End If
ChannelState(Cur_Line).IsListen = LISTEN
ListenChannel = Cur_Line
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If (ListenChannel < MaxLine) Then
ChannelState(ListenChannel).IsListen = UNLISTEN
If (SsmStopListenTo(ListenChannel, 0) = -1) Then 'Stop listen
MessageBox.Show(SsmGetLastErrMsgA())
End If
ListenChannel = MaxLine
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -