lego11

OK-300 Reactor Control

May 28th, 2021 (edited)
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. s = peripheral.wrap("bottom")
  2.  
  3. max_power = 2400
  4. max_flux = 2250
  5. max_thermal = 2320
  6.  
  7.  
  8. function clear()
  9. term.clear()
  10. term.setCursorPos(1,1)
  11. end
  12.  
  13. while true do
  14. u, f, d, t1 = s.get(1)
  15. u, f, d, t2 = s.get(2)
  16.  
  17. current_power = t2.average
  18. neutron_flux = math.floor((current_power/flux)*100)
  19. thermal_power = math.floor((current_power/max_flux)*100)
  20.  
  21. if thermal_power == 0 then
  22. thermal_power = 1.25
  23. end
  24.  
  25. loop1_flow = math.random(18100, 18250)/10
  26. condenser_flow = math.random(18100, 18250)/10
  27.  
  28. sea_in_temp = 13.3
  29. sea_out_temp = math.floor(13.40 + (current_power/1000))
  30.  
  31. voltage = math.floor(385-(current_power/1000))
  32.  
  33. if t1.reactorPoweredB == true then
  34. loop1_in = math.random(2982, 3002)/10
  35. loop1_out = math.random(3352, 3367)/10
  36. steam_generator = math.random(3331, 3363)/10
  37. condenser = math.random(569, 577)/10
  38. turbine = math.random(2436, 2477)/10
  39. turbine_speed = 3000
  40. frequency = 50.0
  41. condenser_vacuum = math.random(85, 91)
  42. else
  43. loop1_in = math.random(1982, 1992)/10
  44. loop1_out = math.random(1352, 1367)/10
  45. steam_generator = math.random(931, 963)/10
  46. condenser = math.random(369, 377)/10
  47. turbine = math.random(336, 2477)/10
  48. turbine_speed = 0
  49. condenser_vacuum = 0
  50. voltage = 0
  51. frequency = 0
  52. end
  53.  
  54. cosphi = math.random(89,92)/100
  55.  
  56. current = math.floor(current_power/voltage)
  57.  
  58. clear()
  59. ---------------------------------------------------
  60. print(" Reactor system \"OK-300\"\n")
  61. print("Neutron Flux: "..neutron_flux .. " % ")
  62. print("Thermal Power: "..thermal_power .. " % ")
  63. print("Electric Power: "..current_power .. " kW")
  64. print("Turbine speed: "..turbine_speed .. " rpm")
  65. print("")
  66. print("Loop 1 Flow: "..loop1_flow)
  67. print("Loop 1 Input: "..loop1_in .. " 'C")
  68. print("Loop 1 Output: "..loop1_out.. " 'C")
  69. print("")
  70. print("Sea input: "..sea_in_temp .. " 'C")
  71.  
  72. term.setCursorPos(27, 3)
  73. term.write("Voltage: "..voltage.." V")
  74. term.setCursorPos(27, 4)
  75. term.write("Current: "..current.." kA")
  76. term.setCursorPos(27, 5)
  77. term.write("Frequency: "..frequency.." Hz")
  78. term.setCursorPos(27, 6)
  79. term.write("Cos.phi: "..cosphi)
  80.  
  81. term.setCursorPos(27, 8)
  82. term.write("Steam generator: " ..steam_generator .. " 'C")
  83. term.setCursorPos(27, 9)
  84. term.write("Condenser: " ..condenser .. " 'C")
  85. term.setCursorPos(27, 10)
  86. term.write("Condenser vac.: " .. condenser_vacuum .. " mmHg")
  87. term.setCursorPos(27, 12)
  88. term.write("Sea output: " .. sea_out_temp .. " 'C")
  89.  
  90. if voltage == 0 then
  91. term.setCursorPos(1, 19)
  92. term.setBackgroundColour(colors.red)
  93. term.write(" REACTOR SCRAM !!! REACTOR SCRAM ")
  94. term.setBackgroundColor(colors.black)
  95. end
  96. sleep(1)
  97. end
  98.  
  99.  
Add Comment
Please, Sign In to add comment