📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, MotoATMode, StdCtrls;
type
TForm1 = class(TForm)
MotoATMode1: TMotoATMode;
ListBox1: TListBox;
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
GroupBox3: TGroupBox;
GroupBox4: TGroupBox;
Memo1: TMemo;
Memo2: TMemo;
Button1: TButton;
Button2: TButton;
Label1: TLabel;
Label2: TLabel;
Button3: TButton;
Button4: TButton;
Edit1: TEdit;
Button5: TButton;
Edit2: TEdit;
Button6: TButton;
Button7: TButton;
Label3: TLabel;
Button8: TButton;
GroupBox5: TGroupBox;
Memo3: TMemo;
Button9: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure MotoATMode1Arrival(Sender: TObject);
procedure MotoATMode1Remove(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure MotoATMode1Debug(const AItem: TMotoATModemItem;
const ADebugText: String; const ADebugType: TDebugType;
const ASubError: Boolean);
procedure Button9Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure AddDebug(AText:string);
begin
Form1.Memo3.Lines.Append(AText);
end;
procedure GetDevises;
var i : integer;
Dev : TMotoATModemItem;
begin
with Form1 do begin
ListBox1.Clear;
MotoATMode1.DeviceList.Update;
for i:=0 to MotoATMode1.DeviceList.Count-1 do begin
Dev := MotoATMode1.DeviceList.Items[i];
if Dev=nil then continue;
ListBox1.Items.Add(Dev.ModemInfo.LocationInfo);
end;
AddDebug(Format('I Found Phone AT Mode count: %d',[MotoATMode1.DeviceList.Count]));
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
GetDevises;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
GetDevises;
end;
procedure TForm1.ListBox1Click(Sender: TObject);
var item : TMotoATModemItem;
begin
Label3.Caption := '';
Memo1.Lines.Clear;
Label2.Caption := 'DisConnect';
if (ListBox1.ItemIndex<0) and (ListBox1.ItemIndex>=ListBox1.Count) then exit;
// Get
item := MotoATMode1.DeviceList.Items[ListBox1.ItemIndex];
if item=nil then exit;
// Info
with item.ModemInfo do begin
Memo1.Lines.Add(Format('DeviceID %d',[DeviceID]));
Memo1.Lines.Add(Format('DevicePath %s',[DevicePath]));
Memo1.Lines.Add(Format('Capabilities %d',[Capabilities]));
Memo1.Lines.Add(Format('ClassDescr %s',[ClassDescr]));
Memo1.Lines.Add(Format('ClassGUID %s',[ClassGUID]));
Memo1.Lines.Add(Format('CompatibleIDs %s',[CompatibleIDs]));
Memo1.Lines.Add(Format('ConfigFlags %d',[ConfigFlags]));
Memo1.Lines.Add(Format('LowerFilters %s',[LowerFilters]));
Memo1.Lines.Add(Format('Mfg %s',[Mfg]));
Memo1.Lines.Add(Format('UpperFilters %s',[UpperFilters]));
Memo1.Lines.Add(Format('Address %s',[Address]));
Memo1.Lines.Add(Format('BusNumber %d',[BusNumber]));
Memo1.Lines.Add(Format('Driver %s',[Driver]));
Memo1.Lines.Add(Format('BusType %s',[BusType]));
Memo1.Lines.Add(Format('Characteristics %s',[Characteristics]));
Memo1.Lines.Add(Format('DevType %s',[DevType]));
Memo1.Lines.Add(Format('Exclusive %d',[Exclusive]));
Memo1.Lines.Add(Format('LegacyBusType %s',[LegacyBusType]));
Memo1.Lines.Add(Format('LocationInfo %s',[LocationInfo]));
Memo1.Lines.Add(Format('PhysDevObjName %s',[PhysDevObjName]));
Memo1.Lines.Add(Format('Security %s',[Security]));
Memo1.Lines.Add(Format('Service %s',[Service]));
Memo1.Lines.Add(Format('UINumber %d',[UINumber]));
Memo1.Lines.Add(Format('UINumberFormat %s',[UINumberFormat]));
end;
// Status
if item.IsOpened then
Label2.Caption := 'Connect'
else
Label2.Caption := 'DisConnect';
// TimeOut
Edit1.Text := Format('%d',[item.TimeOut]);
end;
procedure TForm1.Button2Click(Sender: TObject);
var item : TMotoATModemItem;
begin
if (ListBox1.ItemIndex<0) and (ListBox1.ItemIndex>=ListBox1.Count) then exit;
item := MotoATMode1.DeviceList.Items[ListBox1.ItemIndex];
if item=nil then exit;
item.Open;
item.ClearBuffer;
ListBox1.OnClick(nil);
end;
procedure TForm1.Button3Click(Sender: TObject);
var item : TMotoATModemItem;
begin
if (ListBox1.ItemIndex<0) and (ListBox1.ItemIndex>=ListBox1.Count) then exit;
item := MotoATMode1.DeviceList.Items[ListBox1.ItemIndex];
if item=nil then exit;
item.Close;
ListBox1.OnClick(nil);
end;
procedure TForm1.Button4Click(Sender: TObject);
var item : TMotoATModemItem;
begin
if (ListBox1.ItemIndex<0) and (ListBox1.ItemIndex>=ListBox1.Count) then exit;
item := MotoATMode1.DeviceList.Items[ListBox1.ItemIndex];
if item=nil then exit;
item.SetTimeOut(StrToIntDef(Edit1.Text,item.TimeOut));
ListBox1.OnClick(nil);
end;
procedure TForm1.Button5Click(Sender: TObject);
var item : TMotoATModemItem;
begin
if (ListBox1.ItemIndex<0) and (ListBox1.ItemIndex>=ListBox1.Count) then exit;
item := MotoATMode1.DeviceList.Items[ListBox1.ItemIndex];
if (item=nil) or (Edit2.Text='') then exit;
item.SendCommand(Edit2.Text);
Form1.Caption := 'ATMode - 项塍麇龛
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -