工控编程吧
标题:
威纶通过宏实现弹出小窗口操作相同数据
[打印本页]
作者:
qq263946146
时间:
2022-2-4 21:11
标题:
威纶通过宏实现弹出小窗口操作相同数据
例程效果如图。
(, 下载次数: 5)
上传
点击文件名下载附件
点击不同的电磁阀会弹出一个相同的小窗口,
在小窗口上点击对应按钮可以控制当前选中电磁阀的开与关。
功能小巧,为一网友想实现的功能,让我有偿编写参考。
功能可以通过不同控件配合实现。
当前例程使用三个宏完成,内容如下
macro_command main()
short PopupWindowIndex=11
SetData(PopupWindowIndex, "Local HMI", LW, 0, 1)//弹出开关窗口
bool a=false
SetData(a, "Local HMI", LB, 1000, 1)//此宏触发状态复位
end macro_command
复制代码
macro_command main()
bool bBitActivate[16]={0}
GetData(bBitActivate[0], "Local HMI", LB, 0, 16)//获取全部电磁阀开关状态
short valveChoosed=0
GetData(valveChoosed, "Local HMI", LW, 1, 1)//指示哪个电磁阀被选中
if(1==valveChoosed) then
bBitActivate[0]=true
else if(2==valveChoosed) then
bBitActivate[1]=true
else if(3==valveChoosed) then
bBitActivate[2]=true
else if(4==valveChoosed) then
bBitActivate[3]=true
else if(5==valveChoosed) then
bBitActivate[4]=true
else if(6==valveChoosed) then
bBitActivate[5]=true
else if(7==valveChoosed) then
bBitActivate[6]=true
else if(8==valveChoosed) then
bBitActivate[7]=true
else if(9==valveChoosed) then
bBitActivate[8]=true
else if(10==valveChoosed) then
bBitActivate[9]=true
else if(11==valveChoosed) then
bBitActivate[10]=true
else if(12==valveChoosed) then
bBitActivate[11]=true
else if(13==valveChoosed) then
bBitActivate[12]=true
else if(14==valveChoosed) then
bBitActivate[13]=true
else if(15==valveChoosed) then
bBitActivate[14]=true
else if(16==valveChoosed) then
bBitActivate[15]=true
end if
SetData(bBitActivate[0], "Local HMI", LB, 0, 16)//执行开关
end macro_command
复制代码
macro_command main()
bool bBitActivate[16]={0}
GetData(bBitActivate[0], "Local HMI", LB, 0, 16)//获取全部电磁阀开关状态
short valveChoosed=0
GetData(valveChoosed, "Local HMI", LW, 1, 1)//指示哪个电磁阀被选中
if(1==valveChoosed) then
bBitActivate[0]=false
else if(2==valveChoosed) then
bBitActivate[1]=false
else if(3==valveChoosed) then
bBitActivate[2]=false
else if(4==valveChoosed) then
bBitActivate[3]=false
else if(5==valveChoosed) then
bBitActivate[4]=false
else if(6==valveChoosed) then
bBitActivate[5]=false
else if(7==valveChoosed) then
bBitActivate[6]=false
else if(8==valveChoosed) then
bBitActivate[7]=false
else if(9==valveChoosed) then
bBitActivate[8]=false
else if(10==valveChoosed) then
bBitActivate[9]=false
else if(11==valveChoosed) then
bBitActivate[10]=false
else if(12==valveChoosed) then
bBitActivate[11]=false
else if(13==valveChoosed) then
bBitActivate[12]=false
else if(14==valveChoosed) then
bBitActivate[13]=false
else if(15==valveChoosed) then
bBitActivate[14]=false
else if(16==valveChoosed) then
bBitActivate[15]=false
end if
SetData(bBitActivate[0], "Local HMI", LB, 0, 16)//执行开关
end macro_command
复制代码
具体可以下载例程模拟查看效果。
(, 下载次数: 1)
上传
点击文件名下载附件
欢迎光临 工控编程吧 (https://www.gkbc8.com/)
Powered by Discuz! X3.4