unit LineX;

interface

uses
  // VCL
  ComObj, SysUtils,
  // This
  Line1C_TLB;

type
  { TLineX }

  TLineX = class
  private
    FControlInterface: ILine1C5X;
    procedure RaiseLastError;
    procedure CheckResultCode(Code: Integer);
    property ControlInterface: ILine1C5X read FControlInterface;
  private
  { IStandard }
    function GetResultCode: Integer;
    function GetResultDescription: String;
    function GetVersion: String;
    function GetCurrentDeviceIndex: Integer;
    procedure SetCurrentDeviceIndex(const Value: Integer);
    function GetCurrentDeviceNumber: Integer;
    procedure SetCurrentDeviceNumber(const Value: Integer);
    function GetCurrentDeviceName: String;
    procedure SetCurrentDeviceName(const Value: String);
    function GetDeviceCount: Integer;
  { ILine1C }
    function Get_Model: Integer;
    procedure Set_Model(Value: Integer);
    function Get_PortNumber: Integer;
    procedure Set_PortNumber(Value: Integer);
    function Get_BaudRate: Integer;
    procedure Set_BaudRate(Value: Integer);
    function Get_Parity: Integer;
    procedure Set_Parity(Value: Integer);
    function Get_DataBits: Integer;
    procedure Set_DataBits(Value: Integer);
    function Get_StopBits: Integer;
    procedure Set_StopBits(Value: Integer);
    function Get_LockDevices: Boolean;
    procedure Set_LockDevices(Value: Boolean);
    function Get_DeviceDescription: String;
    function Get_DeviceEnabled: Boolean;
    procedure Set_DeviceEnabled(Value: Boolean);
    function Get_CapBlink: Integer;
    function Get_CapBrightness: Boolean;
    function Get_CapCharacterSet: Integer;
    function Get_CapDescriptors: Boolean;
    function Get_CapHMarquee: Boolean;
    function Get_CapICharWait: Boolean;
    function Get_CapVMarquee: Boolean;
    function Get_DeviceWindows: Integer;
    function Get_DeviceRows: Integer;
    function Get_DeviceColumns: Integer;
    function Get_DeviceDescriptors: Integer;
    function Get_DeviceBrightness: Integer;
    procedure Set_DeviceBrightness(Value: Integer);
    function Get_CharacterSet: Integer;
    procedure Set_CharacterSet(Value: Integer);
    function Get_CharacterSetList: String;
    function Get_CurrentWindow: Integer;
    procedure Set_CurrentWindow(Value: Integer);
    function Get_Rows: Integer;
    function Get_Columns: Integer;
    function Get_CursorRow: Integer;
    procedure Set_CursorRow(Value: Integer);
    function Get_CursorColumn: Integer;
    procedure Set_CursorColumn(Value: Integer);
    function Get_CursorUpdate: Boolean;
    procedure Set_CursorUpdate(Value: Boolean);
    function Get_MarqueeType: Integer;
    procedure Set_MarqueeType(Value: Integer);
    function Get_MarqueeFormat: Integer;
    procedure Set_MarqueeFormat(Value: Integer);
    function Get_MarqueeUnitWait: Integer;
    procedure Set_MarqueeUnitWait(Value: Integer);
    function Get_MarqueeRepeatWait: Integer;
    procedure Set_MarqueeRepeatWait(Value: Integer);
    function Get_InterCharacterWait: Integer;
    procedure Set_InterCharacterWait(Value: Integer);
    function Get_BlinkInterval: Integer;
    procedure Set_BlinkInterval(Value: Integer);
    function Get_CapStatus: Boolean;
    function Get_DrawerOpened: Boolean;
    function Get_ServerVersion: String;
    function Get_MachineName: String;
    procedure Set_MachineName(const Value: String);
    function Get_ClientType: integer;
    function Get_ServerLoaded: Boolean;
  public
    constructor Create(AControlInterface: ILine1C5X);
    destructor Destroy; override;
  { IStandart }
    procedure AddDevice;
    procedure DeleteDevice;
    procedure ShowProperties;
    property ResultCode: Integer read GetResultCode;
    property ResultDescription: String read GetResultDescription;
    property Version: String read GetVersion;
    property CurrentDeviceIndex: Integer read GetCurrentDeviceIndex write SetCurrentDeviceIndex;
    property CurrentDeviceNumber: Integer read GetCurrentDeviceNumber write SetCurrentDeviceNumber;
    property CurrentDeviceName: String read GetCurrentDeviceName write SetCurrentDeviceName;
    property DeviceCount: Integer read GetDeviceCount;
  { ILine1C }
    procedure SelfTest;
    procedure Clear;
    procedure DisplayText(const Data: String; Attribute: Integer);
    procedure ScrollText(Direction, Units: Integer);
    procedure ClearText;
    procedure CreateWindow(ViewPortRow, ViewPortColumn, ViewportHeight,
      ViewportWidth, WindowHeight, WindowWidth: Integer);
    procedure DestroyWindow;
    procedure DisplayTextAt(Row, Column: Integer; const Data: String; Attribute: Integer);
    procedure RefreshWindow(Window: Integer);
    procedure SetDescriptor(Descriptor: Integer; Attribute: Integer);
    procedure ClearDescriptors;
    procedure OpenDrawer;
    procedure AboutBox;
    procedure AddViewPort(Row, Column, Height, Width: Integer);
    procedure ClearViewPorts;
    function GetDeviceColumns(RowIndex: Integer): Integer;
    function CapSelfTest: Boolean;
    function CapDownloadFonts: Boolean;
    property Model: Integer read Get_Model write Set_Model;
    property PortNumber: Integer read Get_PortNumber write Set_PortNumber;
    property BaudRate: Integer read Get_BaudRate write Set_BaudRate;
    property Parity: Integer read Get_Parity write Set_Parity;
    property DataBits: Integer read Get_DataBits write Set_DataBits;
    property StopBits: Integer read Get_StopBits write Set_StopBits;
    property LockDevices: Boolean read Get_LockDevices write Set_LockDevices;
    property DeviceDescription: String read Get_DeviceDescription;
    property DeviceEnabled: Boolean read Get_DeviceEnabled write Set_DeviceEnabled;
    property CapBlink: Integer read Get_CapBlink;
    property CapBrightness: Boolean read Get_CapBrightness;
    property CapCharacterSet: Integer read Get_CapCharacterSet;
    property CapDescriptors: Boolean read Get_CapDescriptors;
    property CapHMarquee: Boolean read Get_CapHMarquee;
    property CapICharWait: Boolean read Get_CapICharWait;
    property CapVMarquee: Boolean read Get_CapVMarquee;
    property DeviceWindows: Integer read Get_DeviceWindows;
    property DeviceRows: Integer read Get_DeviceRows;
    property DeviceColumns: Integer read Get_DeviceColumns;
    property DeviceDescriptors: Integer read Get_DeviceDescriptors;
    property DeviceBrightness: Integer read Get_DeviceBrightness write Set_DeviceBrightness;
    property CharacterSet: Integer read Get_CharacterSet write Set_CharacterSet;
    property CharacterSetList: String read Get_CharacterSetList;
    property CurrentWindow: Integer read Get_CurrentWindow write Set_CurrentWindow;
    property Rows: Integer read Get_Rows;
    property Columns: Integer read Get_Columns;
    property CursorRow: Integer read Get_CursorRow write Set_CursorRow;
    property CursorColumn: Integer read Get_CursorColumn write Set_CursorColumn;
    property CursorUpdate: Boolean read Get_CursorUpdate write Set_CursorUpdate;
    property MarqueeType: Integer read Get_MarqueeType write Set_MarqueeType;
    property MarqueeFormat: Integer read Get_MarqueeFormat write Set_MarqueeFormat;
    property MarqueeUnitWait: Integer read Get_MarqueeUnitWait write Set_MarqueeUnitWait;
    property MarqueeRepeatWait: Integer read Get_MarqueeRepeatWait write Set_MarqueeRepeatWait;
    property InterCharacterWait: Integer read Get_InterCharacterWait write Set_InterCharacterWait;
    property BlinkInterval: Integer read Get_BlinkInterval write Set_BlinkInterval;
    property CapStatus: Boolean read Get_CapStatus;
    property DrawerOpened: Boolean read Get_DrawerOpened;
    property ServerVersion: String read Get_ServerVersion;
    property MachineName: String read Get_MachineName write Set_MachineName;
    property ClientType: integer read Get_ClientType;
    property ServerLoaded: Boolean read Get_ServerLoaded;
  end;

  { EDisplayError }

  EDisplayError = class(Exception)
  private
   FErrorCode: integer;
  public
    property ErrorCode: integer read fErrorCode;
    constructor CreateByCode(ACode: integer; const AMessage: string);
  end;

