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

📄 record.bas

📁 三汇CTI示例程序源码
💻 BAS
字号:
Attribute VB_Name = "Record"
Global MaxLine As Integer
Global Const TRK_IDLE = 0              'Idle
Global Const TRK_PICKUP = 1            'OffHook
Global Const TRK_RECORD = 2            'Recording
Global Const TRK_OUTLINE = 3           'OffLine
Global Const TRK_RINGING = 4           'Ringing
Global Const TRK_ElSE = 5              'Undefined
Global Const NoListen = 0              'ListenStopped
Global Const Listen = 1                'Listening
Global Const SHENGKONG = 0
Global Const YAKONG = 1
Global Const MAKONG = 2
Global ListenChannel As Integer        'ListenChannel
Type TRK_STATE
     State As Integer                 'ChannelState
     ConState As Integer
     ListenState As Integer           'ListenState
     pErrMsg As String * 200
     dwTimeOutCounter As Long
End Type
Global ChannelState(0 To 200) As TRK_STATE
Public Function InitCtiSystem() As Boolean
    Dim ErrMsg As String * 200
    Dim VerMsg As String * 200
    If SsmStartCti("ShConfig.ini", "ShIndex.ini") <> 0 Then
        'to retrieve error message at initialization phrase
        SsmGetLastErrMsg ErrMsg
        MsgBox ErrMsg
        InitCtiSystem = False
    Else
         InitCtiSystem = True
    End If
    If SsmGetMaxUsableBoard() = SsmGetMaxCfgBoard() Then
         MaxLine = SsmGetMaxCh()
    End If
End Function
Public Sub InitTrkChannelList()
   Dim I As Integer
   Dim theIndex As Integer
   MainForm!StateGrid.Cols = 8
   MainForm!StateGrid.Row = 0
   MainForm!StateGrid.Col = 0
   MainForm!StateGrid.Text = "Channel"
   MainForm!StateGrid.Col = 1
   MainForm!StateGrid.Text = "ChannelState"
   MainForm!StateGrid.Col = 2
   MainForm!StateGrid.Text = "Working"
   MainForm!StateGrid.Col = 3
   MainForm!StateGrid.Text = "StartKey"
   MainForm!StateGrid.Col = 4
   MainForm!StateGrid.Text = "Listening"
   MainForm!StateGrid.Col = 5
   MainForm!StateGrid.Text = "RxDTMF"
   MainForm!StateGrid.Col = 6
   MainForm!StateGrid.Text = "CallerId"
   MainForm!StateGrid.Col = 7
   MainForm!StateGrid.Text = "ErrorMsg"
   MainForm!StateGrid.ColWidth(0) = 36 * 12
   MainForm!StateGrid.ColWidth(1) = 85 * 12
   MainForm!StateGrid.ColWidth(2) = 70 * 12
   MainForm!StateGrid.ColWidth(3) = 70 * 12
   MainForm!StateGrid.ColWidth(4) = 70 * 12
   MainForm!StateGrid.ColWidth(5) = 70 * 12
   MainForm!StateGrid.ColWidth(6) = 70 * 12
   MainForm!StateGrid.ColWidth(7) = 350 * 12
   MainForm!StateGrid.Rows = 1
   For I = 0 To MaxLine - 1
     If SsmGetChType(I) = 3 Then MainForm!StateGrid.AddItem (Str(I))
   Next I
End Sub

Public Sub UpdateChannelState()
   Dim I As Integer
   Dim TempStr As String * 20
   Dim OldDtmf As String * 200
   Dim NewDtmf As String * 200
   Dim NewCallerId As String * 200
   Dim State As String
   Dim nResult As Integer
   Dim theIndex As Integer
   Dim Num As Integer
   Num = 0
   For I = 0 To MaxLine - 1
      If SsmGetChType(I) = 3 Then
        theIndex = MainForm!StateGrid.Cols * (Num + 1) + 1
        Select Case ChannelState(I).State
          Case TRK_IDLE:           State = "Idle"
          Case TRK_PICKUP:         State = "OffHook"
          Case TRK_RECORD:         State = "Recording"
          Case TRK_OUTLINE:        State = "OffLine"
          Case TRK_RINGING:        State = "Ringing"    'added by jyp, 2008.3.18
          Case Else:               State = "Undefined"
        End Select
        If MainForm!StateGrid.TextArray(theIndex) <> State Then MainForm!StateGrid.TextArray(theIndex) = State
        theIndex = theIndex + 1
        Select Case ChannelState(I).ConState
            Case SHENGKONG:            State = "VoiceControl"
            Case YAKONG:               State = "VolatageControl"
            Case MAKONG:               State = "CodeControl"
        End Select
        If MainForm!StateGrid.TextArray(theIndex) <> State Then MainForm!StateGrid.TextArray(theIndex) = State
           theIndex = theIndex + 1
        If ChannelState(I).ConState = MAKONG Then
            MainForm!StateGrid.TextArray(theIndex) = "*"
        Else
            MainForm!StateGrid.TextArray(theIndex) = ""
        End If
              
        theIndex = theIndex + 1
        Select Case ChannelState(I).ListenState
           Case NoListen:           State = ""
           Case Listen:             State = "Listening"
        End Select
        If MainForm!StateGrid.TextArray(theIndex) <> State Then MainForm!StateGrid.TextArray(theIndex) = State
      
        theIndex = theIndex + 1
        If (SsmGetDtmfStr(I, NewDtmf) > 0) Then
            OldDtmf = MainForm!StateGrid.TextArray(theIndex)
            MainForm!StateGrid.TextArray(theIndex) = NewDtmf
        End If
      
        theIndex = theIndex + 1
        nResult = SsmGetCallerId(I, NewCallerId)
        If (nResult = -1) Then NewCallerId = "-1"
        If (nResult = 0) Then NewCallerId = ""
        MainForm!StateGrid.TextArray(theIndex) = NewCallerId
      
        theIndex = theIndex + 1
        TempStr = MainForm!StateGrid.TextArray(theIndex)
        If TempStr <> ChannelState(I).pErrMsg Then MainForm!StateGrid.TextArray(theIndex) = ChannelState(I).pErrMsg
        Num = Num + 1
      End If
   Next I
End Sub

Public Sub InitChannelState()
    Dim I As Integer
    For I = 0 To MaxLine - 1
    If SsmGetChType(I) = 3 Then
       ChannelState(I).State = TRK_IDLE
       ChannelState(I).ListenState = NoListen
       ChannelState(I).ConState = SHENGKONG
       Call SsmSetBargeInSens(I, 8)
    
       'Call SsmSetDtrmLineVoltage(I, 28)
       
    End If
       
    Next I
End Sub

Public Sub ScanChannelState()
   Dim I As Integer
   Dim TemDtmf1 As Byte
   Dim TemDtmf2 As Byte
   Dim recordfile As String
   Dim nResult As Integer
   
   recorfile = "test"
   
   
   For I = 0 To MaxLine - 1
   
      If SsmGetChType(I) = 3 Then
      ' recordfile = String(I)
      Select Case ChannelState(I).State
         Case TRK_IDLE:
            nResult = SsmGetChState(I)
            If nResult = 2 Then
                ChannelState(I).State = TRK_RINGING
            ElseIf nResult = 1 Then
                ChannelState(I).State = TRK_PICKUP
                If ChannelState(I).ConState = YAKONG Then
                    Call SsmRecToFile(I, "Test.wav", -1, 0, &HFFFFFFFF, 10, 0)
                    If (ChannelState(I).ListenState = Listen) Then Call PlayListen(0, I)
                    ChannelState(I).State = TRK_RECORD
                End If
            End If
           ' If DetectEmpty(I) = 1 Then ChannelState(I).State = TRK_OUTLINE
            If SsmGetChState(I) = 8 Then ChannelState(I).State = TRK_OUTLINE
            
         Case TRK_PICKUP:
            Select Case ChannelState(I).ConState
                Case SHENGKONG
                    If (SsmDetectBargeIn(I) = 1) Then
                        Call SsmRecToFile(I, "Test.wav", -1, 0, &HFFFFFFFF, 10, 0)
                        If (ChannelState(I).ListenState = Listen) Then Call PlayListen(0, I)
                         ChannelState(I).State = TRK_RECORD
                    End If
                    
                Case YAKONG
                    'If DetectPickUp(I) = 1 Then
                    If SsmGetChState(I) = 1 Then
                        Call SsmRecToFile(I, "Test.wav", -1, 0, &HFFFFFFFF, 10, 0)
                        If (ChannelState(I).ListenState = Listen) Then Call PlayListen(0, I)
                        ChannelState(I).State = TRK_RECORD
                    End If
                
                Case MAKONG
                    Call SsmGet1stDtmf(I, TemDtmf1)
                    If (TemDtmf1 = Asc("*")) Then
                        Call SsmRecToFile(I, "Test.wav", -1, 0, 80000, 10, 0)
                        If (ChannelState(I).ListenState = Listen) Then Call PlayListen(0, I)
                        ChannelState(I).State = TRK_RECORD
                        'ClearDTMFBuf (I)
                        SsmClearRxDtmfBuf (I)
                    End If
            End Select
            'If (DetectEmpty(I) = 1) Then
            If (SsmGetChState(I) = 8) Then
                ChannelState(I).State = TRK_OUTLINE
                SsmStopRecToFile (I)
            End If
            If (SsmGetChState(I) = 0) Then
                SsmStopRecToFile (I)
                ChannelState(I).State = TRK_IDLE
            End If
                        
               
         Case TRK_RECORD:
            Select Case ChannelState(I).ConState
                Case SHENGKONG
                    If (SsmDetectNoSound(I) = 1) Then
                        Call SsmStopRecToFile(I)
                        ChannelState(I).State = TRK_PICKUP
                    End If
                    
                Case YAKONG
                    'If (DetectPickUp(I) = 0) Then
                    If (SsmGetChState(I) = 0) Then
                        SsmStopRecToFile (I)
                
                        ChannelState(I).State = TRK_IDLE
                    End If
                Case MAKONG
                     Call SsmGetLastDtmf(I, TemDtmf2)
                     If (TemDtmf2 = Asc("*")) Then
                        SsmStopRecToFile (I)
                        ChannelState(I).State = TRK_PICKUP
                        'Call ClearDTMFBuf(I)
                        Call SsmClearRxDtmfBuf(I)
                     End If
            End Select
            'If (DetectEmpty(I) = 1) Then
            If (SsmGetChState(I) = 8) Then
                SsmStopRecToFile (I)
                ChannelState(I).State = TRK_OUTLINE
            End If
            If (SsmGetChState(I) = 0) Then
                SsmStopRecToFile (I)
                ChannelState(I).State = TRK_IDLE
            End If
            
            If ChannelState(I).ListenState = Listen Then
                Call PlayListen(0, I)
            Else
                Call StopListen(0)
            End If
                

         Case TRK_OUTLINE:
                'If DetectEmpty(I) = 0 Then ChannelState(I).State = TRK_IDLE
                If SsmGetChState(I) = 0 Then ChannelState(I).State = TRK_IDLE
                
         Case TRK_RINGING:
            If SsmGetChState(I) = 1 Then
                ChannelState(I).State = TRK_PICKUP
                If ChannelState(I).ConState = YAKONG Then
                    Call SsmRecToFile(I, "Test.wav", -1, 0, &HFFFFFFFF, 10, 0)
                    If (ChannelState(I).ListenState = Listen) Then Call PlayListen(0, I)
                    ChannelState(I).State = TRK_RECORD
                    
                End If
            End If
      End Select
      End If
   Next I

End Sub

Public Sub AppErrorHandler(ch As Integer)
      SsmGetLastErrMsg ChannelState(ch).pErrMsg
      ChannelState(ch).State = TRK_IDLE
End Sub

⌨️ 快捷键说明

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