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

#ifndef DLPortIOXH
#define DLPortIOXH
//---------------------------------------------------------------------------
#include <SysUtils.hpp>
#include <Classes.hpp>
#include <Controls.hpp>
#include "LdriverX.h"
//---------------------------------------------------------------------------
class PACKAGE TDLPortIOX : public TCustomControl
{
private:
   TLdriverX mDriver;
   Graphics::TBitmap *BpH;
   AnsiString __fastcall GetDllPAth(){return mDriver.FDLLPath;};
protected:
   virtual void __fastcall Paint();
   __property short Port[int Address]={read=ReadPort,write=WritePort};
   UCHAR __fastcall GetLPTNumPorts() { return mDriver.FLPTCount; }
public:
   __fastcall TDLPortIOX(TComponent* Owner);
   __fastcall ~TDLPortIOX(){};

    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
   short __fastcall ReadPort(int Address)
     { return mDriver.DlReadWord(Address); }
   void __fastcall WritePort(int Address, short Data)
     { mDriver.DlWriteWord(Address, Data); }
__published:
   int __fastcall GetLPTBasePort(char PortNr);
     // 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};
   __property UCHAR LPTNumPorts={read=GetLPTNumPorts};

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