Einfache OPC Schnittstelle Version 2.4

Einleitung

Die OPC Client Schnittstelle liegt als PBOPC.dll vor. Intern verwendet die DLL die Customer Schnittstelle des OPC Servers. Zum lesen und schreiben der Items wird SyncronIO verwendet.

Die Zuordnung der Items zu der richtigen SyncronIO verwaltet die DLL über interne Listen.

OPC läuft unter DCOM und somit mit UNICODE. Die Anwendungen sollten auch in UNICODE kompiliert werden.

Automatische Typenanpassung

Die DLL übernimmt die automatisch Anpassung des Typen über die OLE Automation VariantChangeType. Das heißt das wenn ein Item als Word definiert ist, kann dieser zum Beispiel als String gelesen und geschieben werden.

Ausgeschlossen von der Typenanpassung sind Read und Write Variant. Sowie Items die als Array deklariert sind.

 


Verbindung aufbauen

OpcConnect(ServerName.s, ServerNode.s)

·         Param1: ServerName as String

·         Param2: ServerNode as String (Optional)

·         Result: ServerObject as Pointer

OpcRelease(*ServerObject)

·         Param1: ServerObject as Pointer

·         Result: OPC Server Release or hResult

 


Gruppen anlegen und löschen

OpcAddGroup(*ServerObject, GroupName.s)

·         Param1: ServerObject as Pointer

·         Param2: GroupName as String

·         Result: GroupObject as Pointer

OpcRemoveGroup(*GroupObject)

·         Param1: GroupObject as Pointer

·         Result: hResult

 


Items anlegen und löschen

OpcAddItem(*GroupObject, AccessPath.s, ItemID.s)

·         Param1: Group Object as Pointer

·         Param2: AccessPath as String

·         Param3: ItemID as String

·         Result: Pointer to the ItemObject

OpcRemoveItem(*ItemObject)

·         Param1: Pointer to the ItemObject

·         Result: hResult

 


Items lesen

OpcReadBool(*ItemObject, *pResult.long, *pQuality.long )

·         Param1: Pointer to the ItemObject

·         Param2: Pointer to the pResult as Long

·         Param3: Pointer to the pQuality as Long, can null

·         Result: hResult

OpcReadByte(*ItemObject, *pResult.byte, *pQuality.long)

·         Param1: Pointer to the ItemObject

·         Param2: Pointer to the pResult as Byte

·         Param3: Pointer to the pQuality as Long, can null

·         Result: hResult

OpcReadWord(*ItemObject, *pResult.word, *pQuality.long)

·         Param1: Pointer to the ItemObject

·         Param2: Pointer to the pResult as Word

·         Param3: Pointer to the pQuality as Long can null

·         Result: hResult

OpcReadLong(*ItemObject, *pResult.long, *pQuality.long)

·         Param1: Pointer to the ItemObject

·         Param2: Pointer to the pResult as Long

·         Param3: Pointer to the pQuality as Long

·         Result: hResult

OpcReadFloat(*ItemObject, *pResult.float, *pQuality.long)

·         Param1: Pointer to the ItemObject

·         Param2: Pointer to the pResult as Float

·         Param3: Pointer to the pQuality as Long

·         Result: hResult

OpcReadDouble(*ItemObject, *pResult.double, *pQuality.long)

·         Param1: Pointer to the ItemObject

·         Param2: Pointer to the pResult as Double

·         Param3: Pointer to the pQuality as Long

·         Result: hResult

OpcReadDate(*ItemObject, *pResult.double, *pQuality.long)

·         Param1: Pointer to the ItemObject

·         Param2: Pointer to the pResult as Date (Double)

·         Param3: Pointer to the pQuality as Long

·         Result: hResult

OpcReadDateString(*ItemObject, *pResult, Size.l, *pQuality.long)

·         Param1: Pointer to the ItemObject

·         Param2: Pointer to the pResult as String

·         Param3: Size Of pResult as Long

·         Param4: Pointer to the pQuality as Long

·         Result: hResult

OpcReadString(*ItemObject, *pResult, Size.l, *pQuality.long)

·         Param1: Pointer to the ItemObject

·         Param2: Pointer to the pResult as String

·         Param3: Size Of pResult as Long

·         Param4: Pointer to the pQuality as Long

·         Result: hResult

OpcReadVariant(*ItemObject, *pResult.Variant, *pQuality.long)

·         Param1: Pointer to the ItemObject

·         Param2: Pointer to the pResult as Variant

·         Param3: Pointer to the pQuality as Long

·         Result: hResult

OpcReadItems(ItemCount.l, *ItemObjects.pArray, *pResult.VariantArray, *pQuality.QualityArray, *pErrors.ErrorsArray)

·         Param1: ItemCount as Long

·         Param2: Pointer to the ItemObject as Array

