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

📄 recordfunc.~pas

📁 三汇录音卡的录音源码增加了将来电号码写数据库
💻 ~PAS
📖 第 1 页 / 共 2 页
字号:
unit RecordFunc;

interface
type TRUNK_STATE =  (
   TRK_IDLE,
   TRK_PICKUP,
   TRK_RECORD,
   TRK_OUTLINE,
   TRK_ELSE
   );

type Constrol=
(
   SHENGKONG,
   YAKONG,
   MAKONG

)  ;
type LISTENA=
   (
    NoListen,
    Listen
    );

type TRUNK_RECORD =record

    WorkState:TRUNK_STATE;
    ListenState:LISTENA ;
    ConState:Constrol;
    pErrMsg:string;
    dwTimeOutCounter:LongWord;
end;
 /////////////////////////////////////
 function InitCtiSystem() : boolean;
 procedure ExitCtiSystem() ;
 procedure UpdateChannelState();
 procedure InitChannelState();
 procedure InitTrkChannelList();
 procedure AppErrorHandler(ch : Integer);
 procedure ScanChannelState();
 ////////////////VarDefing
 var
     MaxLine : integer;
     ListenChannel : integer;
     ChannelState : array[0..200] of TRUNK_RECORD;
//////////////////////////////
implementation
  uses Shpa3api,Main,Windows, Messages, SysUtils, Classes, Graphics,
     Controls, Forms, Dialogs,ComCtrls, ExtCtrls;
////////////Function InitCtiSystem Define
function InitCtiSystem():  boolean;
var
    strCurrentDir:string;
    fnIni:string;
    fnIndex:string;
    ErrMsg:PChar;
begin
   strCurrentDir:=GetCurrentDir();
   fnIni:=strCurrentDir+'\ShConfig.ini';
   fnIndex:=strCurrentDir+'\shindex.ini';
   if SsmStartCti(@fnIni[1],@fnIndex[1])<>0 then
   begin
      GetMem(ErrMsg,200);
      SsmGetLastErrMsg(ErrMsg);   ////////
      Application.MessageBox(ErrMsg,'错误',MB_Ok);
      FreeMem(ErrMsg);
      InitCtiSystem:=false;
      Exit;
    end;
    if (SsmGetMaxUsableBoard() <> SsmGetMaxCfgBoard())then
    begin
       GetMem(ErrMsg,200);
       SsmGetLastErrMsg(ErrMsg);
       Application.MessageBox(ErrMsg,'错误', MB_OK);
       FreeMem(ErrMsg);
    end;
    MaxLine:=SsmGetMaxCh();
    InitCtiSystem:=True;
end;
 //////////////////Procedure ExitCtiSystem Define
procedure ExitCtiSystem();
begin
   SsmCloseCti();
end;
 ////////////////////Procedure UpdateChannelState Define
procedure UpdateChannelState();
var
   i : integer;
   State : string;
   NewDtmf : pChar;
   NewCallerId :array  [0..99] of char;
   OldDtmf : String;
   TempStr:String;
   TEmpStr1:String;
   nResult:integer;
   Num   : integer;
