发布于 2016-11-21 14:21:09
1楼
就我以前接触过的WinCC6是没有配方这种东西的,至于WinCC7有没有就不清楚了。
至于WinCC的表格,纯粹是显示历史数据用的,实现不了你要的功能。
只能通过脚本来实现,,,,但是一天触发5000次这个量需要看你的变量有多少个了。如果每秒生成一次cvs文件,且变量少于100个的话wincc还是能承受得起的。如果变量很多(超过999个)由于脚本效率问题估计WinCC要崩溃。
行不行建议你自己尝试了才知道了。
建议:
1、建立一个全局脚本模块 用于读取变量值并保存到cvs文件;
2、建立一个全局脚本动作 用于定时或者根据某个变量值改变触发一次上述的模块;
例子:
1.全局脚本模块,读取Unit01~03.Tag1~10共30个变量,生成CVS文件,保存到C:\<当前时间>.cvs 文件:
Sub procedure1
Dim tagFilename
Dim strFilename,strTxt,strTxtType(4)
Dim c(7),i
Dim fso,objFile,objTag
'clock
c(0) = HMIRuntime.Tags("$year").read
If (HMIRuntime.Tags("$month").read) >= 10 Then c(1) = HMIRuntime.Tags("$month").read Else c(1) = "0" & HMIRuntime.Tags("$Month").read
If (HMIRuntime.Tags("$day").read) >= 10 Then c(2) = HMIRuntime.Tags("$day").read Else c(2) = "0" & HMIRuntime.Tags("$day").read
If (HMIRuntime.Tags("$hour").read) >= 10 Then c(3) = HMIRuntime.Tags("$hour").read Else c(3) = "0" & HMIRuntime.Tags("$hour").read
If (HMIRuntime.Tags("$minute").read) >= 10 Then c(4) = HMIRuntime.Tags("$minute").read Else c(4) = "0" & HMIRuntime.Tags("$minute").read
If (HMIRuntime.Tags("$second").read) >= 10 Then c(5) = HMIRuntime.Tags("$second").read Else c(5) = "0" & HMIRuntime.Tags("$second").read
c(6) = HMIRuntime.Tags("$millisecond").read
If (c(6) < 10) Then
c(6) = "00" & c(6)
Else
If (c(6) < 100) Then c(6) = "0" & c(6)
End If
c(7) = (c(0) & c(1) & c(2) & c(3) & c(4) & c(5) & c(6) )
HMIRuntime.Tags("strTag").Write c(7)
'file
strFilename = "c:\" & c(7) & ".csv"
Set fso = CreateObject("s cripting.FileSystemObject")
Set objFile = fso.CreateTextFile(strFilename,True)
'text
HMIRuntime.Trace("VB-s cript:Write file:" & strFilename & vbCrLf)
strTxtType(1) = "A"
strTxtType(2) = "B"
strTxtType(3) = "C"
strTxt ="TYPE" & "," & "Tag1" & "," & "Tag2" & "," & "Tag3" & "," & "Tag4" & "," & "Tag5" & "," & "Tag6" & "," & "Tag7" & "," & "Tag8" & "," & "Tag9" & "," & "Tag10" & vbCrLf
For i = 1 To 3
strTxt = strTxt & strTxtType(i) & "," & _
HMIRuntime.Tags("Unit0" & i & ".Tag1").read & "," & HMIRuntime.Tags("Unit0" & i & ".Tag2").read & "," & HMIRuntime.Tags("Unit0" & i & ".Tag3").read & "," & _
HMIRuntime.Tags("Unit0" & i & ".Tag4").read & "," & HMIRuntime.Tags("Unit0" & i & ".Tag5").read & "," & HMIRuntime.Tags("Unit0" & i & ".Tag6").read & "," & _
HMIRuntime.Tags("Unit0" & i & ".Tag7").read & "," & HMIRuntime.Tags("Unit0" & i & ".Tag8").read & "," & HMIRuntime.Tags("Unit0" & i & ".Tag9").read & "," & _
HMIRuntime.Tags("Unit0" & i & ".Tag10").read & vbCrLf
Next
'save text
objFile.Writeline strTxt
HMIRuntime.Trace(strTxt & vbCrLf)
objFIle.Close
End Sub
2.全局脚本动作,用系统时钟的秒改变来触发一次上述模块:
Option Explicit
Function action
procedure1
End Function