威纶通官方论坛

请教按钮互锁用宏指令怎么做

[复制链接]
发表于 2024-3-19 10:16:05 | 显示全部楼层 |阅读模式
各位:请教下,我现在触摸屏上20个按钮,还有一个总按钮

1,按下总按钮,1#--20#按钮复位
2,1#--20#按钮只要有一个按钮按下,总按钮就复位
  

我现在做的,第一点可以做到,但是做的第二点的时候,不行,只要总按钮是ON的状态,1#--20#无法长时间按下,帮忙看看哪里问题吧?






macro_command main()

bool b=1,c=0,quanxuan,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21,a22,a23,a24,a25,a26,a27,a28,a29,a30


GetData(quanxuan, "Local HMI", LB, 400, 1)

if quanxuan==1 then


SetData(c, "Local HMI", LB, 301, 1)
SetData(c, "Local HMI", LB, 302, 1)
SetData(c, "Local HMI", LB, 303, 1)
SetData(c, "Local HMI", LB, 304, 1)
SetData(c, "Local HMI", LB, 305, 1)
SetData(c, "Local HMI", LB, 306, 1)
SetData(c, "Local HMI", LB, 307, 1)
SetData(c, "Local HMI", LB, 308, 1)
SetData(c, "Local HMI", LB, 309, 1)
SetData(c, "Local HMI", LB, 310, 1)
SetData(c, "Local HMI", LB, 311, 1)
SetData(c, "Local HMI", LB, 312, 1)
SetData(c, "Local HMI", LB, 313, 1)
SetData(c, "Local HMI", LB, 314, 1)
SetData(c, "Local HMI", LB, 315, 1)
SetData(c, "Local HMI", LB, 316, 1)
SetData(c, "Local HMI", LB, 317, 1)
SetData(c, "Local HMI", LB, 318, 1)
SetData(c, "Local HMI", LB, 319, 1)
SetData(c, "Local HMI", LB, 320, 1)

end if

以上是按下总按钮后1#--20#按钮全部复位,这个是OK了

但是以下的,不行呢,哪里问题啊


GetData(a11, "Local HMI", LB, 301, 1)
GetData(a12, "Local HMI", LB, 302, 1)
GetData(a13, "Local HMI", LB, 303, 1)
GetData(a14, "Local HMI", LB, 304, 1)
GetData(a15, "Local HMI", LB, 305, 1)
GetData(a16, "Local HMI", LB, 306, 1)
GetData(a17, "Local HMI", LB, 307, 1)
GetData(a18, "Local HMI", LB, 308, 1)
GetData(a19, "Local HMI", LB, 309, 1)
GetData(a20, "Local HMI", LB, 310, 1)
GetData(a21, "Local HMI", LB, 311, 1)
GetData(a22, "Local HMI", LB, 312, 1)
GetData(a23, "Local HMI", LB, 313, 1)
GetData(a24, "Local HMI", LB, 314, 1)
GetData(a25, "Local HMI", LB, 315, 1)
GetData(a26, "Local HMI", LB, 316, 1)
GetData(a27, "Local HMI", LB, 317, 1)
GetData(a28, "Local HMI", LB, 318, 1)
GetData(a29, "Local HMI", LB, 319, 1)
GetData(a30, "Local HMI", LB, 320, 1)

if a11==1 or a12==1 or a13==1 or a14==1 or a15==1 or a16==1 or a17==1 or a18==1 or a19==1 or a20==1 or a21==1 or a22==1 or a23==1 or a24==1 or a25==1 or a26==1 or a27==1 or a28==1 or a29==1 or a30==1 then


SetData(c, "Local HMI", LB, 400, 1)

end if




end macro_command



因为在我的总按钮按下之后,宏指令就一直执行前的程序了,导致我的1#--20#按钮一按下就会复位。


 楼主| 发表于 2024-3-19 10:36:34 | 显示全部楼层
可以了,把这两个做成两个宏,不要做成周期触发,做成按钮按下触发,每个按钮都触发,就可以了
发表于 2024-3-19 11:46:05 | 显示全部楼层
根据你的要求 ,想了一个多小时,确实很难
威纶通按钮之间互锁和复位_哔哩哔哩_bilibili
https://www.bilibili.com/video/BV1L6421F7PT/
 楼主| 发表于 2024-3-19 13:57:49 | 显示全部楼层
谢谢,搞定了,不用这么麻烦的
发表于 2024-5-28 08:36:14 | 显示全部楼层
单个按钮按下调用
SetData(c, "Local HMI", LB, 400, 1)
就可以了
您需要登录后才可以发帖 登录 | 注册

本版积分规则

回复帖子

Archiver|小黑屋|威纶通官网 ( 粤ICP备06054553号 )

GMT+8, 2024-11-21 17:54

Powered by Discuz! X3.4

© 2001-2023 Comsenz Inc.

快速回复 返回顶部 返回列表