Private Sub Form_Unload(Cancel As Integer) Command3_Click End Sub Sub StopClient() 'OPC客户端连接后要占用服务器资源,所以如果不需要使用OPC时, '必须进行OPC连接断开。断开的程序相当简单,释放资源即可。 '但在实际的使用中发现,频繁的连接与断开,将使服务器的资源被大量的消耗, '最终让服务器出错。所以尽量减少无谓的OPC连接与断开。 On Error Resume Next MyOPCGroupColl.RemoveAll '释放组和服务器对象 MyOPCServer.Disconnect '与服务器断开连接并且清除 Set MyOPCItemCollIn = Nothing Set MyOPCItemCollOut = Nothing Set MyOPCGroupIn = Nothing Set MyOPCGroupOut = Nothing Set MyOPCGroupColl = Nothing Set MyOPCServer = Nothing End Sub Private Sub Timer1_Timer() '定时读取SLC内存内的标签值 i = 1 For Each aaa In MyOPCItems aaa.Read i, DataValue(i) i = i + 1 Next '根据标签的值,相应改变梯形图中各元件的状态 Text1.Text = DataValue(3) If DataValue(2) = 1 Then Image5.Visible = True Image2.Visible = True Else Image5.Visible = False Image2.Visible = False End If If DataValue(4) = 1 Then Image6.Visible = True Else Image6.Visible = False If DataValue(5) = 1 Then Image7.Visible = True Else Image7.Visible = False End Sub |
|Archiver|手机版|小黑屋|紫外工控论坛. ( 苏ICP备11032118号-1 )
GMT+8, 2024-5-18 19:41 , Processed in 0.343752 second(s), 15 queries .