一、TIA15管道流水动画(水平管道)
首先在HMI里定义3个内部变量:方向waterflowdirection(bool)、启停waterflowstart(bool)速度waterflowspeed(usint)
1. 画一条折线,用折线代表流水
1) 属性→其他→名称,折线命名为poly01
2) 属性→布局→当前角点索引设置为1
3) 属性→布局→当前角点X轴位置添加VB脚本
Function ActualPointLeftValue(ByVal item)
Dim lft,speed,poly
Set poly=HMIRuntime.ActiveScreen.ScreenItems("polyline01")
poly.Index=1
lft=poly.ActualPointLeft
IfHMIRuntime.SmartTags("waterflowdirection")=False Then
IfHMIRuntime.SmartTags("waterflowspeed")=2 Then
ActualPointLeftValue=lft+3
Else
ActualPointLeftValue=lft+1
EndIf
Iflft>=86 Then
poly.ActualPointLeft=58
ActualPointLeftValue=58
EndIf
Else
IfHMIRuntime.SmartTags("waterflowspeed")=2 Then
ActualPointLeftValue=lft-3
Else
ActualPointLeftValue=lft-1
EndIf
Iflft<=58 Then
poly.ActualpointLeft=86
ActualPointLeftValue=86
EndIf
End If
触发器选择位250ms或者画面周期
4) 动画→显示→可见性,选择变量waterflowstart范围从1到1 可见
2. 点击元素添加六个按钮分别命名为下图所示
1) 启动→属性→事件→单击→添加VB脚本
HMIRuntime.Tags("waterflowstart").WriteTrue
Dim poly1
Setpoly1=HMIRuntime.ActiveScreen.ScreenItems("polyline01")
poly1.Visible=True
Select CaseHMIRuntime.SmartTags("waterflowspeed")
Case0
poly1.ActivateDynamic"ActulPointLeft","500 ms"
Case1
poly1.ActivateDynamic"ActulPointLeft","250 ms"
Case2
poly1.ActivateDynamic"ActulPointLeft","125 ms"
End Select
2) 停止→属性→事件→单击→添加VB脚本
Sub OnClick(ByVal item)
HMIRuntime.Tags("waterflowstart").WriteFalse
Dim poly
Setpoly=HMIRuntime.ActiveScreen.ScreenItems("polyline01")
poly.DeactivateDynamic"ActualPointLeft"
poly.Visible=False
End Sub
3) 左右→属性→事件→单击→添加VB脚本
Sub OnClick(ByVal item)
HMIRuntime.Tags("waterflowdirection").WriteFalse
End Sub
4) 右左→属性→事件→单击→添加VB脚本
Sub OnClick(ByVal item)
HMIRuntime.Tags("waterflowdirection").WriteTrue
End Sub
5) 慢速→属性→事件→单击→添加VB脚本
Sub OnClick(ByVal item)
HMIRuntime.Tags("waterflowspeed").Write0
Dim poly
Setpoly=HMIRuntime.ActiveScreen.ScreenItems("polyline01")
poly.ActivateDynamic"ActualPointLeft","500 ms"
End Sub
6) 正常→属性→事件→单击→添加VB脚本
Sub OnClick(ByVal item)
HMIRuntime.Tags("waterflowspeed").Write1
Dim poly
Set poly=HMIRuntime.ActiveScreen.ScreenItems("polyline01")
poly.ActivateDynamic"ActualPointLeft","250 ms"
End Sub
7) 快速→属性→事件→单击→添加VB脚本
Sub OnClick(ByVal item)
HMIRuntime.Tags("waterflowspeed").Write2
Dim poly
Setpoly=HMIRuntime.ActiveScreen.ScreenItems("polyline01")
poly.ActivateDynamic"ActualPointLeft","125 ms"
End Sub
博图15.0的wincc流水动画VB脚本
最新推荐文章于 2024-09-20 20:01:16 发布