implementation

{ EDisplayError }

constructor EDisplayError.CreateByCode(ACode: Integer;
  const AMessage: string);
begin
  inherited Create(AMessage);
  FErrorCode := ACode;
end;

{ TLineX }

constructor TLineX.Create(AControlInterface: ILine1C5X);
begin
  inherited Create;
  FControlInterface := AControlInterface;
end;

destructor TLineX.Destroy;
begin
  FControlInterface := nil;
  inherited Destroy;
end;

procedure TLineX.RaiseLastError;
begin
  if ResultCode < 0 then
    raise EDisplayError.CreateByCode(ResultCode, ResultDescription);
end;

procedure TLineX.CheckResultCode(Code: Integer);
begin
  if Code < 0 then
    raise EDisplayError.CreateByCode(Code, ResultDescription);
end;

procedure TLineX.AddDevice;
begin
  CheckResultCode(ControlInterface.AddDevice);
end;

procedure TLineX.DeleteDevice;
begin
  CheckResultCode(ControlInterface.DeleteDevice);
end;

function TLineX.GetCurrentDeviceIndex: Integer;
begin
  Result := ControlInterface.CurrentDeviceIndex;
  RaiseLastError;
end;

function TLineX.GetCurrentDeviceName: String;
begin
  Result := ControlInterface.CurrentDeviceName;
  RaiseLastError;
