
CPI-UD048 WindowsXP/Vista/7 32bit OS 懳墳 API 巇條彂

CPI Technologies, Inc.
========================================================================

栚師

1.  奣梫
2.  摦嶌娐嫬
3.  僾儘僌儔儉峔惉
4.  API 儕僼傽儗儞僗
4.1.  弶婜壔 API
4.1.1.  D048GetVersion
4.1.2.  D048Create
4.1.3.  D048Close
4.1.4.  D048GetDevInfo
4.1.5.  D048GetUnitType
4.1.6.  D048GetSwitchValue
4.2.  I/O API
4.2.1.  D048GetDirections
4.2.2.  D048SetDirections
4.2.3.  D048InPort
4.2.4.  D048OutPort
4.2.5.  D048SetWdt
4.2.6.  D048ResetWdt
4.2.7.  D048SetDefaultOutput
4.2.8.  D048GetWdtStatus
4.2.9.  D048SetTrgCond
4.2.10. D048SetFilter
4.3.  偦偺懠偺 API
4.3.1.  D048GetLastError
5.  儊僢僙乕僕
6.  掕悢
6.1.  僄儔乕僐乕僪
6.2.  榑棟億乕僩斣崋掕悢
6.3.  擖弌椡曽岦巜掕價僢僩儅僢僾掕悢
6.4.  偦偺懠偺掕悢

========================================================================

1.  奣梫

    杮彂偼 CPI-UD048 梡儐乕僓岞奐 API 傪僟僀僫儈僢僋儕儞僋儔僀僽儔儕
     (埲壓乽DLL乿) 儗儀儖偱掕媊偟傑偡丅
    僨僶僀僗僪儔僀僶偺徻嵶偵偮偄偰偼怗傟偰偄傑偣傫丅
    側偍丄扨堦偺 DLL 偱 CPI-UD048 傪惂屼偟傑偡丅

========================================================================

2.  摦嶌娐嫬

    杮彂偱掕媊偡傞 API 偼 Windows(R) XP/Vista/7 偺 32bit OS忋偱嵟戝
    16 戜傑偱偺 CPI-UD048 (埲壓乽僨僶僀僗乿) 傪惂屼偟傑偡丅

========================================================================

3.  僾儘僌儔儉峔惉

    杮彂偱掕媊偝傟傞 API 偼cpiud048.sys(僨僶僀僗僪儔僀僶)
    偍傛傃丄cpiud048.dll (DLL) 偵傛傝幚尰偝傟傑偡丅

========================================================================

4.  API 儕僼傽儗儞僗

    API 偼埲壓偺傛偆偵戝暿偝傟傑偡丅

        1.  弶婜壔 API
        2.  I/O API
        3.  偦偺懠偺 API

------------------------------------------------------------------------

4.1.  弶婜壔 API

------------------------------------------------------------------------

4.1.1.  D048GetVersion

仭婡擻
    僶乕僕儑儞斣崋庢摼

仭宍幃
    仠Visual C++
      BOOL D048GetVersion(PDWORD pdwDllVersion, PDWORD pdwDriverVersion);

    仠Visual Basic
      Function D048GetVersion(ByRef pdwDllVersion As Long, ByRef pdwDriverVersion As Long) As Long

    仠Delphi
      function D048GetVersion(var pdwDllVersion: DWord; var pdwDriverVersion: DWord): Boolean;

仭擖椡
    pdwDllVersion
        DLL 偺僶乕僕儑儞斣崋傪奿擺偡傞椞堟傊偺億僀儞僞丅
        NULL 壜丅
    pdwDriverVersion
        僨僶僀僗僪儔僀僶偺僶乕僕儑儞斣崋傪奿擺偡傞椞堟傊偺億僀儞僞丅
        NULL 壜丅

仭弌椡
    *pdwDllVersion
        DLL 偺僶乕僕儑儞斣崋丅

    *pdwDriverVersion
        僨僶僀僗僪儔僀僶偺僶乕僕儑儞斣崋丅

仭栠傝抣
    API偑幐攕偟偨応崌偼FALSE傪曉偟傑偡丅

仭夝愢
    DLL 偲 僨僶僀僗僪儔僀僶偺僶乕僕儑儞斣崋傪庢摼偟傑偡丅
        忋埵16Bit儊僕儍乕僶乕僕儑儞
        壓埵16Bit儅僀僫乕僶乕僕儑儞

仭僄儔乕
    D048_ERR_SYSTEM
        僔僗僥儉僄儔乕偱偡丅Windows 偺 GetLastError() 傪僐乕儖偟偰
        偔偩偝偄丅
        強掕偺僼僅儖僟偵僪儔僀僶偑柍偄摍偺棟桼偱僨僶僀僗
        僪儔僀僶偑慻傒崬傑傟偰偄側偄壜擻惈偑偁傝傑偡丅


------------------------------------------------------------------------

4.1.2.  D048Create

仭婡擻
    僨僶僀僗偺巊梡傪愰尵

仭宍幃
    仠Visual C++
      BOOL D048Create(PWORD pwLogDevice, HWND hwnd, UINT uWMCode);

    仠Visual Basic
      Function D048Create(ByRef pwLogDevice As Integer, ByVal hwnd As Long, ByVal uWMCode As Integer) As Long

    仠Delphi
      function D048Create(var pwLogDevice: Word; hwnd: THandle; uWMCode: Word): Boolean;

仭擖椡
    pwLogDevice
        巊梡偟偨偄僨僶僀僗偺榑棟僨僶僀僗斣崋傪巜掕偟傑偡丅
        榑棟僨僶僀僗斣崋偼侽偐傜巒傑傝傑偡丅
        D048_DEVICE_AUTO傪巜掕偟偨応崌丄巊梡壜擻側僨僶僀僗傪扵偟傑偡丅
        榑棟僨僶僀僗斣崋侽偐傜専嶕偟丄尒偮偐偭偨帪揰偱偦偺斣崋傪曉偟傑偡丅
        偡偱偵傾僾儕働乕僔儑儞偵傛傝巊梡偝傟偰偄傞僨僶僀僗偼僗僉僢僾偟傑偡丅
        埲屻丄傾僾儕働乕僔儑儞偼偙偺抣偱僨僶僀僗傪幆暿偟傑偡丅NULL晄壜丅
    hwnd
        億乕僩娔帇婡擻傪巊梡偡傞応崌偵僪儔僀僶偑憲弌偡傞儊僢僙乕僕傪庴偗庢傞
        僂傿儞僪僂偺僴儞僪儖傪巜掕偟傑偡丅
        儊僢僙乕僕傪巊梡偟側偄応崌偼 NULL 傪巜掕偟傑偡丅
    uWMCode
        億乕僩娔帇婡擻傪巊梡偡傞応崌偵憲弌偡傞儊僢僙乕僕 ID 偺抣傪巜掕偟傑偡丅
        捠忢 WM_USER (0x400) 埲忋偺抣傪巜掕偟傑偡丅
        儊僢僙乕僕傪巊梡偟側偄応崌偼 NULL 傪巜掕偟傑偡丅

仭弌椡
    *pwLogDevice
        巊梡壜擻側僨僶僀僗偑尒偮偐偭偨応崌偼丄偦偺榑棟僨僶僀僗斣崋偑
        奿擺偝傟傑偡丅
        尒偮偐傜側偐偭偨応崌丄偙偺抣偼枹掕媊偱偡丅

仭栠傝抣
    API偑幐攕偟偨応崌偼FALSE傪曉偟傑偡丅

仭夝愢
    僨僶僀僗傪傾僾儕働乕僔儑儞偑巊梡偡傞偙偲傪僪儔僀僶偵捠抦偟傑偡丅
    僨僶僀僗偑懚嵼偟偰偄側偄応崌偼丄僄儔乕偲側傝傑偡丅
    偡偱偵懠偺傾僾儕働乕僔儑儞偱巊梡偝傟偰偄傞応崌傕僄儔乕偲側傝傑偡丅
    偙傟偵傛傝丄侾偮偺僨僶僀僗偼扨堦偺傾僾儕働乕僔儑儞偐傜攔懠揑偵巊梡
    偝傟傑偡丅
    懠偺API傪屇傃弌偡慜偵昁偢偙偺API傪屇傃弌偟偰偔偩偝偄丅
    偙偺API偑幐攕偟偨応崌丄D048GetLastError()偺iDev偵偼
    D048_DEVICE_AUTO傪巜掕偟偰偔偩偝偄丅

仭拲堄
    偡傋偰偺億乕僩偼擖椡曽岦偵弶婜壔偝傟傑偡丅
    妱傝崬傒偼嬛巭忬懺偵側傝傑偡丅

仭僄儔乕
    D048_ERR_SYSTEM
        僔僗僥儉僄儔乕偱偡丅
    D048_ERR_NO_DEVICE
        巊梡壜擻側僨僶僀僗偑偁傝傑偣傫丅
    D048_ERR_IN_USE
        巜掕偺僨僶僀僗偼巊梡拞偱偡
    D048_ERR_INVALID_DEVICENO
        柍岠側榑棟僨僶僀僗斣崋偱偡丅
    D048_ERR_INVALID_ARGUMENT
        柍岠側堷悢偑巜掕偝傟傑偟偨丅


------------------------------------------------------------------------

4.1.3.  D048Close

仭婡擻
    巊梡拞偺僨僶僀僗夝曻

仭宍幃
    仠Visual C++
      BOOL D048Close(WORD wLogDevice);

    仠Visual Basic
      Function D048Close(ByVal wLogDevice As Integer) As Long

    仠Delphi
      function D048Close(wLogDevice: Word): Boolean;


仭擖椡
    wLogDevice
        夝曻偡傞僨僶僀僗偺榑棟僨僶僀僗斣崋傪巜掕偟傑偡丅

仭栠傝抣
    API偑幐攕偟偨応崌偼FALSE傪曉偟傑偡丅

仭夝愢
    傾僾儕働乕僔儑儞偑僨僶僀僗偺巊梡傪廔椆偟丄僨僶僀僗傪懠偺
    傾僾儕働乕僔儑儞偵奐曻偡傞偙偲傪僨僶僀僗僪儔僀僶偵捠抦偟傑偡丅
    傾僾儕働乕僔儑儞傪廔椆偡傞慜偵昁偢偙偺API傪屇傃弌偟偰偔偩偝偄丅

仭僄儔乕
    D048_ERR_SYSTEM
        僔僗僥儉僄儔乕偱偡丅
    D048_ERR_INVALID_DEVICENO
        柍岠側榑棟僨僶僀僗斣崋偱偡丅
    D048_ERR_INVALID_ARGUMENT
        柍岠側堷悢偑巜掕偝傟傑偟偨丅


------------------------------------------------------------------------

4.1.4.  D048GetDevInfo

仭婡擻
    僨僶僀僗忣曬傪庢摼

仭宍幃
    仠VisualC++
      #define D048_CCH_VEN         8
      #define D048_CCH_DEV         16
      #define D048_CCH_VER         4

      typedef struct  SD048DI {
          unsigned short  wCdb;       /* bytes of command descriptor */
          unsigned short  wSdb;       /* bytes of status descriptor */
          unsigned long   dwBuff;     /* bytes of internal buffer */
          char sVen[ D048_CCH_VEN ];  /* vendor name */
          char sDev[ D048_CCH_DEV ];  /* device name */
          char sVer[ D048_CCH_VER ];  /* firmware version */
      } TD048DI, * PD048DI;

      BOOL WINAPI D048GetDevInfo(WORD wLogDevice, PD048DI pDevInfo);

    仠Visual Basic
      Global Const D048_CCH_VEN = 8
      Global Const D048_CCH_DEV = 16
      Global Const D048_CCH_VER = 4

      Type SD048DI
          wCdb As Integer                     ' bytes of command descriptor
          wSdb As Integer                     ' bytes of status descriptor
          dwBuff As Long                      ' bytes of internal buffer
          sVen(1 To D048_CCH_VEN) As Byte     ' vendor name
          sDev(1 To D048_CCH_DEV) As Byte     ' device name
          sVer(1 To D048_CCH_VER) As Byte     ' firmware version
      End Type

      Function D048GetDevInfo(ByVal wLogDevice As Integer, ByRef pDevInfo As SD048DI) As Long

    仠Delphi
      const
        D048_CCH_VEN = 8;
        D048_CCH_DEV = 16;
        D048_CCH_VER = 4;

      type
        SD048DI = record
          wCdb:   Word;                                   // bytes of command descriptor
          wSdb:   Word;                                   // bytes of status descriptor
          dwBuff: DWord;                                  // bytes of internal buffer
          sVen:   array [0 .. D048_CCH_VEN - 1] of Byte;  // vendor name
          sDev:   array [0 .. D048_CCH_DEV - 1] of Byte;  // device name
          sVer:   array [0 .. D048_CCH_VER - 1] of Byte;  // firmware version
        end;
     PD048DI = ^SD048DI;

     function D048GetDevInfo(wLogDevice: Word; pDevInfo: PD048DI): Boolean;

