//---------------------------------------------------------------------------

#ifndef DLPortIOH
#define DLPortIOH
//---------------------------------------------------------------------------
#include <SysUtils.hpp>
#include <Classes.hpp>
#include "LDriver.h"
//---------------------------------------------------------------------------
class PACKAGE TDLPortIO : public TComponent
{
private:
   TLdriver mDriver;
//   AnsiString __fastcall GetDllPAth(){return mDriver.FDLLPath;};
   short __fastcall GetPortWord(int Address){ return mDriver.DlReadWord(Address); }
   void __fastcall SetPortWord(int Address, short Data){ mDriver.DlWriteWord(Address, Data); }
protected:
public:
   __fastcall TDLPortIO(TComponent* Owner);
   void __fastcall OpenDriver(){ mDriver.OpenDriver();};
   void __fastcall CloseDriver(){ mDriver.CloseDriver();};
  // Allows write/read array of ports.
   void __fastcall PortControl(TPortRec Ports[], WORD NumPorts);
   void __fastcall PortCommand(TPortCommand Ports[], WORD NumPorts);
  // Allows read/write array of bytes from single port.
    void __fastcall ReadPortFIFO(int PortAddr, int NumPorts, int Buffer[])
     { mDriver.DlReadBufferWord(PortAddr, Buffer, NumPorts); }
   void __fastcall WritePortFIFO(int PortAddr, int NumPorts, int Buffer[])
     { mDriver.DlWriteBufferWord(PortAddr, Buffer, NumPorts); }
   // Access any port as you like, similar to the old pascal way of doing things
   int __fastcall GetLPTBasePort(char PortNr);
   __property short Port[int Address]={read=GetPortWord,write=SetPortWord};

__published:
     // Sets the path (no ending \, nor any filename) of the DLPortIO.SYS file
   // Assumed to be <windows system directory>\DRIVERS if not specified
   // Has no effect if the DriverLINX driver is already installed
   __property AnsiString DriverPath={read=mDriver.FDriverPath,write=mDriver.FDriverPath};

   // Sets the path (no ending \, nor any filename) of the DLPortIO.DLL file
   // Assumed to be "" if not specified, meaning it will search the program
   // path, windows directory and computer's path for the DLL
   __property AnsiString DLLPath={read=mDriver.FDLLPath,write=mDriver.FDLLPath};

   // True when the DLL/Driver has been loaded successfully after OpenDriver()
   __property bool ActiveHW={read=mDriver.FActiveHW};
   // This doesn't really do anything; provided for compatibility only
   __property bool HardAccess={read=mDriver.FHardAccess,write=mDriver.FHardAccess,default=true};

   // Returns the last error which occurred in Open/CloseDriver()
   __property AnsiString LastError={read=mDriver.FLastError};

};
//---------------------------------------------------------------------------
#endif
