⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 VB开发OPC Client的教程和源码
💻 FRM
字号:
VERSION 5.00
Object = "{6FC23E63-9CE1-11D7-8AA8-000476323C57}#1.0#0"; "AE_CLI~1.OCX"
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   6360
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   8250
   LinkTopic       =   "Form1"
   ScaleHeight     =   6360
   ScaleWidth      =   8250
   StartUpPosition =   3  'Windows Default
   Begin VB.ListBox ServerList 
      Height          =   1035
      Left            =   2280
      TabIndex        =   3
      Top             =   360
      Width           =   4335
   End
   Begin AE_CLIENTLib.AE_Client AE_Client1 
      Left            =   7080
      Top             =   120
      _Version        =   65536
      _ExtentX        =   1296
      _ExtentY        =   661
      _StockProps     =   0
   End
   Begin VB.ListBox EventLst 
      Height          =   4155
      Left            =   240
      TabIndex        =   2
      Top             =   1920
      Width           =   7935
   End
   Begin VB.CommandButton DisconnectButton 
      Caption         =   "Disconnect"
      Height          =   375
      Left            =   240
      TabIndex        =   1
      Top             =   1080
      Width           =   1575
   End
   Begin VB.CommandButton ConnectButton 
      Caption         =   "Connect"
      Height          =   375
      Left            =   240
      TabIndex        =   0
      Top             =   600
      Width           =   1575
   End
   Begin VB.Label Label1 
      Caption         =   "Event Messages"
      Height          =   255
      Left            =   3600
      TabIndex        =   5
      Top             =   1560
      Width           =   1215
   End
   Begin VB.Label Text1 
      Caption         =   "AE Server List"
      Height          =   255
      Left            =   3720
      TabIndex        =   4
      Top             =   120
      Width           =   1575
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public hConnect As Long
Public hSubscription As Long
Public ServerName As String
Public Msg As String






Private Sub Form_Load()
Dim MachineName As String

hConnect = -1
hSubscription = -1
ConnectButton.Enabled = False
DisconnectButton.Enabled = False

MachineName = ""  'set to "127.0.0.1" to test dcom link to loopback address
NumberOfServers = AE_Client1.NumberOfAEServers(MachineName)
For i = 0 To NumberOfServers
    ServerList.AddItem AE_Client1.AEServerName(i)
    Next i
    
End Sub

Private Sub ServerList_Click()
    ServerName = ServerList.List(ServerList.ListIndex)
    ConnectButton.Enabled = True
    
End Sub

Private Sub ConnectButton_Click()
Dim SubscriptionBufferTime As Long
Dim SubscriptionMaxSize As Long

    hConnect = AE_Client1.ConnectToAEServer(ServerName)
    If (hConnect = -1) Then
        Return
        End If
    
    SubscriptionBufferTime = 0
    SubscriptionMaxSize = 1
    hSubscription = AE_Client1.CreateAESubscription(hConnect, 1, SubscriptionBufferTime, SubscriptionMaxSize)
    DisconnectButton.Enabled = True
    ConnectButton.Enabled = False
   
End Sub

Private Sub DisconnectButton_Click()
    AE_Client1.DisconnectFromAEServer (hConnect)
    hConnect = -1
    hSubscription = -1
    ConnectButton.Enabled = True
    DisconnectButton.Enabled = False
    
End Sub

Private Sub AE_Client1_AEEventsNotfication(ByVal SubscriptionHandle As Long, ByVal NumberOfEvents As Long)
Dim ChangeMask As Integer
Dim NewState As Integer
Dim Source As String
Dim TimeStamp As Date
Dim Message As String
Dim EventType As Long
Dim EventCategory As Long
Dim Severity As Long
Dim ConditionName As String
Dim SubConditionName As String
Dim Quality As Integer
Dim AckRequired As Boolean
Dim ActiveTime As Date
Dim Cookie As Long


For i = 0 To NumberOfEvents - 1

    ChangeMask = AE_Client1.EventChangeMask(i)
    NewState = AE_Client1.EventNewState(i)
    Source = AE_Client1.EventSource(i)
    TimeStamp = AE_Client1.EventTime(i)
    Message = AE_Client1.EventMessage(i)
    EventType = AE_Client1.EventType(i)
    EventCategory = AE_Client1.EventCategory(i)
    Severity = AE_Client1.EventSeverity(i)
    ConditionName = AE_Client1.EventConditionName(i)
    SubConditionName = AE_Client1.EventSubCondition(i)
    Quality = AE_Client1.EventQuality(i)
    AckRequired = AE_Client1.EventAckRequired(i)
    Cookie = AE_Client1.EventCookie(i)
    Msg = TimeStamp
    Msg = Msg + ":" + Source + " " + Message
    EventLst.AddItem Msg
    
Next i

End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -