⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 etransport.pas

📁 .net 方面的开发说明资料。
💻 PAS
📖 第 1 页 / 共 2 页
字号:
// ========================================================
// eTransport 1.0
//
// Design by:
// - Floris van den Berg
// - Ben Ashley
//
// Implementation by:
// - Floris van den Berg
// ========================================================

unit eTransport;

interface

uses
  Windows;

const
  DLL_NAME = 'ETransport.dll';

  // ========================================================
  // Typedefs/Defines for data
  // ========================================================

  TRANSPORT_INVALID = -1;
  TRANSPORT_NULL = 0;             // transport for test purposes
  TRANSPORT_SERIAL = 1;           // serial port transport
  TRANSPORT_TCPIP = 2;            // tcpip (winsock) transport
  TRANSPORT_TCPIP_SERVER = 3;     // tcpip (winsock listener) transport
  TRANSPORT_UDP = 4;              // udp (winsock) transport

  // ========================================================
  // Plug Options
  // ========================================================

  UDP_MULTICAST_LOOP = 0;
  UDP_MULTICAST_TTL = 1;
  UDP_MULTICAST_ADDMEMBERSHIP = 2;
  UDP_MULTICAST_DROPMEMBERSHIP = 3;

  // ========================================================
  // Defined protocol CLSIDs
  // ========================================================

  CLSID_NULL_PROTOCOL : TGUID =   '{00000000-0000-0000-C000-000000000000}';
  CLSID_SYSTEM_PROTOCOL : TGUID = '{e1223458-8996-4676-bea6-a17ff4eea04e}';
  CLSID_MODEM_PROTOCOL : TGUID =  '{0e2022a7-2ec1-4627-8dac-5358b3581e2f}';

