WINCC画面多变量连接问题

我在现场给人做个项目,根据甲方的要求要在画面给人做色彩显示,打个比方,有8台电机,要求1,3,,5,7号电机运行时,方块1指示灯为绿色,方块2指示灯红色,当2,4,6,8号电机运行时,方块2指示灯为绿色,方块1是红色,当然必须用这两个指示,不能在加别的颜色指示了,求前辈们指点一二,谢谢了.

最佳答案

在下位机做如果1357运行=m0.0,如果2468运行=m0.1,上位机建立变量tag1连接m0.0,tag2连接m0.1.如果你的电机运行和停止的不是你设定的怎么办?显示第三种颜色。
方框的背景颜色c脚本:
define TAG_1 "tag1"
define TAG_2 "tag2"
if((unsigned long)GetTagDouble(TAG_1))
return 65280;//绿色
else if((unsigned long)GetTagDouble(TAG_2))
return 255;//红色
else return 0;//其他颜色


脚本的触发变量连接tag1和tag2

vbs脚本:
function backcolor_trigger(byval item)
dim tag_1,tag_2
tag_1=hmiruntime.tags("tag1").read
tag_2=hmiruntime.tags("tag2").read
if tag_1 then
backcolor_trigger=65280
end if
if tag_2 then
backcolor_trigger=255
end if
if  not tag_1 and not tag_2 then
backcolor_trigger=0
end if
end function
脚本触发变量添加tag1和tag2
如果你把8个信号全部取上来的话用vbs做简单:
dim tag_1,tag_2,tag_3,tag_4,tag_5,tag_6,tag_7,tag_8
tag_1=hmiruntime.tags("tag1").read
tag_2=hmiruntime.tags("tag2").read
tag_3=hmiruntime.tags("tag3").read
tag_4=hmiruntime.tags("tag4").read
tag_5=hmiruntime.tags("tag5").read
tag_6=hmiruntime.tags("tag6").read
tag_7=hmiruntime.tags("tag7").read
tag_8=hmiruntime.tags("tag8").read

if tag_1 and tag_3 and tag_5 and tag_7 then
backcolor_trigger=65280
end if
if tag_2 and tag_4 and tag_6 and tag_8 then
backcolor_trigger=255
end if
if not(tag_1 and tag_3 and tag_5 and tag_7) and not(tag_2 and tag_4 and tag_6 and tag_8) then
backcolor_trigger=0
end if
触发变量为tag1~tag8

提问者对于答案的评价:
可能是我说的不明白,我的意思是,不管电机1,3,5什么的,只要有一个运行,画面只是灯就亮。不过我在程序里做了,你的答案我以后会采纳!因为这个东西以后用的不少。

原创文章,作者:more0621,如若转载,请注明出处:https://www.zhaoplc.com/plc253283.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2018年12月7日
下一篇 2018年12月7日

相关推荐