仭擖椡
    wLogDevice
        榑棟僨僶僀僗斣崋傪巜掕偟傑偡丅
    pDevInfo
        僨僶僀僗忣曬傪奿擺偡傞椞堟傊偺億僀儞僞傪巜掕偟傑偡丅

仭弌椡
    *pDevInfo
        wCdb
            僐儅儞僪 僨傿僗僋儕僾僞偺僶僀僩悢偑奿擺偝傟傑偡丅
        wSdb
            僗僥乕僞僗 僨傿僗僋儕僾僞偺僶僀僩悢偑奿擺偝傟傑偡丅
        dwBuff
            僨僶僀僗撪晹僶僢僼傽偺僶僀僩悢偑奿擺偝傟傑偡丅
        sVen
            儀儞僟幆暿暥帤楍偑奿擺偝傟傑偡丅
        sDev
            僾儘僟僋僩幆暿暥帤楍偑奿擺偝傟傑偡丅
        sVer
            僼傽乕儉僂僃傾偺僶乕僕儑儞暥帤楍偑奿擺偝傟傑偡丅

仭栠傝抣
    API偑幐攕偟偨応崌偼FALSE傪曉偟傑偡丅

仭夝愢
    巜掕僨僶僀僗偺忣曬傪庢摼偟傑偡丅
    暥帤楍偼NUL廔抂偱偼偁傝傑偣傫丅

仭僄儔乕
    D048_ERR_SYSTEM
        僔僗僥儉僄儔乕偱偡丅
    D048_ERR_INVALID_DEVICENO
        柍岠側榑棟僨僶僀僗斣崋偱偡丅
    D048_ERR_INVALID_ARGUMENT
        柍岠側堷悢偑巜掕偝傟傑偟偨丅


------------------------------------------------------------------------

4.1.5. D048GetUnitType

仭婡擻
    儐僯僢僩僞僀僾乮TTL/CMOS乯傪庢摼

仭宍幃
    仠Visual C++
      #define D048_TYPE_TTL    0
      #define D048_TYPE_CMOS   1

      BOOL D048GetUnitType(WORD wLogDevice, PDWORD pdwType);

    仠Visual Basic
      Global Const D048_TYPE_TTL = 0
      Global Const D048_TYPE_CMOS = 1

      Function D048GetUnitType(ByVal wLogDevice As Integer, ByRef pdwType As Long) As Long

    仠Delphi
      D048_TYPE_TTL  = 0;
      D048_TYPE_CMOS = 1;

      function D048GetUnitType(wLogDevice: Word; var pdwType: Dword): Boolean;

仭擖椡
    wLogDevice
        榑棟僨僶僀僗斣崋傪巜掕偟傑偡丅
    pdwType
        僞僀僾抣傪奿擺偡傞椞堟傊偺億僀儞僞丅
        NULL偼晄壜丅

仭弌椡
    *pdwType
        僞僀僾抣丅

仭栠傝抣
    API偑幐攕偟偨応崌偼FALSE傪曉偟傑偡丅

仭夝愢
    巜掕僨僶僀僗偺僞僀僾乮TTL/CMOS乯傪庢摼偟傑偡丅

仭僄儔乕
    D048_ERR_SYSTEM
        僔僗僥儉僄儔乕偱偡丅
    D048_ERR_INVALID_DEVICENO
        柍岠側榑棟僨僶僀僗斣崋偱偡丅
    D048_ERR_INVALID_ARGUMENT
        pdwType偑NULL偱偡丅

------------------------------------------------------------------------

4.1.6. D048GetSwitchValue

仭婡擻
    儐僯僢僩僙儗僋僩僗僀僢僠偺抣傪庢摼

仭宍幃
    仠Visual C++
      BOOL D048GetSwitchValue(WORD wLogDevice, PDWORD pdwSwitchValue);

    仠Visual Basic
      Function D048GetSwitchValue(ByVal wLogDevice As Integer, ByRef pdwSwitchValue As Long) As Long

    仠Delphi
      function D048GetSwitchValue(wLogDevice: Word; var pdwSwitchValue: DWord): Boolean;

仭擖椡
    wLogDevice
        榑棟僨僶僀僗斣崋傪巜掕偟傑偡丅
    pdwSwitchValue
        儐僯僢僩僙儗僋僩僗僀僢僠偺抣傪奿擺偡傞椞堟傊偺億僀儞僞丅
        NULL偼晄壜丅

仭弌椡
    *pdwSwitchValue
        儐僯僢僩僙儗僋僩僗僀僢僠偺抣丅

仭栠傝抣
    API偑幐攕偟偨応崌偼FALSE傪曉偟傑偡丅

仭夝愢
    巜掕僨僶僀僗偺儐僯僢僩僙儗僋僩僗僀僢僠偺抣傪庢摼偟傑偡丅

仭僄儔乕

    D048_ERR_SYSTEM
        僔僗僥儉僄儔乕偱偡丅
    D048_ERR_INVALID_DEVICENO
        柍岠側榑棟僨僶僀僗斣崋偱偡丅
    D048_ERR_INVALID_ARGUMENT
        pdwSwitchValue偑NULL偱偡丅

------------------------------------------------------------------------

4.2.  I/O API

------------------------------------------------------------------------

4.2.1. D048GetDirections

仭婡擻
    曽岦庢摼