end;

function TLineX.GetCurrentDeviceNumber: Integer;
begin
  Result := ControlInterface.CurrentDeviceNumber;
  RaiseLastError;
end;

function TLineX.GetDeviceCount: Integer;
begin
  Result := ControlInterface.DeviceCount;
  RaiseLastError;
end;

function TLineX.GetResultCode: Integer;
begin
  Result := ControlInterface.ResultCode;
end;

function TLineX.GetResultDescription: String;
begin
  Result := ControlInterface.ResultDescription;
end;

function TLineX.GetVersion: String;
begin
  Result := ControlInterface.Version;
  RaiseLastError;
end;

procedure TLineX.SetCurrentDeviceIndex(const Value: Integer);
begin
  ControlInterface.CurrentDeviceIndex := Value;
  RaiseLastError;
end;

procedure TLineX.SetCurrentDeviceName(
  const Value: String);
begin
  ControlInterface.CurrentDeviceName := Value;
  RaiseLastError;
end;

procedure TLineX.SetCurrentDeviceNumber(const Value: Integer);
begin
  ControlInterface.CurrentDeviceNumber := Value;
  RaiseLastError;
end;

procedure TLineX.ShowProperties;
begin
  CheckResultCode(ControlInterface.ShowProperties);
end;

{ ILine1C }

function TLineX.Get_Model: Integer;
begin
  Result := ControlInterface.Model;
  RaiseLastError;
end;

procedure TLineX.Set_Model(Value: Integer);
begin
  ControlInterface.Model := Value;
  RaiseLastError;
