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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
上海巴鲁图工程机械科技有限公司_
2022-05-15 广告
2022-05-15 广告
光电编码器,是一种通过光电转换将输出轴上的机械几何位移量转换成脉冲或数字量的传感器。光电编码器每转输出60(我们用老板没有说)个脉冲,五线制。其中两根为电源线,三根为脉冲线(A相、B相、Z)。电源的工作电压为 (+5~+24V)直流电源。光...
点击进入详情页
本回答由上海巴鲁图工程机械科技有限公司_提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询