仭宍幃
    仠Visual C++
      BOOL D048GetDirections(WORD wLogDevice, PDWORD pdwDirections);

    仠Visual Basic
      Function D048GetDirections(ByVal wLogDevice As Integer, ByRef pdwDirections As Long) As Long

    仠Delphi
      function D048GetDirections(wLogDevice: Word; var pdwDirections: Dword): Boolean;

仭擖椡
    wLogDevice
        榑棟僨僶僀僗斣崋傪巜掕偟傑偡丅
    pdwDirections
        曽岦忣曬傪奿擺偡傞椞堟傊偺億僀儞僞丅
        NULL偼晄壜丅

仭弌椡
    *pdwDirections
        庢摼偟偨曽岦丅
        偙偺抣偼奺億乕僩偵懳墳偟偨價僢僩儅僢僾偵側偭偰偄傑偡丅
            劕劒劒劒劒劚劒劒劒劒劖
            劔 價僢僩 劔 億乕僩 劔
            劙劒劒劒劒劥劒劒劒劒劜
            劔   侽   劔   俙   劔
            劔   侾   劔   俛   劔
            劔   俀   劔   俠   劔
            劔   俁   劔   俢   劔
            劔   係   劔   俤   劔
            劔   俆   劔   俥   劔
            劘劒劒劒劒劤劒劒劒劒劗
        奺價僢僩偼侽偱弌椡丄侾偱擖椡曽岦偵愝掕偝傟偰偄傑偡丅

仭栠傝抣
    API偑幐攕偟偨応崌偼FALSE傪曉偟傑偡丅

仭夝愢
    巜掕僨僶僀僗偺曽岦傪庢摼偟傑偡丅

仭僄儔乕
    D048_ERR_SYSTEM
        僔僗僥儉僄儔乕偱偡丅
    D048_ERR_INVALID_DEVICENO
        柍岠側榑棟僨僶僀僗斣崋偱偡丅
    D048_ERR_INVALID_ARGUMENT
        pdwDirections偑NULL偱偡丅

------------------------------------------------------------------------

4.2.2. D048SetDirections

仭婡擻
    曽岦愝掕

仭宍幃
    仠Visual C++
      BOOL D048SetDirections(WORD wLogDevice, DWORD dwDirections);

    仠Visual Basic
      Function D048SetDirections(ByVal wLogDevice As Integer, ByVal dwDirections As Long) As Long

    仠Delphi
      function D048SetDirections(wLogDevice: Word; dwDirections: Dword): Boolean;

仭擖椡
    wLogDevicev
        榑棟僨僶僀僗斣崋傪巜掕偟傑偡丅
    dwDirections
        曽岦傪奺億乕僩偵懳墳偟偨價僢僩儅僢僾偱巜掕偟傑偡丅
            劕劒劒劒劒劚劒劒劒劒劖
            劔 價僢僩 劔 億乕僩 劔
            劙劒劒劒劒劥劒劒劒劒劜
            劔   侽   劔   俙   劔
            劔   侾   劔   俛   劔
            劔   俀   劔   俠   劔
            劔   俁   劔   俢   劔
            劔   係   劔   俤   劔
            劔   俆   劔   俥   劔
            劘劒劒劒劒劤劒劒劒劒劗
        奺價僢僩偼侽偱弌椡丄侾偱擖椡曽岦偵愝掕偝傟傑偡丅

仭栠傝抣
    API偑幐攕偟偨応崌偼FALSE傪曉偟傑偡丅

仭夝愢
    巜掕僨僶僀僗偺僨傿儗僋僔儑儞傪愝掕偟傑偡丅

仭拲堄
    桳岠側億乕僩悢埲忋偺價僢僩偼柍帇偝傟傑偡丅

仭僄儔乕
    D048_ERR_SYSTEM
        僔僗僥儉僄儔乕偱偡丅
    D048_ERR_INVALID_DEVICENO
        柍岠側榑棟僨僶僀僗斣崋偱偡丅

------------------------------------------------------------------------

4.2.3. D048InPort

仭婡擻
    擟堄偺億乕僩偐傜僨乕僞傪擖椡

仭宍幃
    仠Visual C++
      BOOL D048InPort(WORD wLogDevice, DWORD dwLogPort, PBYTE pbInValue);

    仠Visual Basic
      Function D048InPort(ByVal wLogDevice As Integer, ByVal dwLogPort As Long, ByRef pbInValue As Byte) As Long

    仠Delphi
      function D048InPort(wLogDevice: Word; dwLogPort: DWord; var pbInValue: Byte): Boolean;

仭擖椡
    wLogDevice
        榑棟僨僶僀僗斣崋傪巜掕偟傑偡丅
    dwLogPort
        偙偺榑棟億乕僩斣崋偺擖椡傪幚峴偟傑偡丅
    pbInValue
        擖椡僨乕僞傪奿擺偡傞椞堟傊偺億僀儞僞丅
        NULL偼晄壜丅

仭弌椡
    *pbInValue
        奩摉億乕僩(dwLogPort抣)偑擖椡億乕僩偵愝掕偝傟偰偄傞応崌
            擖椡僨乕僞抣偵懳偟D048SetFilter偱愝掕偝傟偨僼傿儖僞偑偐偗傜傟偨
            抣偑撉傒弌偝傟傑偡丅

        奩摉億乕僩(dwLogPort抣)偑弌椡億乕僩偵愝掕偝傟偰偄傞応崌
            D048OutPort偱弌椡偝傟偨弌椡僨乕僞抣偑儕乕僪僶僢僋偝傟傑偡丅

仭栠傝抣
    API偑幐攕偟偨応崌偼FALSE傪曉偟傑偡丅

仭夝愢
    巜掕僨僶僀僗偺巜掕榑棟億乕僩偐傜擖椡偟傑偡丅

仭僄儔乕
    D048_ERR_SYSTEM
        僔僗僥儉僄儔乕偱偡丅
    D048_ERR_INVALID_DEVICENO
        柍岠側榑棟僨僶僀僗斣崋偱偡丅
    D048_ERR_INVALID_ARGUMENT
        pbInValue偑NULL偱偡丅
    D048_ERR_INVALID_PORT
        柍岠側榑棟億乕僩斣崋偱偡丅

------------------------------------------------------------------------

4.2.4. D048OutPort

仭婡擻
    擟堄偺億乕僩傊偺僨乕僞弌椡

仭宍幃
    仠Visual C++
      BOOL D048OutPort(WORD wLogDevice, DWORD dwLogPort, BYTE bOutValue);

    仠Visual Basic
      Function D048OutPort(ByVal wLogDevice As Integer, ByVal dwLogPort As Long, ByVal bOutValue As Byte) As Long

    仠Delphi
      function D048OutPort(wLogDevice: Word; dwLogPort: DWord; bOutValue: Byte): Boolean;

仭擖椡
    wLogDevice
        榑棟僨僶僀僗斣崋傪巜掕偟傑偡丅
    dwLogPort
        偙偺榑棟億乕僩斣崋傊偺弌椡傪幚峴偟傑偡丅
    bOutValue
        弌椡僨乕僞丅

仭栠傝抣
    API偑幐攕偟偨応崌偼FALSE傪曉偟傑偡丅

仭夝愢
    巜掕僨僶僀僗偺巜掕榑棟億乕僩偵弌椡偟傑偡丅

仭僄儔乕
    D048_ERR_SYSTEM
        僔僗僥儉僄儔乕偱偡丅
    D048_ERR_INVALID_DEVICENO
        柍岠側榑棟僨僶僀僗斣崋偱偡丅
    D048_ERR_INVALID_PORT
        柍岠側榑棟億乕僩斣崋偱偡丅
    D048_ERR_BAD_DIRECTION
        晄惓側曽岦偱偡丅

------------------------------------------------------------------------

4.2.5. D048SetWdt

仭婡擻
    僂僅僢僠僪僢僌僞僀儉傾僂僩帪娫偺愝掕
    偍傛傃僂僅僢僠僪僢僌婡擻偺奐巒丄掆巭

仭宍幃
    仠Visual C++
      bWdtValue偵愝掕偡傞抣
        #define D048_WDT_INTERVAL_STOP        0
        #define D048_WDT_INTERVAL_126         1
        #define D048_WDT_INTERVAL_252         2
        #define D048_WDT_INTERVAL_504         3
        #define D048_WDT_INTERVAL_1008        4
        #define D048_WDT_INTERVAL_2016        5

      BOOL D048SetWdt(WORD wLogDevice, BYTE bWdtValue);

    仠Visual Basic
      bWdtValue偵愝掕偡傞抣
        Global Const D048_WDT_INTERVAL_STOP = 0
        Global Const D048_WDT_INTERVAL_126 = 1
        Global Const D048_WDT_INTERVAL_252 = 2
        Global Const D048_WDT_INTERVAL_504 = 3
        Global Const D048_WDT_INTERVAL_1008 = 4
        Global Const D048_WDT_INTERVAL_2016 = 5

     Function D048SetWdt(ByVal wLogDevice As Integer, ByVal bWdtValue As Byte) As Long

    仠Delphi
      bWdtValue偵愝掕偡傞抣
        D048_WDT_INTERVAL_STOP = 0;
        D048_WDT_INTERVAL_126  = 1;
        D048_WDT_INTERVAL_252  = 2;
        D048_WDT_INTERVAL_504  = 3;
        D048_WDT_INTERVAL_1008 = 4;
        D048_WDT_INTERVAL_2016 = 5;

     function D048SetWdt(wLogDevice: Word; bWdtValue: Byte): Boolean;

仭擖椡
    wLogDevicev
        榑棟僨僶僀僗斣崋傪巜掕偟傑偡丅
    bWdtValue
        僂僅僢僠僪僢僌僞僀儉傾僂僩帪娫傪懳墳偟偨抣偱巜掕偟傑偡丅

            劕劒劒劒劒劒劒劒劒劒劚劒劒劒劒劒劒劒劒劒劒劒劒劖
            劔        抣        劔   帪娫                 劔
            劙劒劒劒劒劒劒劒劒劒劥劒劒劒劒劒劒劒劒劒劒劒劒劜
            劔侽(僨僼僅儖僩抣)  劔僂僅僢僠僪僢僌婡擻掆巭  劔
            劔侾                劔            侾俀俇倣俽  劔
            劔俀                劔            俀俆俀倣俽  劔
            劔俁                劔            俆侽係倣俽  劔
            劔係                劔          侾侽侽俉倣俽  劔
            劔俆                劔          俀侽侾俇倣俽  劔
            劘劒劒劒劒劒劒劒劒劒劤劒劒劒劒劒劒劒劒劒劒劒劒劗

仭栠傝抣
    API偑幐攕偟偨応崌偼FALSE傪曉偟傑偡丅

仭夝愢
    巜掕僨僶僀僗偺僂僅僢僠僪僢僌僞僀儉傾僂僩帪娫傪愝掕偟傑偡丅

仭僄儔乕
    D048_ERR_SYSTEM
        僔僗僥儉僄儔乕偱偡丅
    D048_ERR_INVALID_DEVICENO
        柍岠側榑棟僨僶僀僗斣崋偱偡丅
    D048_ERR_INVALID_ARGUMENT
        bWdtValue偑柍岠側抣偱偡丅

------------------------------------------------------------------------

4.2.6.  D048ResetWdt

仭婡擻
    僂僅僢僠僪僢僌僞僀儉傾僂僩帪娫傪弶婜抣偵偡傞丅

仭宍幃
    仠Visual C++
      BOOL D048ResetWdt(WORD wLogDevice);

    仠Visual Basic
      Function D048ResetWdt(ByVal wLogDevice As Integer) As Long

    仠Delphi
      function UD048ResetWdt(wLogDevice: Word): Boolean;

仭擖椡
    wLogDevice
        榑棟僨僶僀僗斣崋傪巜掕偟傑偡丅

仭栠傝抣
    API偑幐攕偟偨応崌偼FALSE傪曉偟傑偡丅

仭夝愢
    巜掕僨僶僀僗偺僞僀儅傪弶婜壔偟傑偡丅

仭僄儔乕
    D048_ERR_SYSTEM
        僔僗僥儉僄儔乕偱偡丅
    D048_ERR_SYSTEM
        僔僗僥儉僄儔乕偱偡丅
    D048_ERR_INVALID_DEVICENO
        柍岠側榑棟僨僶僀僗斣崋偱偡丅

