技成培训网 技成学习APP 技成工具箱 技成企业服务

欢迎回到技成培训网

技成培训网

电工题库宝典

技成电工课堂

PLC练习题

技成PLC课堂

变频器故障查询

技成PLC学吧

伺服驱动故障查询

技成PLC网校

当前位置:技成首页 > 文章中心 > 技成百科 > wincc的vbs的按钮代码分析

wincc的vbs的按钮代码分析

郑志武 发布于2012-12-04 22:58 5 0 标签:

编了2个按钮代码:个按钮按下去后出现小画面,再按第二个按钮,给b赋1;松开0;
个按钮:
dimmotor_command_req
setmotor_command_req=hmiruntime.tags("motor_command_req_1")
motor_command_req.write"b"

第二个按钮按下去:
subonlbuttondown(byvalitem,byvalflags,byvalx,byvaly)

dimmotor_command_req_1
setmotor_command_req_1=hmiruntime.tags("motor_command_req_1")

dimmotor_1
setmotor_1=hmiruntime.tags(motor_command_req_1.read)
motor_1.write1
endsub

第二个按钮松开:
subonlbuttonup(byvalitem,byvalflags,byvalx,byvaly)

dimmotor_command_req_1
setmotor_command_req_1=hmiruntime.tags("motor_command_req_1")

dimmotor
setmotor=hmiruntime.tags(motor_command_req_1.read)
motor.write0
endsub
其中motor_command_req_1为wincc内部变量;b是写给plc的变量;
按下个按钮后,再按第二个按钮实现给plc变量b赋值1;松开b赋值0;
1.个按钮的代码起什么作用??终的目的是给plc的b变量写值,为什么把b写给motor_command_req_1????在我看来应该是
setmotor_command_req_1=hmiruntime.tags("b")
motor_command_req_1.write"motor_command_req_1"
2.dimmotor_command_req_1
setmotor_command_req_1=hmiruntime.tags("motor_command_req_1")
这2行起啥作用??
dimmotor
setmotor=hmiruntime.tags(motor_command_req_1.read)
motor.write0
这3行起啥作用???

佳答案

1、实际按钮1的代码等同于:
hmiruntime.tags("motor_command_req_1").write"b"
2、这是定义一个脚本内的变量连接到motor_command_req_1
3、这个脚本是有问题的,应该是直接用
dimmotor
setmotor=hmiruntime.tags("motor_command_req_1")
motor.write0
这个是给变量motor_command_req_1赋值0
如果你怀疑我的分析你可以原来的这些代码赋值到项目中运行一下看看。

若有收获,就点个赞吧!

文章来源于网络及文献如有侵权请联系站长
分享到:

微信扫一扫分享

阅读与本文标签相同的文章

相关推荐

最新文章 热门文章
最新课程 免费课程
PLC资料下载 电工电气资料下载
应用新秀
变频器故障代码查询APP
伺服故障代码查询APP
技成
手机APP
热门标签