首页 威纶通(we. 正文

回复

威纶通宏指令控制红绿灯显示

威纶通(weinview)HMI 浏览:2275 回复:9 收藏

hz118  2021-12-24 14:30


macro_command main()

int i=1,j=0,k=0

int a=0

int t=0,t2=0,t3=0,t4=0

int t1=0,t0=0

int t9=0,d=0,h=0,m=0,s=0

GetData(t9, "Local HMI", LW, 60, 1)

GetData(s, "Local HMI", LW, 100, 1)//红绿灯运行时间秒

GetData(m, "Local HMI", LW, 90, 1)//红绿灯运行时间分

GetData(h, "Local HMI", LW, 80, 1)//红绿灯运行时间时

GetData(d, "Local HMI", LW, 70, 1)//红绿灯运行时间日

t9=t9+1

m=t9/60

s=t9%60

h=m/60

m=m%60

d=h/24

h=h%24

SetData(s, "Local HMI", LW, 100, 1)

SetData(m, "Local HMI", LW, 90, 1)

SetData(h, "Local HMI", LW, 80, 1)

SetData(d, "Local HMI", LW, 70, 1)

SetData(t9, "Local HMI", LW, 60, 1)


GetData(t, "Local HMI", LW, 20, 1)

GetData(t0, "Local HMI", LW, 50, 1)


t=t+1//红绿灯运行一个周期时间39秒

SetData(t, "Local HMI", LW, 20, 1)


if 0<t and t<20 then

t0=t0+1//为方便减计时增加t0

SetData(t0, "Local HMI", LW, 50, 1)

GetData(t1, "Local HMI", LW, 30, 1)

t1=19-t0

SetData(t1, "Local HMI", LW, 30, 1)

//红灯1亮计时显示

if t0==19 then

t0=0

SetData(t0, "Local HMI", LW, 50, 1)

end if


SetData(i, "Local HMI", LW, 0, 1)

else

SetData(j, "Local HMI", LW, 0, 1)

end if//红灯1亮19秒


if 0<t and t<16 then

GetData(t2, "Local HMI", LW, 26, 1)

t2=15-t0

SetData(t2, "Local HMI", LW, 26, 1)

//绿灯1亮计时显示


SetData(i, "Local HMI", LW, 8, 1)

else

SetData(j, "Local HMI", LW, 8, 1)

end if//绿灯1亮15秒


if 15<t and t<20 then

SetData(i, "Local HMI", LB, 10, 1)

else

SetData(j, "Local HMI", LB, 10, 1)

end if//黄灯1闪烁


if 19<t and t<40 then

GetData(t3, "Local HMI", LW, 24, 1)

t3=39-t

SetData(t3, "Local HMI", LW, 24, 1)

//红灯2亮计时显示


SetData(i, "Local HMI", LW, 6, 1)

else

SetData(j, "Local HMI", LW, 6, 1)

end if//红灯2亮19秒


if 19<t and t<36 then

GetData(t4, "Local HMI", LW, 22, 1)

t4=35-t

SetData(t4, "Local HMI", LW, 22, 1)

//绿灯2亮计时显示


SetData(i, "Local HMI", LW, 2, 1)

else

SetData(j, "Local HMI", LW, 2, 1)

end if//绿灯2亮15秒


if 35<t and t<40 then

SetData(i, "Local HMI", LB, 4, 1)

else

SetData(j, "Local HMI", LB, 4, 1)

end if//黄灯2闪烁

if t==39 then

t=0

SetData(t, "Local HMI", LW, 20, 1)

end if

end macro_command


image.png


正在下载,请等待……
下载附件需 1 积分!

我知道了