demoss

pannel2

May 4th, 2022
833
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.18 KB | None | 0 0
  1. btn1="SET,0,INPUT0,STEP,1,2,10."
  2. btn2="SET,0,INPUT0,STEP,3,3,10."
  3. btn3="SET,0,INPUT0,STEP,4,5,10."
  4. btn4="SET,0,INPUT0,STEP,6,6,10."
  5. btn5="SET,0,INPUT0,STEP,7,7,10."
  6. btn6="SET,0,INPUT0,STEP,8,8,10."
  7. btn7="SET,0,OUTPUT0,STEP,6,6,20."
  8. btn8="SET,0,OUTPUT0,STEP,7,7,20."
  9. btn9="SET,0,INPUT0,STEP,1,2,-10."
  10. btn10="SET,0,INPUT0,STEP,3,3,-10."
  11. btn11="SET,0,INPUT0,STEP,4,5,-10."
  12. btn12="SET,0,INPUT0,STEP,6,6,-10."
  13. btn13="SET,0,INPUT0,STEP,7,7,-10."
  14. btn14="SET,0,INPUT0,STEP,8,8,-10."
  15. btn15="SET,0,OUTPUT0,STEP,6,6,-20."
  16. btn16="SET,0,OUTPUT0,STEP,7,7,-20."
  17. btn17="SET,0,INPUT0,MUTE,1,2,1."
  18. btn18="SET,0,INPUT0,MUTE,3,3,1."
  19. btn19="SET,0,INPUT0,MUTE,4,5,1."
  20. btn20="SET,0,INPUT0,MUTE,6,6,1."
  21. btn21="SET,0,INPUT0,MUTE,7,7,1."
  22. btn22="SET,0,INPUT0,MUTE,8,8,1."
  23. btn23="SET,0,OUTPUT0,MUTE,6,6,1."
  24. btn24="SET,0,OUTPUT0,MUTE,7,7,1."
  25. btn25="SET,0,INPUT0,MUTE,1,8,1."
  26. btn25_="SET,0,OUTPUT0,MUTE,1,8,1."
  27.  
  28. btn17_1="SET,0,INPUT0,MUTE,1,2,0."
  29. btn18_1="SET,0,INPUT0,MUTE,3,3,0."
  30. btn19_1="SET,0,INPUT0,MUTE,4,5,0."
  31. btn20_1="SET,0,INPUT0,MUTE,6,6,0."
  32. btn21_1="SET,0,INPUT0,MUTE,7,7,0."
  33. btn22_1="SET,0,INPUT0,MUTE,8,8,0."
  34. btn23_1="SET,0,OUTPUT0,MUTE,6,6,0."
  35. btn24_1="SET,0,OUTPUT0,MUTE,7,7,0."
  36. btn25_1="SET,0,INPUT0,MUTE,1,8,0."
  37. btn25_2="SET,0,OUTPUT0,MUTE,1,8,0."
  38. btn26="SET,0,PRESET,ID,0,0,1."
  39.  
  40. request_in ="GET,0,INPUT0,MUTE,1,8,0."
  41. request_out ="GET,0,OUTPUT0,MUTE,1,8,0."
  42.  
  43.  
  44. --[[function net_send(msg)
  45.   local tmp = {}
  46.   for i = 1, #msg do
  47.     tmp[i-1] = msg[i]
  48.   end
  49.   client_send_data(tmp)
  50. end--]]
  51.  
  52.  
  53. inmut = {0, 0, 0, 0, 0, 0, 0, 0}
  54. outmut = {0, 0, 0, 0, 0, 0, 0, 0}
  55.  
  56. local wificom = 0
  57.             local mode = 1
  58.             local server_port = '5557'
  59.             local server_ip = '10.0.255.186'       
  60.             local dhcp    = 0
  61.             local ipaddr  = '10.0.255.123'
  62.             local netmask = '255.255.255.0'
  63.             local gateway = '10.0.255.1'
  64.             local dns     = '10.0.255.1'   
  65. function on_init() 
  66. start_timer(1, 1000, 1, 0)
  67.             set_network_cfg(dhcp, ipaddr, netmask, gateway, dns)
  68.             --set_network_service_cfg(wificom, mode, server_port, server_ip)
  69.             save_network_cfg() 
  70.         sockfd=udp_create(12345)
  71. end
  72.  
  73. function on_timer(timer_id)
  74. if timer_id ==1 then
  75. byte_cmd(request_in)
  76. byte_cmd(request_out)
  77. rcudp(sockfd)
  78. if inmut[1] == 1 and inmut[2] == 1 then set_value(0,17,1) end
  79. if inmut[1] == 0 and inmut[2] == 0 then set_value(0,17,0) end
  80. if inmut[3] == 1 then set_value(0,18,1) end
  81. if inmut[3] == 0 then set_value(0,18,0) end
  82. if inmut[4] == 1 and inmut[5] == 1 then set_value(0,19,1) end
  83. if inmut[4] == 0 and inmut[5] == 0 then set_value(0,19,0) end
  84. if inmut[6] == 1 then set_value(0,20,1) end
  85. if inmut[6] == 0 then set_value(0,20,0) end
  86. if inmut[7] == 1 then set_value(0,21,1) end
  87. if inmut[7] == 0 then set_value(0,21,0) end
  88. if inmut[8] == 1 then set_value(0,22,1) end
  89. if inmut[8] == 0 then set_value(0,22,0) end
  90. if outmut[6] == 1 then set_value(0,23,1) end
  91. if outmut[7] == 0 then set_value(0,23,0) end
  92. if outmut[6] == 1 then set_value(0,24,1) end
  93. if outmut[7] == 0 then set_value(0,24,0) end
  94. end
  95. end
  96.  
  97. function on_control_notify(screen,control,value)
  98. if screen == 0 then
  99. if control >0 and control <=16 and value==1 then
  100. byte_cmd(_G["btn".. tostring(control)])
  101. end
  102. if control >16 and control < 25 and value==1 then
  103.  
  104. byte_cmd(_G["btn".. tostring(control)])
  105. end
  106. if control >16 and control < 25 and value==0 then
  107. byte_cmd(_G["btn".. tostring(control).. '_1'])
  108. end
  109. if control ==26 and value==1 then
  110. byte_cmd(btn26)
  111. end
  112. if control ==25 and value==1 then
  113. byte_cmd(btn25)
  114. byte_cmd(btn25_)
  115. end
  116. if control ==25 and value==0 then
  117. byte_cmd(btn25_1)
  118. byte_cmd(btn25_2)
  119. end
  120. end
  121. end
  122.  
  123. function byte_cmd (cmd)
  124. local cmd_loc = {}
  125. for i = 1, cmd:len() do
  126.   cmd_loc[i-1] = cmd:byte(i)
  127. end
  128. udp_sendto(sockfd, server_ip, server_port, cmd_loc)
  129. end
  130.  
  131. function rcudp(sockfd)
  132.   local ret,ip,port,packet = udp_recvfrom(sockfd)
  133.   local packet_str = ""
  134.  
  135.   for _, ch in ipairs(packet) do
  136.     packet_str = packet_str .. string.char(ch)  
  137.   end
  138.  
  139.   local _,_,i,j,v = packet_str:find("INPUT0,MUTE,(%d+),(%d+),(%d+)")
  140.   local _,_,s,t,r = packet_str:find("OUTPUT0,MUTE,(%d+),(%d+),(%d+)")
  141.  
  142.   if i == j and i ~= nil then
  143.     inmut[tonumber(i)] = tonumber(v)
  144.   end
  145.     if s == t and s ~= nil then
  146.     outmut[tonumber(s)] = tonumber(r)
  147.   end
  148. end
Advertisement
Add Comment
Please, Sign In to add comment