This is probably where the problem exists. This is the "Collection Script" file
(mdr2000.col) thats used by OTM to pull CDR from our MDR2000. Is there anything
here that could be causing the trouble?
;*******************************************************************************
; Script file for the Data Script Engine to process MDR-2000 records.
; Created 19-APR-98 by MGR
;*******************************************************************************
;
; 16-NOV-00 Modification to support 'Jimmy Chip'. MGR
; 16-JAN-01 Including MDR2KE.INC file to support Ethernet communications. RT
;
;[End of Revision History]
;*******************************************************************************
; INCLUDE LANGUAGE FILES
;*******************************************************************************
Include LNGFILE(COMMON)
Include LNGFILE(MDR)
;*******************************************************************************
; INCLUDE STATUS.INC - Includes constants for sending status information.
;*******************************************************************************
INCLUDE STATUS.INC
;*******************************************************************************
; INCLUDE CONNECT.COM - Includes routines for communications - serial or file.
;*******************************************************************************
INCLUDE CONNECT.CON
;*******************************************************************************
; INCLUDE COLLECT.INC - Includes common CDR handling routines.
;*******************************************************************************
INCLUDE COLLECT.INC
;*******************************************************************************
; INCLUDE MDR2KE.INC - Includes routines for ETHERNET communications.
;*******************************************************************************
INCLUDE MDR2KE.INC
;*******************************************************************************
; ZeroStrip removes preceding zeroes in from of the ID's. This will reset
; the ID to the format before the MDR-2000 added zeroes.
;*******************************************************************************
routine ZeroStrip
begin
loop
let ZeroChar$ = copy(ID$, 2, 1)
if ZeroChar$ <> '0' then Exit
let ZeroChar$ = copy(ID$, 1, 1)
let ID$ = ZeroChar$ + copy(ID$, 3, 255)
endloop
; Do not strip all the zeros if there are only zeros (e.g. A000)
let CheckLength = Length(ID$)
if CheckLength = 1 then
let ID$ = ID$ + '0'
end
;*******************************************************************************
; Converts an MDR-2000 format CDR record to the new delimited format.
; The routine takes MDRRecord$ as the input and produces a converted record
; in the variable CDRRecord$.
;*******************************************************************************
routine ConvertCDRRecord
begin
Do GetSequenceNumber
let ID$ = copy(MDRRecord$, 7, 8)
Do ZeroStrip
let OrigID$ = ID$
let ID$ = copy(MDRRecord$, 15, 8)
Do ZeroStrip
let TermID$ = ID$
let CDRDate$ = copy(MDRRecord$, 23,2) + '/' + copy(MDRRecord$, 25, 2)
let CDRYear$ = CDRDate$
Do GetCDRYear
let CDRDate$ = CDRDate$ + '/' + CDRYear$
let CDRTime$ = copy(MDRRecord$, 27,2) + ':' + copy(MDRRecord$, 29,2) + ':00'
let Duration$ = copy(MDRRecord$, 31, 2)+':'+copy(MDRRecord$, 33, 2)
let Duration$ = Duration$ + ':' + copy(MDRRecord$, 35, 2)
; Get all the digit information from the CDR record.
; The MDR-2000 places all the additional call information into the CDR
; record in the digits field and identifies it using character ID's.
let M2KData$ = copy(MDRRecord$, 43, 255)
; Retrieve the Authorization code from the call.
let CheckPos = pos('A', M2KData$, FALSE)
if CheckPos <> 0 then
begin
loop
let M2KTemp$ = copy(M2KData$, 1, CheckPos-1)
let M2KTemp$ = M2KTemp$ + copy(M2KData$, CheckPos+1, 255)
let M2KData$ = M2KTemp$
let M2KChar$ = copy(M2KData$, CheckPos, 1)
if (M2KChar$ < '0') or (M2KChar$ > '9') then Exit
let AuthCode$ = AuthCode$ + M2KChar$
endloop
end
; Retrieve the Account code from the call.
let CheckPos = pos('#', M2KData$, FALSE)
if CheckPos <> 0 then
begin
loop
let M2KTemp$ = copy(M2KData$, 1, CheckPos-1)
let M2KTemp$ = M2KTemp$ + copy(M2KData$, CheckPos+1, 255)
let M2KData$ = M2KTemp$
let M2KChar$ = copy(M2KData$, CheckPos, 1)
; Special edit for "Jimmy Chip" to allow special codes prefixed by a 'T'.
; Refer to JMM or MGR or CS for further information.
if (M2KChar$ <> 'T') then
if (M2KChar$ < '0') or (M2KChar$ > '9') then Exit
let AcctCode$ = AcctCode$ + M2KChar$
endloop
end
; The ring time will always preceed the digits dialled if it is available.
let CheckPos = pos('T', M2KData$, FALSE)
if CheckPos <> 0 then
begin
let RingTime$ = copy(M2KData$, CheckPos+1, 3)
let M2KData$ = copy(M2KData$, CheckPos+4, 255)
end
; Retrieve the digits dialled from the call.
loop
let M2KDataLength = Length(M2KData$)
if M2KDataLength = 0 then Exit
let M2KChar$ = copy(M2KData$, 1, 1)
if (M2KChar$ < '0') or (M2KChar$ > '9') then Exit
let Digits$ = Digits$ + M2KChar$
let M2KData$ = copy(M2KData$, 2, 255)
endloop
; Retrieve the Calling Line ID from the call.
let CheckPos = pos('D', M2KData$, FALSE)
if CheckPos <> 0 then
begin
loop
let M2KTemp$ = copy(M2KData$, 1, CheckPos-1)
let M2KTemp$ = M2KTemp$ + copy(M2KData$, CheckPos+1, 255)
let M2KData$ = M2KTemp$
let M2KChar$ = copy(M2KData$, CheckPos, 1)
if (M2KChar$ < '0') or (M2KChar$ > '9') then Exit
let CLID$ = CLID$ + M2KChar$
endloop
end
loop
let CheckPos = pos('I', M2KData$, FALSE)
if CheckPos = 0 then Exit
let M2KChar$ = copy(M2KData$, CheckPos+1, 1)
; Get the Hold Time information.
if M2KChar$ = '0' then
begin
let HoldTime$ = copy(M2KData$, CheckPos+2, 3)
let M2KTemp$ = copy(M2KData$, 1, CheckPos-1)
let M2KTemp$ = M2KTemp$ + copy(M2KData$, CheckPos+1, 255)
let M2KData$ = M2KTemp$
end
; Get the 100 hour duration digits.
if M2KChar$ = '1' then
begin
let ExDuration$ = copy(M2KData$, CheckPos+2, 3)
let M2KTemp$ = copy(M2KData$, 1, CheckPos-1)
let M2KTemp$ = M2KTemp$ + copy(M2KData$, CheckPos+1, 255)
let M2KData$ = M2KTemp$
; Append 100 hour duration digits in front of the hours.
let Duration$ = ExDuration$ + Duration$
end
endloop
let DNIS$ = ''
if DNISInAccountCode! then
begin
let DNIS$ = AcctCode$
let AcctCode$ = ''
end
let Pulses$ = ''
let AnswerSupervision$ = ''
Do BuildCDRRecord
end
;*******************************************************************************
;Retrieves an MDR-2000 record from the specified data source.
;*******************************************************************************
routine GetMDR2000Record
begin
let Valid! = FALSE
let TimeOut! = FALSE
if ConnectionType$ = 'FILE' then
begin
GetFileData(FileName$, CRLF$, 0, MDRRecord$, TimeOut!)
let Valid! = TRUE
end
else if ConnectionType$ = 'ETHERNET' then
begin
Do GetEthernetData
let Valid! = TRUE
end
else
GetMDRRec(CtrlType$,M2KType,CollectCmd$,MDRRecord$,Valid!)
let DataRecord$ = MDRRecord$
Do PutBackupFile
end
;*******************************************************************************
;*******************************************************************************
routine MDR2000Collect
begin
let Valid! = FALSE
let CtrlType$ = chr(22)
let M2KType = 3
let CollectCMD$ = 'XT'
let MDR2000Error = 0
let MDR2000MaxRetries = 5
let MDR2000Retries = 0
let MDR2000TotalRetries = 0
if (ConnectionType$ = 'FILE') or (ConnectionType$ = 'ETHERNET') then
let Valid! = true
else
GetMDRType(CtrlType$,M2KType,Valid!)
; if not Valid! then ; Error getting the buffer type.
; let MDR2000Error = 1
; If cannot determine the type then default to a CTRL-V type 3 buffer.
if not Valid! then
begin
let Valid! = TRUE
let CtrlType$ = chr(22)
let M2KType = 3
end
if MDR2000Error = 0 then
begin
if (ConnectionType$ <> 'FILE') and (ConnectionType$ <> 'ETHERNET') then
begin
delay(1000)
sendln(CtrlType$+'DB')
if not WaitFor('HE',3) then
let MDR2000Error = 2 ; Error establishing connection.
end
end
if MDR2000Error = 0 then
begin
delay(500)
; The following line should only be uncommented when testing a buffer
; and a reset to the start of the record list needs to be done.
; This is used when a buffer is not CLRed at the end and a recollection
; of test data needs to be done.
; sendln(CtrlType$+'BE')
let PreviousRecord$ = '$$$$$$$$$$$$$' ; Set to dummy value.
Do InitCDRVariables
let RealTimeCount = 0
println(MDR_COLLECT$)
SendStatus(STAT_OK, MDR_COLLECT$, Result!)
; ******************************************
; Start Loop for Real-Time Collection
; ******************************************
loop
; ***************************************
; Start Loop for Collection
; ***************************************
loop ; Loop Start for Record Collection.
Do ResetCDRVariables
if Cancel_Flag! then Exit
Do GetMDR2000Record
if TimeOut! then Exit
if (MDRRecord$ = '') then
begin
; There is an error sometimes in real-time collection where the buffer
; does not respond to the collect command from time to time.
; This is a temporary fix during troubleshooting and is in place to
; work around the problem. MGR 07-JUL-99
let Valid! = true
end
if (MDRRecord$ = PreviousRecord$) or (not Valid!) then
begin
inc(MDR2000Retries)
inc(MDR2000TotalRetries)
if MDR2000Retries > MDR2000MaxRetries then
begin
let MDR2000Error = 3
Exit
end
end
else ; Record is OK.
begin
let MDR2000Retries = 0
let CheckPos = pos('END', MDRRecord$, true)
if CheckPos > 0 then Exit
; Reset real-time display counter.
let RealTimeCount = 0
let PreviousRecord$ = MDRRecord$
let TypeCheck$ = copy(MDRRecord$, 7, 1)
if TypeCheck$ = 'I' then
begin
let CDRRecord$ = 'IMG,'+MDRRecord$
Do SendCDRRecord
end
else
begin
; Send MDRRecord$ in and get CDRRecord$ out.
Do ConvertCDRRecord
Do SendCDRRecord
end
if ConnectionType$ <> 'FILE' then
begin
if ConnectionType$ = 'ETHERNET' then
Do Ethernet_SendOK
else
SendLn(CtrlType$+'OK')
end
end
endloop ; EndLoop for Record Collection.
if Cancel_Flag! then Exit
if not RealTime! then Exit
if MDR2000Error <> 0 then Exit
if ConnectionType$ = 'ETHERNET' then
begin
Do Ethernet_SendClear
; If can't Clear MDR-2000e buffer
if not ClearFound! then
let Cancel_Flag! = TRUE
end
else
begin
; *****************************************************
; If in Real-Time mode then the records must be deleted
; through each loop of the script.
; *****************************************************
SendLn(CtrlType$ + 'CL')
if not EXWaitFor('CLR',3) then
begin
println(MDR_ERRRTCLR$)
SendStatus(STAT_ERROR, MDR_ERRRTCLR$, Result!)
let Cancel_Flag! = TRUE
end
end
; *****************************************************
; To avoid the MDR2000Error = 3 check the PreviousRecord$
; must be reset. The buffer will say 'END' continuously.
; Therefore there will be a match of MDRRecord and
; PreviousRecord resuting in retries when the buffer is
; empty eventually causing an error.
; *****************************************************
let PreviousRecord$ = '$$$$$$$$$$$$$$$'
; *****************************************************
; Display a tick in the DataScr message window when
; waiting in real-time so that there is an indication
; that the script is still running.
; *****************************************************
inc(RealTimeCount)
if (RealTimeCount = 1) then
PrintLn(MDR_RTWAIT$)
else
Print('.')
if (RealTimeCount = 50) then
let RealTimeCount = 0
; *****************************************************
; Do not want to hit the buffer with too many commands
; when running real-time mode. Therefore, only attempt
; a collection every x number of milliseconds.
; *****************************************************
delay(7000)
endloop ; EndLoop for Real-Time collection.
if ConnectionType$ <> 'FILE' then
begin
if ConnectionType$ = 'ETHERNET' then
Do Ethernet_SendClear
else
begin
; *****************************************************
; The lines below can be removed so that once records
; are collected from the buffer they are not deleted.
; *****************************************************
SendLn(CtrlType$ + 'CL')
if not EXWaitFor('CLR',3) then
begin
println(MDR_ERRCLR$)
SendStatus(STAT_ERROR, MDR_ERRCLR$, Result!);
end
end
end
end
if MDR2000Error = 1 then
let MDR2000Error$ = MDR_ERRBUFTYP$
if MDR2000Error = 2 then
let MDR2000Error$ = MDR_ERRHELLO$
if MDR2000Error = 3 then
let MDR2000Error$ = MDR_ERRRECS$
if MDR2000Error <> 0 then
begin
println(MDR2000Error$)
SendStatus(STAT_ABORT, MDR2000Error$, Result!)
end
end
;******************************** Main Routine *************************
;*************************************************************************
;*************************************************************************
;
println(MDR_START$)
SendStatus(STAT_OK, MDR_START$, Result!);
let DNISInAccountCode! = FALSE
Do InitiateConnection
if not ConnectionError! then
if not Cancel_Flag! then
Do MDR2000Collect
Do TerminateConnection
if ConnectionError! then
SendStatus(STAT_ERROR, MDR_ERRCNCT$, Result!)
if Cancel_Flag! then
SendStatus(STAT_CANCEL, SCR_CANCEL$, Result!)
println(MDR_CLOSE$)
SendStatus(STAT_OK, MDR_CLOSE$, Result!)
delay(1000)