unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Button1: TButton;
    Button2: TButton;
    Label4: TLabel;
    Edit4: TEdit;
    Label5: TLabel;
    Edit5: TEdit;
    Label6: TLabel;
    Edit6: TEdit;
    Label7: TLabel;
    Label8: TLabel;
    Edit7: TEdit;
    Edit8: TEdit;
    Edit9: TEdit;
    Label9: TLabel;
    Button3: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Button3Click(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }

  end;

var
  Form1: TForm1;

implementation

uses I7000,I7000u;

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
Var
    wRetVal,wT:Word;
    wAddr,wModule:Word;

begin
     wAddr      := StrToInt(EDit4.text);
     wModule    := StrToInt(Edit5.text);
     gw7000[0]   := Word(gcPort);
     gw7000[1]   := wAddr;
     gw7000[2]   := wModule;
     //gw7000[3] := 0;      // CheckSum disable
     gw7000[3]   := StrToInt( Edit9.Text ); //Get Checksum status
     gw7000[4]   := 200;  // TimeOut Constant
     gw7000[6]   := 1;      // debug mode
     wRetVal    := AnalogIn(@gw7000[0],@gf7000[0],gszSend,gszReceive);
     Edit6.text := IntToStr(wRetVal);
     Edit7.text := gszSend;
     Edit8.text := gszReceive;
end;


procedure TForm1.Button2Click(Sender: TObject);
Var
    wRetVal:Word;
begin
     gcPort := Char(StrToInt(Edit1.text));
     gdwBaudRate := StrToInt(Edit2.text);
     wRetVal := IOpenCom(gcPort,gdwBaudRate);
     Edit3.text := IntToStr(wRetVal);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
     gszSend    := StrAlloc(128);
     gszReceive := StrAlloc(128);
end;

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

end;

procedure TForm1.Button3Click(Sender: TObject);
begin
     Close_Com(gcPort);
     close;
end;

end.
