unit UnitForm;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, A1560APICOM_TLB, Vcl.StdCtrls,
  VclTee.TeeGDIPlus, VCLTee.TeEngine, Vcl.ExtCtrls, VCLTee.TeeProcs,
  VCLTee.Chart, VCLTee.Series;

type
  TForm1 = class(TForm)
    EditIp: TEdit;
    ButtonConnect: TButton;
    Button1: TButton;
    Chart1: TChart;
    Series1: TLineSeries;
    procedure FormCreate(Sender: TObject);
    procedure ShowAscan(ASender: TObject; const data: IAcquisitionData);
    procedure ButtonConnectClick(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    private
    { Private declarations }
  public
    { Public declarations }
    A1560:TA1560;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.ShowAscan(ASender: TObject; const data: IAcquisitionData);
var i : Integer;
var vector: OleVariant;
begin
  vector := data.Vector;
  Chart1.Series[0].Clear;
  for i := VarArrayLowBound(vector, 1) to VarArrayHighBound(vector, 1) do
  begin
    Chart1.Series[0].AddXY(i, vector[i], '', clTeeColor);
  end;

end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  A1560.Stop();   //Most of the settings can be changed only when no measurement is perormed.
  A1560.VectorLengthSamples := 1024; //make vector shorter (default is 32768)
  A1560.TransducerType := 1;  //Set single transduer mode to view the pulse in our result
  A1560.TriggeringMode := 0;  //Set manual mode
  A1560.Start();  //Start in manual mode performs one measurement and does not need to be stopped.

end;

procedure TForm1.ButtonConnectClick(Sender: TObject);
begin
    A1560.Connect1(EditIp.Text);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
    A1560 := TA1560.Create(nil);            //All the tediousness of dealing with an COM object is incapsulated
                                            //inside TA1560 and other sample classes automatically defined in
                                            //A1560APICOM_TLB.pas generated by importing of A1560APICOM.tlb
                                            //(but do not forget to regasm.exe /codebase /tlb A1560APICOM.dll)
    A1560.OnDataReceived := self.ShowAscan; //Assign the procedure to call on every new piece of data from A1560
                                            //TODO - it should probably be unregistered in FormDestroy()

end;


end.
