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

📄 telphon.pas

📁 软件类别: 数据库 软件大小: 2.60M 运行环境: Win9xNT/2000/XP 一套车辆管理系统,此版本为商业版,大家一定用的着。
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit Telphon;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, SPComm, ExtCtrls, Buttons, StdCtrls,Registry;

type
  Tfrm_Telphon = class(TForm)
    Comm1: TComm;
    Panel1: TPanel;
    Edit_NO: TLabeledEdit;
    SpeedButton1: TSpeedButton;
    Cmd_Read: TSpeedButton;
    Memo1: TMemo;
    Button1: TButton;
    SpeedButton3: TSpeedButton;
    SpeedButton4: TSpeedButton;
    Edit1: TLabeledEdit;
    Edit2: TLabeledEdit;
    Edit3: TLabeledEdit;
    Edit4: TLabeledEdit;
    Edit5: TLabeledEdit;
    Edit6: TLabeledEdit;
    LabeledEdit1: TLabeledEdit;
    LabeledEdit2: TLabeledEdit;
    LabeledEdit3: TLabeledEdit;
    Timer1: TTimer;
    Cmd_Save: TSpeedButton;
    procedure Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
      BufferLength: Word);
    procedure FormCreate(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Cmd_ReadClick(Sender: TObject);
    procedure SpeedButton3Click(Sender: TObject);
    procedure SpeedButton4Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Timer1Timer(Sender: TObject);
    procedure Cmd_SaveClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frm_Telphon :Tfrm_Telphon;
  viewstring  :String;
  rbuf,sbuf   :array[1..500] of String;
  i:Integer;
  Tbuf:array[1..10] of byte;
  RRbuf:array[1..12] of byte;
  grbuf:array[1..250] of byte;
implementation

uses Data;

{$R *.dfm}
//自定义发送过程
//*************初始化短消息信息格式函数***************(任何一个均可以)//
function SendT:boolean; //初始化短消息信息格式函数
var
    i:integer;
    commflg:boolean;
begin
    viewstring:='' ;
    commflg:=true;
    for i:=1 to 10 do
    begin
        if not frm_Telphon.comm1.writecommdata(@Tbuf[i],1) then
        begin
            commflg:=false;
            break;
        end;
        //发送时字节间的延时
        sleep(2);
        viewstring:=viewstring + inttohex(Tbuf[i],2)+'' ;
    end;
    viewstring:=viewstring;
    result := commflg;
end;

function SendText:boolean; //初始化短消息信息格式函数
var
    i:integer;
    commflg:boolean;
    StrText:String;
begin
    StrText:='at+cmgf=1'+#13;
    commflg:=true;
    frm_Telphon.comm1.WriteCommData(Pchar(StrText),Length(StrText));
    StrText:=StrText;
    result := commflg;
    {for i:=1 to 7 do
    begin
        frm_Telphon.comm1.writecommdata(@sbuf[i],1);
        StrText:=StrText+sbuf[i];
    end; }
end;
//*******************************************//

//??????????????????????请求阅读短消息?????????????//
function Senddata:boolean; //请求阅读短消息函数
var
    i:integer;
    commflg:boolean;
begin
    viewstring:='' ;
    commflg:=true;
    for i:=1 to 12 do
    begin
        if not frm_Telphon.comm1.writecommdata(@RRbuf[i],2) then
        begin
            commflg:=false;
            break;
        end;
        //发送时字节间的延时
        sleep(2);
        viewstring:=viewstring + inttohex(RRbuf[i],2)+'';
    end;
    viewstring:=viewstring;
    result := commflg;
end;

function SendRead:boolean; //请求阅读短消息函数
var
    i:integer;
    commflg:boolean;
    StrText:String;
begin
    StrText:='at+cmgr='+Trim(frm_Telphon.Edit_NO.Text)+#13;
    commflg:=true;
    frm_Telphon.comm1.WriteCommData(Pchar(StrText),Length(StrText));
    StrText:=StrText;
    result := commflg;
end;
//???????????????????????????????????//

//************请求未读的短消息的函数
function UnRead:boolean; //请求阅读短消息函数
var
    i:integer;
    commflg:boolean;
    StrText:String;
begin
    StrText:='at+cmgl="rec unread"'+#13;
    commflg:=true;
    frm_Telphon.comm1.WriteCommData(Pchar(StrText),Length(StrText));
    StrText:=StrText;
    result := commflg;
end;
//*********************************
procedure Tfrm_Telphon.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
  BufferLength: Word);
var
   i,j,k,l,m,n:integer;
   s:String;
   tempstr:String;
   tempno:String; //对方电话号码
   tempsql:String;
   re_rec,re_length:integer;
