Advertisement
pitrey

security

Nov 17th, 2019
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.01 KB | None | 0 0
  1. red = colors.red
  2. yellow = colors.yellow
  3. green = colors.green
  4. black = colors.black
  5. white = colors.white
  6. orange = colors.orange
  7. blue = colors.blue
  8.  
  9. modemW = peripheral.wrap('right')--wifi
  10. modemW.open(61)
  11. moni = peripheral.wrap("monitor_10") --securité
  12. moni.setBackgroundColor(black)
  13. moni.setTextScale(1)
  14. moni12 = peripheral.wrap("monitor_12") -- enté
  15. moni12.setBackgroundColor(black)
  16. moni12.setTextScale(4)
  17. moni11 = peripheral.wrap("monitor_11") -- hub
  18. moni11.setBackgroundColor(black)
  19. moni11.setTextScale(4)
  20. etat_energy,etat_lux,etat_porte,etat_securite = false,false,false,false
  21.  
  22. moni.setTextScale(1)
  23. chan = 61
  24.  
  25. sto = fs.open("DEFCON", "r")
  26. DEFCON = tonumber(sto.readLine())
  27. sto.close()
  28.  
  29. lux = fs.open("lux","r")
  30. etat_lux = lux.readLine()
  31. lux.close()
  32.  
  33. function recevoir()
  34.  
  35. e, s, frequency, reply, m, d = os.pullEvent()
  36.  
  37. if e == "modem_message" then
  38. if frequency == 61 then
  39. if reply == 62 then
  40. etat_porte = m
  41. elseif reply == 63 then
  42. etat_lux = m
  43. elseif reply == 64 then
  44. etat_energy = m
  45. elseif reply == 65 then
  46. etat_securite = m
  47. elseif reply == 66 then
  48. DEFCON = m
  49. elseif reply == 67 then
  50. --cube2Max = m
  51. elseif reply == 68 then
  52. --mfeMax = m
  53. elseif reply == 69 then
  54. --mfe2Max = m
  55. end
  56.  
  57. end
  58. end
  59. if e == "monitor_touch" and s == "monitor_10" then
  60. compare(frequency,reply)
  61. end
  62. end
  63.  
  64. function compare(x,y)
  65. if x >= 2 and x <= #etat_porte+2 and y == 4 then
  66. if DEFCON == 4
  67. DEFCON = 1
  68. else
  69. DEFCON = DEFCON +1
  70. end
  71. h = fs.open("DEFCON", "w")
  72. h.write(DEFCON)
  73. h.close()
  74. end
  75. if x >= 2 and x <= #etat_lux+2 and y == 7 then
  76. if etat_lux == "full" then
  77. etat_lux = "restrein"
  78. elseif etat_lux == "restrein" then
  79. etat_lux = "black out"
  80. elseif etat_lux == "black out" then
  81. etat_lux = "full"
  82. end
  83. end
  84. end
  85.  
  86. function emet()
  87. while true do
  88. modemW.transmit(61,66,DEFCON)
  89. modemW.transmit(61,63,etat_lux)
  90. sleep(20)
  91. end
  92. end
  93.  
  94. function titre (x,y,titre,c)
  95. moni.setTextColor(c)
  96. moni.setCursorPos(x,y)
  97. moni.write (titre)
  98. end
  99.  
  100.  
  101. function barre (x,y,pourcent,col)
  102. moni.setCursorPos(x,y)
  103. I = pourcent /10
  104. for i =1,I do
  105. moni.setBackgroundColor(col)
  106. moni.write(" ")
  107. end
  108. moni.setBackgroundColor(black)
  109. end
  110.  
  111. function defcon (mon,DEFCON)
  112. mon.clear()
  113. o = 1
  114. for i = 1,5 do
  115. mon.setTextColor(white)
  116. mon.setCursorPos(1,i)
  117. if i == DEFCON then
  118. if DEFCON == 5 then
  119. def = blue
  120. elseif DEFCON == 4 then def = green
  121. elseif DEFCON == 3 then def = yellow
  122. elseif DEFCON == 2 then def = red
  123. elseif DEFCON == 1 then
  124. def = white
  125. mon.setTextColor(black)
  126. end
  127. mon.setBackgroundColor(def)
  128. mon.write("D")
  129. mon.write(o)
  130. mon.setBackgroundColor(black)
  131. mon.setTextColor(white)
  132. else
  133. mon.write("D")
  134. mon.write(o)
  135. end
  136. o = o +1
  137. end
  138. mon.setBackgroundColor(black)
  139. end
  140.  
  141. while true do
  142. moni.clear()
  143.  
  144. if DEFCON == 1 then etat_porte = " Acces refusé"
  145. elseif DEFCON == 2 then etat_porte = " Acces restrein"
  146. elseif DEFCON == 3 then etat_porte = " Acces surveillé"
  147. elseif DEFCON == 4 then etat_porte = " Acces libre"
  148. end
  149.  
  150. defcon (moni12,DEFCON)
  151. defcon (moni11,DEFCON)
  152.  
  153. titre(10,1,"The security",yellow)
  154.  
  155. titre (2,3,"acces principal :",yellow)
  156. moni.setCursorPos(2,4)
  157. if etat_porte == false then
  158. moni.setTextColor(red)
  159. moni.write(" Offline")
  160. elseif etat_porte == " Acces libre" or etat_porte == " Acces surveillé" then
  161. moni.setTextColor(green)
  162. moni.write(etat_porte)
  163. else
  164. moni.setTextColor(orange)
  165. moni.write(etat_porte)
  166. end
  167.  
  168. titre(2,6,"éclairage :",yellow)
  169. moni.setCursorPos(2,7)
  170. if etat_lux == false then
  171. moni.setTextColor(red)
  172. moni.write(" Offline")
  173. elseif etat_lux == "full"
  174. moni.setTextColor(green)
  175. moni.write(etat_porte)
  176. elseif etat_lux == "restrein"
  177. moni.setTextColor(orange)
  178. moni.write(etat_porte)
  179. elseif etat_lux == "black out"
  180. moni.setTextColor(red)
  181. moni.write(etat_porte)
  182. end
  183.  
  184. titre(2,9,"energy HUB :",yellow)
  185. if etat_lux == false then
  186. moni.setTextColor(red)
  187. moni.write(" Offline") end
  188.  
  189. titre(2,11,"securité HUB :",yellow)
  190. if etat_securite == false then
  191. moni.setTextColor(red)
  192. moni.write(" Offline") end
  193.  
  194.  
  195.  
  196. parallel.waitForAny(recevoir, emet)
  197.  
  198.  
  199. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement