unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses I7000, I7000u;
{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
Var
    wt : Word;
begin
    gcPort := Char(1);
    Open_Com(gcPort, 9600, Char(8), Char(0), Char(0));
    gszSend := StrAlloc( 100 );
    gszReceive := StrAlloc( 100 );
    StrCopy( gszSend,'$01M');
    Send_Receive_Cmd( gcPort, gszSend, gszReceive, 100, 0, wt);
    Button1.Caption := TCaption( gszReceive );
    StrDispose( gszSend );
    StrDispose( gszReceive );
    Close_Com( gcPort );
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
    gcPort     := Char(1);              //Use COM1
    Open_Com( gcPort, 9600, char(8), char(0), char(0) );   //Open COM Port with Baud Rate 9600, 8 DataBits, None Paritybits , One stop bit
    gszSend := StrAlloc( 100 );
    gszReceive := StrAlloc( 100 );
    gw7000[0]  := WORD(gcPort);         //COM port that you using
    gw7000[1]  := 1;                    //Module Address at 0x01
    gw7000[2]  := $7012;                //Module ID 0x7012
    gw7000[3]  := 0;                    //Checksum 0:disable
    gw7000[4]  := 100;                  //Timeout value 0.1 second

    //Call the function "AnalogIn" to get the value from module
    //Parameters are w7000(0), f7000(0), SendTo7000, ReceiveFrom7000
    AnalogIn (@gw7000[0], @gf7000[0], gszSend, gszReceive);

    //Use caption of button "Command2" to show the analog value
    Button2.Caption := FloatToStr(gf7000[0]);
    //Close the COM port that you opened previously

    StrDispose( gszSend );
    StrDispose( gszReceive );
    Close_Com( gcPort );
end;

end.
