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
如果你怀疑我的分析你可以原来的这些代码赋值到项目中运行一下看看。