对比之前文章介绍“KUKA机器人自定义4个工艺按键”(点击红色字体部分直接进入文章),当按住按键时设置的信号置位,一松开信号就会复位,对于某些现场操作时不太方便,因为有时需要按一下就置位,再按一下才复位,基于安全考虑呢,以下将第4个按键做成ON/OFF状态选择操作按键。
直接上步骤 :
1、创建KFD文件:
这里使用自带的TestStat.kfd文件,具体解释参考“KUKA机器人自定义4个工艺按键”。
DEFTP StatkeyTest
;定义两个字段为数字的类型
Decl Param BildNr={Value {Number: Min 0, Max 2, default 1}}
Decl Param StatKeyNr={Value {Number: Min 0, Max 3, default 1}}
;定义四个按键
Decl StatKey Stat1
Decl StatKey Stat2
Decl StatKey Stat3
Decl StatKey Stat4
;定义脚本文件,输出信息,其中“%StatkeyNr”为参数调用
DefScript StatKeyTrue
Message "OUT %StatkeyNr = ON"
ENDSCRIPT
;定义脚本文件,输出信息
DefScript StatKeyFalse
Message "OUT %StatkeyNr = OFF"
ENDSCRIPT
;定义脚本文件,输出信息,其中"%BildNr"为参数调用
DefScript StatKeyBool
SWITCH "%BildNr"
Case "1" do StatKeyTrue
Case "2" do StatKeyFalse
ENDSWITCH
ENDSCRIPT
;定义脚本文件,置位$OUT[1]
DefScript OUT1TRUE
SETVAR (FULLPATH[] "$OUT[1]", VALUE[] "TRUE")
ENDSCRIPT
;定义脚本文件,复位$OUT[1]
DefScript OUT1FALSE
SETVAR (FULLPATH[] "$OUT[1]", VALUE[] "FALSE")
ENDSCRIPT
DefScript OUT2TRUE
SETVAR (FULLPATH[] "$OUT[2]", VALUE[] "TRUE")
ENDSCRIPT
DefScript OUT2FALSE
SETVAR (FULLPATH[] "$OUT[2]", VALUE[] "FALSE")
ENDSCRIPT
DefScript OUT3TRUE
SETVAR (FULLPATH[] "$OUT[3]", VALUE[] "TRUE")
ENDSCRIPT
DefScript OUT3FALSE
SETVAR (FULLPATH[] "$OUT[3]", VALUE[] "FALSE")
ENDSCRIPT
Defscript ST1
Showvar(FULLPATH[] "1", PARAM StatKeyNr )
SWITCH "%BildNr"
Case "1" do OUT1TRUE
Case "2" do OUT1FALSE
ENDSWITCH
DO StatKeyBool
ENDSCRIPT
Defscript ST2
Showvar(FULLPATH[] "2", PARAM StatKeyNr )
SWITCH "%BildNr"
Case "1" do OUT2TRUE
Case "2" do OUT2FALSE
ENDSWITCH
DO StatKeyBool
ENDSCRIPT
Defscript ST3
Showvar(FULLPATH[] "3", PARAM StatKeyNr )
SWITCH "%BildNr"
Case "1" do OUT3TRUE
Case "2" do OUT3FALSE
ENDSWITCH
DO StatKeyBool
ENDSCRIPT
Defscript SKB1
Showvar(FULLPATH[] "1", PARAM BildNr )
SET Stat1 = {Picture[] "C:\KRC\TP\UserTech\UserTechResources\Bild11.ICO"}
SET Stat2 = {Picture[] "C:\KRC\TP\UserTech\UserTechResources\Bild21.ICO"}
SET Stat3 = {Picture[] "C:\KRC\TP\UserTech\UserTechResources\Bild31.ICO"}
ENDSCRIPT
Defscript SKB2
Showvar(FULLPATH[] "2", PARAM BildNr )
SET Stat1 = {Picture[] "C:\KRC\TP\UserTech\UserTechResources\Bild12.ICO"}
SET Stat2 = {Picture[] "C:\KRC\TP\UserTech\UserTechResources\Bild22.ICO"}
SET Stat3 = {Picture[] "C:\KRC\TP\UserTech\UserTechResources\Bild32.ICO"}
ENDSCRIPT
Defscript CHGSTatkey
SWITCH "%BildNr"
Case "1" do SKB2
Case "2" do SKB1
ENDSWITCH
ENDSCRIPT
Set Stat1 = {Picture[] "C:\KRC\TP\UserTech\UserTechResources\Bild11.ICO", onkeydown ST1}
Set Stat2 = {Picture[] "C:\KRC\TP\UserTech\UserTechResources\Bild21.ICO", onkeydown ST2}
Set Stat3 = {Picture[] "C:\KRC\TP\UserTech\UserTechResources\Bild31.ICO", onkeydown ST3}
Set Stat4 = {Picture[] "C:\KRC\TP\UserTech\UserTechResources\Bild41.ICO", onkeydown CHGStatkey}
Decl StatKeyBar Test = {STATKEY[1] STAT1,STATKEY[2] STAT2,STATKEY[3] STAT3,STATKEY[4] STAT4}
ENDTP
2、工艺集成于 KUKA smartHMI
SmartHMI.User.Config 中调用TestStat.kfd文件中定义的StatkeyTest
直接在SmartHMI.User.Config 插入红色框标记部分就可以了,然后关机,以“重新读入文件”重新启动控制器就可以了。
<?xml version="1.0"?>
<configuration>
<!--Menu -->
<KukaRoboter.SmartHMI.Menu type="KukaRoboter.SmartHMI.UIFramework.Menu.MenuRootImpl,SmartHMI">
<MenuRoot SystemName="CommandMenu">
<MenuFolder DisplayName="MenuBar#CmdUserTech" MergeOrder="1100">
<MenuFolder DisplayName="MenuBar#CmdMyTech" MergeOrder="100">
<MenuItem DisplayName="MenuBar#CmdMyCmd" MergeOrder="100">
<CommandCall Target="LegacyLoader.InvokeModuleProc">
<Argument Name="PlugInName">INLINEFORM</Argument> <Argument Name="ProcID">2011</Argument>
<Argument Name="ParamList">KUKATPUSER;MyTech;MyCmd</Argument>
</CommandCall>
</MenuItem>
</MenuFolder>
</MenuFolder>
</MenuRoot>
<!-- Demo to implement a UserTech StatusKeyBar-->
<MenuRoot SystemName="MainMenu">
<MenuFolder DisplayName="MenuBar#ConfigStatKeys" MergeOrder="210">
<MenuItem DisplayName="MenuBar#UserTStatKeys">
<CommandCall Target="LegacyLoader.InvokeModuleProc">
<Argument Name="PlugInName">USERSTATKEYBAROCX</Argument>
<Argument Name="ProcID">11</Argument>
<Argument Name="ParamList">KUKATPUSER;StatkeyTest.Test</Argument>
</CommandCall>
</MenuItem>
</MenuFolder>
</MenuRoot>
<!-- Demo to implement a UserTech LOL-->
<MenuRoot SystemName="MainMenu">
<MenuFolder DisplayName="MenuBar#Config">
<MenuFolder DisplayName="MenuBar#ConfigStatKeys" MergeOrder="210">
<MenuItem DisplayName="MenuBar#LOL">
<CommandCall Target="LegacyLoader.InvokeModuleProc">
<Argument Name="PlugInName">USERSTATKEYBAROCX</Argument>
<Argument Name="ProcID">11</Argument>
<Argument Name="ParamList">KUKATPUSER;LOL.TEST</Argument>
</CommandCall>
</MenuItem>
</MenuFolder>
</MenuFolder>
</MenuRoot>
</KukaRoboter.SmartHMI.Menu>