end;

function TLineX.Get_PortNumber: Integer;
begin
  Result := ControlInterface.PortNumber;
  RaiseLastError;
end;

procedure TLineX.Set_PortNumber(Value: Integer);
begin
  ControlInterface.PortNumber := Value;
  RaiseLastError;
end;

function TLineX.Get_BaudRate: Integer;
begin
  Result := ControlInterface.BaudRate;
  RaiseLastError;
end;

procedure TLineX.Set_BaudRate(Value: Integer);
begin
  ControlInterface.BaudRate := Value;
  RaiseLastError;
end;

function TLineX.Get_Parity: Integer;
begin
  Result := ControlInterface.Parity;
  RaiseLastError;
end;

procedure TLineX.Set_Parity(Value: Integer);
begin
  ControlInterface.Parity := Value;
  RaiseLastError;
end;

function TLineX.Get_DataBits: Integer;
begin
  Result := ControlInterface.DataBits;
  RaiseLastError;
end;

procedure TLineX.Set_DataBits(Value: Integer);
begin
  ControlInterface.DataBits := Value;
  RaiseLastError;
end;

function TLineX.Get_StopBits: Integer;
begin
  Result := ControlInterface.StopBits;
  RaiseLastError;
end;

procedure TLineX.Set_StopBits(Value: Integer);
begin
  ControlInterface.StopBits := Value;
  RaiseLastError;
end;

function TLineX.Get_DeviceDescription: String;
begin
  Result := ControlInterface.DeviceDescription;
  RaiseLastError;
end;

function TLineX.Get_DeviceEnabled: Boolean;
begin
  Result := ControlInterface.DeviceEnabled;
  RaiseLastError;
end;

procedure TLineX.Set_DeviceEnabled(Value: Boolean);
begin
  ControlInterface.DeviceEnabled := Value;
  RaiseLastError;
end;

function TLineX.Get_CapBlink: Integer;
begin
  Result := ControlInterface.CapBlink;
  RaiseLastError;
end;

function TLineX.Get_CapBrightness: Boolean;
begin
  Result := ControlInterface.CapBrightness;
  RaiseLastError;
end;

function TLineX.Get_CapCharacterSet: Integer;
begin
  Result := ControlInterface.CapCharacterSet;
  RaiseLastError;
end;

function TLineX.Get_CapDescriptors: Boolean;
begin
  Result := ControlInterface.CapDescriptors;
  RaiseLastError;
end;

function TLineX.Get_CapHMarquee: Boolean;
begin
  Result := ControlInterface.CapHMarquee;
  RaiseLastError;
end;

function TLineX.Get_CapICharWait: Boolean;
begin
  Result := ControlInterface.CapICharWait;
  RaiseLastError;
end;

function TLineX.Get_CapVMarquee: Boolean;
begin
  Result := ControlInterface.CapVMarquee;
  RaiseLastError;
end;

function TLineX.Get_DeviceWindows: Integer;
begin
  Result := ControlInterface.DeviceWindows;
  RaiseLastError;
end;

function TLineX.Get_DeviceRows: Integer;
begin
  Result := ControlInterface.DeviceRows;
  RaiseLastError;
end;

function TLineX.Get_DeviceColumns: Integer;
begin
  Result := ControlInterface.DeviceColumns;
  RaiseLastError;
end;

function TLineX.Get_DeviceDescriptors: Integer;
begin
  Result := ControlInterface.DeviceDescriptors;
  RaiseLastError;
end;

function TLineX.Get_DeviceBrightness: Integer;
begin
  Result := ControlInterface.DeviceBrightness;
  RaiseLastError;
end;

procedure TLineX.Set_DeviceBrightness(Value: Integer);
begin
  ControlInterface.DeviceBrightness := Value;
  RaiseLastError;
end;

function TLineX.Get_CharacterSet: Integer;
begin
  Result := ControlInterface.CharacterSet;
  RaiseLastError;
