wincc如何导出报警记录中的消息,并显示在监控画面上 10
1个回答
展开全部
你打开报警归档的数据库的table 看看各个字段 按照需求读取
这是我写的 读取报警归档之后 将归档值写入内部变量的例子
Dim sPro
Dim sDsn
Dim sSer
Dim sCon
Dim sSql
Dim conn
Dim oRs
Dim oCom
Dim oItem
'Dim m,n,s
'connection string
sPro = "Provider=WinCCOLEDBProvider.1;"
sDsn = "Catalog=CC_GDSmartP_12_03_10_08_18_49R;" '数据库名
sSer = "Data Source=.\WinCC"
sCon = sPro + sDsn + sSer
'sCon="Provider=WinCCOLEDBProvider.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=SSEJRecord;Data Source=.\WINCC"
'MsgBox "set sCon"
'sSQL为查询命令
sSql = "ALARMVIEW:Select * FROM AlgViewCht WHERE MsgNr=1"
'sSql = "ALARMVIEW:SELECT * from AlgViewChs"
'MsgBox "Set SQL"
'建立连接
Set conn = CreateObject("ADODB.Connection")
conn.ConnectionString = sCon
conn.CursorLocation = 3
conn.Open
'MsgBox "conn Open"
'进行查询
Set oRs = CreateObject("ADODB.Recordset")
Set oCom = CreateObject("ADODB.Command")
oCom.CommandType = 1
Set oCom.ActiveConnection = conn
oCom.CommandText = sSql
'MsgBox "set command"
'填充记录集
Set oRs = oCom.Execute
'm = oRs.Fields.Count
MsgBox oRs.EOF
If(oRs.EOF) Then
oRs.Close
Else
oRs.MoveFirst
Do While Not oRs.EOF
HMIRuntime.Tags("AlarmText1").Write CStr(oRs.Fields(17).Value)
HMIRuntime.Tags("AlarmText2").Write CStr(oRs.Fields(18).Value)
HMIRuntime.Tags("AlarmText3").Write CStr(oRs.Fields(19).Value)
HMIRuntime.Tags("AlarmText4").Write CStr(oRs.Fields(20).Value)
HMIRuntime.Tags("AlarmText5").Write CStr(oRs.Fields(21).Value)
HMIRuntime.Tags("AlarmText6").Write CStr(oRs.Fields(22).Value)
HMIRuntime.Tags("AlarmText7").Write CStr(oRs.Fields(23).Value)
oRs.MoveNext
Loop
oRs.Close
End If
Set oRs = Nothing
conn.Close
Set conn = Nothing
这是我写的 读取报警归档之后 将归档值写入内部变量的例子
Dim sPro
Dim sDsn
Dim sSer
Dim sCon
Dim sSql
Dim conn
Dim oRs
Dim oCom
Dim oItem
'Dim m,n,s
'connection string
sPro = "Provider=WinCCOLEDBProvider.1;"
sDsn = "Catalog=CC_GDSmartP_12_03_10_08_18_49R;" '数据库名
sSer = "Data Source=.\WinCC"
sCon = sPro + sDsn + sSer
'sCon="Provider=WinCCOLEDBProvider.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=SSEJRecord;Data Source=.\WINCC"
'MsgBox "set sCon"
'sSQL为查询命令
sSql = "ALARMVIEW:Select * FROM AlgViewCht WHERE MsgNr=1"
'sSql = "ALARMVIEW:SELECT * from AlgViewChs"
'MsgBox "Set SQL"
'建立连接
Set conn = CreateObject("ADODB.Connection")
conn.ConnectionString = sCon
conn.CursorLocation = 3
conn.Open
'MsgBox "conn Open"
'进行查询
Set oRs = CreateObject("ADODB.Recordset")
Set oCom = CreateObject("ADODB.Command")
oCom.CommandType = 1
Set oCom.ActiveConnection = conn
oCom.CommandText = sSql
'MsgBox "set command"
'填充记录集
Set oRs = oCom.Execute
'm = oRs.Fields.Count
MsgBox oRs.EOF
If(oRs.EOF) Then
oRs.Close
Else
oRs.MoveFirst
Do While Not oRs.EOF
HMIRuntime.Tags("AlarmText1").Write CStr(oRs.Fields(17).Value)
HMIRuntime.Tags("AlarmText2").Write CStr(oRs.Fields(18).Value)
HMIRuntime.Tags("AlarmText3").Write CStr(oRs.Fields(19).Value)
HMIRuntime.Tags("AlarmText4").Write CStr(oRs.Fields(20).Value)
HMIRuntime.Tags("AlarmText5").Write CStr(oRs.Fields(21).Value)
HMIRuntime.Tags("AlarmText6").Write CStr(oRs.Fields(22).Value)
HMIRuntime.Tags("AlarmText7").Write CStr(oRs.Fields(23).Value)
oRs.MoveNext
Loop
oRs.Close
End If
Set oRs = Nothing
conn.Close
Set conn = Nothing
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
万山数据
2024-11-14 广告
2024-11-14 广告
实时数仓处理是我们北京万山数据科技有限公司数据处理能力的核心之一。它基于先进的流处理技术,能够实时捕获、处理和分析海量数据,确保数据的时效性和准确性。通过构建高效的实时数据管道,我们能够实现数据的即时入库与查询,为业务决策提供强有力的支持。...
点击进入详情页
本回答由万山数据提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询