SHOW:
|
|
- or go back to the newest paste.
| 1 | -- Made by FoxWorn3365 | |
| 2 | term.setBackgroundColor(colors.white) | |
| 3 | term.clear() | |
| 4 | ||
| 5 | -- Sistemo le funzioni | |
| 6 | function header(lol) | |
| 7 | term.setBackgroundColor(colors.lightBlue) | |
| 8 | term.setTextColor(colors.white) | |
| 9 | term.setCursorPos(16, 1) | |
| 10 | print(lol) | |
| 11 | end | |
| 12 | ||
| 13 | function button(x, y, text, color) | |
| 14 | term.setBackgroundColor(colors[color]) | |
| 15 | term.setTextColor(colors.white) | |
| 16 | term.setCursorPos(x, y) | |
| 17 | print(text) | |
| 18 | end | |
| 19 | ||
| 20 | function sotText(x, y, tex, col, bkcol) | |
| 21 | term.setBackgroundColor(colors[bkcol]) | |
| 22 | term.setTextColor(colors[col]) | |
| 23 | term.setCursorPos(x, y) | |
| 24 | print(tex) | |
| 25 | term.setBackgroundColor(colors.white) | |
| 26 | end | |
| 27 | ||
| 28 | function ntext(x, y, text, col) | |
| 29 | term.setBackgroundColor(colors.white) | |
| 30 | term.setTextColor(colors[col]) | |
| 31 | term.setCursorPos(x, y) | |
| 32 | print(text) | |
| 33 | end | |
| 34 | ||
| 35 | function n(ca) | |
| 36 | term.setBackgroundColor(colors.white) | |
| 37 | term.setTextColor(colors[ca]) | |
| 38 | end | |
| 39 | ||
| 40 | function reactorSend(id, msg) | |
| 41 | rednet.send(id, msg) | |
| 42 | end | |
| 43 | ||
| 44 | function allarme(nun) | |
| 45 | if nun == 1 then | |
| 46 | sotText(5, 14, "! TEMPERATURA REATTORE SUPERIORE DI 1000C", "white", "red") | |
| 47 | n("blue")
| |
| 48 | elseif nun == 2 then | |
| 49 | sotText(5, 15, "! TEMPERATURA REATTORE SUPERIORE DI 8500C", "white", "red") | |
| 50 | n("blue")
| |
| 51 | elseif nun == 3 then | |
| 52 | sotText(5, 16, "! TEMPERATURA REATTORE SUPERIORE DI 5000C OFF", "white", "yellow") | |
| 53 | n("blue")
| |
| 54 | elseif nun == 4 then | |
| 55 | sotText(5, 17, "! TEMPERATURA REATTORE SUPERIORE DI 5000C", "white", "orange") | |
| 56 | n("blue")
| |
| 57 | elseif nun == 5 then | |
| 58 | sotText(5, 18, "! OUTPUT INFERIORE A 250kW", "white", "green") | |
| 59 | n("blue")
| |
| 60 | end | |
| 61 | end | |
| 62 | ||
| 63 | -- Immeto i dati per configurare | |
| 64 | id = 14 | |
| 65 | reactorName = "Reattore01" | |
| 66 | ||
| 67 | -- Sistemo qualche variabile d'ambiente | |
| 68 | alarmHeat0 = true | |
| 69 | alarmHeat1 = true | |
| 70 | alarmHeat2 = true | |
| 71 | alarmOutput = true | |
| 72 | ||
| 73 | -- Inizio il programma | |
| 74 | - | while true do -- Il while servir�A0 per tenere sempre aggiornati i dati |
| 74 | + | while true do -- Il while servir�A0 per tenere sempre aggiornati i dati |
| 75 | -- Recupero i dati del reattore | |
| 76 | term.clear() | |
| 77 | p = peripheral.wrap("bottom")
| |
| 78 | local a, b, c, t = p.get(1) | |
| 79 | ||
| 80 | heat = t.heat | |
| 81 | status = t.reactorPoweredB | |
| 82 | mheat = t.maxHeat | |
| 83 | output = t.output | |
| 84 | ||
| 85 | -- Elaboro alcune informazioni | |
| 86 | if status == true then | |
| 87 | statusColor = "green" | |
| 88 | statusText = "ATTIVO" | |
| 89 | else | |
| 90 | statusColor = "red" | |
| 91 | statusText = "DISATTIVO" | |
| 92 | end | |
| 93 | ||
| 94 | if heat <= 1000 then | |
| 95 | heatColor = "green" | |
| 96 | alarmHeat0 = false | |
| 97 | alarmHeat1 = false | |
| 98 | alarmHeat2 = false | |
| 99 | elseif heat > 1000 and heat < 5000 then | |
| 100 | heatColor = "yellow" | |
| 101 | alarmHeat0 = true | |
| 102 | elseif heat > 5000 and heat < 8500 then | |
| 103 | heatColor = "orange" | |
| 104 | alarmHeat1 = true | |
| 105 | elseif heat > 8500 then | |
| 106 | alarmHeat2 = true | |
| 107 | heatColor = "red" | |
| 108 | end | |
| 109 | ||
| 110 | if output <= 250 then | |
| 111 | outputColor = "orange" | |
| 112 | elseif output >= 251 and output <= 500 then | |
| 113 | outputColor = "yellow" | |
| 114 | else | |
| 115 | outputColor = "green" | |
| 116 | end | |
| 117 | ||
| 118 | if heat > 5000 and status == false then | |
| 119 | alarmStatus = true | |
| 120 | else | |
| 121 | alarmStatus = false | |
| 122 | end | |
| 123 | ||
| 124 | if output < 250 then | |
| 125 | alarmOutput = true | |
| 126 | else | |
| 127 | alarmOutput = false | |
| 128 | end | |
| 129 | ||
| 130 | -- Inizio l'interfaccia utente | |
| 131 | header("GESTIONE REATTORE")
| |
| 132 | n("black")
| |
| 133 | print("\nBenvenuto nel pannello di gestione del reattore "..reactorName)
| |
| 134 | print("\n---------------------------------------")
| |
| 135 | n("blue")
| |
| 136 | print("\nStato Reattore:")
| |
| 137 | ntext(17, 8, statusText, statusColor) | |
| 138 | n("blue")
| |
| 139 | print("Temperatura:")
| |
| 140 | ntext(14, 9, heat, heatColor) | |
| 141 | ntext(20, 9, " / "..mheat, "black") | |
| 142 | print("Output:")
| |
| 143 | ntext(9, 10, output.."kW", outputColor) | |
| 144 | ||
| 145 | n("blue")
| |
| 146 | ntext(5, 12, "ALLARMI", "red") | |
| 147 | if alarmHeat0 == true then | |
| 148 | allarme(1) | |
| 149 | end | |
| 150 | ||
| 151 | if alarmHeat1 == true then | |
| 152 | allarme(2) | |
| 153 | end | |
| 154 | ||
| 155 | if alarmHeat2 == true then | |
| 156 | allarme(3) | |
| 157 | end | |
| 158 | ||
| 159 | if alarmStatus == true then | |
| 160 | allarme(4) | |
| 161 | end | |
| 162 | ||
| 163 | if alarmOutput == true then | |
| 164 | allarme(5) | |
| 165 | term.setBackgroundColor(colors.white) | |
| 166 | end | |
| 167 | ||
| 168 | n("blue")
| |
| 169 | sleep(1) | |
| 170 | end | |
| 171 |