end;

procedure TLineX.Set_CharacterSet(Value: Integer);
begin
  ControlInterface.CharacterSet := Value;
  RaiseLastError;
end;

function TLineX.Get_CharacterSetList: String;
begin
  Result := ControlInterface.CharacterSetList;
  RaiseLastError;
end;

function TLineX.Get_CurrentWindow: Integer;
begin
  Result := ControlInterface.CurrentWindow;
  RaiseLastError;
end;

procedure TLineX.Set_CurrentWindow(Value: Integer);
begin
  ControlInterface.CurrentWindow := Value;
  RaiseLastError;
end;

function TLineX.Get_Rows: Integer;
begin
  Result := ControlInterface.Rows;
  RaiseLastError;
end;

function TLineX.Get_Columns: Integer;
begin
  Result := ControlInterface.Columns;
  RaiseLastError;
end;

function TLineX.Get_CursorRow: Integer;
begin
  Result := ControlInterface.CursorRow;
  RaiseLastError;
end;

procedure TLineX.Set_CursorRow(Value: Integer);
begin
  ControlInterface.CursorRow := Value;
  RaiseLastError;
end;

function TLineX.Get_CursorColumn: Integer;
begin
  Result := ControlInterface.CursorColumn;
  RaiseLastError;
end;

procedure TLineX.Set_CursorColumn(Value: Integer);
begin
  ControlInterface.CursorColumn := Value;
  RaiseLastError;
end;

function TLineX.Get_CursorUpdate: Boolean;
begin
  Result := ControlInterface.CursorUpdate;
  RaiseLastError;
end;

procedure TLineX.Set_CursorUpdate(Value: Boolean);
begin
  ControlInterface.CursorUpdate := Value;
  RaiseLastError;
end;

function TLineX.Get_MarqueeType: Integer;
begin
  Result := ControlInterface.MarqueeType;
  RaiseLastError;
end;

procedure TLineX.Set_MarqueeType(Value: Integer);
begin
  ControlInterface.MarqueeType := Value;
  RaiseLastError;
end;

function TLineX.Get_MarqueeFormat: Integer;
begin
  Result := ControlInterface.MarqueeFormat;
  RaiseLastError;
end;

procedure TLineX.Set_MarqueeFormat(Value: Integer);
begin
  ControlInterface.MarqueeFormat := Value;
  RaiseLastError;
end;

function TLineX.Get_MarqueeUnitWait: Integer;
begin
  Result := ControlInterface.MarqueeUnitWait;
  RaiseLastError;
end;

procedure TLineX.Set_MarqueeUnitWait(Value: Integer);
begin
  ControlInterface.MarqueeUnitWait := Value;
  RaiseLastError;
end;

function TLineX.Get_MarqueeRepeatWait: Integer;
begin
  Result := ControlInterface.MarqueeRepeatWait;
  RaiseLastError;
end;

procedure TLineX.Set_MarqueeRepeatWait(Value: Integer);
begin
  ControlInterface.MarqueeRepeatWait := Value;
  RaiseLastError;
end;

function TLineX.Get_InterCharacterWait: Integer;
begin
  Result := ControlInterface.InterCharacterWait;
  RaiseLastError;
end;

procedure TLineX.Set_InterCharacterWait(Value: Integer);
begin
  ControlInterface.InterCharacterWait := Value;
  RaiseLastError;
end;

function TLineX.Get_BlinkInterval: Integer;
begin
  Result := ControlInterface.BlinkInterval;
  RaiseLastError;
end;

procedure TLineX.Set_BlinkInterval(Value: Integer);
begin
  ControlInterface.BlinkInterval := Value;
  RaiseLastError;
end;

function TLineX.Get_CapStatus: Boolean;
begin
  Result := ControlInterface.CapStatus;
  RaiseLastError;
end;

function TLineX.Get_DrawerOpened: Boolean;
begin
  Result := ControlInterface.DrawerOpened;
  RaiseLastError;