type
  TRANSPORT_HANDLE = Pointer;

  // ========================================================
  // System protocol events and EpEvent structure
  // ========================================================

  SYSTEM_PROTOCOL = (
    SYSTEM_DATA_IN = 0,                  // the transport has received some data
    SYSTEM_DATA_OUT,                     // the transport has sent some data
    SYSTEM_SENT_PROGRESS_BYTES,          // a number of bytes were sent
    SYSTEM_SENT_PROGRESS_PERCENTAGE,     // a percentage of the packet was sent
    SYSTEM_SENT_SUCCEEDED,               // complete packet was sent
    SYSTEM_SENT_FAILED,                  // packet failed to sent completely
    SYSTEM_TIMEOUT,                      // timeout event raised
    SYSTEM_IO_ERROR,                     // generic IO error occured
    SYSTEM_CONNECTED,                    // the transport was connected
    SYSTEM_CONNECTION_FAILED,            // the transport couldn't make a connection
    SYSTEM_DISCONNECTED,                 // the transport was disconnected
    SYSTEM_NOT_SUPPORTED,                // this feature is not supported for this link
    SYSTEM_CONNECTION_REQUEST,           // a server transport request a new connection
    SYSTEM_RS232_BREAK,                  // rs232 break flag triggered
    SYSTEM_RS232_ERR_BREAK,              // The hardware detected a break condition
    SYSTEM_RS232_ERR_DNS,                // A parallel device is not selected
    SYSTEM_RS232_ERR_FRAME,              // The hardware detected a framing error
    SYSTEM_RS232_ERR_IOE,                // An I/O error occurred during communications with the device
    SYSTEM_RS232_ERR_MODE,               // The requested mode is not supported
    SYSTEM_RS232_ERR_OOP,                // A parallel device signaled that it is out of paper.
    SYSTEM_RS232_ERR_OVERRUN,            // A character-buffer overrun has occurred. The next character is lost
    SYSTEM_RS232_ERR_PTO,                // A time-out occurred on a parallel device
    SYSTEM_RS232_ERR_RXOVER,             // An input buffer overflow has occurred
    SYSTEM_RS232_ERR_RXPARITY,           // The hardware detected a parity error
    SYSTEM_RS232_ERR_TXFULL,             // The application tried to transmit a character, but the output buffer was full
    SYSTEM_RS232_CTS_ON,                 // carrier detect flag on
    SYSTEM_RS232_CTS_OFF,                // carrier detect flag off
    SYSTEM_RS232_DSR_ON,                 // data-set-ready flag on
    SYSTEM_RS232_DSR_OFF,                // data-set-ready flag off
    SYSTEM_RS232_RING_ON,                // ring indicator on
    SYSTEM_RS232_RING_OFF,               // ring indicator off
    SYSTEM_RS232_RLSD_ON,                // receive-line-signal-detect (e.g. carrier detect) on
    SYSTEM_RS232_RLSD_OFF,               // receive-line-signal-detect (e.g. carrier detect) off
    SYSTEM_TCPIP_NO_SUPPORT      ,       // addresses in the specified family cannot be used with this socket
    SYSTEM_TCPIP_CONNECTION_REFUSED,     // the attempt to connect was forcefully rejected
    SYSTEM_TCPIP_ADDRESS_UNAVAILABLE,    // the host address couldn't be resolved
    SYSTEM_TCPIP_NET_UNREACHABLE,        // the network cannot be reached from this host at this time
    SYSTEM_TCPIP_NO_BUFFERSPACE,         // no buffer space is available. the socket cannot be connected
    SYSTEM_TCPIP_NOT_CONNECTED,          // connection has been reset when SO_KEEPALIVE is set
    SYSTEM_TCPIP_CONNECTION_TIMEOUT,     // attempt to connect timed out without establishing a connection
    SYSTEM_TCPIP_SUBSYSTEM_FAILED,       //	the network subsystem has failed
    SYSTEM_TCPIP_CONNECTION_RESET,       // the connection was reset by the remote side
    SYSTEM_TCPIP_CONNECTION_ABORTED,     // the connection was terminated due to a time-out or other failure
    SYSTEM_TCPIP_NET_RESET,              // the connection has been broken due to keep-alive activity detecting a failure while the operation was in progress
    SYSTEM_TCPIP_OPERATION_ABORTED,      // the overlapped operation has been canceled due to the closure of the socket
    SYSTEM_TCPIP_UNIMPLEMENTED,          // a (not yet) implemented error occurred
    SYSTEM_TCPIP_ACCEPT_FAILED,          // winsock tried to accept a connection but couldn't
    SYSTEM_TCPIP_ACCEPT_TRY_AGAIN,       // the accept was refused by the transport. try again later
    SYSTEM_TCPIP_ACCEPT_WITHDRAWN,       // the connection request that was offered has timed out or been withdrawn.
    SYSTEM_USB_DEVICEARRIVAL,            // an USB device has been inserted and became available
    SYSTEM_USB_DEVICEQUERYREMOVE,        // request permission to remove an USB device
    SYSTEM_USB_DEVICEQUERYREMOVEFAILED,  // request to remove an USB device has been canceled
    SYSTEM_USB_DEVICEREMOVECOMPLETE,     // an USB device has been physically removed
    SYSTEM_USB_DEVICEREMOVEPENDING       // the device driver stack has been removed and the device is no longer available for use
  );

  MODEM_PROTOCOL = (
    MODEM_OK = 0,                        // modem reported 'OK'
    MODEM_CONNECT,                       // modem reported 'CONNECT'
    MODEM_BUSY,                          // modem reported 'BUSY'
    MODEM_NOCARRIER,                     // modem reported 'NO CARRIER'
    MODEM_NODIALTONE,                    // modem reported 'NO DIAL TONE'
    MODEM_DELAYEDNUMBERWAIT,             // modem reported 'DELAYED NUMBER WAIT'
    MODEM_FORBIDDENNUMBER,               // modem reported 'FORBIDDEN NUMBER'
    MODEM_RING,                          // modem reported 'RING'
    MODEM_ERROR_IN_COMMAND               // modem reported 'ERROR'
  );

  // ========================================================
  // Plug Types and property structures
  // ========================================================

  PTransportProperties = ^TransportProperties;
  TransportProperties = packed record
    size : Integer;
  end;

  PTransportPropertiesSerial = ^TransportPropertiesSerial;
  TransportPropertiesSerial = packed record
    size : Integer;
    port : PChar;
    dcb  : DCB;
  end;

  PTransportPropertiesTCPIPServer = ^TransportPropertiesTCPIPServer;
  TransportPropertiesTCPIPServer = packed record
    size : Integer;
    port : Integer;
  end;

  PTransportPropertiesUDP = ^TransportPropertiesUDP;
  TransportPropertiesUDP = packed record
    size : Integer;
    port : Integer;
  end;

  // ========================================================
  // Eplug Event
  // ========================================================

  PEpAction = ^EpAction;
  EpAction = packed record
    protocol : TGuid;
    msg : Integer;
    size : Integer;
    data : PByte;
    timeout : Integer;
  end;

  PEpEvent = ^EpEvent;
  EpEvent = packed record
    protocol : TGuid;
    msg : Integer;
    size : Integer;
    data : PByte;
    reference_id : Integer;
  end;

  PEpConnectionRequest = ^EpConnectionRequest;
  EpConnectionRequest = packed record
    _type : Integer;
    handle : Integer;
  end;

  PEpTimeOut = ^EpTimeOut;
  EpTimeOut = packed record
    protocol : TGUID;
    msg : Integer;
  end;

  // ========================================================
  // Protocol Handling
  // ========================================================

  ProtocolCreateProc = function(transport : TRANSPORT_HANDLE) : Pointer; stdcall;
  ProtocolReceiveProc = function(self : Pointer; data : PByte; size : Integer) : Boolean; stdcall;
  ProtocolSendProc = function(self : Pointer; action : PEpAction) : Boolean; stdcall;
  ProtocolDestroyProc = procedure(self : Pointer); stdcall;
  CallbackProc = procedure(transport : TRANSPORT_HANDLE; event : PEpEvent); stdcall;
  FilterProc = function(transport : TRANSPORT_HANDLE; event : PEpEvent) : Boolean; stdcall;

  PProtocol = ^Protocol;
  Protocol = packed record
    create : ProtocolCreateProc;
    receive : ProtocolReceiveProc;
    send : ProtocolSendProc;
    destroy : ProtocolDestroyProc;
  end;

  // ========================================================
  // eTransport Functions
  // ========================================================
  // ----------------------------------------------------------
  // Purpose: initialises the EPlug communication system
  // Usage  : call this function exactly ONE time at the start
  //          of the program
  // Notes  : None
  // ----------------------------------------------------------

  function EpInit(proc : CallbackProc) : Boolean; stdcall; external DLL_NAME name '_EpInit@4';

  // ----------------------------------------------------------
  // Purpose: Retrieves the number of cpus in the system
  // Usage  : This function is used internally in the library
  //          for thread creation and data load balancing
  // Notes  : This function calls the Win32 API function
  //          GetSystemInfo
  // ----------------------------------------------------------

  function EpGetCpuCount() : Integer; stdcall; external DLL_NAME name '_EpGetCpuCount@0';

  // ----------------------------------------------------------
  // Purpose: Receives the version string of the library
  // Usage  : Use this function to show the EPlug
  //          version string in an application
  // Notes  : None
  // ----------------------------------------------------------

  function EpGetVersion() : PChar; stdcall; external DLL_NAME name '_EpGetVersion@0';

  // ----------------------------------------------------------
  // Purpose: deinitialises the EPlug communication system
  // Usage  : call this function exactly ONE time at the end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -