一个新手编的2个按钮代码: 第一个按钮按下去后出现小画面,再按第二个按钮,给B赋1;松开0;
第一个按钮:
Dim motor_command_req
Set motor_command_req=HMIRuntime.Tags("motor_command_req_1")
motor_command_req.Write "B"
第二个按钮按下去:
Sub OnLButtonDown(Byval Item, Byval Flags, Byval x, Byval y)
Dim motor_command_req_1
Set motor_command_req_1=HMIRuntime.Tags("motor_command_req_1")
Dim motor_1
Set motor_1=HMIRuntime.Tags(motor_command_req_1.read)
motor_1.Write 1
End Sub
第二个按钮松开:
Sub OnLButtonUp(Byval Item, Byval Flags, Byval x, Byval y)
Dim motor_command_req_1
Set motor_command_req_1=HMIRuntime.Tags("motor_command_req_1")
Dim motor
Set motor=HMIRuntime.Tags(motor_command_req_1.read)
motor.Write 0
End Sub
其中motor_command_req_1 为WINCC内部变量;B是写给PLC的变量;
按下第一个按钮后,再按第二个按钮实现给PLC变量B赋值1;松开B赋值0;
请大侠分析下:
1.第一个按钮的代码起什么作用??最终的目的是给PLC 的B变量写值,为什么把B写给motor_command_req_1???? 在我看来应该是
SET motor_command_req_1=HMIRuntime.Tags("B")
motor_command_req_1.Write " motor_command_req_1"
2. Dim motor_command_req_1
Set motor_command_req_1=HMIRuntime.Tags("motor_command_req_1")
这2行起啥作用??
Dim motor
Set motor=HMIRuntime.Tags(motor_command_req_1.read)
motor.Write 0
这3行起啥作用???