Attribute VB_Name = "adamtcpce"
'------------------ define error code -----------------------
Public Const ADAMTCP_NoError = 0
Public Const ADAMTCP_StartupFailure = (-1)
Public Const ADAMTCP_SocketFailure = (-2)
Public Const ADAMTCP_UdpSocketFailure = (-3)
Public Const ADAMTCP_SetTimeoutFailure = (-4)
Public Const ADAMTCP_SendFailure = (-5)
Public Const ADAMTCP_ReceiveFailure = (-6)
Public Const ADAMTCP_ExceedMaxFailure = (-7)
Public Const ADAMTCP_CreateWsaEventFailure = (-8)
Public Const ADAMTCP_ReadStreamDataFailure = (-9)
Public Const ADAMTCP_InvalidIP = (-10)
Public Const ADAMTCP_ThisIPNotConnected = (-11)
Public Const ADAMTCP_AlarmInfoEmpty = (-12)

'--- always receiving sream data in despite of if alarm change ---
Public Const ADAMTCP_ReceiveStreamIngoreAlarm = 0
'--- only receiving sream data when any alarm change ---
'--- for example:    Hi-Alarm On -> Off , Hi-Alarm Off ->On,
'---                 Lo-Alarm On -> Off , Lo-Alarm Off ->On
Public Const ADAMTCP_ReceiveStreamWhenAlarm = 1

'Type TypeOfStreamData
'    DIO(0 To 7) As Integer     ' DI/DO data for Slot0, Slot1,....,Slot7
'    Slot0(0 To 7) As Integer   ' AI/AO data for Slot0
'    Slot1(0 To 7) As Integer   ' AI/AO data for Slot1
'    Slot2(0 To 7) As Integer   ' AI/AO data for Slot2
'    Slot3(0 To 7) As Integer   ' AI/AO data for Slot3
'    Slot4(0 To 7) As Integer   ' AI/AO data for Slot4
'    Slot5(0 To 7) As Integer   ' AI/AO data for Slot5
'    Slot6(0 To 7) As Integer   ' AI/AO data for Slot6
'    Slot7(0 To 7) As Integer   ' AI/AO data for Slot7
'End Type

'Type TypeOfAlarmInfo
'    bySlot         As Byte  ' the Slot of 5000/TCP which cause the alarm change
'    byChannel      As Byte  ' the Channel of 5000/TCP which cause the alarm change
'    byAlarmType    As Byte  ' 0: Low Alarm, 1: High Alarm
'    byAlarmaStatus As Byte  ' 0: Alarm Off, 1: Alarm On
'    byIndexOf5KTCP As Byte  ' indicate the index 5000/TCP which cause the alarm change, zero-based
'    szIP           As String * 20  ' the IP address which cause the alarm change
'    szDataTime     As String * 48  ' e.x 2001/09/23 10:12:34:567 (Year/Month/Day Hour:Minute:Second:mSecond)
'End Type


'**********************************************************
'----------------------  adamtcpce.dll --------------------
Declare Function ADAMTCP_Open Lib "adamtcpce.dll" () As Long
Declare Sub ADAMTCP_Close Lib "adamtcpce.dll" ()

Declare Function ADAMTCP_Connect Lib "adamtcpce.dll" (ByVal IPAddress As String, ByVal Port As Integer, _
                  ByVal ConnectionTimeout As Long, ByVal SendTimeout As Long, ByVal ReceiveTimeout As Long) As Long
Declare Sub ADAMTCP_Disconnect Lib "adamtcpce.dll" ()
Declare Function ADAMTCP_GetDLLVersion Lib "adamtcpce.dll" () As Long
Declare Function ADAMTCP_ReadReg Lib "adamtcpce.dll" (ByVal IPAddress As String, ByVal wID As Integer, ByVal wStartAddress As Integer, _
                ByVal wCount As Integer, ByVal strDataString As String) As Long
Declare Function ADAMTCP_WriteReg Lib "adamtcpce.dll" (ByVal IPAddress As String, ByVal wID As Integer, ByVal wStartAddress As Integer, _
                ByVal wCount As Integer, ByVal strDataString As String) As Long
Declare Function ADAMTCP_ReadCoil Lib "adamtcpce.dll" (ByVal IPAddress As String, ByVal wID As Integer, ByVal wStartAddress As Integer, _
                ByVal wCount As Integer, ByVal strDataString As String) As Long
Declare Function ADAMTCP_WriteCoil Lib "adamtcpce.dll" (ByVal IPAddress As String, ByVal wID As Integer, ByVal wStartAddress As Integer, _
                ByVal wCount As Integer, ByVal strDataString As String) As Long
Declare Function ADAMTCP_SendReceive5KTCPCmd Lib "adamtcpce.dll" (ByVal IPAddress As String, _
                ByVal szSend As String, ByVal szResult As String, ByVal szModbusSend As String, ByVal szModbusReceive As String) As Long

Declare Function ADAMTCP_Add5KTCPForStream Lib "adamtcpce.dll" (ByVal IPAddress As String) As Long
'Declare Function ADAMTCP_ReadStreamData Lib "adamtcpce.dll" (ByVal IPAddress As String, StreamData As TypeOfStreamData) As Long
'Declare Function ADAMTCP_ReadAlarmInfo Lib "adamtcpce.dll" (AlarmInfo As TypeOfAlarmInfo) As Long

Declare Function ADAMTCP_ReadStreamData Lib "adamtcpce.dll" (ByVal IPAddress As String, DIO As Integer, _
                                    Slot0 As Integer, Slot1 As Integer, Slot2 As Integer, Slot3 As Integer, _
                                    Slot4 As Integer, Slot5 As Integer, Slot6 As Integer, Slot7 As Integer) As Long
                                    
'--- alarm function for EVB ---
Declare Function ADAMTCP_ReadAlarmInfoEVB Lib "adamtcpce.dll" (bySlot As Byte, byChannel As Byte, byAlarmType As Byte, _
                                                byAlarmStatus As Byte, byIndexOf5KTCP As Byte, ByVal szIP As String, ByVal szDateTime As String) As Long

'--- stream data function for EVB ----
Declare Function ADAMTCP_CaptureStreamDataEVB Lib "adamtcpce.dll" (ByVal IPAddress As String) As Long
Declare Function ADAMTCP_GetDIODataEVB Lib "adamtcpce.dll" (DIOs0 As Integer, DIOs1 As Integer, DIOs2 As Integer, DIOs3 As Integer, _
                                    DIOs4 As Integer, DIOs5 As Integer, DIOs6 As Integer, DIOs7 As Integer) As Long
Declare Function ADAMTCP_GetAIODataEVB Lib "adamtcpce.dll" (ByVal SlotIndex As Integer, _
                                    AIOc0 As Integer, AIOc1 As Integer, AIOc2 As Integer, AIOc3 As Integer, _
                                    AIOc4 As Integer, AIOc5 As Integer, AIOc6 As Integer, AIOc7 As Integer) As Long

Declare Function ADAMTCP_StartStream Lib "adamtcpce.dll" (hEvent As Long) As Long
Declare Function ADAMTCP_StopStream Lib "adamtcpce.dll" () As Long
Declare Function ADAMTCP_SetStreamAlarmState Lib "adamtcpce.dll" (ByVal wStreamAlarmState As Integer) As Long
Declare Function ADAMTCP_Debug Lib "adamtcpce.dll" (iMatchIndex As Long, iReceiveCount As Long, iThreadRun As Long, iTotalStream As Long, ByVal szFromIP As String) As Long
Declare Function ADAMTCP_UDPOpen Lib "adamtcpce.dll" (ByVal SendTimeout As Long, ByVal ReceiveTimeout As Long) As Long
Declare Function ADAMTCP_UDPClose Lib "adamtcpce.dll" () As Long
Declare Function ADAMTCP_SendReceiveUDPCmd Lib "adamtcpce.dll" (ByVal IPAddress As String, _
                ByVal szSend As String, ByVal szResult As String) As Long
                
'Declare Function ADAMTCP_WcsToMbs Lib "adamtcpce.dll" (ByVal wcs As String, ByVal mbs As String) As Long
                