begin
   num:=0;
   for i:=0 to MaxLine-1 do
   begin
       if SsmGetChType(i)=3 then
           begin
              case (ChannelState[i].WorkState ) of
                 TRK_IDLE:        State:='空闲';
                 TRK_PICKUP:      State:='摘机';
                 TRK_RECORD:      State:='录音';
                 TRK_OUTLINE:     State:='断线';
                 TRK_ELSE:        State:='未定义';
              end;
              TempStr:=MainForm.ChannelListView.Items[num].SubItems[0];
              if State<>TempStr then
                  MainForm.ChannelListView.Items[num].SubItems[0]:=State;

              case (ChannelState[I].ConState ) of
                 SHENGKONG:        State:='声控';
                 YAKONG:           State:='压控';
                 MAKONG:           State:='码控';
              end;
              TempStr:=MainForm.ChannelListView.Items[num].SubItems[1];
              if State<>TempStr then
                  MainForm.ChannelListView.Items[num].SubItems[1]:=state;

              case ChannelState[i].ConState of
                  MAKONG:                         State:='*';
                  SHENGKONG,YAKONG:               State:='';
              end;
              TempStr:=MainForm.ChannelListView.Items[num].SubItems[2];
              if TempStr<>state then
                 MainForm.ChannelListView.Items[num].SubItems[2]:=state ;

              case ChannelState[i].ListenState of
                 NOLISTEN:            State:=' ';
                 LISTEN:              sTATE:='监听';
              end;
              TempStr:=MainForm.ChannelListView.Items[num].SubItems[3];
              if TempStr<>STATE then
                 MainForm.ChannelListView.Items [num].SubItems [3]:=State;

              GetMem(NewDtmf,100);
              SsmGetDtmfStr(I, NewDtmf);
              OldDtmf:=MainForm.ChannelListView.Items[num].SubItems[4];
              //if OldDtmf<>NewDtmf then
              //   MainForm.ChannelListView.Items [num].SubItems [4]:=StrPas(NewDtmf);
              Freemem(newdtmf);

              nResult := SsmGetCallerId(I, @NewCallerId[0]);
              If (nResult = -1) Then NewCallerId := '-1' ;
              If (nResult = 0) Then NewCallerId := ''  ;
              OldDtmf:=MainForm.ChannelListView.Items[num].SubItems[5];
              if  OldDtmf <> String(NewCallerId) then
                 MainForm.ChannelListView.Items [num].SubItems [5] := StrPas(NewCallerId);
              //我加的东西
               If (OldDtmf <> String(NewCallerId)) and (Length(StrPas(NewCallerId)) > 4)  then
               Begin
                 MainForm.Query1.Close;
                 Sleep(500);
                 MainForm.Query1.Open;
                 MainForm.CallerID_Extension[i] := MainForm.Query1.FieldByName('来电号码').AsString;
                 MainForm.Call_Extension[i] := MainForm.Query1.FieldByName('呼叫分机').AsString;
                 MainForm.StatusBar1.Panels[1].Text := '呼叫分机:'+ MainForm.Call_Extension[i];
                 MainForm.CallerID_Extension[i] := 'aaa';
//                 If MainForm.Mp3_AAA[i] <> MainForm.Record_FileName[i] then
//                 Begin  //数据发送,下面不行再考虑放开
                 MainForm.SendData( i, MainForm.CallerID_Extension[i]
                   + ';'+ NewCallerID, MainForm.Record_FileName[i]); //+';'+MainForm.Record_FileName[i]);
                 MainForm.Call_Time[i] := Now;
//                   MainForm.Mp3_AAA[i] := MainForm.Record_FileName[i];
//                 End;

                 MainForm.CallerID_Num[i] := NewCallerID;
               End;
{///////////////////////////////////////试验数据发送
                 If MainForm.Mp3_AAA[i] <> MainForm.Record_FileName[i] then
                 Begin
                 MainForm.SendData(MainForm.ChannelIP[i+1],
                   MainForm.CallerID_Extension[i]
                   + ';'+ NewCallerID, IntToStr(i)+';'+MainForm.Record_FileName[i]);
                   MainForm.Mp3_AAA[i] := MainForm.Record_FileName[i];
                 End;
///////////////////////////////////////}
               If (OldDtmf <> String(NewCallerId))and(String(NewCallerId) = '')and(Trim(MainForm.CallerID_Num[i])<>'') then
               Begin
                  // MainForm.Call_Time[i] := Round(((GetTickCount - MainForm.Call_Time[i])/
                  //    1000)/60);
                   PostMessage(MainForm.Handle, Save_Message, i, 0);
                   MainForm.StatusBar1.Panels[0].Text := IntToStr(i)+ 'Abc';
                  //Application.MessageBox(PAnsiChar('通道'+IntToStr(I)),'来电话了');
               //到此结束
               End;
               TempStr:=MainForm.ChannelListView.Items[num].SubItems[6];
               TempStr1:=ChannelState[i].pErrMsg ;
               if TempStr<>TempStr1 then
                  MainForm.ChannelListView.Items[num].SubItems[6]:=TempStr1;
            num:=num+1 ;
            end;
   end;
end;
 /////////////Procedure InitChannelState() Define
procedure InitChannelState();
var
   I:Integer;
Begin
   for I:=0 to MaxLine-1 do
   If SsmGetChType(I) = 3 Then
     begin
       ChannelState[i].WorkState :=TRK_IDLE;
       ChannelState[i].ListenState :=Nolisten;
       ChannelState[i].ConState := YAKONG; //SHENGKONG;
       //SetSoundJudgeLevel(I, 1); //新版本不提供
       SsmSetBargeInSens(I, 8)  ;
       //SetJudge(I, 28); //新版本不提供
       SsmSetDtrmLineVoltage(I, 28);
     end;
end;

⌨️ 快捷键说明

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