wincc的vbs的按鈕代碼分析
鄭志武
發(fā)布于2012-12-04 22:58
5
0
標簽:
編了2個按鈕代碼:個按鈕按下去后出現(xiàn)小畫面,再按第二個按鈕,給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內(nèi)部變量;b是寫給plc的變量;
按下個按鈕后,再按第二個按鈕實現(xiàn)給plc變量b賦值1;松開b賦值0;
1.個按鈕的代碼起什么作用??終的目的是給plc的b變量寫值,為什么把b寫給motor_command_req_1????在我看來應(yīng)該是
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、這是定義一個腳本內(nèi)的變量連接到motor_command_req_1
3、這個腳本是有問題的,應(yīng)該是直接用
dimmotor
setmotor=hmiruntime.tags("motor_command_req_1")
motor.write0
這個是給變量motor_command_req_1賦值0
如果你懷疑我的分析你可以原來的這些代碼賦值到項目中運行一下看看。