begin
    viewstring:='' ;tempno:='';
    re_length:=BufferLength;
    Edit_No.Clear;
    LabeledEdit1.Clear;LabeledEdit2.Clear; LabeledEdit3.Clear;
    //Edit1.Clear;Edit2.Clear;Edit3.Clear;Edit4.Clear;Edit5.Clear;Edit6.Clear;
    move(buffer^,grbuf,BufferLength);
    //如果收到的命令格式是:+CMTI: "MT",12(index(表示短消息存储的位置));
    //实际上pc机通过232串口收到的数据格式是 :CMTI: "MT",12    后面还有结素和换行符号
    // CMTI: "MT",12
       //******这里的空行是不能掉的(0D 0A)
    //然后调用读短消息的函数
    if ((grbuf[1]=byte($0D)) and (grbuf[2]=byte($0A)) and (grbuf[3]=byte($2B))and (grbuf[4]=byte($43))and (grbuf[5]=byte($4D))and (grbuf[6]=byte($54))and (grbuf[7]=byte($49))and (grbuf[8]=byte($3A))and (grbuf[9]=byte($20))and (grbuf[10]=byte($22))and (grbuf[11]=byte($4D))and (grbuf[12]=byte($54))and (grbuf[13]=byte($22))and (grbuf[14]=byte($2C))) then
    begin
        for i:=15 to BufferLength-2 do
        begin
            tempsql:=tempsql+Chr(grbuf[i]);
            if ((StrToInt(tempsql)>0) and (StrToInt(tempsql)<10)) then
                tempsql:='0'+tempsql;
            if ((StrToInt(tempsql)>10) and (StrToInt(tempsql)<100)) then
                tempsql:=tempsql;
            Edit_No.Text:=Edit_No.Text+Chr(grbuf[i]);
            Cmd_Read.Click; //调用读短消息的函数
        end;
    end;
    //调用读短消息的函数后 、进行数据接受
    //首先接收到的数据是:at+cmgr=12
    //+CMGR: "REC UNREAD","+8613982026973",,"03/09/03,14:21:58+00" 表示未读取的信息
    if (Chr(grbuf[1])+Chr(grbuf[2])+Chr(grbuf[3])+Chr(grbuf[4])+Chr(grbuf[5])+Chr(grbuf[6])+Chr(grbuf[7])+Chr(grbuf[8]))='at+cmgr='then
    begin
        if re_length<234 then //最少长度不能小于234
        begin
            exit
        end
        else
        begin
            re_rec:=BufferLength-202+3;
            //for i:=1 to BufferLength do
            //viewstring:=viewstring + inttohex(grbuf[i],2)+'' ;
            //viewstring:=viewstring;
            Edit_NO.Clear;
            //Memo1.Lines.Add(viewstring);
            //电话号码
            for i:=re_rec to (BufferLength-187)  do
            begin
                tempno:=tempno+chr(grbuf[i]);
                LabeledEdit1.Text:=tempno;
            end;
            //短信日期
            for i:=(BufferLength-184+2) to (BufferLength-175)  do
            begin
                LabeledEdit2.Text:=LabeledEdit2.Text+chr(grbuf[i]);
            end;
            //短信时间
            for i:=(BufferLength-174+1) to (BufferLength-166)  do
            begin
                LabeledEdit3.Text:=LabeledEdit3.Text+chr(grbuf[i]);
            end;
            //****************************************************************//
            //GPS定位数据分析
            for i:=(BufferLength-160+1) to (BufferLength-8) do
            begin
                //发短信日期和时间
                for k:=0 to 3 do
                begin
                    Edit1.Clear;Edit2.Clear;Edit3.Clear;
                    Edit2.Clear;Edit5.Clear;Edit6.Clear;
                    for j:=(BufferLength-(160-38*k)+1) to (BufferLength-(160-38*k-9)) do
                    //for j:=(BufferLength-160+1) to (BufferLength-151) do
                    begin
                        Edit1.Text:='20'+inttohex(grbuf[j+2],2)+'-' +inttohex(grbuf[j+1],2)+'-'+inttohex(grbuf[j],2);//日期
                        Edit2.Text:=Chr(grbuf[j+3])+Chr(grbuf[j+4])+':' +Chr(grbuf[j+5])+Chr(grbuf[j+6])+':'+Chr(grbuf[j+7])+Chr(grbuf[j+8]); //时间
                    end;
                    //经度
                    for j:=(BufferLength-(160-38*k-9)+1) to (BufferLength-(160-38*k-19)) do
                    //for j:=(BufferLength-151+1) to (BufferLength-141) do
                    begin
                         Edit3.Text:=Edit3.Text+chr(grbuf[j]);
                    end;
                    //纬度
                    for j:=(BufferLength-(160-38*k-19)+1) to (BufferLength-(160-38*k-28)) do
                    //for j:=(BufferLength-141+1) to (BufferLength-132) do
                    begin
                         Edit4.Text:=Edit4.Text+chr(grbuf[j]);
                    end;
                    //速度

⌨️ 快捷键说明

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