Advertisement
On_The_Edge

Vertikale Füllstandsanzeige real Data V5

Feb 24th, 2021 (edited)
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Komponenten --
  2. event.ignoreAll()
  3. gpu1 = computer.getGPUs(1)[1]
  4. Screen = component.proxy("7380B37A465C2D5B7C1E5FA98EADB15E")
  5. Tank1 = component.proxy("27982CDC4CD4B0C3C4B874A848A7A007")
  6. Tank2 = component.proxy("5A8736A345158E9700D710BDF83AB387")
  7. Tank3 = component.proxy("6681E56349AD7FABB0E07B8A69148B2A")
  8. Tank4 = component.proxy("7082385B48C55BF5B1E64E94D30BD8BF")
  9. Tank5 = component.proxy("F102D89B4394932DF65DA2BCA05323A5")
  10. Tank6 = component.proxy("5B8B130D496D10FF3B486596D99BF3DF")
  11. Tank7 = component.proxy("6347B26B42EA2FBA38232BBB58B7EA30")
  12. Tank8 = component.proxy("9BA0A46E414F3B1F722789898807FF32")
  13. Tank9 = component.proxy("9CA14D0D412674B09226569E0864E5E1")
  14. Tank10 = component.proxy("EE90BD0248789F7897BD07BE730693A8")
  15. Tank11 = component.proxy("BA3F48844C6CCA90D53AF995FC630383")
  16. Tank12 = component.proxy("52C78C1D4D8657F2BD241C8F632C283E")
  17. Tank13 = component.proxy("117A436640B42B5BCEB4C9B8D067E1CA")
  18.  
  19.  
  20. gpu1:bindScreen(Screen)
  21. gpu1:setsize(100,20)
  22. gpu1:setForeground(1,1,1,1)
  23. gpu1:setBackground(0,0,0,0)
  24.  
  25. -- OPTION --
  26. -- Tank1:flush()
  27. -- Tank2:flush()
  28.  
  29. -- DATEN --
  30. z = 0 -- Zeilenreset
  31. o = 5 -- oberes ende
  32. u = o+13 -- unteres ende
  33. T = 13 -- Anzahl der Tanks
  34. h = {}
  35. p = {}
  36.  
  37. function getdata()
  38.  
  39. VS = {}
  40. VS = {Tank1.fluidcontent, Tank2.fluidcontent, Tank3.fluidcontent, Tank4.fluidcontent, Tank5.fluidcontent, Tank6.fluidcontent, Tank7.fluidcontent, Tank8.fluidcontent, Tank9.fluidcontent, Tank10.fluidcontent, Tank11.fluidcontent, Tank12.fluidcontent, Tank13.fluidcontent}
  41.  
  42. xv = 1 -- Datensatz Start 1
  43. T = 13 -- Anzahl der Tanks
  44.  
  45. for i = 1,T,1 do -- Daten schreiben
  46. VS[xv] = math.floor(VS[xv]) -- runden --
  47. if VS[xv] > 2400 then VS[xv] = 2400
  48. end
  49. xv = xv +1
  50. end
  51.  
  52. hx = 1 -- Start h = 1
  53. for i = 1,T,1 do -- Prozente für Balken ausrechnen
  54. h[hx] = VS[hx]
  55. p[hx] = math.floor((100/2400)*h[hx]/10)
  56. -- print ((h[hx]), (p[hx]))
  57. hx = hx + 1
  58. end
  59. end
  60.  
  61. -- AUSGABE --
  62. function stream()
  63. gpu1:fill(0,0,100,20," ")
  64.  
  65. x = 5 -- x Spalte für Anzeigen vom linken Rand
  66.  
  67. -- Display Titel --
  68. gpu1:setText(5,1,"S U P E R C O M P U T E R // F U E L  T A N K S")
  69. gpu1:SetBackground(60,60,60,0.3)
  70. gpu1:fill(5,2,47,1," ")
  71.  
  72. function Zahlenformat() -- Anzeige der Zahl je nach Länge der Zahl
  73. if Z < 10 then Z = "   "..h[hx]
  74. return Z
  75. end
  76.  
  77. if Z < 100 then Z = "  "..h[hx]
  78. return Z
  79. end
  80.  
  81. if Z < 1000 then Z = " "..h[hx]
  82. return Z
  83. end
  84. end
  85.  
  86. -- Farbe der Balken festlegen --
  87. function Balkenfarbe()
  88. if Z < 400 then gpu1:setBackground(255,0,0,1)
  89. end
  90. if Z >= 400 and Z < 2000 then gpu1:setBackground(255,165,0,1)
  91. end
  92. if Z >= 2000 then gpu1:setBackground(0,255,0,1)
  93. end
  94. end
  95.  
  96.  
  97. -- Tanks --
  98. hx = 1  -- Datensatz 1 starten
  99.  
  100. for i = 1,T,1 do
  101. Z = h[hx]
  102. Balkenfarbe()
  103. Zahlenformat()
  104. if VS[hx] < 240 then p[hx] = 1
  105. end
  106. gpu1:fill(x+1,u-p[hx],2,p[hx]," ") -- Füllstand Balken zeichnen
  107. gpu1:setBackground(0,0,0,0)
  108. gpu1:setText(x,u,"----")
  109. gpu1:fill(x,o+3,1,10,"|")
  110. gpu1:fill(x+3,o+3,1,10,"|")
  111. gpu1:setText(x,o+2,"----")
  112. gpu1:setText(x,o+1,Z)
  113. gpu1:setText(x,o,"----")
  114. gpu1:setText(x,o-1," T"..hx)
  115.  
  116. x = x + 7 -- Abstand der Anzeigen zueinander
  117. hx = hx +1
  118. end
  119.  
  120.  
  121. gpu1:flush()
  122. end
  123.  
  124. -- RUN --
  125. while true do
  126. event.pull(2)
  127. getdata()
  128. stream()
  129. hx = 1
  130. Z = ""
  131. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement