' Author : 
'     Dipl.-Ing. A. Traeger
'     Traeger Industriesoftware
'     Mitglied im TPA e.V.
'     Vertrieb durch:
'     Process Informatik GmbH
'     Im Gewerbegebiet 1
'     73116 Waeschenbeuren
'     Tel. 07172/926660
'     Fax  07172/9266630
'           
' Version 1.77.0.0
Attribute VB_Name = "IPS7LNK"
     
Declare Function IPS7Open& Lib "IPS7LNK.dll" (ByVal IPAdr As String, _
                                              ByVal Rack&, ByVal Slot&, _
                                              ByVal RxTimeout&, _
                                              ByVal TxTimeout&, _
                                              ByVal ConnectTimeout&)
Declare Function IPS7Close& Lib "IPS7LNK.dll" (ByVal Ref&)

Declare Function IPS7RdW& Lib "IPS7LNK.dll" (ByVal Ref&, ByVal Typ&, ByVal DBNr&, ByVal AbWort&, ByVal WortAnz&, Wert As Integer)
Declare Function IPS7RdB& Lib "IPS7LNK.dll" (ByVal Ref&, ByVal Typ&, ByVal DBNr&, ByVal AbWort&, ByVal WortAnz&, Wert As Byte)
Declare Function IPS7WrW& Lib "IPS7LNK.dll" (ByVal Ref&, ByVal Typ&, ByVal DBNr&, ByVal AbWort&, ByVal WortAnz&, Wert As Integer)
Declare Function IPS7WrB& Lib "IPS7LNK.dll" (ByVal Ref&, ByVal Typ&, ByVal DBNr&, ByVal AbWort&, ByVal WortAnz&, Wert As Byte)
' ab Version 1.05
Declare Function IPS7GetSockErr& Lib "IPS7LNK.dll" (ByVal Ref&)
Declare Function IPS7RdBit& Lib "IPS7LNK.dll" (ByVal Ref&, ByVal Typ&, ByVal DBNr&, ByVal ByteNr&, ByVal BitNr&, Wert As Byte)
Declare Function IPS7SetBit& Lib "IPS7LNK.dll" (ByVal Ref&, ByVal Typ&, ByVal DBNr&, ByVal ByteNr&, ByVal BitNr&)
Declare Function IPS7ResetBit& Lib "IPS7LNK.dll" (ByVal Ref&, ByVal Typ&, ByVal DBNr&, ByVal ByteNr&, ByVal BitNr&)
Declare Function IPS7RdReal& Lib "IPS7LNK.dll" (ByVal Ref&, ByVal Typ&, ByVal DBNr&, ByVal AbWort&, ByVal WortAnz&, Wert As Double)
Declare Function IPS7WrReal& Lib "IPS7LNK.dll" (ByVal Ref&, ByVal Typ&, ByVal DBNr&, ByVal AbWort&, ByVal WortAnz&, Wert As Double)
Declare Function IPS7RdDW& Lib "IPS7LNK.dll" (ByVal Ref&, ByVal Typ&, ByVal DBNr&, ByVal AbWort&, ByVal WortAnz&, Wert As Long)
Declare Function IPS7WrDW& Lib "IPS7LNK.dll" (ByVal Ref&, ByVal Typ&, ByVal DBNr&, ByVal AbWort&, ByVal WortAnz&, Wert As Long)


Declare Function IPS7OpenEx& Lib "IPS7LNK.dll" (ByVal IPAdr As String, _
                                                ByVal Rack&, ByVal Slot&, _
                                                ByVal SubNetId&, ByVal DstMPIAdr&, ByVal AccessMode&, _
                                                ByVal RxTimeout&, _
                                                ByVal TxTimeout&, _
                                                ByVal ConnectTimeout&)

Declare Function IPS7OpenExWithTSAP& Lib "IPS7LNK.dll" (ByVal IPAdr As String, _
                                                ByVal Rack&, ByVal Slot&, _
                                                ByVal SubNetId&, ByVal DstMPIAdr&, ByVal AccessMode&, _
                                                ByVal RxTimeout&, _
                                                ByVal TxTimeout&, _
                                                ByVal ConnectTimeout&, _
                                                ByVal LocalTSAP As Byte, _
                                                ByVal RemoteTSAP As Byte)


Declare Function IPS7GetConnectStatus& Lib "IPS7LNK.dll" (ByVal Ref&)
Declare Function IPS7SetKeepAlive& Lib "IPS7LNK.dll" (ByVal Ref&, ByVal AliveInterval&, ByVal AliveTime&)



Declare Function IPS7GetPLCTime& Lib "IPS7LNK.dll" (ByVal Ref&, Year As Long, Month As Long, Day As Long, Hour As Long, Minutes As Long, Sec As Long, MilliSec As Long)
Declare Function IPS7SetPLCTime& Lib "IPS7LNK.dll" (ByVal Ref&, ByVal Year&, ByVal Month&, ByVal Day&, ByVal Hour&, ByVal Min&, ByVal Sec&, ByVal Ms&)

Declare Function IPS7GetPLCName& Lib "IPS7LNK.dll" (ByVal Ref&, ByVal Str As String)

Declare Function IPS7GetModuleName& Lib "IPS7LNK.dll" (ByVal Ref&, ByVal Str As String)

Declare Function IPS7GetPlantIdName& Lib "IPS7LNK.dll" (ByVal Ref&, ByVal Str As String)

Declare Function IPS7GetCopyrightEntry& Lib "IPS7LNK.dll" (ByVal Ref&, ByVal Str As String)

Declare Function IPS7GetModuleSNr& Lib "IPS7LNK.dll" (ByVal Ref&, ByVal Str As String)
    
Declare Function IPS7GetModuleTypeName& Lib "IPS7LNK.dll" (ByVal Ref&, ByVal Str As String)

Declare Function IPS7GetMMCSNr& Lib "IPS7LNK.dll" (ByVal Ref&, ByVal Str As String)

Declare Function IPS7GetOEMId& Lib "IPS7LNK.dll" (ByVal Ref&, ByVal Str As String)

Declare Function IPS7GetLocationDesignation& Lib "IPS7LNK.dll" (ByVal Ref&, ByVal Str As String)


Declare Function IPS7WrStr& Lib "IPS7LNK.dll" (ByVal Ref&, ByVal Typ&, ByVal DBNr&, ByVal Start&, ByVal Str As String)

Declare Function IPS7RdStr& Lib "IPS7LNK.dll" (ByVal Ref&, ByVal Typ&, ByVal DBNr&, ByVal Start&, ByVal StrLen&, ByVal Str As String)

Declare Function IPS7GetDBLen& Lib "IPS7LNK.dll" (ByVal Ref&, ByVal DBNr&)



Enum Enum_S7_DATATYPE
  IPS7_BIT = 0
  IPS7_BYTE
  IPS7_WORD  '16 Unsigned
  IPS7_INT   '16 Bit signed
  IPS7_DWORD
  IPS7_DINT  '32 Bit signed
  IPS7_REAL
  IPS7_TIMER
  IPS7_COUNTER
  IPS7_STRING
  IPS7_BADTYPE
End Enum


Enum Enum_PC_DATATYPE
  PC_BYTE = 0
  PC_WORD16
  PC_INT16
  PC_WORD32
  PC_INT32
  PC_FLOAT
  PC_DOUBLE
  PC_STRING
End Enum
    
Type IPS7_RQ_MULTI
    DataArea As Long
    DataType As Long
    DBNr As Long
    Cnt As Long
    Start As Long
    StartBit As Long
    PcDataType As Long
    Result As Long
    UserData_0 As Long
    UserData_1 As Long
    Data As Long
    pUserData As Long
End Type


Declare Function IPS7RdMulti& Lib "IPS7LNK.dll" (ByVal Ref&, pRqList As IPS7_RQ_MULTI, ByVal Cnt&)