end;

procedure TLineX.SelfTest;
begin
  ControlInterface.SelfTest;
  RaiseLastError;
end;

procedure TLineX.Clear;
begin
  ControlInterface.Clear;
  RaiseLastError;
end;

procedure TLineX.DisplayText(const Data: String; Attribute: Integer);
begin
  ControlInterface.DisplayText(Data, Attribute);
  RaiseLastError;
end;

procedure TLineX.ScrollText(Direction, Units: Integer);
begin
  ControlInterface.ScrollText(Direction, Units);
  RaiseLastError;
end;

procedure TLineX.ClearText;
begin
  ControlInterface.ClearText;
  RaiseLastError;
end;

procedure TLineX.CreateWindow(ViewPortRow, ViewPortColumn, ViewportHeight,
  ViewportWidth, WindowHeight, WindowWidth: Integer);
begin
  ControlInterface.CreateWindow(ViewPortRow, ViewPortColumn, ViewportHeight, ViewportWidth, WindowHeight, WindowWidth);
  RaiseLastError;
end;

procedure TLineX.DestroyWindow;
begin
  ControlInterface.DestroyWindow;
  RaiseLastError;
end;

procedure TLineX.DisplayTextAt(Row, Column: Integer; const Data: String; Attribute: Integer);
begin
  ControlInterface.DisplayTextAt(Row, Column, Data, Attribute);
  RaiseLastError;
end;

procedure TLineX.RefreshWindow(Window: Integer);
begin
  ControlInterface.RefreshWindow(Window);
  RaiseLastError;
end;

procedure TLineX.SetDescriptor(Descriptor: Integer; Attribute: Integer);
begin
  ControlInterface.SetDescriptor(Descriptor, Attribute);
  RaiseLastError;
end;

procedure TLineX.ClearDescriptors;
begin
  ControlInterface.ClearDescriptors;
  RaiseLastError;
end;

procedure TLineX.OpenDrawer;
begin
  ControlInterface.OpenDrawer;
  RaiseLastError;
end;

procedure TLineX.AboutBox;
begin
  ControlInterface.AboutBox;
  RaiseLastError;
end;

function TLineX.Get_LockDevices: Boolean;
begin
  Result := ControlInterface.LockDevices;
  RaiseLastError;
end;

procedure TLineX.Set_LockDevices(Value: Boolean);
begin
  ControlInterface.LockDevices := Value;
  RaiseLastError;
end;

function TLineX.Get_ServerVersion: String;
begin
  Result := ControlInterface.ServerVersion;;
  RaiseLastError;
end;

function TLineX.Get_ServerLoaded: Boolean;
begin
  Result := ControlInterface.ServerLoaded;;
  RaiseLastError;
end;

function TLineX.Get_MachineName: String;
begin
  Result := ControlInterface.MachineName;
  RaiseLastError;
end;

procedure TLineX.Set_MachineName(const Value: String);
begin
  ControlInterface.MachineName := Value;
  RaiseLastError;
end;

function TLineX.Get_ClientType: integer;
begin
  Result := ControlInterface.ClientType;
  RaiseLastError;
end;

procedure TLineX.AddViewPort(Row, Column, Height, Width: Integer);
begin
  ControlInterface.AddViewPort(Row, Column, Height, Width);
  RaiseLastError;
end;

procedure TLineX.ClearViewPorts;
begin
  ControlInterface.ClearViewPorts;
  RaiseLastError;
end;

function TLineX.GetDeviceColumns(RowIndex: Integer): Integer;
begin
  Result := ControlInterface.GetDeviceColumns(RowIndex);
  RaiseLastError;
end;

function TLineX.CapSelfTest: Boolean;
begin
  Result := ControlInterface.CapSelfTest;
  RaiseLastError;
end;

function TLineX.CapDownloadFonts: Boolean;
begin
  Result := ControlInterface.CapDownloadFonts;
  RaiseLastError;
end;

end.
