Attribute VB_Name = "AIO"
Option Explicit

'======================================================================
'======================================================================
'  API-CAP(W32)
'  CCAPAIO.BAS                    CONTEC.CO.,LTD.
'======================================================================
'======================================================================

'======================================================================
' Range
'======================================================================
Public Const PM10 = 0                   '}10V
Public Const PM5 = 1                    '}5V
Public Const P10 = 50                   '0`10V
Public Const P5 = 51                    '0`5V
Public Const P20MA = 100                '0`20mA

'======================================================================
' Error Code
'======================================================================
Public Const AIO_ERR_SUCCESS = 0                        'I
Public Const AIO_ERR_INI_MEMORY = 3                     '̊蓖ĂɎs܂
Public Const AIO_ERR_INI_REGISTRY = 4                   'ݒt@C̃ANZXɎs܂
Public Const AIO_ERR_DLL_DEVICE_NAME = 10000            'ݒ胆[eBeBɓo^ĂȂfoCXw肳܂
Public Const AIO_ERR_DLL_INVALID_ID = 10001             'IDw肳܂
Public Const AIO_ERR_DLL_CREATE_FILE = 10003            'nh̎擾Ɏs܂
Public Const AIO_ERR_DLL_CLOSE_FILE = 10004             'nh̃N[YɎs܂
Public Const AIO_ERR_INFO_NOT_FIND_DEVICE = 10006       'p\ȃfoCX܂
Public Const AIO_ERR_PTR_DEVICE_NAME = 10007            'DeviceNamẽ|C^NULLł
Public Const AIO_ERR_PTR_DEVICE = 10008                 'Devicẽ|C^NULLł
Public Const AIO_ERR_UNKNOWN_DEVICE = 10013             'foCX̎ނ𔻕ʂł܂
Public Const AIO_ERR_PTR_DEVICE_TYPE = 10015            'DeviceTypẽ|C^NULLł
Public Const AIO_ERR_INFO_INVALID_DEVICE = 10050        'w肵foCX̂܂BXymFĂB
Public Const AIO_ERR_NULL_DEVICE = 10100                'DeviceNameɃfoCXi[Ă܂
Public Const AIO_ERR_PTR_ID = 10101                     'Id̃|C^NULLł
Public Const AIO_ERR_PTR_ERR_STR = 10180                'ErrorString̃|C^NULLł
Public Const AIO_ERR_PTR_AI_RANGE = 11051               'AiRangeNULLł
Public Const AIO_ERR_AI_RANGE = 11060                   'AiRange̒l֐̎w͈͊Oł
Public Const AIO_ERR_AI_CHANNEL = 11420                 'AiChannel̒l֐̎w͈͊Oł
Public Const AIO_ERR_PTR_AI_DATA = 11421                'AiDatã|C^NULLł
Public Const AIO_ERR_PTR_AI_MAX_CHANNELS = 11720        'AiMaxChannels̃|C^NULLł
Public Const AIO_ERR_PTR_AI_RESOLUTION = 11740          'AiResolutioñ|C^NULLł
Public Const AIO_ERR_AO_CHANNEL = 13000                 'AoChannel̒l֐̎w͈͊Oł
Public Const AIO_ERR_AO_CHANNELS = 13020                'AoChannels̒l֐̎w͈͊Oł
Public Const AIO_ERR_PTR_AO_DATA = 13021                'AoDatã|C^NULLł
Public Const AIO_ERR_PTR_AO_RESOLUTION = 13040          'AoResolutioñ|C^NULLł
Public Const AIO_ERR_PTR_AO_MAX_CHANNELS = 13080        'AoMaxChannels̃|C^NULLł
Public Const AIO_ERR_PTR_AO_RANGE = 13111               'AoRangẽ|C^NULLł
Public Const AIO_ERR_AO_RANGE = 13120                   'AoRange̒l֐̎w͈͊Oł
Public Const AIO_ERR_AP_CHANNEL = 13500                 'AoChannel̒l֐̎w͈͊Oł
Public Const AIO_ERR_SYS_NOT_SUPPORTED = 20001          'gpĂfoCXł͂̊֐gp邱Ƃł܂
Public Const AIO_ERR_DEVICE_BUSY = 20002                'foCX쒆̂ߎsł܂
Public Const AIO_ERR_AI_DEVICE_RANGE = 21060            'AiRange̒lgpĂfoCX̎w͈͊Oł
Public Const AIO_ERR_AI_SET_RANGE = 21063               'W̐ݒɎs܂
Public Const AIO_ERR_AI_DEVICE_CHANNEL = 21420          'AiChannel̒lgpĂfoCX͈̔͊Oł
Public Const AIO_ERR_AD_ERROR = 21421                   'ADϊG[܂
Public Const AIO_ERR_AI_CHANNEL_NUM_OVER = 21441        'ϊ`lI[o[܂Aő`lŕϊ܂
Public Const AIO_ERR_AO_DEVICE_CHANNEL = 23000          'AoChannel̒lgpĂfoCX͈̔͊Oł
Public Const AIO_ERR_DA_ERROR = 23001                   'DAϊG[܂
Public Const AIO_ERR_AO_DATA_RANGE1 = 23002             'AoDataɐݒ肷f[^͂0`4095͈̔͂Ŏw肵Ă
Public Const AIO_ERR_AO_DATA_RANGE2 = 23003             'AoDataɐݒ肷f[^͂0`65535͈̔͂Ŏw肵Ă
Public Const AIO_ERR_AO_CHANNEL_NUM_OVER = 23021        'ϊ`lI[o[܂Bő`lŕϊ܂
Public Const AIO_ERR_AO_DEVICE_RANGE = 23120            'AoRange̒lgpĂfoCX̎w͈͊Oł
Public Const AIO_ERR_AO_SET_RANGE = 23121               'W̐ݒɎs܂
Public Const AIO_ERR_START_ERROR = 28001                'W[NɃG[܂B
Public Const AIO_ERR_NOT_START = 28002                  'foCX͂܂NĂ܂B
Public Const AIO_ERR_ACCESS_RIGHT = 28003               'ANZXG[łB
Public Const AIO_ERR_DLL_TIMEOUT = 28004                'ʐM^CAEg܂B
Public Const AIO_ERR_COMPOSITION = 28005                '@\G[łBO[vID=8ȊO̐ݒłIOAVXgT[o[KvłB

'======================================================================
' Function Prototype
'======================================================================
Declare Function AioInit Lib "CCAPAIO.DLL" (ByVal DeviceName As String, ByRef Id As Integer) As Long
Declare Function AioExit Lib "CCAPAIO.DLL" (ByVal Id As Integer) As Long
Declare Function AioGetErrorString Lib "CCAPAIO.DLL" (ByVal Err As Long, ByVal szMsg As String) As Long
Declare Function AioQueryDeviceName Lib "CCAPAIO.DLL" (ByVal Index As Integer, ByRef GroupID As Integer, ByRef UnitID As Integer, ByRef DeviceID As Integer, ByVal DeviceName As String, ByVal Device As String) As Long
Declare Function AioGetDeviceType Lib "CCAPAIO.DLL" (ByVal Device As String, ByRef DeviceType As Integer) As Long

Declare Function AioSetAccessRight Lib "CCAPAIO.DLL" (ByRef AccsRight As Byte) As Long
Declare Function AioSetDirectMode Lib "CCAPAIO.DLL" (ByVal Id As Integer, ByVal DirectMode As Integer) As Long
Declare Function AioSetIOInterval Lib "CCAPAIO.DLL" (ByVal Interval As Long) As Long
Declare Function AioStartIO Lib "CCAPAIO.DLL" (ByVal Id As Integer, ByVal Start As Integer) As Long
Declare Function AioGetRemoteStatus Lib "CCAPAIO.DLL" (ByVal Id As Integer, ByRef Start As Byte, ByRef Status As Byte) As Long

Declare Function AioSingleAi Lib "CCAPAIO.DLL" (ByVal Id As Integer, ByVal AiChannel As Integer, ByRef AiData As Long) As Long
Declare Function AioSingleAiEx Lib "CCAPAIO.DLL" (ByVal Id As Integer, ByVal AiChannel As Integer, ByRef AiData As Single) As Long
Declare Function AioMultiAi Lib "CCAPAIO.DLL" (ByVal Id As Integer, ByVal AiChannels As Integer, ByRef AiData As Long) As Long
Declare Function AioMultiAiEx Lib "CCAPAIO.DLL" (ByVal Id As Integer, ByVal AiChannels As Integer, ByRef AiData As Single) As Long
Declare Function AioGetAiResolution Lib "CCAPAIO.DLL" (ByVal Id As Integer, ByRef AiResolution As Integer) As Long
Declare Function AioGetAiMaxChannels Lib "CCAPAIO.DLL" (ByVal Id As Integer, ByRef AiMaxChannels As Integer) As Long
Declare Function AioSetAiRangeAll Lib "CCAPAIO.DLL" (ByVal Id As Integer, ByVal AiRange As Integer) As Long
Declare Function AioGetAiRange Lib "CCAPAIO.DLL" (ByVal Id As Integer, ByVal AiChannel As Integer, ByRef AiRange As Integer) As Long

Declare Function AioSingleAo Lib "CCAPAIO.DLL" (ByVal Id As Integer, ByVal AoChannel As Integer, ByVal AoData As Long) As Long
Declare Function AioSingleAoEx Lib "CCAPAIO.DLL" (ByVal Id As Integer, ByVal AoChannel As Integer, ByVal AoData As Single) As Long
Declare Function AioSingleAoEcho Lib "CCAPAIO.DLL" (ByVal Id As Integer, ByVal AoChannel As Integer, ByRef AoData As Long) As Long
Declare Function AioMultiAo Lib "CCAPAIO.DLL" (ByVal Id As Integer, ByVal AoChannels As Integer, ByRef AoData As Long) As Long
Declare Function AioMultiAoEx Lib "CCAPAIO.DLL" (ByVal Id As Integer, ByVal AoChannels As Integer, ByRef AoData As Single) As Long
Declare Function AioMultiAoEcho Lib "CCAPAIO.DLL" (ByVal Id As Integer, ByVal AoChannels As Integer, ByRef AoData As Long) As Long
Declare Function AioGetAoResolution Lib "CCAPAIO.DLL" (ByVal Id As Integer, ByRef AoResolution As Integer) As Long
Declare Function AioGetAoMaxChannels Lib "CCAPAIO.DLL" (ByVal Id As Integer, ByRef AoMaxChannels As Integer) As Long
Declare Function AioSetAoRangeAll Lib "CCAPAIO.DLL" (ByVal Id As Integer, ByVal AoRange As Integer) As Long
Declare Function AioGetAoRange Lib "CCAPAIO.DLL" (ByVal Id As Integer, ByVal AoChannel As Integer, ByRef AoRange As Integer) As Long
