'*************************************************************************************************
'       API-GPIB(WDM)                                                                   Ver1.03
'       CGPIB.vb                                                                CONTEC.CO.,LTD.
'*************************************************************************************************

'==============================================================================================
'       Function prototype
'==============================================================================================
Option Strict Off
Option Explicit On
Imports System.Runtime.InteropServices 

Module GPIBVB1
'-----------------------------------------------
'       Public presentation
'-----------------------------------------------
' Common
	Declare Function GpibInit Lib "CGPIB.DLL" (ByVal strDeviceName As String, ByRef shDevId As Short) As Integer
	Declare Function GpibExit Lib "CGPIB.DLL" (ByVal shDevId As Short) As Integer
	Declare Function GpibGetErrorString Lib "CGPIB.DLL" (ByVal intErrorCode As Integer, ByVal strErrorString As System.Text.StringBuilder) As Integer

' Initialization
	Declare Function GpibSetEquipment Lib "CGPIB.DLL" (ByVal shDevId As Short, ByRef shEqpId As Short, ByVal shPrmAddr As Short, ByVal shScdAddr As Short, ByVal shDelim As Short) As Integer
	Declare Function GpibGetEquipment Lib "CGPIB.DLL" (ByVal shEqpId As Short, ByRef shPrmAddr As Short, ByRef shScdAddr As Short, ByRef shDelim As Short) As Integer
	Declare Function GpibSendIFC Lib "CGPIB.DLL" (ByVal shId As Short, ByVal shIfcTime As Short) As Integer
	Declare Function GpibChangeREN Lib "CGPIB.DLL" (ByVal shId As Short, ByVal shEnable As Short) As Integer
	Declare Function GpibEnableRemote Lib "CGPIB.DLL" (ByVal shId As Short) As Integer

' Send and Reception
	Declare Function GpibSendData Lib "CGPIB.DLL" (ByVal shId As Short, ByRef intSendLen As Integer, ByVal strSendBuf As System.Text.StringBuilder) As Integer
    Declare Function GpibSendData Lib "CGPIB.DLL" (ByVal shId As Short, ByRef intSendLen As Integer, <MarshalAs(UnmanagedType.LPArray)> ByVal byteSendBuf() As Byte) As Integer
	Declare Function GpibRecData Lib "CGPIB.DLL" (ByVal shId As Short, ByRef intRecLen As Integer, ByVal strRecBuf As System.Text.StringBuilder) As Integer
    Declare Function GpibRecData Lib "CGPIB.DLL" (ByVal shId As Short, ByRef intRecLen As Integer, <MarshalAs(UnmanagedType.LPArray)> ByVal byteRecBuf() As Byte) As Integer
	Declare Function GpibSetDelim Lib "CGPIB.DLL" (ByVal shId As Short, ByVal shDelim As Short, ByVal shEoi As Short, ByVal shEos As Short) As Integer
	Declare Function GpibGetDelim Lib "CGPIB.DLL" (ByVal shId As Short, ByRef shDelim As Short, ByRef shEoi As Short, ByRef shEos As Short) As Integer
	Declare Function GpibSetTimeOut Lib "CGPIB.DLL" (ByVal shId As Short, ByVal intTimeOut As Integer) As Integer
	Declare Function GpibGetTimeOut Lib "CGPIB.DLL" (ByVal shId As Short, ByRef intTimeOut As Integer) As Integer
	Declare Function GpibSetEscape Lib "CGPIB.DLL" (ByVal shId As Short, ByVal shEnable As Short, ByVal shKeyType As Short, ByVal intKeyCode As Integer) As Integer
	Declare Function GpibGetEscape Lib "CGPIB.DLL" (ByVal shId As Short, ByRef shEnable As Short, ByVal shKeyType As Short, ByRef intKeyCode As Integer) As Integer
	Declare Function GpibSetSlowMode Lib "CGPIB.DLL" (ByVal shId As Short, ByVal shSlowTime As Short) As Integer
	Declare Function GpibGetSlowMode Lib "CGPIB.DLL" (ByVal shId As Short, ByRef shSlowTime As Short) As Integer
	Declare Function GpibSetSmoothMode Lib "CGPIB.DLL" (ByVal shId As Short, ByVal shMode As Short) As Integer
	Declare Function GpibGetSmoothMode Lib "CGPIB.DLL" (ByVal shId As Short, ByRef shMode As Short) As Integer
	Declare Function GpibSetAddrInfo Lib "CGPIB.DLL" (ByVal shId As Short, ByVal shTalker As Short, <MarshalAs(UnmanagedType.LPArray)> ByVal shListenerArray() As Short) As Integer
	Declare Function GpibGetAddrInfo Lib "CGPIB.DLL" (ByVal shId As Short, ByRef shTalker As Short, <MarshalAs(UnmanagedType.LPArray)> ByVal shListenerArray() As Short) As Integer

' Serial poll
	Declare Function GpibSPoll Lib "CGPIB.DLL" (ByVal shEqpId As Short, ByRef shStb As Short, ByRef shSrq As Short) As Integer
	Declare Function GpibSPollAll Lib "CGPIB.DLL" (ByVal shId As Short, <MarshalAs(UnmanagedType.LPArray)> ByVal shAddrArray() As Short, <MarshalAs(UnmanagedType.LPArray)> ByVal shStbArray() As Short, <MarshalAs(UnmanagedType.LPArray)> ByVal shSrqArray() As Short) As Integer

' Parallel poll
	Declare Function GpibPPoll Lib "CGPIB.DLL" (ByVal shDevId As Short, ByRef shPpr As Short) As Integer
	Declare Function GpibSetPPoll Lib "CGPIB.DLL" (ByVal shDevId As Short, <MarshalAs(UnmanagedType.LPArray)> ByVal shAddrArray() As Short, <MarshalAs(UnmanagedType.LPArray)> ByVal shDataLineArray() As Short, <MarshalAs(UnmanagedType.LPArray)> ByVal shPolarityArray() As Short) As Integer
	Declare Function GpibGetPPoll Lib "CGPIB.DLL" (ByVal shDevId As Short, <MarshalAs(UnmanagedType.LPArray)> ByVal shAddrArray() As Short, <MarshalAs(UnmanagedType.LPArray)> ByVal shDataLineArray() As Short, <MarshalAs(UnmanagedType.LPArray)> ByVal shPolarityArray() As Short) As Integer
	Declare Function GpibResetPPoll Lib "CGPIB.DLL" (ByVal shDevId As Short, <MarshalAs(UnmanagedType.LPArray)> ByVal shAddrArray() As Short) As Integer

' SRQ response
	Declare Function GpibSetPPollResponse Lib "CGPIB.DLL" (ByVal shDevId As Short, ByVal shResponse As Short) As Integer
	Declare Function GpibGetPPollResponse Lib "CGPIB.DLL" (ByVal shDevId As Short, ByRef shResponse As Short) As Integer
	Declare Function GpibSetIst Lib "CGPIB.DLL" (ByVal shDevId As Short, ByVal shIst As Short) As Integer
	Declare Function GpibGetIst Lib "CGPIB.DLL" (ByVal shDevId As Short, ByRef shIst As Short) As Integer
	Declare Function GpibSendSRQ Lib "CGPIB.DLL" (ByVal shDevId As Short, ByVal shSrqSend As Short, ByVal shStb As Short) As Integer
	Declare Function GpibCheckSPoll Lib "CGPIB.DLL" (ByVal shDevId As Short, ByRef shSPoll As Short, ByRef shStb As Short) As Integer

' Control
	Declare Function GpibSendCommands Lib "CGPIB.DLL" (ByVal shDevId As Short, <MarshalAs(UnmanagedType.LPArray)> ByVal shCmdArray() As Short) As Integer
	Declare Function GpibSendTrigger Lib "CGPIB.DLL" (ByVal shId As Short) As Integer
	Declare Function GpibSendDeviceClear Lib "CGPIB.DLL" (ByVal shId As Short) As Integer
	Declare Function GpibChangeLocal Lib "CGPIB.DLL" (ByVal shId As Short) As Integer
	Declare Function GpibSendLocalLockout Lib "CGPIB.DLL" (ByVal shDevId As Short) As Integer

' Status
	Declare Function GpibSetStatus Lib "CGPIB.DLL" (ByVal shId As Short, ByVal shSelect As Short, ByVal intData As Integer) As Integer
	Declare Function GpibGetStatus Lib "CGPIB.DLL" (ByVal shId As Short, ByVal shSelect As Short, ByRef intData As Integer) As Integer
	Declare Function GpibReadLines Lib "CGPIB.DLL" (ByVal shId As Short, ByVal shSelect As Short, ByRef shLineStatus As Short) As Integer
	Declare Function GpibFindListener Lib "CGPIB.DLL" (ByVal shDevId As Short, ByVal shPrmAddr As Short, ByVal shScdAddr As Short, ByRef shArraySize As Short, <MarshalAs(UnmanagedType.LPArray)> ByVal shAddrArray() As Short) As Integer
	Declare Function GpibGetSignal Lib "CGPIB.DLL" (ByVal shDevId As Short, ByRef intwParam As Integer, ByRef intlParam As Integer) As Integer

'Event
	Declare Function GpibSetNotifySignal Lib "CGPIB.DLL" (ByVal shDevId As Short, ByVal hWnd As Integer, ByVal intNotifySignalMask As Integer) As Integer
	Declare Function GpibGetNotifySignal Lib "CGPIB.DLL" (ByVal shDevId As Short, ByRef hWnd As Integer, ByRef intNotifySignalMask As Integer) As Integer
	Declare Function GpibSetNotifyMessage Lib "CGPIB.DLL" (ByVal shDevId As Short, ByVal intMessage As Integer) As Integer
	Declare Function GpibGetNotifyMessage Lib "CGPIB.DLL" (ByVal shDevId As Short, ByRef intMessage As Integer) As Integer
End Module
