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

📄 data.pas

📁 由内线接电话终端
💻 PAS
字号:
//交换机数据结构及数据保存
unit Data;

interface

uses Classes;

//内线状态结构
type
  TAgentState = class                                 //记录内线通道的状态
  public
    State : Integer;                                  //通道状态,0为空闲,1为呼出,2为呼入,3为通话
    SimilarRow : array of Integer;                    //路由相似的行,每收一个被叫号码在路由表匹配一次,存放能匹配上的行
    SimilarCount : Integer;                           //路由相似的行数
    AcmOk : Boolean;                                  //是否收码足够,和路由表匹配
    CalledType : Integer;                             //被叫类型,在内线呼出时用
    CalledIndex : Integer;                            //被叫通道号,在内线呼出时用
    CallerType : Integer;                             //主叫类型,在呼入内线时用
    CallerIndex : Integer;                            //主叫通道号,在呼入内线时用
    CalledRow : Integer;                              //对应被叫的行
    CallerRow : Integer;                              //对应主叫的行
    Caller : String[20];                              //主叫号码 
    Called : String[20];                              //被叫号码
    Data : String[250];                               //数据暂存
    
  public
    constructor Create(ArrRows : Integer);
    procedure SetRowArrLen(Len : Integer);
    destructor Destroy;
  end;

//按内线通道数创建的状态保存链表,存放每个内线通道的状态  
  TAgentList = class
    PList : TList;
  public
    //建构函数,参数分别为内线数,设置SimilarRow的长度(默认为路由表中路由数)
    constructor Create(ChNum, ArrRows : Integer);
    //设置SimilarRow的长度
    procedure SetRowArrLength(Leng : Integer);
    //获取某个通道的状态结构
    function GetChPointer(Index : Integer) : Pointer;
    destructor Destroy;
  private
    ChCount : Integer;
  end;

  //数字PCM的状态
  TDigitState = class
  public                                            
    UsedCount  : Integer;                             //使用的通道数
    CallInLine : array[0..24] of Integer;             //经过的内线通道,0为空闲,1为呼入,2为呼出
  public
    constructor Create;
  end;

  TDigitList = class
    PList : TList;
  public
    constructor Create(ChNum : Integer);
    function GetChPointer(Index : Integer) : Pointer;
    destructor Destroy;
  private
    ChCount : Integer;
  end;
  
implementation

constructor TAgentState.Create(ArrRows : Integer);
var
  i : Integer;
begin
  SetLength(SimilarRow, ArrRows);
  for i := 1 to ArrRows do
  begin
    SimilarRow[i - 1] := i;
  end;

  State := 0;
  SimilarCount := ArrRows;
  Data := '';
  AcmOk := False;
  CallerType := 0;
  CallerIndex := 0;
  CalledType := 0;
  CalledIndex := 0;
  CallerRow := 0;
  CalledRow := 0;
  Caller := '';
  Called := '';
  Data := '';
end;

procedure TAgentState.SetRowArrLen(Len : Integer);
begin
  SetLength(SimilarRow, Len);
end;

destructor TAgentState.Destroy;
begin
  SimilarRow := Nil;
end;

constructor TAgentList.Create(ChNum, ArrRows : Integer);
var
  i : Integer;
  AStmp : TAgentState;
begin
  PList := TList.Create;

  ChCount := ChNum;

  for i := 1 to ChNum do
  begin
    AStmp := TAgentState.Create(ArrRows);
    PList.Add(AStmp);
  end;
end;

destructor TAgentList.Destroy;
var
  i : Integer;
  AStmp : TAgentState;
begin
  inherited destroy;

  if PList.Count > 0 then
  begin
    for i := 0 to PList.Count - 1 do
    begin
      AStmp := PList.Items[i];
      AStmp.Destroy;
    end;
  PList.Destroy;
  end;
end;

procedure TAgentList.SetRowArrLength(Leng : Integer);
var
  i, j : Integer;
  AStmp : TAgentState;
begin
  if ChCount > 0 then
  begin
    for i := 0 to ChCount - 1 do
    begin
      AStmp := PList.Items[i];
      AStmp.SetRowArrLen(Leng);
      for j := 1 to Leng do
      begin
        AStmp.SimilarRow[j - 1] := j;
      end;
    end;
  end;
end;

function TAgentList.GetChPointer(Index : Integer) : Pointer;
begin
  if Index < ChCount then
  begin
    result := PList.Items[Index];
  end;
end;

constructor TDigitState.Create;
var
  i : Integer;
begin
  UsedCount := 0;
  for i := 0 to 23 do
  begin
    CallInLine[i] := 0;
  end;
end;

constructor TDigitList.Create(ChNum : Integer);
var
  i, j : Integer;
  AStmp : TDigitState;
begin
  PList := TList.Create;

  ChCount := ChNum;

  for i := 1 to ChNum do
  begin
    AStmp := TDigitState.Create();
    PList.Add(AStmp);
  end;
end;

function TDigitList.GetChPointer(Index : Integer) : Pointer;
begin
  if Index < ChCount then
  begin
    result := PList.Items[Index];
  end;
end;

destructor TDigitList.Destroy;
var
  i : Integer;
  AStmp : TDigitState;
begin
  inherited destroy;

  if PList.Count > 0 then
  begin
    for i := 0 to PList.Count - 1 do
    begin
      AStmp := PList.Items[i];
      AStmp.Destroy;
    end;
  PList.Destroy;
  end;
end;


end.

⌨️ 快捷键说明

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