·         Param3: Pointer to the pResult as Array of Variant

·         Param4: Pointer to the pQuality as Array of Long

·         Param5: Pointer to the pErrors as Array of Long

·         Result: hResult

OpcReadItemArray(ItemCount.l, ItemCount.l, *ItemObject.variant, *pResult.variant, *pQuality.variant, *pErrors.variant)

Kompatibilität zu VisualStudio

·         Param1: ItemCount as int32

·         Param2: ItemObject as Array of int32 (Object)

·         Param3: pResult as Array of Variant (Object)

·         Param4: pQuality as Array of int32 (Object)

·         Param5: pErrors as Array of int32 (Object)

·         Result: hResult as int32

 


Items schreiben

OpcWriteBool(*ItemObject, value.l)

·         Param1: Pointer to the ItemObject

·         Param2: Value as Long

·         Result: hResult

OpcWriteByte(*ItemObject, value.b)

·         Param1: Pointer to the ItemObject

·         Param2: Value as Byte

·         Result: hResult

OpcWriteWord(*ItemObject, value.w)

·         Param1: Pointer to the ItemObject

·         Param2: Value as Word

·         Result: hResult

OpcWriteLong(*ItemObject, value.l)

·         Param1: Pointer to the ItemObject

·         Param2: Value as Long

·         Result: hResult

OpcWriteFloat(*ItemObject, value.f)

·         Param1: Pointer to the ItemObject

·         Param2: Value as Float

·         Result: hResult

OpcWriteDouble(*ItemObject, value.d)

·         Param1: Pointer to the ItemObject

·         Param2: Value as Double

·         Result: hResult

OpcWriteDate(*ItemObject, value.d)

·         Param1: Pointer to the ItemObject

·         Param2: Value as Date (Double)

·         Result: hResult

OpcWriteDateString(*ItemObject, value.s)

·         Param1: Pointer to the ItemObject

·         Param2: Value as Date String

·         Result: hResult

OpcWriteString(*ItemObject, value.s)

·         Param1: Pointer to the ItemObject

·         Param2: Value as String

·         Result: hResult

OpcWriteVariant(*ItemObject, *pValue.Variant)

·         Param1: Pointer to the ItemObject

·         Param2: Value as Variant

·         Result: hResult

OpcWriteItems(ItemCount, *ItemObjects.pArray, *pValues.VariantArray, *pErrors.ErrorsArray)

·         Param1: ItemCount as Long

·         Param2: Pointer to the ItemObject as Array

·         Param3: Pointer to the pValues as Array of Variant

·         Param4: Pointer to the pErrors as Array of Long

·         Result: hResult

OpcWriteItemArray(ItemCount, *ItemObject.variant, *pValues.variant, *pErrors.variant)

Kompatibilität zu VisualStudio

·         Param1: ItemCount as int32

·         Param2: ItemObject as Array of int32 (Object)

·         Param3: pResult as Array of Variant (Object)

·         Param4: pErrors as Array of int32 (Object)

·         Result: hResult as int32


Zusatzinfo

OpcGetQualityText(qnr.l)

·         Param1: Quality Number

·         Result: Qualitytext as pString (Unicode)

OpcGetErrorString(*ServerObject, ErrorNumber.l)

·         Para 1: ServerObject

·         Para 2: Errorcode

·         Result: Errortext as pString (Unicode)

OpcGetLastError()

·         Result: Last Error

 


Server Shutdown

OpcInitShutdown(*ServerObject)

·        Param1: ServerObject as pointer

·        Result: ServerObject as pointer or zero by fault

OpcReleaseShutdown(*ServerObject)

·        Param1: ServerObject as pointer

·        Result: Ok = 0 - Shutdown Object = Fail

OpcIsShutdown(*ServerObject)

·         Param1: ServerObject as pointer

·         Result: True is shutdown request

OpcIsShutdownText(*ServerObject)

·         Param1: ServerObject as pointer

·         Result: Shutdown Text as String

OpcSetShutdownCallBack(*ServerObject, *Callback)

·         Param1: ServerObject as pointer

·         Param2: Callback function adress (MyCallback(*szReason))

·         Result: Old callback adress

 


License agreement

-====================================================================-

Using of the program

-====================================================================-

This program can be used for free.

I can´t give any warranty for the functionality and the correctness of the

results. I can´t take any responsibility for any damage of hardware or

software. You will use this software on your own risk.

-====================================================================-

Distribution of the program

-====================================================================-

You can distribute this program for free if you use the package of the

author without any changes. You are not allowed charge any money for the

distribution. If you want to distribute this program in any commerital way

you have to contact the author for a permission.

 

Freeware by Michael Kastner (mk-soft) [mk_soft@arcor.de or http://www.mksoft-planet.de]