Intouch/ifix语音报警系统制作(2)
在我的先前一篇关于语音报警系统制作的文章中,阐述了如何通过标签组来获得@name@的详细内容,以通过这种方式来进行详细的设备故障播报。经过一段时间的试运行,发现使用标签组的方式会产生较大的耦合,(即当标签组内容或者脚本内容发生错误时,脚本会弹出错误,妨碍了其他脚本的执行)
于是,在现场将所有的绑定标签组的报警脚本修改为直接传参到全局变量,实现解耦。
1.后台调度修改:
Private Sub FixEvent2_WhileTrue() ’将全局变量PicNumBer赋值为所需要报警的设备名称 Dim workspace As Object Set workspace = GetObject("", "Workspace.Application") Dim tagvar As Object Set tagvar = workspace.Documents("User").Page.FindObject("PicNumBer") tagvar.Description = "二期粗格栅2号污水泵" Dim TOP As Integer Dim LEFT As Integer TOP = Int((50 * Rnd) + 1) LEFT = Int((50 * Rnd) + 1) Dim conODBC As ADODB.Connection Dim StrD As String Dim userid As String Dim username As String Dim groupname As String System.FixGetUserInfo userid, username, groupname StrD = Format(Now, "yyyy-mm-dd hh:mm:ss") Set conODBC = New ADODB.Connection conODBC.ConnectionString = "DSN=QPWS;UID=sa;PWD=;" conODBC.Open "QPWS", "sa", "" conODBC.Execute "insert into kaitingshijian (DateTimee,mingcheng,neirong,operator) values ('" + StrD + "','二期粗格栅污水泵2', '故障', '" + username + "')" conODBC.Close openpicture "故障报警.grf", "", TOP, LEFT, 0, , NONE, "", True End Sub
2.1弹窗界面初始化:
Private Sub CFixPicture_Initialize() Dim a As String User.jishu.CurrentValue = User.jishu.CurrentValue + 1 playSound ("D:\alarm.wav") '将设备名称赋值给text标签的caption属性 Text2.Caption = User.PicNumBer.Description '故障报警.LoadTagGroupFile User.PicNumBer.Description '故障报警.tagGroupSubstitution "@name@", a 'JTTS_ActiveX1.Play (a) JTTS_ActiveX1.Play (Text2.Caption + Text1.Caption + Text2.Caption + Text1.Caption + Text2.Caption + Text1.Caption) End Sub
2.2界面关闭:
Private Sub CFixPicture_Close() If User.tagname.CurrentValue = False Then User.tagname.CurrentValue = True Else Dim a As String a = Text2.Caption Dim conODBC As ADODB.Connection Dim StrD As String Dim userid As String Dim username As String Dim groupname As String System.FixGetUserInfo userid, username, groupname StrD = Format(Now, "yyyy-mm-dd hh:mm:ss") Set conODBC = New ADODB.Connection conODBC.ConnectionString = "DSN=QPWS;UID=sa;PWD=;" conODBC.Open "QPWS", "sa", "" conODBC.Execute "insert into querenguzhang (DateTimee,mingcheng,neirong,operator,queren) values ('" + StrD + "','" + a + "', '故障', '" + username + "','未确认')" User.jishu1.CurrentValue = User.jishu1.CurrentValue + 1 conODBC.Close End If End Sub
2.3确认按钮脚本编写:
Private Sub CommandButton1_Click() Dim a As String a = Text2.Caption Dim conODBC As ADODB.Connection Dim StrD As String Dim userid As String Dim username As String Dim groupname As String System.FixGetUserInfo userid, username, groupname StrD = Format(Now, "yyyy-mm-dd hh:mm:ss") Set conODBC = New ADODB.Connection conODBC.ConnectionString = "DSN=QPWS;UID=sa;PWD=;" conODBC.Open "QPWS", "sa", "" conODBC.Execute "insert into querenguzhang (DateTimee,mingcheng,neirong,operator,queren) values ('" + StrD + "','" + a + "', '故障', '" + username + "','已确认')" conODBC.Close User.tagname.CurrentValue = False 'If (User.jishu.CurrentValue > 0) Then 'User.jishu.CurrentValue = User.jishu.CurrentValue - 1 'Else 'User.jishu.CurrentValue = 0 'End If closepicture End Sub
显示效果如图:
本文来自博客园,作者:cache.yuan,转载请注明原文链接:https://www.cnblogs.com/cache-yuan/p/9218450.html