------------------------------------------------------------------------

4.2.7. D048SetDefaultOutput

仭婡擻
    僂僅僢僠僪僢僌僞僀儉傾僂僩屻偵弌椡偡傞億乕僩偍傛傃抣偺愝掕

仭宍幃
    仠Visual C++
      BOOL D048SetDefaultOutput(WORD wLogDevice, DWORD dwLogPort, BYTE bDefaultValue);

    仠Visual Basic
      Function D048SetDefaultOutput(ByVal wLogDevice As Integer, ByVal dwLogPort As Long, ByVal bDefaultValue As Byte) As Long

    仠Delphi
      function D048SetDefaultOutput(wLogDevice: Word; dwLogPort: DWord; bDefaultValue: Byte): Boolean;

仭擖椡
    wLogDevice
        榑棟僨僶僀僗斣崋傪巜掕偟傑偡丅
    dwLogPort
        偙偺榑棟億乕僩斣崋傊偺弌椡傪幚峴偟傑偡丅
    bDefaultValue
        弌椡僨乕僞丅
        僨僼僅儖僩抣偼0x00

仭栠傝抣
    API偑幐攕偟偨応崌偼FALSE傪曉偟傑偡丅

仭夝愢
    僂僅僢僠僪僢僌僞僀儉傾僂僩屻偵弌椡偡傞抣傪
    巜掕僨僶僀僗偺巜掕榑棟億乕僩偵愝掕偟傑偡丅

仭僄儔乕
    D048_ERR_SYSTEM
        僔僗僥儉僄儔乕偱偡丅
    D048_ERR_INVALID_DEVICENO
        柍岠側榑棟僨僶僀僗斣崋偱偡丅
    D048_ERR_INVALID_PORT
        柍岠側榑棟億乕僩斣崋偱偡丅
    D048_ERR_BAD_DIRECTION
        晄惓側曽岦偱偡丅

------------------------------------------------------------------------

4.2.8. D048GetWdtStatus

仭婡擻
    僂僅僢僠僪僢僌僇僂儞僞偺忬懺傪庢摼

仭宍幃
    仠Visual C++
      #define D048_WDT_FLAG_OFF    0
      #define D048_WDT_FLAG_ON     1

      BOOL D048GetWdtStatus(WORD wLogDevice, PBYTE pbWdtStatus);

    仠Visual Basic
      Global Const D048_WDT_FLAG_OFF = 0
      Global Const D048_WDT_FLAG_ON = 1

      Function D048GetWdtStatus(ByVal wLogDevice As Integer, ByRef pbWdtStatus As Byte) As Long

    仠Delphi
      D048_WDT_FLAG_OFF = 0;
      D048_WDT_FLAG_ON  = 1;

      function D048GetWdtStatus(wLogDevice: Word; var pbWdtStatus: Byte): Boolean;

仭擖椡
    wLogDevice
        榑棟僨僶僀僗斣崋傪巜掕偟傑偡丅
    pbWdtStatus
        僂僅僢僠僪僢僌僇僂儞僞偺忬懺傪奿擺偡傞椞堟傊偺億僀儞僞丅
        NULL偼晄壜丅

仭弌椡
    *pbWdtStatus
        僂僅僢僠僪僢僌僇僂儞僞偺忬懺丅

仭栠傝抣
    API偑幐攕偟偨応崌偼FALSE傪曉偟傑偡丅

仭夝愢
    巜掕僨僶僀僗偺僂僅僢僠僪僢僌僇僂儞僞偺忬懺傪庢摼偟傑偡丅
    D048_WDT_FLAG_OFF 0: 僂僅僢僠僪僢僌偑柍岠傑偨偼丄僞僀儉傾僂僩慜
    D048_WDT_FLAG_ON  1: 僂僅僢僠僪僢僌偑僞僀儉傾僂僩

仭僄儔乕
    D048_ERR_SYSTEM
        僔僗僥儉僄儔乕偱偡丅
    D048_ERR_INVALID_DEVICENO
        柍岠側榑棟僨僶僀僗斣崋偱偡丅
    D048_ERR_INVALID_ARGUMENT
        pbWdtStatus偑NULL偱偡丅

------------------------------------------------------------------------

4.2.9.  D048SetTrgCond

仭婡擻
    億乕僩娔帇偺愝掕

仭宍幃
    仠VisualC++
      TD048PTRGCOND.bMode偵愝掕偡傞抣
        #define D048_MON_NONE          0
        #define D048_MON_ALT           1
        #define D048_MON_AND           2
        #define D048_MON_OR            3

      typedef struct SD048PTRGCOND {
          BYTE bMode;
          BYTE bMask;
          BYTE bData;
      } TD048PTRGCOND, *PD048PTRGCOND;

      BOOL WINAPI D048SetTrgCond(WORD wLogDevice, DWORD dwLogPort, PD048PTRGCOND pTrgCond);

    仠Visual Basic
      TD048PTRGCOND.bMode偵愝掕偡傞抣
        Global Const D048_MON_NODE = 0
        Global Const D048_MON_ALT = 1
        Global Const D048_MON_AND = 2
        Global Const D048_MON_OR = 3

      Type SD048PTRGCOND
          bMode As Byte
          bMask As Byte
          bData As Byte
      End Type

      Function D048SetTrgCond(ByVal wLogDevice As Integer, ByVal dwLogPort As Long, ByRef pTrgCond As SD048PTRGCOND) As Long

    仠Delphi
      TD048PTRGCOND.bMode偵愝掕偡傞抣
        D048_MON_NODE = 0;
        D048_MON_ALT  = 1;
        D048_MON_AND  = 2;
        D048_MON_OR   = 3;

      type
        SD048PTRGCOND = record
          bMode:  Byte;
          bMask:  Byte;
          bData:  Byte;
        end;
      PD048PTRGCOND = ^SD048PTRGCOND;

     function D048SetTrgCond(wLogDevice: Word; dwLogPort: DWord; pTrgCond: PD048PTRGCOND): Boolean;

