The unit Unit1;
Interface
USES the
Winapi. Windows, Winapi Messages, System. SysUtils, System. Variants, System. Classes, Vcl. Graphics,
The Vcl. Controls, Vcl. Forms, Vcl. Dialogs, Vcl.Com Ctrls, Vcl. StdCtrls, Registry,
Nrclasses nrcomm, rtcInfo rtcConn, rtcTcpCli, Unit2;
Type
TForm1=class (TForm)
Cbb2: TComboBox;
Tv1: TTreeView;
Cbb1: TComboBox;
Scrlbx1: TScrollBox;
Scrlbx2: TScrollBox;
Edt1: TEdit;
Lbl1: TLabel;
Btn1: TButton;
Btn2: TButton;
Nrcm1: TnrComm;
Edt2: TEdit;
Lbl2: TLabel;
Btn3: TButton;
Btn4: TButton;
Edt3: TEdit;
Edt4: TEdit;
Lbl3: TLabel;
Lbl4: TLabel;
Rtctcpclnt1: TRtcTcpClient;
Edt5: TEdit;
Edt6: TEdit;
Lbl5: TLabel;
Lbl6: TLabel;
Btn5: TButton;
Mmo1: TMemo;
Btn6: TButton;
Btn7: TButton;
Procedure cbb1Change (Sender: TObject);
Procedure FormCreate (Sender: TObject);
Procedure btn1Click (Sender: TObject);
Procedure btn2Click (Sender: TObject);
Procedure nrcm1AfterReceive (Com: TObject; Buffer: Pointer;
Received: Cardinal);
Procedure btn3Click (Sender: TObject);
Procedure cbb2Change (Sender: TObject);
Procedure tv1Change (Sender: TObject; Node: TTreeNode);
Procedure btn5Click (Sender: TObject);
Procedure rtctcpclnt1DataReceived (Sender: TRtcConnection);
Procedure rtctcpclnt1Connect (Sender: TRtcConnection);
Procedure btn6Click (Sender: TObject);
Procedure btn7Click (Sender: TObject);
Private
{Private declarations}
Public
{Public declarations}
end;
Var
Form1: TForm1;
Implementation
Var
C: Integer;
STR: TStrings;
Idd, idd1 idd2: string;
{$R *. DFM}
Procedure TForm1. Btn1Click (Sender: TObject);
The begin
Nrcm1. SendString (' \ RDID ');
C:=1;
end;
Procedure TForm1. Btn2Click (Sender: TObject);
The begin
Nrcm1. SendString (' \ STID '+ edt1. Text);
C:=2;
end;
Procedure TForm1. Btn3Click (Sender: TObject);
The begin
Nrcm1. SendString (' \ STALL? ');
Sleep (200);
C:=3;
end;
Procedure TForm1. Btn5Click (Sender: TObject);
The begin
Rtctcpclnt1. ServerAddr:=edt5. Text;
Rtctcpclnt1. ServerPort:=edt6. Text;
Rtctcpclnt1. Connect;
Rtctcpclnt1. Write (' hsware ');
end;
Procedure TForm1. Btn6Click (Sender: TObject);
The begin
Rtctcpclnt1. Write (' \ READ '+ Copy (tv1. Selected. Text, 4, 2));
end;
Procedure TForm1. Btn7Click (Sender: TObject);
The begin
Mmo1. The Clear;
end;
Procedure TForm1. Cbb1Change (Sender: TObject);
Var
I, s, n: Integer;
Node1: TTreeNode;
The begin
S:=0;
N:=1;
If cbb1. ItemIndex=0 then
Node1:=tv1. Items. The Add (nil, 'concentrator)
The else
If cbb1. ItemIndex=1 then
The begin
If tv1. Selected=nil then
ShowMessage (' choose concentrator after adding probe)
The else
If tv1. Selected. Level=1 then
ShowMessage (' can only be added to here! ')
The else
Form2. Show;
end;
end;
Procedure TForm1. Cbb2Change (Sender: TObject);
Var
B, c: Integer;
The begin
B:=Length (cbb2. Text);
C:=StrToInt (Copy (cbb2. Text, b, 8));
Nrcm1. Active:=False;
Nrcm1.Com PortNo: number=c;
Nrcm1. Active:=True;
end;
Procedure TForm1. FormCreate (Sender: TObject);
Var
Reg: TRegistry;//note: refer to the Registry unit
Namelst: TStrings;
I: integer;
The begin
Namelst:=TStringList. Create;
Reg:=TRegistry. Create;
Reg. RootKey:=HKEY_LOCAL_MACHINE;
Reg. OpenKey (' HARDWARE \ DEVICEMAP \ SERIALCOMM ', true);
Reg. GetValueNames (Namelst);
Form1. Cbb2. The Clear;
For I:=0 to Namelst. Do the Count - 1
Form1. Cbb2. Items. The Add (reg. ReadString (Namelst [I]));
Form1. Cbb2. ItemIndex:=0;
Reg. CloseKey;
Reg. Free;
Namelst. Free;
end;
//code is in this period of wrong!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Procedure TForm1. Nrcm1AfterReceive (Com: TObject; Buffer: Pointer;
Received: Cardinal);
Var
I: Integer;
S: a string;
The begin
S:=';
For I:=0 to do Received - 1
S:=s + PAnsiChar (Buffer) [I];
If c=1 then
Edt1. Text:=Copy (s, 18, 6);
If c=2 then
ShowMessage (' modify success! ');
If c=3 then
STR:=TStringList. Create;
STR. Delimiter:='; ';
STR. DelimitedText:=s;
For I:=0 to STR. Do the Count - 1
The idd: STR=[0];
Idd1: STR=[1].
Idd2:=STR [2];
Edt2. Text:=Copy (idd, 7, 20);
Edt3. Text:=idd1;
Edt4. Text:=idd2;
end;
Procedure TForm1. Rtctcpclnt1Connect (Sender: TRtcConnection);
The begin
ShowMessage (' connection success! ');
end;
Procedure TForm1. Rtctcpclnt1DataReceived (Sender: TRtcConnection);
Var
S: a string;
The begin
S:=Sender. Read;
If s<> "' then
Mmo1. Lines. The Add (s);
end;
Procedure TForm1. Tv1Change (Sender: TObject; Node: TTreeNode);
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull