Help Icon
Search Results for

    Show / Hide Table of Contents

    Add Reference in Delphi using Lazarus

    1. In order to use COM type libraries it is necessary to install LazActiveX package (comes already with Lazarus). Component

    2. Select LazActivex from the right hand side list, click on "Install package" and the package should appear in the list on the left. Component

    3. Click on "Save and Compile IDE".

    4. Register for COM library: Open Tools → "Import Type Library ..." ... Component

    5. ... and select the listed "Automation Interface for the ..." Component

    Note

    Using COM is not recommended for new developments. We recommend using the SCPI interface.

    Example of program:

    ```
    program DelphyCOMTest;
    
    {$mode objfpc}{$H+}
    
    uses
      {$IFDEF UNIX}{$IFDEF UseCThreads}
      cthreads,
      {$ENDIF}{$ENDIF}
      Classes, mscorlib_2_4_TLB, ActiveX, Windows,
    	 OmicronLab_VectorNetworkAnalysis_AutomationInterface_3_25_TLB;
    var
      ai: BodeAutomationInterface;
      bode: BodeDevice;
      s21 : S21Measurement;
      execState: ExecutionState;
      lb : Longint;
      ub : Longint;
      index : Longint;
      pindex : PLongint;
      mag : double;
      freq : double;
      executed : bool;
    
    begin
     try
    	executed := false;
    	Writeln('Hello everybody ...');
    	ai := CoBodeAutomation.Create;
    	bode := ai.Connect();
    	s21 := bode.Transmission.CreateS21Measurement();
    	s21.ConfigureSweep(10,1000,201,SweepMode_Linear);
    
    	WriteLn('Device type: ' + bode.DeviceType);
    	writeln('Serial nr.: ', bode.serialNumber);
    	writeln('Source mode: ', bode.SourceMode);
    	writeln('Min frequency: ', bode.DeviceProperties.MinFrequency);
    	writeln('Max frequency: ', bode.DeviceProperties.MaxFrequency);
    	writeln('Min output level: ', bode.DeviceProperties.MinOutputLevel);
    	writeln('Max output level: ', bode.DeviceProperties.MaxOutputLevel);
    
    	WriteLn('Executing measurement ...');
    	execState := s21.ExecuteMeasurement();
    	WriteLn('Execution returned with: ', execState);
    
    	SafeArrayGetLBound(s21.Results.Magnitude(MagnitudeUnit_dB), 1, lb);
    	SafeArrayGetUBound(s21.Results.Magnitude(MagnitudeUnit_dB), 1, ub);
    
    	 // Write results to console
    	 for index := lb to ub do
    	 begin
    		 pindex := @index; // different to embaccadero!
    		 SafeArrayGetElement(s21.Results.Magnitude(MagnitudeUnit_dB), pindex, mag);
    		 SafeArrayGetElement(s21.Results.MeasurementFrequencies, pindex, freq);
    		 Writeln('Magnitude: ', mag, ' dB', ' @', freq, ' Hz' );
    	 end;
    	 executed := true;
     finally
    	 bode.ShutDown();
    	 if (executed = false)
    		then writeln('There was an exception during the execution!')
    		else writeln('Execution completed!');
    	 WriteLn('Press ENTER key to continue ...');
    	 ReadLn;
     end;
    end.         
    ```
    
    Note

    In the line "ai := CoBodeAutomation.Create;", pay attention to the "Co" in the beginning. This is a naming convention from Delphi and it is mandatory, to create an instance of the automation interface.

    Note

    An alternative to the cost free Lazarus is Embarcadero. It can also be used to access the Bode Automation Interface at the cost of a payed license though.

    In this article
    Back to top Generated by DocFX