unit iiro8u; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons, Registry, ExtCtrls ; type TMainFrm = class(TForm) Label5: TLabel; GroupBox1: TGroupBox; ExitButton: TBitBtn; Memo1: TMemo; CardName: TLabel; BeginSample: TButton; RunTimer: TTimer; RelayOut: TPanel; RelayRead: TPanel; OptoIn: TPanel; Label2: TLabel; Label3: TLabel; Label4: TLabel; AddressLabel: TLabel; procedure ExitButtonClick(Sender: TObject); procedure FormCreate(Sender: TObject); // procedure AddressListChange(Sender: TObject); procedure RunTimerTimer(Sender: TObject); procedure BeginSampleClick(Sender: TObject); procedure FormActivate(Sender: TObject); private { Private declarations } public { Public declarations } end; var MainFrm: TMainFrm; Offset : WORD; NumCards, CardNum : Integer; RunFlag:Boolean; implementation uses AIOWDM; //global variables for internal use var Siz: Integer = 8; {$R *.DFM} procedure TMainFrm.FormCreate(Sender: TObject); var found: Boolean; DeviceID, Base: LongWord; NameSize: LongWord ; Name: String; Success: LongWord; //NameSize := 256; begin found := false; RunFlag:=True; // Not a relative address call just for detection or error value return if (InPortB($61) = $AA55) then begin Application.MessageBox('ACCESNT.SYS not detected. Please copy ACCESNT.SYS into [NT]/system32/drivers and re-run this sample.', 'Warning', IDOK); end; // Use WDM driver num cards NumCards := GetNumCards(); CardNum := 0; // one and only card Offset := 0; // One and only card offset if NumCards = 0 then begin Memo1.Text := 'No cards found. The cards may not be installed, or they may be installed using a driver other than AIOWDM.sys.'; end; Success := QueryCardInfo(CardNum, @DeviceID, @Base, @NameSize, PChar(Name)); case DeviceID of $0F00: begin CardName.Caption:='PCI-IIRO-8 Digital Input/Relay Output Card'; Label5.Caption:='Windows IIRO-8/16 Sample'; Siz := 8; found := true; end; $0F08: begin CardName.Caption:='PCI-IIRO-16 Digital Input/Relay Output Card'; Label5.Caption:='Windows IIRO-8/16 Sample'; Siz := 16; found := true; end; $0DC8: begin CardName.Caption:='PCI-IDIO-16 Solid-State Input/Output Card'; Label5.Caption:='Windows IIRO-8/16 Sample'; Siz := 16; found := true; end; $0F02: begin CardName.Caption:='PCIe-IIRO-8 Digital Input/Relay Output Card'; Label5.Caption:='Windows IIRO-8/16 Sample'; Siz := 8; found := true; end; $0F09: begin CardName.Caption:='PCIe-IIRO-16 Digital Input/Relay Output Card'; Label5.Caption:='Windows IIRO-8/16 Sample'; Siz := 16; found := true; end; end;{case} if found then begin RelayOut.Caption := StringOfChar('0', Siz); RelayRead.Caption := StringOfChar('0', Siz); OptoIn.Caption := StringOfChar('0', Siz); end else begin Label5.Caption:='Windows IIRO-8/16 Sample'; CardName.Caption:='No Card Found In System'; Memo1.Lines.Clear; Memo1.Lines.Append('No Card Found.'); Memo1.Lines.Append('This may mean no card is installed, or that NTioPCI.SYS is not installed.'); //Memo1.Lines.Append('If you have a PCI card installed, please make sure you have run PCIFind.EXE.'); RunFlag:=False; end; if RunFlag then Offset := 0; // We wont use any offsets for our Relative Port commands end; procedure TMainFrm.ExitButtonClick(Sender: TObject); begin Close; end; procedure TMainFrm.RunTimerTimer(Sender: TObject); const value:array[0..2] of LongWord=(0,0,0); i:Integer=0; var j:integer; msg: String; begin value[0]:=1 shl i; RelOutPortB(CardNum, Offset,value[0]); // we will be using the Relative Port functions // You may wait here to let the relays switch before we read and display values // Useful when testing with a loopback test fixture //sleep(10); value[1] := RelInPortB(CardNum, Offset); value[2] := RelInPortB(CardNum, Offset+1); if Siz > 8 then begin RelOutPortB(CardNum, Offset + 4, value[0] shr 8); value[1] := value[1] + InPortB(Offset+ 4) shl 8; value[2] := value[2] + InPortB(Offset + 4 + 1) shl 8; end; inc(i); i := i mod Siz; msg:=StringOfChar('0', Siz); for j:=0 to Siz-1 do msg[Siz-j]:=chr(ord((value[0] and (1 shl j))>0)+$30); RelayOut.Caption := msg; for j:=0 to Siz-1 do msg[Siz-j]:=chr(ord((value[1] and (1 shl j))>0)+$30); RelayRead.Caption := msg; for j:=0 to Siz-1 do msg[Siz-j]:=chr(ord((value[2] and (1 shl j))>0)+$30); OptoIn.Caption := msg; end; procedure TMainFrm.BeginSampleClick(Sender: TObject); begin //if not RunFlag then //Placeholder if RunTimer.Enabled=True then Begin RunTimer.Enabled:=False; BeginSample.Caption:='Perform I/O'; end else begin RunTimer.Enabled:=True; BeginSample.Caption:='Stop I/O'; end; end; procedure TMainFrm.FormActivate(Sender: TObject); begin // Placeholder end; END.