仭擖椡
    wLogDevice
        榑棟僨僶僀僗斣崋傪巜掕偟傑偡丅
    dwLogPort
        娔帇傪偡傞億乕僩偺榑棟斣崋傪巜掕偟傑偡丅
    pTrgCond
        億乕僩娔帇抣傪奿擺偡傞椞堟傊偺億僀儞僞丅
        NULL偼晄壜丅

       丒bMode偵愝掕偡傞抣
            劕劒劒劒劒劒劒劒劒劒劚劒劒劒劒劒劒劒劒劚劒劒劒劒劒劒劒劒劒劒劒劚劒劒劒劒劒劒劒劖
            劔   抣             劔      掕媊      劔    億乕僩娔帇忦審    劔   娭學梫場   劔
            劙劒劒劒劒劒劒劒劒劒劥劒劒劒劒劒劒劒劒劥劒劒劒劒劒劒劒劒劒劒劒劥劒劒劒劒劒劒劒劜
            劔 侽(僨僼僅儖僩抣) 劔 D048_MON_NONE  劔 柍偟                 劔 柍偟         劔
            劔 侾               劔 D048_MON_ALT   劔 懳徾價僢僩偵曄壔偁傝 劔 bMask        劔
            劔 俀               劔 D048_MON_AND   劔 懳徾價僢僩慡堦抳     劔 bMask,bData  劔
            劔 俁               劔 D048_MON_OR    劔 懳徾價僢僩晹暘堦抳   劔 bMask,bData  劔
            劘劒劒劒劒劒劒劒劒劒劤劒劒劒劒劒劒劒劒劤劒劒劒劒劒劒劒劒劒劒劒劤劒劒劒劒劒劒劒劗

       丒bMask偵愝掕偡傞抣
            0x00乣0xFF傪擟堄偱愝掕
            僨僼僅儖僩抣偼0x00

       丒bData偵愝掕偡傞抣
            0x00乣0xFF傪擟堄偱愝掕
            僨僼僅儖僩抣偼0x00

仭栠傝抣
    API偑幐攕偟偨応崌偼FALSE傪曉偟傑偡丅

仭夝愢
    巜掕僨僶僀僗偺億乕僩娔帇傪愝掕偟傑偡丅

仭僄儔乕
    D048_ERR_SYSTEM
        僔僗僥儉僄儔乕偱偡丅
    D048_ERR_INVALID_DEVICENO
        柍岠側榑棟僨僶僀僗斣崋偱偡丅
    D048_ERR_INVALID_ARGUMENT
        柍岠側堷悢偑巜掕偝傟傑偟偨丅

------------------------------------------------------------------------

4.2.10. D048SetFilter

仭婡擻
    僼傿儖僞偺僒僀僋儖丄堦抳夞悢偺愝掕

仭宍幃
    仠Visual C++
      bInterval偵愝掕偡傞抣
        #define D048_FILTER_INTERVAL_STOP        0
        #define D048_FILTER_INTERVAL_1260        1
        #define D048_FILTER_INTERVAL_2520        2
        #define D048_FILTER_INTERVAL_5040        3
        #define D048_FILTER_INTERVAL_10080       4
        #define D048_FILTER_INTERVAL_20160       5

      BOOL D048SetFilter(WORD wLogDevice, BYTE bInterval, BYTE bCount);

    仠Visual Basic
      bInterval偵愝掕偡傞抣
        Global Const D048_FILTER_INTERVAL_STOP = 0
        Global Const D048_FILTER_INTERVAL_1260 = 1
        Global Const D048_FILTER_INTERVAL_2520 = 2
        Global Const D048_FILTER_INTERVAL_5040 = 3
        Global Const D048_FILTER_INTERVAL_10080 = 4
        Global Const D048_FILTER_INTERVAL_20160 = 5

     Function D048SetFilter(ByVal wLogDevice As Integer, ByVal bInterval As Byte, ByVal bCount As Byte) As Long

    仠Delphi
      bInterval偵愝掕偡傞抣
        D048_FILTER_INTERVAL_STOP  = 0;
        D048_FILTER_INTERVAL_1260  = 1;
        D048_FILTER_INTERVAL_2520  = 2;
        D048_FILTER_INTERVAL_5040  = 3;
        D048_FILTER_INTERVAL_10080 = 4;
        D048_FILTER_INTERVAL_20160 = 5;

     function D048SetFilter(wLogDevice: Word; bInterval: Byte; bCount: Byte): Boolean;

仭擖椡
    wLogDevicev
        榑棟僨僶僀僗斣崋傪巜掕偟傑偡丅
    bWdtValue
        僼傿儖僞偺僒僀僋儖乮僨乕僞庢摼帪娫乯傪懳墳偟偨抣偱巜掕偟傑偡丅
            劕劒劒劒劒劒劒劒劒劒劚劒劒劒劒劒劒劒劒劒劒劒劒劒劒劚劒劒劒劒劒劒劒劖
            劔        抣        劔           掕媊             劔     帪娫     劔
            劙劒劒劒劒劒劒劒劒劒劥劒劒劒劒劒劒劒劒劒劒劒劒劒劒劥劒劒劒劒劒劒劒劜
            劔侽(僨僼僅儖僩抣)  劔D048_FILTER_INTERVAL_STOP   劔      俽俿俷俹劔
            劔侾                劔D048_FILTER_INTERVAL_1260   劔  侾俀俇侽倳俽劔
            劔俀                劔D048_FILTER_INTERVAL_2520   劔  俀俆俀侽倳俽劔
            劔俁                劔D048_FILTER_INTERVAL_5040   劔  俆侽係侽倳俽劔
            劔係                劔D048_FILTER_INTERVAL_10080  劔侾侽侽俉侽倳俽劔
            劔俆                劔D048_FILTER_INTERVAL_20160  劔俀侽侾俇侽倳俽劔
            劘劒劒劒劒劒劒劒劒劒劤劒劒劒劒劒劒劒劒劒劒劒劒劒劒劤劒劒劒劒劒劒劒劗
    bCount
        堦抳夞悢傪巜掕偟傑偡丅0x00乣0xFF偱擟堄抣
        僨僼僅儖僩抣0x00

仭栠傝抣
    API偑幐攕偟偨応崌偼FALSE傪曉偟傑偡丅

仭夝愢
    巜掕僨僶僀僗偺僼傿儖僞僒僀僋儖偍傛傃丄堦抳夞悢傪愝掕偟傑偡丅

仭僄儔乕
    D048_ERR_SYSTEM
        僔僗僥儉僄儔乕偱偡丅
    D048_ERR_INVALID_DEVICENO
        柍岠側榑棟僨僶僀僗斣崋偱偡丅
    D048_ERR_INVALID_ARGUMENT
        bInterva偑柍岠側抣偱偡丅


------------------------------------------------------------------------

4.3.  偦偺懠偺 API

------------------------------------------------------------------------

4.3.1.  D048GetLastError

仭婡擻
    僄儔乕僐乕僪庢摼

仭宍幃
    仠Visual C++
      DWORD D048GetLastError(WORD wLogSlot);

    仠Visual Basic
      Function D048GetLastError(ByVal wLogDevice As Integer) As Long

    仠Delphi
      function D048GetLastError(wLogDevice: Word): DWord;

仭擖椡
    wLogSlot
        僨僶僀僗偺榑棟僗儘僢僩斣崋傪巜掕丅

仭栠傝抣
    僄儔乕僐乕僪丅

仭夝愢
    傕偭偲傕嵟嬤婲偙偭偨僄儔乕偺僐乕僪傪庢摼偟傑偡丅

========================================================================

5.  儊僢僙乕僕

    uWMCode 偵偼僨僶僀僗屌桳偺 ID 偑擖傝傑偡丅

    WM_CHECK_TRG 丗 億乕僩娔帇婡擻傪巊梡偡傞応崌偵愝掕偟偨忦審偑惉棫帪
                    僪儔僀僶偑儊僢僙乕僕傪憲弌偟傑偡丅


仭宍幃
    仠VisualC++
      #define WM_CHECK_TRG     0x2000      /* 儊僢僙乕僕ID */

      BOOL D048Create(PWORD pwLogDevice, HWND hwnd, UINT uWMCode);

    仠Visual Basic
      Global Const WM_CHECK_TRG = &H2000   ' 儊僢僙乕僕ID

      Function D048Create(ByRef pwLogDevice As Integer, ByVal hwnd As Long, ByVal uWMCode As Integer) As Long

    仠Delphi
      WM_CHECK_TRG                  = $2000;  // 儊僢僙乕僕ID

      function D048Create(var pwLogDevice: Word; hwnd: THandle; uWMCode: Word): Boolean;


    丒儊僢僙乕僕僴儞僪儔偺愝掕乮乽4.1.2.  D048Create乿傪嶲徠乯

========================================================================

6.  掕悢

------------------------------------------------------------------------

6.1.  僄儔乕僐乕僪

#define D048_SUCCESS                 0        /* 惓忢廔椆*/
#define D048_ERR_SYSTEM              1        /* GetLastError 傪僐乕儖 */
#define D048_ERR_NO_DEVICE           2        /* 巊梡壜擻側僨僶僀僗偑側偄 */
#define D048_ERR_IN_USE              3        /* 巜掕僨僶僀僗偼巊梡拞偱偡 */
#define D048_ERR_INVALID_DEVICENO    4        /* 柍岠側榑棟僨僶僀僗斣崋 */
#define D048_ERR_INVALID_ARGUMENT    5        /* 柍岠側堷悢 */
#define D048_ERR_INVALID_PORT        6        /* 柍岠側榑棟億乕僩 */
#define D048_ERR_BAD_DIRECTION       7        /* 晄惓側曽岦 */
#define	D048_ERR_TRG_DATA_INVALID    8        /* 億乕僩娔帇忦審堦抳僨乕僞偑側偄 */
#define D048_ERR_DLL                 ( ~0UL ) /* DLL 儘乕僪幐攕 */



------------------------------------------------------------------------

6.2. 榑棟億乕僩斣崋掕悢

#define D048_PORT_A          0
#define D048_PORT_B          1
#define D048_PORT_C          2
#define D048_PORT_D          3
#define D048_PORT_E          4
#define D048_PORT_F          5

6.3. 擖弌椡曽岦巜掕價僢僩儅僢僾掕悢

#define D048_DIR_A_OUTPUT    ( 0 << D048_PORT_A )
#define D048_DIR_A_INPUT     ( 1 << D048_PORT_A )
#define D048_DIR_B_OUTPUT    ( 0 << D048_PORT_B )
#define D048_DIR_B_INPUT     ( 1 << D048_PORT_B )
#define D048_DIR_C_OUTPUT    ( 0 << D048_PORT_C )
#define D048_DIR_C_INPUT     ( 1 << D048_PORT_C )
#define D048_DIR_D_OUTPUT    ( 0 << D048_PORT_D )
#define D048_DIR_D_INPUT     ( 1 << D048_PORT_D )
#define D048_DIR_E_OUTPUT    ( 0 << D048_PORT_E )
#define D048_DIR_E_INPUT     ( 1 << D048_PORT_E )
#define D048_DIR_F_OUTPUT    ( 0 << D048_PORT_F )
#define D048_DIR_F_INPUT     ( 1 << D048_PORT_F )

#define D048_DIR_ALL_OUTPUT  ( D048_DIR_A_OUTPUT    \
                                | D048_DIR_B_OUTPUT \
                                | D048_DIR_C_OUTPUT \
                                | D048_DIR_D_OUTPUT \
                                | D048_DIR_E_OUTPUT \
                                | D048_DIR_F_OUTPUT \
                                )
#define D048_DIR_ALL_INPUT   ( D048_DIR_A_INPUT     \
                                | D048_DIR_B_INPUT  \
                                | D048_DIR_C_INPUT  \
                                | D048_DIR_D_INPUT  \
                                | D048_DIR_E_INPUT  \
                                | D048_DIR_F_INPUT  \
                                )

6.4. 偦偺懠偺掕悢

#define D048_MAX_DEVICES     16              /* 嵟戝僨僶僀僗悢 */
#define D048_MAX_PORTS       6               /* 億乕僩悢 */
#define D048_DEVICE_AUTO     ( ( WORD )~0 )

========================================================================

7. 棜楌

1.00    2010/03/23  弶斉

