📄 yfopcsdk.vb
字号:
Option Strict Off
Option Explicit On
Imports System.Runtime.InteropServices
Imports System.Text
Module YFOPCSDK
Public Delegate Sub AddOPCnameProxy(ByVal Name As String, ByVal clsid As String)
Public Delegate Sub AddLandHostIPProxy(ByVal Host As StringBuilder, ByVal ip As StringBuilder)
Public Delegate Sub AddProcessProxy(ByVal ev As StringBuilder)
Public Delegate Sub ServerDataChangeProcProxy(ByVal ServerHandle As Integer, ByVal GroupHandle As Integer, ByVal ItemHandle As Integer, ByVal Value As Object, ByVal Ft As Double, ByVal Quality As Short)
Public Delegate Sub ServerShutdownProcProxy(ByVal ServerHandle As Integer)
Public Declare Function OPC_GetVersion Lib "YFOPCSDK.dll" () As Integer
Public Declare Function OPC_Init Lib "YFOPCSDK.dll" () As Integer
Public Declare Function OPC_Uninit Lib "YFOPCSDK.dll" () As Integer
Public Declare Function OPC_ActiveCode Lib "YFOPCSDK.dll" (ByVal regName As String, ByRef regCode As String) As Integer
Public Declare Function OPC_GetServers Lib "YFOPCSDK.dll" (ByVal Host As String, ByVal Version As Integer, ByRef ServerNames As Object, ByRef ServerClassIDs As Object) As Integer
Public Declare Function OPC_Connect Lib "YFOPCSDK.dll" (ByVal Host As String, ByVal ServerClass As String, ByVal Version As Integer) As Integer
Public Declare Function OPC_Disconnect Lib "YFOPCSDK.dll" (ByVal ServerHandle As Integer) As Integer
Public Declare Function OPC_GetServerStatus Lib "YFOPCSDK.dll" (ByVal ServerHandle As Integer, ByRef StartTime As Double, ByRef CurrentTime As Double, ByRef LastUpdateTime As Double, ByRef State As Short, ByRef BandWidth As Integer, ByRef GroupCount As Integer, ByRef MajorVersion As Short, ByRef MinorVersion As Short, ByRef BuildNumber As Short, ByVal vendor As String, ByVal size As Integer) As Integer
Public Declare Function OPC_AddGroup Lib "YFOPCSDK.dll" (ByVal ServerHandle As Integer, ByVal Name As String, ByVal Active As Integer, ByVal UpdateRate As Integer, ByVal TimeBias As Integer, ByVal DeadBand As Single, ByVal LCID As Integer) As Integer
Public Declare Function OPC_RemoveGroup Lib "YFOPCSDK.dll" (ByVal ServerHandle As Integer, ByVal GroupHandle As Integer) As Boolean
Public Declare Function OPC_SetGroupName Lib "YFOPCSDK.dll" (ByVal ServerHandle As Integer, ByVal GroupHandle As Integer, ByVal Name As String) As Integer
Public Declare Function OPC_SetGroupStat Lib "YFOPCSDK.dll" (ByVal ServerHandle As Integer, ByVal GroupHandle As Integer, ByVal UpdateRate As Integer, ByVal Active As Integer, ByVal TimeBias As Integer, ByVal DeadBand As Single, ByVal LCID As Integer) As Integer
Public Declare Function OPC_GetGroupStat Lib "YFOPCSDK.dll" (ByVal ServerHandle As Integer, ByVal GroupHandle As Integer, ByRef UpdateRate As Integer, ByRef pActive As Integer, ByRef pTimeBias As Integer, ByRef pDeadBand As Single, ByRef pLCID As Integer) As Integer
Public Declare Function OPC_RefreshGroup Lib "YFOPCSDK.dll" (ByVal ServerHandle As Integer, ByVal GroupHandle As Integer, ByVal DataSoure As Short) As Integer
'UPGRADE_NOTE: NameSpace 已升级到 NameSpace_Renamed。 单击以获得更多信息:“ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"”
Public Declare Function OPC_GetNameSpace Lib "YFOPCSDK.dll" (ByVal ServerHandle As Integer, ByRef NameSpace_Renamed As Short) As Integer
Public Declare Function OPC_ChangeBrowsePosition Lib "YFOPCSDK.dll" (ByVal ServerHandle As Integer, ByVal Direct As Short, ByVal NodeName As String) As Integer
Public Declare Function OPC_BrowseItems Lib "YFOPCSDK.dll" (ByVal ServerHandle As Integer, ByVal FilterType As Short, ByVal FilterString As String, ByVal FilterDataType As Short, ByVal FilterAccessRight As Short, ByRef ItemNames As Object) As Integer
Public Declare Function OPC_GetItemFullName Lib "YFOPCSDK.dll" (ByVal ServerHandle As Integer, ByVal Name As String, ByVal pFullName As String, ByVal size As Integer) As Integer
Public Declare Function OPC_GetItemProperties Lib "YFOPCSDK.dll" (ByVal ServerHandle As Integer, ByVal GroupHandle As Integer, ByVal Name As String, ByRef IDList As Object, ByRef DataTypeList As Object, ByRef DescList As Object) As Integer
Public Declare Function OPC_GetItemPropertyValue Lib "YFOPCSDK.dll" (ByVal ServerHandle As Integer, ByVal GroupHandle As Integer, ByVal Name As String, ByVal PropertyID As Integer, ByRef Value As Object) As Integer
Public Declare Function OPC_AddItem Lib "YFOPCSDK.dll" (ByVal ServerHandle As Integer, ByVal GroupHandle As Integer, ByVal Name As String) As Integer
Public Declare Function OPC_RemoveItem Lib "YFOPCSDK.dll" (ByVal ServerHandle As Integer, ByVal GroupHandle As Integer, ByVal ItemHandle As Integer) As Integer
Public Declare Function OPC_ActiveItem Lib "YFOPCSDK.dll" (ByVal ServerHandle As Integer, ByVal GroupHandle As Integer, ByVal Active As Integer) As Integer
Public Declare Function OPC_WriteItem Lib "YFOPCSDK.dll" (ByVal ServerHandle As Integer, ByVal GroupHandle As Integer, ByVal ItemHandle As Integer, ByVal Value As Object, ByVal DoAsync As Integer) As Integer
Public Declare Function OPC_ReadItem Lib "YFOPCSDK.dll" (ByVal ServerHandle As Integer, ByVal GroupHandle As Integer, ByVal ItemHandle As Integer, ByRef Value As Object, ByRef TimeStamp As Double, ByRef Quality As Short) As Integer
Public Declare Function OPC_ValidateItem Lib "YFOPCSDK.dll" (ByVal ServerHandle As Integer, ByVal GroupHandle As Integer, ByVal Name As String, ByRef DataType As Short, ByVal AccessRight As Short) As Integer
'// prototype for the callback function is as follows:
'// void CALLBACK EXPORT DataChangeProc(HANDLE GroupHandle, HANDLE ItemHandle, VARIANT pVar, FILETIME timestamp, WORD quality)
'// Param: HANDLE ServerHandle -- HANDLE of connected opc server
'// DATACHANGEPROC lpCallback -- pointer of callback function in user application
'// Return: BOOL -- TRUE if succeded, FALSE if failed
Public Declare Function OPC_SetDataChangeProc Lib "YFOPCSDK.dll" (ByVal ServerHandle As Integer, ByVal callback As ServerDataChangeProcProxy) As Integer
'// prototype for the callback function is as follows:
'// void CALLBACK EXPORT ShutDownProc(HANDLE ServerHandle)
'// Param: HANDLE ServerHandle -- HANDLE of connected opc server
Public Declare Function OPC_SetShutdownProc Lib "YFOPCSDK.dll" (ByVal ServerHandle As Integer, ByVal callback As ServerShutdownProcProxy) As Integer
Public Declare Function EnumLanHostIPA Lib "YFOPCSDK.dll" (ByVal lpAddHostIP As AddLandHostIPProxy) As Boolean
Public Declare Function EnumOPCNameA Lib "YFOPCSDK.dll" (ByVal hostname As String, ByVal Version As Integer, ByVal lpAddOPCname As AddOPCnameProxy) As Boolean
Public Declare Sub OPC_SetProcessTiggerProcA Lib "YFOPCSDK.dll" (ByVal callback As AddProcessProxy)
End Module
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -