unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    eSend: TEdit;
    GroupBox1: TGroupBox;
    Button1: TButton;
    Button2: TButton;
    Label4: TLabel;
    Label5: TLabel;
    cbBaudRate: TComboBox;
    Label6: TLabel;
    eReceive: TEdit;
    Label3: TLabel;
    cbCheckSum: TComboBox;
    eCOMPort: TEdit;
    Label2: TLabel;
    eTimeOut: TEdit;
    procedure Button2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

  iRet, iStatus : Integer;
  wRet          : Word ;

implementation

Uses I7000,I7000u;

{$R *.DFM}

procedure TForm1.Button2Click(Sender: TObject);
begin
     Close;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
     cbCheckSum.ItemIndex := 0;
     cbBaudRate.ItemIndex := 4;
     eCOMPort.Text        := '4';
     gszSend              := StrAlloc( 100 );
     gszReceive           := StrAlloc( 100 );
end;

procedure TForm1.Button1Click(Sender: TObject);
Var
     iRet : Integer ;
     wt : Word;
begin
     gcPort      := Char(StrToInt(eCOMPort.Text)) ;   // Setting Com Port
     gdwBaudRate := StrToInt( cbBaudRate.Text );

     iRet := IOpenCOM(gcPort, gdwBaudRate);
     If iRet > 0 Then
     Begin
        ShowMessage('COM Port Open Errror!!');
        exit;
     End;

     strCopy( gszSend, PChar(eSend.Text) );
     strCopy( gszReceive, '' );
     wRet := Send_Receive_Cmd( gcPort, gszSend, gszReceive, StrToInt(eTimeOut.Text), cbCheckSum.ItemIndex, wt );
     If wRet <> 0 Then
     Begin
          ShowMessage( 'Send-Receive-Command function error!!' + #13
                     + 'Error Code:' + IntToStr( wRet ) );
     end;

     eSend.Text    := gszSend ;
     eReceive.Text := gszReceive ;
     Close_Com (gcPort);
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
     StrDispose( gszSend );
     StrDispose( gszReceive );
end;



end.
