📄 fax.bas
字号:
Attribute VB_Name = "Module1"
Public Declare Function SsmSetEvent Lib "SHP_A3.dll" (ByVal wEvent As Integer, ByVal nReference As Long, ByVal bEnable As Boolean, ByRef pEventSet As EVENT_SET_INFO) As Long
'event struct, refer to programmer manual for more details.
Type EVENT_SET_INFO
dwWorkMode As Long
lpHandlerParam As Long
dwOutCondition As Long
dwOutParamVal As Long
dwUser As Long
End Type
Public Type TRUNK_STRUCT
bEnCalled As Boolean 'enable or disenable calling: TRUE-enable FALSE-forbid
bRecord As Boolean 'recording or not : TRUE-record FALSE-not record
nCallFlag As Long 'inbound or outbound call : 0-inbound 1-call outbound
nLineState As Long 'channel state
szChErrMsg As String * 250 'error message
szCallNo As String 'called party number
szCallerId As String * 20 '[20] 'calling party number
szDtmf As String 'DTMF received
nToFaxCh As Long 'fax channel connected with trunk channel by bus
nStep As Long 'user-defined trunk channel state
bUseful As Boolean 'channel seizure flag: FALSE- not seized TRUE-seized
nIndex As Long 'Which number is the received DTMF?
nDtmfChose As Long 'stored the first received DTMF of "1" or "2"
nFirstDtmf As Long 'check if it is the first received DTMF "1" or "2"
nTimer As Long 'timer ID
bLinked As Boolean
End Type
Type FAX_STRUCT
bUseful As Boolean 'channel seizure flag: FALSE- not seized TRUE-seized
szChErrMsg As String 'error message
szPage As String 'number of fax pages
szGetID As String 'ID of the receiver's fax machine
nDirection As Long 'fax direction : 0-send 1-receive
nStep As Long ' user-defined fax channel state
nAnswered As Long 'check whether press start-up button : 0-no 1-yes
szRcvPathFile As String 'file name received(include path)
szSendFile As String 'file name to be sent
nCheckEnd As Long 'test execution result of faxing task
nTrunkCh As Long 'trunk channel ID linked to fax channel
nAllBytes As Long ' total number of bytes to be sent
nSendBytes As Long 'number of bytes sent
nRcvBytes As Long 'number of bytes received
End Type
Public m_FaxCh(500) As FAX_STRUCT 'fax channel
Public m_TrkCh(500) As TRUNK_STRUCT 'trunk channel
Dim strbErrMsg As String * 200 ' error message
Dim m_nTotalCh As Long ' amount of on-board channels
Public SysPath As String ' path of fax file to send
Public RcvPath As String 'path of fax file to receive
Public Function InitCtiBoard() As Boolean
'Initialization of CTI driver
Dim fnIni As String * 260
Dim CurPath As String * 260
Dim str1 As String * 200
Dim nDirection As Long
Dim EventSet As EVENT_SET_INFO
EventSet.dwWorkMode = 2
EventSet.lpHandlerParam = CallbackPt(AddressOf CallBack_MessageProc)
CurPath = App.Path + "\ShConfig.ini" + Chr(0)
fnIni = App.Path + "\ShIndex.ini" + Chr(0)
If (SsmStartCti(CurPath, fnIni) <> 0) Then
SsmGetLastErrMsg (str1)
MsgBox str1
InitCtiBoard = False
Else
If (SsmSetEvent(-1, -1, True, EventSet) = -1) Then ' set event as callback mode
MsgBox ("Fail to call SsmSetEvent")
InitCtiBoard = False
End If
m_nTotalCh = SsmGetMaxCh()
For i = 0 To m_nTotalCh - 1
m_TrkCh(i).bEnCalled = False
nCheck = SsmGetChType(i)
If (nCheck = -1) Then
' fax channel or soft fax
ElseIf (nCheck = ChType.FAX_CH Or nCheck = ChType.SOFTFAX_CH) Then
m_FaxCh(i).szChErrMsg = ""
m_FaxCh(i).szRcvPathFile = ""
m_FaxCh(i).szSendFile = ""
m_FaxCh(i).szPage = ""
m_FaxCh(i).szGetID = ""
m_FaxCh(i).nStep = FaxChStep.FAX_IDLE
m_FaxCh(i).nAnswered = 0
m_FaxCh(i).bUseful = False
m_FaxCh(i).nAllBytes = 0
m_FaxCh(i).nSendBytes = 0
m_FaxCh(i).nRcvBytes = 0
m_FaxCh(i).nCheckEnd = 0
Else
Dim temp As Long
'get automatic call progress enable flag and call direction
nCheck = SsmGetAutoCallDirection(i, temp)
If (nCheck = -1) Then
'enable automatic call progress
ElseIf (nCheck = 1) Then
m_TrkCh(i).nCallFlag = -1
m_TrkCh(i).nStep = TrkChState.TRK_IDLE
m_TrkCh(i).szChErrMsg = " "
m_TrkCh(i).bEnCalled = True
m_TrkCh(i).bRecord = True
m_TrkCh(i).szDtmf = ""
m_TrkCh(i).nDtmfChose = 0
m_TrkCh(i).bUseful = False
m_TrkCh(i).nIndex = 0
m_TrkCh(i).nFirstDtmf = 0
m_TrkCh(i).bLinked = False
m_TrkCh(i).nTimer = -1
m_TrkCh(i).szCallerId = ""
End If
End If
Next i
'load speech data "Step1.voc" and "Step2.voc"
nCheck = SsmLoadIndexData(1, "", 6, "Step1.voc", 0, -1)
nChk = SsmLoadIndexData(2, "", 6, "Step2.voc", 0, -1)
If (nCheck = -1 Or nChk = -1) Then
MessageBox.Show ("Failed to load speech file")
If (SsmCloseCti() = -1) Then
'WriteLog ("Failed to call SsmCloseCti")
End If
End If
InitCtiBoard = True
End If
End Function
Public Sub InitFaxChListCtrl() 'initialize fax control FLEXGRID
Dim nIndex As Long
Dim i As Long
Dim nCheck As Long
Fax.m_FaxChList.Cols = 8
Fax.m_FaxChList.Row = 0
Fax.m_FaxChList.Col = 0
Fax.m_FaxChList.Text = "Ch"
Fax.m_FaxChList.Col = 1
Fax.m_FaxChList.Text = "Channel State"
Fax.m_FaxChList.Col = 2
Fax.m_FaxChList.Text = "Page number"
Fax.m_FaxChList.Col = 3
Fax.m_FaxChList.Text = "Remote ID"
Fax.m_FaxChList.Col = 4
Fax.m_FaxChList.Text = "Current file name"
Fax.m_FaxChList.Col = 5
Fax.m_FaxChList.Text = "Number of fax bytes"
Fax.m_FaxChList.Col = 6
Fax.m_FaxChList.Text = "Execution result of faxing"
Fax.m_FaxChList.Col = 7
Fax.m_FaxChList.Text = "Error message"
Fax.m_FaxChList.ColWidth(0) = 30 * 12
Fax.m_FaxChList.ColWidth(1) = 130 * 12
Fax.m_FaxChList.ColWidth(2) = 40 * 12
Fax.m_FaxChList.ColWidth(3) = 100 * 12
Fax.m_FaxChList.ColWidth(4) = 150 * 12
Fax.m_FaxChList.ColWidth(5) = 150 * 12
Fax.m_FaxChList.ColWidth(6) = 200 * 12
Fax.m_FaxChList.ColWidth(7) = 300 * 12
Fax.m_FaxChList.Rows = 1
For i = 0 To m_nTotalCh - 1
nCheck = SsmGetChType(i)
If nCheck = -1 Then
'WriteLog ("Fail to call SsmGetChType")
ElseIf nCheck = ChType.FAX_CH Or nCheck = ChType.SOFTFAX_CH Then
Fax.m_FaxChList.AddItem (Str(i))
End If
Next i
End Sub
Public Sub InitTrunkChListCtrl() 'initialize trunk control LEXGRID
Dim i As Long
Dim nIndex As Long
Fax.m_TrkChList.Cols = 6
Fax.m_TrkChList.Row = 0
Fax.m_TrkChList.Col = 0
Fax.m_TrkChList.Text = "Ch"
Fax.m_TrkChList.Col = 1
Fax.m_TrkChList.Text = "Channel State"
Fax.m_TrkChList.Col = 2
Fax.m_TrkChList.Text = "Faxing state"
Fax.m_TrkChList.Col = 3
Fax.m_TrkChList.Text = "Calling party number"
Fax.m_TrkChList.Col = 4
Fax.m_TrkChList.Text = "DTMF"
Fax.m_TrkChList.Col = 5
Fax.m_TrkChList.Text = "Error message"
Fax.m_TrkChList.ColWidth(0) = 30 * 12
Fax.m_TrkChList.ColWidth(1) = 130 * 12
Fax.m_TrkChList.ColWidth(2) = 130 * 12
Fax.m_TrkChList.ColWidth(3) = 200 * 12
Fax.m_TrkChList.ColWidth(4) = 200 * 12
Fax.m_TrkChList.ColWidth(5) = 300 * 12
Fax.m_TrkChList.Rows = 1
For i = 0 To m_nTotalCh - 1
If m_TrkCh(i).bEnCalled Then
Fax.m_TrkChList.AddItem (Str(i))
End If
Next i
End Sub
Public Sub UpdateFaxChListCtrl() 'update fax control FLEXGRID
Dim szNewStat As String * 200
Dim szOldStat As String * 200
Dim szStatemsg As String * 200
Dim strbFaxId As String * 20 'id of remote fax machine
Dim nIndex As Long
Dim nCheck As Long
Dim nRow As Long
Dim i As Long
nRow = 0
For i = 0 To m_nTotalCh - 1
nCheck = SsmGetChType(i)
If (nCheck = 5 Or nCheck = 9) Then 'faxch
nIndex = Fax.m_FaxChList.Cols * (nRow + 1)
'channel state
Select Case (m_FaxCh(i).nStep)
Case FaxChStep.FAX_IDLE
szNewStat = "Idle"
Case FaxChStep.FAX_CHECK_END
If (m_FaxCh(i).nDirection = FaxDir.C_SEND_FAX) Then
szNewStat = "Sending:"
Else
szNewStat = "Receiving:"
End If
nCheck = SsmFaxGetChStateMsg(i, szStatemsg)
If (nCheck = -1) Then
'WriteLog ("Fail to call SsmFaxGetChStateMsg")
ElseIf (nCheck = 0) Then
szNewStat = szNewStat & szStatemsg
End If
End Select
szOldStat = Fax.m_FaxChList.TextArray(nIndex + 1)
If (szOldStat <> szNewStat) Then
Fax.m_FaxChList.TextArray(nIndex + 1) = szNewStat
End If
'display page number of fax
szOldStat = Fax.m_FaxChList.TextArray(nIndex + 2)
If (szOldStat <> m_FaxCh(i).szPage) Then
Fax.m_FaxChList.TextArray(nIndex + 2) = m_FaxCh(i).szPage
End If
'display ID of the receiver's fax machine
m_FaxCh(i).szGetID = ""
If (SsmFaxGetID(i, strbFaxId) = -1) Then
'WriteLog ("Fail to call SsmFaxGetID")
End If
m_FaxCh(i).szGetID = strbFaxId
szOldStat = Fax.m_FaxChList.TextArray(nIndex + 3)
If (szOldStat <> m_FaxCh(i).szGetID) Then
Fax.m_FaxChList.TextArray(nIndex + 3) = m_FaxCh(i).szGetID
End If
If (m_FaxCh(i).nStep <> FaxChStep.FAX_IDLE) Then
'display fax file name
If (m_FaxCh(i).nDirection = FaxDir.C_SEND_FAX) Then 'send
szNewStat = m_FaxCh(i).szSendFile
Else
szNewStat = m_FaxCh(i).szRcvPathFile
End If
szOldStat = Fax.m_FaxChList.TextArray(nIndex + 4)
If (szOldStat <> szNewStat) Then
Fax.m_FaxChList.TextArray(nIndex + 4) = szNewStat
End If
'display number of bytes being sent or received
If (m_FaxCh(i).nDirection = FaxDir.C_SEND_FAX) Then
'get total number of bytes to be sent
m_FaxCh(i).nAllBytes = SsmFaxGetAllBytes(i)
'get number of bytes sent
m_FaxCh(i).nSendBytes = SsmFaxGetSendBytes(i)
szNewStat = Str(m_FaxCh(i).nAllBytes) + ":" + Str(m_FaxCh(i).nSendBytes)
Else
' get number of bytes received
m_FaxCh(i).nRcvBytes = SsmFaxGetRcvBytes(i)
szNewStat = Str(m_FaxCh(i).nRcvBytes)
End If
szOldStat = Fax.m_FaxChList.TextArray(nIndex + 5)
If (szOldStat <> szNewStat) Then
Fax.m_FaxChList.TextArray(nIndex + 5) = szNewStat
End If
End If
'display faxing state
szNewStat = Str(m_FaxCh(i).nCheckEnd)
szOldStat = Fax.m_FaxChList.TextArray(nIndex + 6)
If (szOldStat <> szNewStat) Then
Fax.m_FaxChList.TextArray(nIndex + 6) = szNewStat
End If
' display error message
szNewStat = m_FaxCh(i).szChErrMsg
szOldStat = Fax.m_FaxChList.TextArray(nIndex + 7)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -