Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Dies ist die erste Funktion, die bei Programmstart aufgeführt wird. Die darin aufgerufenen Funktionen initialisieren das Programm und alle notwendigen Variablen. Darüber hinaus werden alle Anzeigefenster erzeugt.
- ]]
- function programInitialize()
- systemStart()
- configTable = config.load()
- config.check()
- if debugLevel == 0 then
- handler(globalVariables)
- elseif debugLevel == 1 then
- globalVariables()
- end
- globalTables()
- windowCreate.foundation()
- windowCreate.interface()
- windowCreate.aboutAutor()
- windowCreate.optionMain()
- windowCreate.pageMain()
- windowCreate.pageRF()
- windowCreate.pageFuel()
- windowCreate.pageEfficiency()
- windowCreate.optionSetting()
- windowCreate.systemControl()
- reactorAutostart()
- end
- --[[
- In dieser Funktion wird der optische Start des Programms durchgeführt. Anzeigen auf dem Terminal und dem angeschlossenen Monitor erscheinen. Zudem wird hier die initialisierung der Peripherie eingeleitet.
- ]]
- function systemStart()
- peripheralInitialize()
- windowCreate.bootScreen()
- monitor.clear()
- display.bootScreen("PC fährt hoch...")
- term.clear()
- term.setTextColor(colors.white)
- term.setCursorPos(1,1)
- print("Reaktoranzeige Stavros V.: 1.1")
- print("Powered by PlatinKinggg")
- sleep(0.75)
- term.setTextColor(colors.red)
- print("Initialisiere")
- sleep(1)
- term.setTextColor(colors.white)
- print(".")
- sleep(0.5)
- print("..")
- sleep(0.5)
- print("...")
- sleep(0.5)
- term.setTextColor(colors.red)
- print("Suche nach Programmkonflikten startet jetzt")
- term.setTextColor(colors.green)
- print("Keine Initialisierungsfehler detektiert")
- print("Beginne mit Anzeige")
- sleep(0.5)
- term.clear()
- term.setTextColor(colors.white)
- term.setCursorPos(1,1)
- print("Reaktoranzeige Stavros V.: 1.1")
- print("Powered by PlatinKinggg")
- term.setTextColor(colors.red)
- print(" ")
- print("Drücke Entf um das System neuzustarten")
- term.setTextColor(colors.white)
- end
- --[[
- In dieser Funktion werden die Peripheriegeräte Reaktor, Monitor und Alaram hier initialisiert und mit einem Wrap versehen.
- ]]
- function peripheralInitialize()
- for key, value in pairs(peripheral.getNames()) do
- if peripheral.getType(value) == "BiggerReactors_Reactor" then
- reactor = peripheral.wrap(value)
- elseif peripheral.getType(value) == "monitor" then
- monitor = peripheral.wrap(value)
- elseif peripheral.getType(value) == "industrialAlarm" then
- alarm = peripheral.wrap(value)
- end
- end
- sleep(1)
- if reactor == nil then
- print("An das Netzwerk ist kein Reaktor angeschlossen")
- print("Programm wird gestoppt und der CC-Computer in 10 Sekunden neugestartet")
- sleep(10)
- os.reboot()
- elseif monitor == nil then
- print("An das Netzwerk ist kein Monitor angeschlossen")
- print("Programm wird gestoppt und der CC-Computer in 5 Minuten neugestartet")
- sleep(300)
- os.reboot()
- end
- monitorCheck()
- monitor.setBackgroundColor(colors.black)
- monitor.clear()
- end
- function monitorCheck()
- monitorWidth, monitorHeight = monitor.getSize()
- if monitorWidth < 39 then
- print("Bildschirm nicht Breit genug! Bitte den Monitor auf 4 Blöcke Breite erweitern")
- sleep(1)
- print("Programm wird gestoppt und der CC-Computer in 10 Sekunden neugestartet")
- sleep(10)
- os.reboot()
- elseif monitorHeight < 19 then
- print("Bildschirm nicht Hoch genug! Bitte den Monitor auf 3 Blöcke Breite erweitern")
- sleep(1)
- print("Programm wird gestoppt und der CC-Computer in 10 Sekunden neugestartet")
- sleep(10)
- os.reboot()
- end
- end
- function globalVariables()
- configTableText = {}
- configTableInfo = {}
- configTableInfo[1] = "Auswahl Programmsprache:"
- configTableText[1] = {"Deutsch", "Englisch"}
- if configTable[1] == 1 then
- --WIP: Table language <- Table Deutsch
- elseif configTable[1] == 2 then
- --WIP: Table language <- Table Englisch
- end
- configTableInfo[2] = "Reaktor startet bei Programmstart:"
- configTableText[2] = {"Aktiv", "Kein Autostart"}
- if configTable[2] == 1 then
- autostart = true
- else
- autostart = false
- end
- configTableInfo[3] = "Format Uhrzeitanzeige:"
- configTableText[3] = {"24 Stunden Anzeige ohne Uhr Suffix", "24 Stunden Anzeige mit Uhr Suffix", "AM/PM Zeit mit AM/PM Suffix", "AM/PM Zeit ohne AM/PM Suffix"}
- if configTable[3] == 1 then
- dayTime = os.date("%R") -- 24 Stunden Anzeige ohne "Uhr" Suffix
- elseif configTable[3] == 2 then
- dayTime = os.date("%R Uhr") -- 24 Stunden Anzeige mit "Uhr" Suffix
- elseif configTable[3] == 3 then
- dayTime = os.date("%I:%M") -- AM/PM Zeit ohne "AM/PM" Suffix
- elseif configTable[3] == 4 then
- dayTime = os.date("%I:%M %p") -- AM/PM Zeit mit "AM/PM" Suffix
- end
- configTableInfo[4] = "Format Datumsanzeige:"
- configTableText[4] = {"Datumsangabe Deutsch", "Datumsangabe Englisch I", "Datumsangabe Englisch II", "Datumsangabe Europäisch"}
- if configTable[4] == 1 then
- dateTime = os.date("%d.%m.%Y") -- Datumsangabe Deutsch
- elseif configTable[4] == 2 then
- dateTime = os.date("%d/%m/%Y") -- Datumsangabe Englisch I
- elseif configTable[4] == 3 then
- dateTime = os.date("%m/%d/%Y") -- Datumsangabe Englisch II
- elseif configTable[4] == 4 then
- dateTime = os.date("%Y/%m/%d") -- Datumsangabe Europäisch
- end
- configTableInfo[5] = "Startseite bei Programmstart:"
- configTableText[5] = {"Übersicht", "Energieproduktion", "Brennstoff-Info", "Brennstoff-Effizienz"}
- if page == nil then
- if configTable[5] == 1 then
- page = 1
- pageHeader = "Übersicht"
- elseif configTable[5] == 2 then
- page = 2
- pageHeader = "Energieproduktion"
- elseif configTable[5] == 3 then
- page = 3
- pageHeader = "Brennstoff-Info"
- elseif configTable[5] == 4 then
- page = 4
- pageHeader = "Brennstoff-Effizienz"
- end
- end
- for i = 6, 12, 1 do
- local variableName
- if configTable[i] == 1 then
- variableName = colors.white
- elseif configTable[i] == 2 then
- variableName = colors.orange
- elseif configTable[i] == 3 then
- variableName = colors.magenta
- elseif configTable[i] == 4 then
- variableName = colors.lightBlue
- elseif configTable[i] == 5 then
- variableName = colors.yellow
- elseif configTable[i] == 6 then
- variableName = colors.lime
- elseif configTable[i] == 7 then
- variableName = colors.pink
- elseif configTable[i] == 8 then
- variableName = colors.gray
- elseif configTable[i] == 9 then
- variableName = colors.lightGray
- elseif configTable[i] == 10 then
- variableName = colors.cyan
- elseif configTable[i] == 11 then
- variableName = colors.purple
- elseif configTable[i] == 12 then
- variableName = colors.blue
- elseif configTable[i] == 13 then
- variableName = colors.brown
- elseif configTable[i] == 14 then
- variableName = colors.green
- elseif configTable[i] == 15 then
- variableName = colors.red
- elseif configTable[i] == 16 then
- variableName = colors.black
- end
- if i == 6 then
- configTableInfo[i] = "Hintergrundfarbe Tastenleiste:"
- configTableText[i] = {"Weiß", "Orange", "Magenta", "Hellblau", "Gelb", "Limette", "Pink", "Grau", "HellGrau", "Cyan", "Lila", "Blau", "Braun", "Grün", "Rot", "Schwarz"}
- backgroundWindowBackgroundColor = variableName
- elseif i == 7 then
- configTableInfo[i] = "Hintergrundfarbe der Tasten:"
- configTableText[i] = {"Weiß", "Orange", "Magenta", "Hellblau", "Gelb", "Limette", "Pink", "Grau", "HellGrau", "Cyan", "Lila", "Blau", "Braun", "Grün", "Rot", "Schwarz"}
- buttonWindowBackgroundColor = variableName
- elseif i == 8 then
- configTableInfo[i] = "Schriftfarbe der Tasten:"
- configTableText[i] = {"Weiß", "Orange", "Magenta", "Hellblau", "Gelb", "Limette", "Pink", "Grau", "HellGrau", "Cyan", "Lila", "Blau", "Braun", "Grün", "Rot", "Schwarz"}
- buttonWindowTextColor = variableName
- elseif i == 9 then
- configTableInfo[i] = "Hintergrundfarbe der Header/Datum Anzeige:"
- configTableText[i] = {"Weiß", "Orange", "Magenta", "Hellblau", "Gelb", "Limette", "Pink", "Grau", "HellGrau", "Cyan", "Lila", "Blau", "Braun", "Grün", "Rot", "Schwarz"}
- textWindowBackgroundColor = variableName
- elseif i == 10 then
- configTableInfo[i] = "Schriftfarbe der Header/Datum Anzeige:"
- configTableText[i] = {"Weiß", "Orange", "Magenta", "Hellblau", "Gelb", "Limette", "Pink", "Grau", "HellGrau", "Cyan", "Lila", "Blau", "Braun", "Grün", "Rot", "Schwarz"}
- textWindowTextColor = variableName
- elseif i == 11 then
- configTableInfo[i] = "Hintergrundfarbe der Seite Übersicht:"
- configTableText[i] = {"Weiß", "Orange", "Magenta", "Hellblau", "Gelb", "Limette", "Pink", "Grau", "HellGrau", "Cyan", "Lila", "Blau", "Braun", "Grün", "Rot", "Schwarz"}
- paigeMainBackgroundColor = variableName
- elseif i == 12 then
- configTableInfo[i] = "Schriftfarbe der Seite Übersicht:"
- configTableText[i] = {"Weiß", "Orange", "Magenta", "Hellblau", "Gelb", "Limette", "Pink", "Grau", "HellGrau", "Cyan", "Lila", "Blau", "Braun", "Grün", "Rot", "Schwarz"}
- paigeMainTextColor = variableName
- end
- end
- if fuelburnedLastTick == nil then
- fuelburnedLastTick = {}
- end
- fuelburnedLastTickRaw = reactor.fuelTank().burnedLastTick()
- if fuelburnedLastTickRaw < 1 then
- fuelburnedLastTick[1] = string.format("%.3f", reactor.fuelTank().burnedLastTick())
- fuelburnedLastTick[2] = " mB/Tick"
- elseif fuelburnedLastTickRaw < 1000 then
- fuelburnedLastTick[1] = string.format("%.1f", reactor.fuelTank().burnedLastTick())
- fuelburnedLastTick[2] = " mB/Tick"
- elseif fuelburnedLastTickRaw < 1000000 then
- fuelburnedLastTick[1] = string.format("%.32f", (reactor.fuelTank().burnedLastTick() / 1000))
- fuelburnedLastTick[2] = " B/Tick"
- end
- if fuelAmount == nil then
- fuelAmount = {}
- end
- fuelAmountRaw = reactor.fuelTank().fuel()
- if fuelAmountRaw < 1000 then
- fuelAmount[1] = math.ceil(reactor.fuelTank().fuel())
- fuelAmount[2] = " mB"
- elseif fuelAmountRaw < 1000000 then
- fuelAmount[1] = math.ceil(reactor.fuelTank().fuel() / 1000)
- fuelAmount[2] = " B"
- elseif fuelAmountRaw < 1000000000 then
- fuelAmount[1] = math.ceil(reactor.fuelTank().fuel() / 1000000)
- fuelAmount[2] = " KB"
- end
- fuelTankCapacity = reactor.fuelTank().capacity()
- fuelAmountPercent = math.ceil((fuelAmountRaw / fuelTankCapacity) * 100)
- fuelTotalReactant = reactor.fuelTank().totalReactant()
- ejectWaste = reactor.fuelTank().ejectWaste
- fuelTankWaste = reactor.fuelTank().waste()
- fuelReactivity = reactor.fuelTank().fuelReactivity()
- reactorActive = reactor.active()
- ambietTemperature = reactor.ambientTemperature()
- connected = reactor.connected()
- setAllControlRodLevels = reactor.setAllControlRodLevels
- stackTemperature = reactor.stackTemperature()
- apiVersion = reactor.apiVersion
- setActive = reactor.setActive
- casingTemperature = reactor.casingTemperature()
- fuelTemperature = math.ceil(reactor.fuelTemperature())
- controlRodCount = reactor.controlRodCount()
- getControlRodLevel = reactor.getControlRod(0).level()
- if type(reactor.battery()) == "table" then
- activeCooling = false
- if storedRF == nil then
- storedRF = {}
- end
- storedRFRaw = reactor.battery().stored()
- if storedRFRaw >= 1000000000 then
- storedRF[1] = math.floor(storedRFRaw / 1000000000)
- storedRF[2] = " gRF"
- elseif storedRFRaw >= 1000000 then
- storedRF[1] = math.floor(storedRFRaw / 1000000)
- storedRF[2] = " mRF"
- elseif storedRFRaw >= 1000 then
- storedRF[1] = math.floor(storedRFRaw / 1000)
- storedRF[2] = " kRF"
- elseif storedRFRaw > 0 then
- storedRF[1] = math.floor(storedRFRaw)
- storedRF[2] = " RF"
- else
- storedRF[1] = 0
- storedRF[2] = " RF"
- end
- capacityRFRaw = reactor.battery().capacity()
- if capacityRF == nil then
- capacityRF = {}
- end
- if capacityRFRaw >= 1000000000 then
- capacityRF[1] = math.floor(capacityRFRaw / 1000000000)
- capacityRF[2] = " GRF"
- elseif capacityRFRaw >= 1000000 then
- capacityRF[1] = math.floor(capacityRFRaw / 1000000)
- capacityRF[2] = " MRF"
- elseif capacityRFRaw >= 1000 then
- capacityRF[1] = math.floor(capacityRFRaw / 1000)
- capacityRF[2] = " KRF"
- elseif capacityRFRaw > 0 then
- capacityRF[1] = math.floor(capacityRFRaw)
- capacityRF[2] = " RF"
- else
- capacityRF[1] = 0
- capacityRF[2] = " RF"
- end
- producedRFLastTickRaw = reactor.battery().producedLastTick()
- if producedRFLastTick == nil then
- producedRFLastTick = {}
- end
- if producedRFLastTickRaw >= 1000000000 then
- producedRFLastTick[1] = math.floor(producedRFLastTickRaw / 1000000000)
- producedRFLastTick[2] = " GRF/Tick"
- elseif producedRFLastTickRaw >= 1000000 then
- producedRFLastTick[1] = math.floor(producedRFLastTickRaw / 1000000)
- producedRFLastTick[2] = " MRF/Tick"
- elseif producedRFLastTickRaw >= 1000 then
- producedRFLastTick[1] = math.floor(producedRFLastTickRaw / 1000)
- producedRFLastTick[2] = " KRF/Tick"
- elseif producedRFLastTickRaw > 0 then
- producedRFLastTick[1] = math.floor(producedRFLastTickRaw)
- producedRFLastTick[2] = " RF/Tick"
- else
- producedRFLastTick[1] = 0
- producedRFLastTick[2] = " RF/Tick"
- end
- passivEfficiencyRaw = math.floor((producedRFLastTickRaw / fuelburnedLastTickRaw))
- if passivEfficiency == nil then
- passivEfficiency = {}
- end
- if passivEfficiencyRaw >= 1000000 then
- passivEfficiency[1] = math.floor(passivEfficiencyRaw / 1000000)
- passivEfficiency[2] = " MRF/Tick/mB"
- elseif passivEfficiencyRaw >= 1000 then
- passivEfficiency[1] = math.floor(passivEfficiencyRaw / 1000)
- passivEfficiency[2] = " KRF/Tick/mB"
- elseif passivEfficiencyRaw > 0 then
- passivEfficiency[1] = math.floor(passivEfficiencyRaw)
- passivEfficiency[2] = " RF/Tick/mB"
- else
- passivEfficiency[1] = 0
- passivEfficiency[2] = " RF/Tick/mB"
- end
- else
- activeCooling = true
- coolantTankMaxTransitionedLastTick = reactor.coolantTank().maxTransitionedLastTick()
- coolantTankTransitionedLastTick = reactor.coolantTank().transitionedLastTick()
- coolantTankCapacity = reactor.coolantTank().capacity()
- HotFluidAmount = reactor.coolantTank().hotFluidAmount()
- ColdFluidAmount = reactor.coolantTank().coldFluidAmount()
- coolantTankDump = reactor.coolantTank().dump
- activEfficiency = math.floor(coolantTankTransitionedLastTick / R.fuelburnedLastTick)
- end
- if controlRodSteeringTimer == nil then
- controlRodSteeringTimer = 0
- end
- if storedRFOld == nil then
- storedRFOld = 0
- end
- if fuelTemperatureOld == nil then
- fuelTemperatureOld = 0
- end
- fuelTemperatureSweetSpot = 1273
- if currentOptionPage == nil then
- currentOptionPage = 1
- end
- --[[
- Mit diesem Abschnitt wird die RF Produktion der letzten 5 Minuten aufgezeichnet. Hierzu wird eine Table angelegt und jede Sekunde die aktuelle Energieproduktion darin hinterlegt und zusammengerechnet.
- ]]
- if rfProducedHistory == nil then
- rfProducedHistory = {producedRFLastTickRaw * 20}
- end
- if table.getn(rfProducedHistory) < 300 then
- table.insert(rfProducedHistory, (producedRFLastTickRaw * 20))
- else
- table.remove(rfProducedHistory, 1)
- table.insert(rfProducedHistory, (producedRFLastTickRaw * 20))
- end
- rfProducedHistoryTotal = 0
- for key, value in ipairs(rfProducedHistory) do
- rfProducedHistoryTotal = rfProducedHistoryTotal + value
- end
- if rfProducedHistorySum == nil then
- rfProducedHistorySum = {}
- end
- if rfProducedHistoryTotal >= 1000000000 then
- rfProducedHistorySum[1] = string.format("%.2f", rfProducedHistoryTotal / 1000000000)
- rfProducedHistorySum[2] = " GRF"
- elseif rfProducedHistoryTotal >= 1000000 then
- rfProducedHistorySum[1] = string.format("%.2f", rfProducedHistoryTotal/ 1000000)
- rfProducedHistorySum[2] = " MRF"
- elseif rfProducedHistoryTotal >= 1000 then
- rfProducedHistorySum[1] = string.format("%.2f", rfProducedHistoryTotal/ 1000)
- rfProducedHistorySum[2] = " KRF"
- elseif rfProducedHistoryTotal > 0 then
- rfProducedHistorySum[1] = string.format("%.2f", rfProducedHistoryTotal)
- rfProducedHistorySum[2] = " RF"
- else
- rfProducedHistorySum[1] = 0
- rfProducedHistorySum[2] = " RF"
- end
- --[[
- Mit diesem Abschnitt wird der Brennstoffverbrauch der letzten 5 Minuten aufgezeichnet. Hierzu wird eine Table angelegt und jede Sekunde die aktuellen Verbrauchswerte darin hinterlegt und zusammengerechnet.
- ]]
- fuelburnedLastTickOld= fuelburnedLastTickRaw
- if fuelBurnedHistory == nil then
- fuelBurnedHistory = {fuelburnedLastTickRaw}
- end
- if table.getn(fuelBurnedHistory) < 300 then
- table.insert(fuelBurnedHistory, (fuelburnedLastTickRaw * 20))
- else
- table.remove(fuelBurnedHistory, 1)
- table.insert(fuelBurnedHistory, (fuelburnedLastTickRaw * 20))
- end
- fuelBurnedHistoryTotal = 0
- for key, value in ipairs(fuelBurnedHistory) do
- fuelBurnedHistoryTotal = fuelBurnedHistoryTotal + value
- end
- if fuelBurnedHistorySum == nil then
- fuelBurnedHistorySum = {}
- end
- if fuelBurnedHistoryTotal < 1 then
- fuelBurnedHistorySum[1] = string.format("%.3f", fuelBurnedHistoryTotal)
- fuelBurnedHistorySum[2] = " mB"
- elseif fuelBurnedHistoryTotal < 1000 then
- fuelBurnedHistorySum[1] = string.format("%.1f", fuelBurnedHistoryTotal)
- fuelBurnedHistorySum[2] = " mB"
- elseif fuelBurnedHistoryTotal < 1000000 then
- fuelBurnedHistorySum[1] = string.format("%.2f", (fuelBurnedHistoryTotal / 1000))
- fuelBurnedHistorySum[2] = " B"
- else
- fuelBurnedHistorySum[1] = string.format("%.3f", (fuelBurnedHistoryTotal / 1000000))
- fuelBurnedHistorySum[2] = " KB"
- end
- end
- --[[
- In dieser Funktion werden die globalen Tables für verschiedene Zwecke initialisiert. Da die Werte in den Tables statisch sind, ist diese Funktion gesondert definiert und nicht in der globalVariables-Funktion eingebettet.
- ]]
- function globalTables()
- --SystemControlText[currentSettingsPage][settingsWindow][text]
- SystemControlText = { { {}, {}, {}, {} }, { {}, {}, {}, {} }, { {}, {}, {}, {} } }
- SystemControlText[1][1][1] = "Über den Autor"
- SystemControlText[1][1][2] = "dieses Programms"
- SystemControlText[1][2][1] = "test"
- SystemControlText[1][2][2] = "test"
- SystemControlText[1][3][1] = "test"
- SystemControlText[1][3][2] = "test"
- SystemControlText[1][4][1] = "test"
- SystemControlText[1][4][2] = "test"
- SystemControlText[2][1][1] = "Reaktor"
- SystemControlText[2][1][2] = "Runterfahren"
- SystemControlText[2][1][3] = "Hochfahren"
- SystemControlText[2][2][1] = "Steuerstäbe"
- SystemControlText[2][2][2] = "Zurücksetzen"
- SystemControlText[2][3][1] = "Manuelle"
- SystemControlText[2][3][2] = "Abfallentleerung"
- SystemControlText[2][4][1] = "Reaktorsteuerung"
- SystemControlText[2][4][2] = "Neustarten"
- aboutAutorText = {}
- aboutAutorText[1] = "Über das Programm: Stavros - Reaktosteuerung"
- aboutAutorText[2] = " "
- aboutAutorText[3] = "Vielen Dank für die Nutzung meines Programms :)"
- aboutAutorText[4] = "Mein Name ist Domenic Halking aka PlatinKinggg und"
- aboutAutorText[5] = "die Reaktorsteuerung über ein selbstgeschriebenes"
- aboutAutorText[6] = "Programm, hat mich schon seit Jahren interessiert."
- aboutAutorText[7] = "Deshalb habe ich mit dem Programmieren angefangen."
- aboutAutorText[8] = "Ich hoffe, das Ergebnis hier stellt Dich"
- aboutAutorText[9] = "zufrieden und hilft Dir, deinen Reaktor gut im"
- aboutAutorText[10] = "Auge zu behalten."
- aboutAutorText[11] = "Falls dir das Programm gefällt, würde ich mich"
- aboutAutorText[12] = "über ein Spende per PayPal freuen. Vielen Dank"
- aboutAutorText[13] = " "
- aboutAutorText[14] = "https://paypal.me/DHalking"
- end
- function alarmTrigger()
- if fuelAmountRaw < (fuelTankCapacity / 4) then
- rs.setOutput("top", true)
- else
- rs.setOutput("top", false)
- end
- end
- function controlRodSteering()
- controlMethod = 2
- if controlMethod == 1 then
- if storedRFRaw <= (capacityRFRaw * 0.01) then
- setAllControlRodLevels(getControlRodLevel - 25)
- elseif storedRFRaw >= (capacityRFRaw * 0.99) then
- setAllControlRodLevels(getControlRodLevel + 25)
- elseif storedRFRaw > storedRFOld then
- if storedRFRaw >= (capacityRFRaw * 0.90) then
- setAllControlRodLevels(getControlRodLevel + 9)
- elseif storedRFRaw >= (capacityRFRaw * 0.80) then
- setAllControlRodLevels(getControlRodLevel + 7)
- elseif storedRFRaw >= (capacityRFRaw * 0.7) then
- setAllControlRodLevels(getControlRodLevel + 5)
- elseif storedRFRaw >= (capacityRFRaw * 0.6) or storedRFRaw >= (storedRFOld * 1.03) then
- setAllControlRodLevels(getControlRodLevel + 3)
- else
- setAllControlRodLevels(getControlRodLevel + 1)
- end
- elseif storedRFRaw < storedRFOld then
- if storedRFRaw <= (capacityRFRaw * 0.1) then
- setAllControlRodLevels(getControlRodLevel - 9)
- elseif storedRFRaw <= (capacityRFRaw * 0.2) then
- setAllControlRodLevels(getControlRodLevel - 7)
- elseif storedRFRaw <= (capacityRFRaw * 0.3) then
- setAllControlRodLevels(getControlRodLevel - 5)
- elseif storedRFRaw <= (capacityRFRaw * 0.4) or storedRFRaw <= (storedRFOld * 0.97) then
- setAllControlRodLevels(getControlRodLevel - 3)
- else
- setAllControlRodLevels(getControlRodLevel - 1)
- end
- end
- elseif controlMethod == 2 then
- if fuelTemperature > 2000 then
- setAllControlRodLevels(getControlRodLevel + 9)
- elseif fuelTemperature > (fuelTemperatureSweetSpot * 1.4) then
- setAllControlRodLevels(getControlRodLevel + 7)
- elseif fuelTemperature > (fuelTemperatureSweetSpot * 1.3) then
- setAllControlRodLevels(getControlRodLevel + 5)
- elseif fuelTemperature > (fuelTemperatureSweetSpot * 1.2) then
- setAllControlRodLevels(getControlRodLevel + 3)
- elseif fuelTemperature > fuelTemperatureSweetSpot then
- setAllControlRodLevels(getControlRodLevel + 1)
- elseif fuelTemperature < (fuelTemperatureSweetSpot * 0.2) then
- setAllControlRodLevels(getControlRodLevel - 9)
- elseif fuelTemperature < (fuelTemperatureSweetSpot * 0.4) then
- setAllControlRodLevels(getControlRodLevel - 7)
- elseif fuelTemperature < (fuelTemperatureSweetSpot * 0.6) then
- setAllControlRodLevels(getControlRodLevel - 5)
- elseif fuelTemperature < (fuelTemperatureSweetSpot * 0.8) then
- setAllControlRodLevels(getControlRodLevel - 3)
- elseif fuelTemperature < fuelTemperatureSweetSpot then
- setAllControlRodLevels(getControlRodLevel - 1)
- end
- end
- fuelTemperatureOld = fuelTemperature
- storedRFOld = storedRFRaw
- controlRodSteeringTimer = 0
- end
- function deleteProgram()
- fs.delete("startUp")
- fs.delete("Reaktoranzeige")
- fs.delete("Programmkonfiguration")
- fs.delete("ReadMeVariables")
- end
- config = {
- save = (function()
- local configFile = io.open("Programmkonfiguration", "w")
- configFile:write(textutils.serialise(configTable))
- configFile:close()
- end),
- load = (function()
- if fs.exists("Programmkonfiguration") == false then
- print(" ")
- term.setTextColor(colors.yellow)
- print("Keine Programmkonfigurations-Datei gefunden. Lege Datei nun an.")
- term.setTextColor(colors.white)
- print(" ")
- configTable = config.restore()
- end
- local configFile = io.open("Programmkonfiguration", "r")
- local configSerialse = configFile:read("a")
- configFile:close()
- configTable = textutils.unserialise(configSerialse)
- return configTable
- end),
- check = (function()
- if type(configTable) ~= "table" then
- configTable = config.restore()
- else
- local configTableLength = 0
- for _ in pairs(configTable) do
- configTableLength = configTableLength + 1
- end
- if configTableLength ~= 12 then
- term.setTextColor(colors.red)
- print("Fehler in der Länge der Programmkonfiguration...")
- term.setTextColor(colors.white)
- configTable = config.restore()
- elseif configTable[1] < 1 or configTable[1] > 2 then -- Sprache
- term.setTextColor(colors.red)
- print("Fehler in der Zeitanzeige Einstellung...")
- term.setTextColor(colors.white)
- configTable = config.restore()
- elseif configTable[2] < 1 or configTable[2] > 2 then -- Auto-Einschalten
- term.setTextColor(colors.red)
- print("Fehler in der Zeitanzeige Einstellung...")
- term.setTextColor(colors.white)
- configTable = config.restore()
- elseif configTable[3] < 1 or configTable[3] > 4 then -- Uhrzeit
- term.setTextColor(colors.red)
- print("Fehler in der Zeitanzeige Einstellung...")
- term.setTextColor(colors.white)
- configTable = config.restore()
- elseif configTable[4] < 1 or configTable[4] > 4 then -- Datum
- term.setTextColor(colors.red)
- print("Fehler in der Datumsanzeige Einstellung...")
- term.setTextColor(colors.white)
- configTable = config.restore()
- elseif configTable[5] < 1 or configTable[5] > 5 then -- Startseite
- term.setTextColor(colors.red)
- print("Fehler in der Startseiten Einstellung")
- term.setTextColor(colors.white)
- configTable = config.restore()
- elseif configTable[6] < 1 or configTable[6] > 16 then -- StartseiteHintergrundfarbe buttonWindows
- term.setTextColor(colors.red)
- print("Fehler in der Einstellung zur Tasten-Hintergrundfarbe...")
- term.setTextColor(colors.white)
- configTable = config.restore()
- elseif configTable[7] < 1 or configTable[7] > 16 then -- Schriftfarbe buttonWindows
- term.setTextColor(colors.red)
- print("Fehler in der Einstellung zur Tasten-Schriftfarbe...")
- term.setTextColor(colors.white)
- configTable = config.restore()
- elseif configTable[8] < 1 or configTable[8] > 16 then -- Hintergrundfarbe textWindows
- term.setTextColor(colors.red)
- print("Fehler in der Einstellung zur Textanzeige-Hintergrundfarbe...")
- term.setTextColor(colors.white)
- configTable = config.restore()
- elseif configTable[9] < 1 or configTable[9] > 16 then -- Schriftfarbe textWindows
- term.setTextColor(colors.red)
- print("Fehler in der Einstellung zur Textanzeige-Schriftfarbe...")
- term.setTextColor(colors.white)
- configTable = config.restore()
- elseif configTable[10] < 1 or configTable[10] > 16 then -- Hintergrundfarbe buttonWindowBackgroundColor
- term.setTextColor(colors.red)
- print("Fehler in der Hintergrundfarbe der Tastenleiste...")
- term.setTextColor(colors.white)
- configTable = config.restore()
- elseif configTable[11] < 1 or configTable[11] > 16 then -- Hintergrundfarbe Übersicht
- term.setTextColor(colors.red)
- print("Fehler in der Hintergrundfarbe der Seite Übersicht...")
- term.setTextColor(colors.white)
- configTable = config.restore()
- elseif configTable[12] < 1 or configTable[12] > 16 then -- Schriftfarbe Übersicht
- term.setTextColor(colors.red)
- print("Fehler in der Schriftfarbe der Seite Übersicht...")
- term.setTextColor(colors.white)
- configTable = config.restore()
- end
- end
- end),
- restore = (function()
- configTable = {1, 1, 1, 1, 1, 16, 2, 16, 13, 16, 16, 1}
- -- ConfigTable Werte: Sprache, Auto-Einschalten, Zeit, Datum, Buttonfenster Farbe, Buttonfenster Textfarbe, Textfenster Textfarbe, Textfenster Textfarbe, Hintergrundfarbe Übersicht, Schriftfarbe Übersicht
- local configFile = io.open("Programmkonfiguration", "w")
- configFile:write(textutils.serialise(configTable))
- configFile:close()
- term.setTextColor(colors.red)
- print("Die Standardeinstellungen werden nun geladen!")
- term.setTextColor(colors.white)
- return configTable
- end)
- }
- function writeTextToWindow(windowName, windowLength, windowHeight, backgroundColor, textColor, text1, text1SetOffX, text1SetOffY, text2, text2SetOffX, text2SetOffY)
- if text2 == true then
- text2 = "Aktiv"
- elseif text2 == false then
- text2 = "Inaktiv"
- end
- windowName.setBackgroundColor(backgroundColor)
- windowName.setTextColor(textColor)
- windowName.clear()
- local textLength1 = string.len(text1)
- local drawPositionX1
- local drawPositionY1
- if text2 then
- local textLength2 = string.len(text2)
- local drawPositionX2
- local drawPositionY2
- if text1SetOffX == "left" then
- drawPositionX1 = 2
- else
- drawPositionX1 = (math.floor((windowLength - textLength1) / 2) + text1SetOffX)
- end
- if text2SetOffX == "left" then
- drawPositionX2 = 2
- else
- drawPositionX2 = (math.ceil((windowLength - textLength2) / 2) + text2SetOffX)
- end
- if text1SetOffY == "split" then
- drawPositionY1 = 2
- drawPositionY2 = windowHeight
- elseif windowHeight <= 3 then
- drawPositionY1 = 1
- drawPositionY2 = 2
- elseif windowHeight == 4 then
- drawPositionY1 = 2
- drawPositionY2 = 3
- else
- if math.fmod(windowHeight / 2, 2) == 0 then
- drawPositionY1 = (windowHeight / 2) - 1 + text1SetOffY
- drawPositionY2 = drawPositionY1 + 2 + text2SetOffY
- else
- drawPositionY1 = (math.floor(windowHeight / 2)) + text1SetOffY
- drawPositionY2 = drawPositionY1 + 2 + text2SetOffY
- end
- end
- windowName.setCursorPos(drawPositionX2 , drawPositionY2)
- windowName.write(text2)
- windowName.setCursorPos(drawPositionX1 , drawPositionY1)
- windowName.write(text1)
- else
- if text1SetOffX == "left" then
- drawPositionX1 = 2
- else
- drawPositionX1 = (math.floor((windowLength - textLength1) / 2) + text1SetOffX)
- end
- if math.fmod(windowHeight / 2, 2) == 0 then
- drawPositionY1 = (windowHeight / 2) + text1SetOffY
- else
- drawPositionY1 = (math.ceil(windowHeight / 2)) + text1SetOffY
- end
- windowName.setCursorPos(drawPositionX1 , drawPositionY1)
- windowName.write(text1)
- end
- end
- windowCreate = {
- foundation = (function()
- backgroundButtonWindowInfo = {1, monitorHeight - 4, monitorWidth, 5}
- backgroundButtonWindow = window.create(monitor, backgroundButtonWindowInfo[1], backgroundButtonWindowInfo[2], backgroundButtonWindowInfo[3], backgroundButtonWindowInfo[4])
- foundationWindowInfo = {1, 6, monitorWidth, monitorHeight - 10}
- foundationWindow = window.create(monitor, foundationWindowInfo[1], foundationWindowInfo[2], foundationWindowInfo[3], foundationWindowInfo[4])
- usableWidth = foundationWindowInfo[3]
- usableWidthHalf = math.ceil(foundationWindowInfo[3] / 2)
- usableWidthHalfRest = foundationWindowInfo[3] - usableWidthHalf
- usableHeightFull = foundationWindowInfo[4]
- usableHeightHalf = math.ceil(foundationWindowInfo[4] / 2)
- usableHeightHalfRest = foundationWindowInfo[4] - usableHeightHalf
- usableHeight1 = math.ceil(foundationWindowInfo[4] / 4)
- usableHeight2 = math.ceil((foundationWindowInfo[4] - usableHeight1) / 3)
- usableHeight3 = math.ceil((foundationWindowInfo[4] - usableHeight1 - usableHeight2) / 2)
- usableHeight4 = foundationWindowInfo[4] - usableHeight1 - usableHeight2 - usableHeight3
- end),
- bootScreen = (function()
- bootWindowInfo = {}
- bootWindow = {}
- bootWindowInfo[1] = {1, 1, monitorWidth, monitorHeight}
- bootWindowInfo[2] = {3, 3, monitorWidth - 4, monitorHeight - 4}
- bootWindowInfo[3] = {4, 4, monitorWidth - 6, monitorHeight - 6}
- bootWindowInfo[4] = {5, 5, monitorWidth - 8, monitorHeight - 8}
- bootWindowInfo[5] = {6, 6, monitorWidth - 10, monitorHeight - 10}
- bootWindowInfo[6] = {7, 7, monitorWidth - 12, monitorHeight - 12}
- bootWindowInfo[7] = {8, 8, monitorWidth - 14, monitorHeight - 14}
- for i = 1, 7, 1 do
- bootWindow[i] = window.create(monitor, bootWindowInfo[i][1], bootWindowInfo[i][2], bootWindowInfo[i][3], bootWindowInfo[i][4])
- end
- end),
- aboutAutor = (function()
- aboutAutorWindowInfo = {1, 1, usableWidth, usableHeightFull + 5}
- aboutAutorWindow = window.create(monitor, aboutAutorWindowInfo[1], aboutAutorWindowInfo[2], aboutAutorWindowInfo[3], aboutAutorWindowInfo[4])
- end),
- interface = (function()
- leftButtonWindowInfo = {2, 2, 5, 3}
- leftButtonWindow = window.create(backgroundButtonWindow, leftButtonWindowInfo[1], leftButtonWindowInfo[2], leftButtonWindowInfo[3], leftButtonWindowInfo[4])
- rightButtonWindowInfo = {backgroundButtonWindowInfo[3] - 5, 2, 5, 3}
- rightButtonWindow = window.create(backgroundButtonWindow , rightButtonWindowInfo[1], rightButtonWindowInfo[2], rightButtonWindowInfo[3], rightButtonWindowInfo[4])
- if math.fmod(backgroundButtonWindowInfo[3], 2) == 0 then
- leftCenterButtonWindowInfo = {8, 2 ,(backgroundButtonWindowInfo[3] / 2) - 8, 3}
- leftCenterButtonWindow = window.create(backgroundButtonWindow, leftCenterButtonWindowInfo[1], leftCenterButtonWindowInfo[2], leftCenterButtonWindowInfo[3], leftCenterButtonWindowInfo[4])
- rightCenterButtonWindowInfo = {(backgroundButtonWindowInfo[3] / 2) + 2, 2,(backgroundButtonWindowInfo[3] / 2) - 8, 3}
- rightCenterButtonWindow = window.create(backgroundButtonWindow, rightCenterButtonWindowInfo[1], rightCenterButtonWindowInfo[2], rightCenterButtonWindowInfo[3], rightCenterButtonWindowInfo[4])
- else
- leftCenterButtonWindowInfo = {8, 2 ,math.floor(backgroundButtonWindowInfo[3] / 2) - 7, 3}
- leftCenterButtonWindow = window.create(backgroundButtonWindow, leftCenterButtonWindowInfo[1], leftCenterButtonWindowInfo[2], leftCenterButtonWindowInfo[3], leftCenterButtonWindowInfo[4])
- rightCenterButtonWindowInfo = {math.ceil(backgroundButtonWindowInfo[3] / 2) + 1, 2, math.floor(backgroundButtonWindowInfo[3] / 2) - 7, 3}
- rightCenterButtonWindow = window.create(backgroundButtonWindow, rightCenterButtonWindowInfo[1], rightCenterButtonWindowInfo[2], rightCenterButtonWindowInfo[3], rightCenterButtonWindowInfo[4])
- end
- optionButtonWindowInfo = {1, 1, 7, 5}
- optionButtonWindow = window.create(monitor, optionButtonWindowInfo[1], optionButtonWindowInfo[2], optionButtonWindowInfo[3], optionButtonWindowInfo[4])
- timeTextWindowInfo = {monitorWidth - 11, 1, 12, 5}
- timeTextWindow = window.create(monitor, timeTextWindowInfo[1], timeTextWindowInfo[2], timeTextWindowInfo[3], timeTextWindowInfo[4])
- headerTextWindowInfo = {optionButtonWindowInfo[3] + 1, 1, monitorWidth - optionButtonWindowInfo[3] - timeTextWindowInfo[3] , 5}
- headerTextWindow = window.create(monitor, headerTextWindowInfo[1], headerTextWindowInfo[2], headerTextWindowInfo[3], headerTextWindowInfo[4])
- end),
- optionMain = (function()
- optionMainWindowInfo = {}
- optionMainWindow = {}
- optionMainWindowInfo[1] = {1, 1, usableWidth, usableHeight1}
- optionMainWindowInfo[2] = {1, (1 + usableHeight1), usableWidth, usableHeight2}
- optionMainWindowInfo[3] = {1, (1 + usableHeight1 + usableHeight2), usableWidth, usableHeight3}
- optionMainWindowInfo[4] = {1, (1 + usableHeight1 + usableHeight2 + usableHeight3), usableWidth, usableHeight4}
- optionMainWindow[1] = window.create(foundationWindow, optionMainWindowInfo[1][1], optionMainWindowInfo[1][2], optionMainWindowInfo[1][3], optionMainWindowInfo[1][4])
- optionMainWindow[2] = window.create(foundationWindow, optionMainWindowInfo[2][1], optionMainWindowInfo[2][2], optionMainWindowInfo[2][3], optionMainWindowInfo[2][4])
- optionMainWindow[3] = window.create(foundationWindow, optionMainWindowInfo[3][1], optionMainWindowInfo[3][2], optionMainWindowInfo[3][3], optionMainWindowInfo[3][4])
- optionMainWindow[4] = window.create(foundationWindow, optionMainWindowInfo[4][1], optionMainWindowInfo[4][2], optionMainWindowInfo[4][3], optionMainWindowInfo[4][4])
- end),
- optionSetting = (function()
- optionSettingWindowInfo = {4, 3, usableWidth - 5, 7}
- optionSettingWindow = window.create(foundationWindow, optionSettingWindowInfo[1], optionSettingWindowInfo[2], optionSettingWindowInfo[3], optionSettingWindowInfo[4])
- end),
- systemControl = (function()
- systemControlWindowInfo = {}
- systemControlWindow = {}
- systemControlWindowInfo[1] = {1, 1, usableWidthHalf, usableHeightHalf}
- systemControlWindowInfo[2] = {1 + usableWidthHalf, 1, usableWidthHalfRest, usableHeightHalf}
- systemControlWindowInfo[3] = {1 , 1 + usableHeightHalf, usableWidthHalf, usableHeightHalfRest}
- systemControlWindowInfo[4] = {1 + usableWidthHalf, 1 + usableHeightHalf, usableWidthHalfRest, usableHeightHalfRest}
- systemControlWindow[1] = window.create(foundationWindow, systemControlWindowInfo[1][1], systemControlWindowInfo[1][2], systemControlWindowInfo[1][3], systemControlWindowInfo[1][4])
- systemControlWindow[2] = window.create(foundationWindow, systemControlWindowInfo[2][1], systemControlWindowInfo[2][2], systemControlWindowInfo[2][3], systemControlWindowInfo[2][4])
- systemControlWindow[3] = window.create(foundationWindow, systemControlWindowInfo[3][1], systemControlWindowInfo[3][2], systemControlWindowInfo[3][3], systemControlWindowInfo[3][4])
- systemControlWindow[4] = window.create(foundationWindow, systemControlWindowInfo[4][1], systemControlWindowInfo[4][2], systemControlWindowInfo[4][3], systemControlWindowInfo[4][4])
- end),
- pageMain = (function()
- paigeMainWindow1Info = {1, 1, usableWidthHalf, usableHeight1}
- paigeMainWindow2Info = {1 + usableWidthHalf, 1, usableWidthHalfRest, usableHeight1}
- paigeMainWindow3Info = {1, (1 + usableHeight1), usableWidthHalf, usableHeight2}
- paigeMainWindow4Info = {1 + usableWidthHalf, (1 + usableHeight1), usableWidthHalfRest, usableHeight2}
- paigeMainWindow5Info = {1, (1 + usableHeight1 + usableHeight2), usableWidthHalf, usableHeight3}
- paigeMainWindow6Info = {1 + usableWidthHalf, (1 + usableHeight1 + usableHeight2), usableWidthHalfRest, usableHeight3}
- paigeMainWindow7Info = {1, (1 + usableHeight1 + usableHeight2 + usableHeight3), usableWidthHalf, usableHeight4}
- paigeMainWindow8Info = {1 + usableWidthHalf, (1 + usableHeight1 + usableHeight2 + usableHeight3), usableWidthHalfRest, usableHeight4}
- paigeMainWindow1 = window.create(foundationWindow, paigeMainWindow1Info[1], paigeMainWindow1Info[2], paigeMainWindow1Info[3], paigeMainWindow1Info[4])
- paigeMainWindow2 = window.create(foundationWindow, paigeMainWindow2Info[1], paigeMainWindow2Info[2], paigeMainWindow2Info[3], paigeMainWindow2Info[4])
- paigeMainWindow3 = window.create(foundationWindow, paigeMainWindow3Info[1], paigeMainWindow3Info[2], paigeMainWindow3Info[3], paigeMainWindow3Info[4])
- paigeMainWindow4 = window.create(foundationWindow, paigeMainWindow4Info[1], paigeMainWindow4Info[2], paigeMainWindow4Info[3], paigeMainWindow4Info[4])
- paigeMainWindow5 = window.create(foundationWindow, paigeMainWindow5Info[1], paigeMainWindow5Info[2], paigeMainWindow5Info[3], paigeMainWindow5Info[4])
- paigeMainWindow6 = window.create(foundationWindow, paigeMainWindow6Info[1], paigeMainWindow6Info[2], paigeMainWindow6Info[3], paigeMainWindow6Info[4])
- paigeMainWindow7 = window.create(foundationWindow, paigeMainWindow7Info[1], paigeMainWindow7Info[2], paigeMainWindow7Info[3], paigeMainWindow7Info[4])
- paigeMainWindow8 = window.create(foundationWindow, paigeMainWindow8Info[1], paigeMainWindow8Info[2], paigeMainWindow8Info[3], paigeMainWindow8Info[4])
- end),
- pageRF = (function()
- pageRFWindowInfo = {}
- pageRFWindow = {}
- pageRFWindowInfo[1] = {1, 1, 11, usableHeightFull - 1}
- pageRFWindowInfo[2] = {5, 2, 3, usableHeightFull - 2}
- pageRFWindowInfo[3] = {6, usableHeightFull - (math.ceil((storedRFRaw / capacityRFRaw) * (usableHeightFull - 2))), 1, (math.ceil((storedRFRaw / capacityRFRaw) * (usableHeightFull - 2)))}
- pageRFWindowInfo[4] = {1, usableHeightFull, 11, 1}
- pageRFWindowInfo[5] = {12, 1, usableWidth - 11, math.ceil(usableHeightFull / 3)}
- pageRFWindowInfo[6] = {12, pageRFWindowInfo[5][4] + 1, usableWidth - 11, math.ceil((usableHeightFull - pageRFWindowInfo[5][4]) / 2)}
- pageRFWindowInfo[7] = {12, pageRFWindowInfo[5][4] + pageRFWindowInfo[6][4] + 1, usableWidth - 11, usableHeightFull - pageRFWindowInfo[5][4] - pageRFWindowInfo[6][4]}
- pageRFWindow[1] = window.create(foundationWindow, pageRFWindowInfo[1][1], pageRFWindowInfo[1][2], pageRFWindowInfo[1][3], pageRFWindowInfo[1][4])
- pageRFWindow[2] = window.create(foundationWindow, pageRFWindowInfo[2][1], pageRFWindowInfo[2][2], pageRFWindowInfo[2][3], pageRFWindowInfo[2][4])
- pageRFWindow[3] = window.create(foundationWindow, pageRFWindowInfo[3][1], pageRFWindowInfo[3][2], pageRFWindowInfo[3][3], pageRFWindowInfo[3][4])
- pageRFWindow[4] = window.create(foundationWindow, pageRFWindowInfo[4][1], pageRFWindowInfo[4][2], pageRFWindowInfo[4][3], pageRFWindowInfo[4][4])
- pageRFWindow[5] = window.create(foundationWindow, pageRFWindowInfo[5][1], pageRFWindowInfo[5][2], pageRFWindowInfo[5][3], pageRFWindowInfo[5][4])
- pageRFWindow[6] = window.create(foundationWindow, pageRFWindowInfo[6][1], pageRFWindowInfo[6][2], pageRFWindowInfo[6][3], pageRFWindowInfo[6][4])
- pageRFWindow[7] = window.create(foundationWindow, pageRFWindowInfo[7][1], pageRFWindowInfo[7][2], pageRFWindowInfo[7][3], pageRFWindowInfo[7][4])
- end),
- pageFuel = (function()
- pageFuelWindowInfo = {}
- pageFuelWindow = {}
- pageFuelWindowInfo[1] = {1, 1, 11, usableHeightFull - 1}
- pageFuelWindowInfo[2] = {5, 2, 3, usableHeightFull - 2}
- pageFuelWindowInfo[3] = {6, usableHeightFull - (math.ceil((fuelAmountRaw / fuelTankCapacity) * (usableHeightFull - 2))), 1, (math.ceil((fuelAmountRaw / fuelTankCapacity) * (usableHeightFull - 2)))}
- pageFuelWindowInfo[4] = {1, usableHeightFull, 11, 1}
- pageFuelWindowInfo[5] = {12, 1, usableWidth - 11, math.ceil(usableHeightFull / 3)}
- pageFuelWindowInfo[6] = {12, pageFuelWindowInfo[5][4] + 1, usableWidth - 11, math.ceil((usableHeightFull - pageFuelWindowInfo[5][4]) / 2)}
- pageFuelWindowInfo[7] = {12, pageFuelWindowInfo[5][4] + pageFuelWindowInfo[6][4] + 1, usableWidth - 11, usableHeightFull - pageFuelWindowInfo[5][4] - pageFuelWindowInfo[6][4]}
- pageFuelWindow[1] = window.create(foundationWindow, pageFuelWindowInfo[1][1], pageFuelWindowInfo[1][2], pageFuelWindowInfo[1][3], pageFuelWindowInfo[1][4])
- pageFuelWindow[2] = window.create(foundationWindow, pageFuelWindowInfo[2][1], pageFuelWindowInfo[2][2], pageFuelWindowInfo[2][3], pageFuelWindowInfo[2][4])
- pageFuelWindow[3] = window.create(foundationWindow, pageFuelWindowInfo[3][1], pageFuelWindowInfo[3][2], pageFuelWindowInfo[3][3], pageFuelWindowInfo[3][4])
- pageFuelWindow[4] = window.create(foundationWindow, pageFuelWindowInfo[4][1], pageFuelWindowInfo[4][2], pageFuelWindowInfo[4][3], pageFuelWindowInfo[4][4])
- pageFuelWindow[5] = window.create(foundationWindow, pageFuelWindowInfo[5][1], pageFuelWindowInfo[5][2], pageFuelWindowInfo[5][3], pageFuelWindowInfo[5][4])
- pageFuelWindow[6] = window.create(foundationWindow, pageFuelWindowInfo[6][1], pageFuelWindowInfo[6][2], pageFuelWindowInfo[6][3], pageFuelWindowInfo[6][4])
- pageFuelWindow[7] = window.create(foundationWindow, pageFuelWindowInfo[7][1], pageFuelWindowInfo[7][2], pageFuelWindowInfo[7][3], pageFuelWindowInfo[7][4])
- end),
- pageEfficiency = (function()
- pageEfficiencyWindowInfo = {}
- pageEfficiencyWindow = {}
- pageEfficiencyWindowInfo[1] = {1, 1, usableWidth, math.ceil(usableHeightFull / 3)}
- pageEfficiencyWindowInfo[2] = {1, pageEfficiencyWindowInfo[1][4] + 1, usableWidthHalf, math.ceil((usableHeightFull - pageEfficiencyWindowInfo[1][4]) / 2)}
- pageEfficiencyWindowInfo[3] = {usableWidthHalf + 1, pageEfficiencyWindowInfo[1][4] + 1, usableWidthHalfRest, math.ceil((usableHeightFull - pageEfficiencyWindowInfo[1][4]) / 2)}
- pageEfficiencyWindowInfo[4] = {1, pageEfficiencyWindowInfo[1][4] + pageEfficiencyWindowInfo[2][4] + 1, usableWidthHalf, usableHeightFull - pageEfficiencyWindowInfo[1][4] - pageEfficiencyWindowInfo[2][4]}
- pageEfficiencyWindowInfo[5] = {usableWidthHalf + 1, pageEfficiencyWindowInfo[1][4] + pageEfficiencyWindowInfo[2][4] + 1, usableWidthHalfRest, usableHeightFull - pageEfficiencyWindowInfo[1][4] - pageEfficiencyWindowInfo[2][4]}
- pageEfficiencyWindow[1] = window.create(foundationWindow, pageEfficiencyWindowInfo[1][1], pageEfficiencyWindowInfo[1][2], pageEfficiencyWindowInfo[1][3], pageEfficiencyWindowInfo[1][4])
- pageEfficiencyWindow[2] = window.create(foundationWindow, pageEfficiencyWindowInfo[2][1], pageEfficiencyWindowInfo[2][2], pageEfficiencyWindowInfo[2][3], pageEfficiencyWindowInfo[2][4])
- pageEfficiencyWindow[3] = window.create(foundationWindow, pageEfficiencyWindowInfo[3][1], pageEfficiencyWindowInfo[3][2], pageEfficiencyWindowInfo[3][3], pageEfficiencyWindowInfo[3][4])
- pageEfficiencyWindow[4] = window.create(foundationWindow, pageEfficiencyWindowInfo[4][1], pageEfficiencyWindowInfo[4][2], pageEfficiencyWindowInfo[4][3], pageEfficiencyWindowInfo[4][4])
- pageEfficiencyWindow[5] = window.create(foundationWindow, pageEfficiencyWindowInfo[5][1], pageEfficiencyWindowInfo[5][2], pageEfficiencyWindowInfo[5][3], pageEfficiencyWindowInfo[5][4])
- end),
- }
- display = {
- bootScreen = (function(text)
- colorBackground = colors.white
- for i = 1, 7, 1 do
- if colorBackground == colors.white then
- colorBackground = colors.black
- else
- colorBackground = colors.white
- end
- bootWindow[i].setBackgroundColor(colorBackground)
- bootWindow[i].clear()
- end
- writeTextToWindow(bootWindow[7], bootWindowInfo[7][3], bootWindowInfo[7][4], colors.black, colors.white, text, 1, 0)
- end),
- interface = (function(leftCenterButtonText, rightCenterButtonText)
- if leftCenterButtonText == nil then
- leftCenterButtonText = "unbelegt"
- end
- if rightCenterButtonText == nil then
- rightCenterButtonText = "unbelegt"
- end
- backgroundButtonWindow.setBackgroundColor(backgroundWindowBackgroundColor)
- backgroundButtonWindow.clear()
- writeTextToWindow(rightButtonWindow, rightButtonWindowInfo[3], rightButtonWindowInfo[4], buttonWindowBackgroundColor, buttonWindowTextColor, ">" , 1, 0)
- writeTextToWindow(leftButtonWindow, leftButtonWindowInfo[3], leftButtonWindowInfo[4], buttonWindowBackgroundColor, buttonWindowTextColor, "<", 1, 0)
- writeTextToWindow(leftCenterButtonWindow, leftCenterButtonWindowInfo[3], leftCenterButtonWindowInfo[4], buttonWindowBackgroundColor, buttonWindowTextColor, leftCenterButtonText, 1, 0)
- writeTextToWindow(rightCenterButtonWindow, rightCenterButtonWindowInfo[3], rightCenterButtonWindowInfo[4], buttonWindowBackgroundColor, buttonWindowTextColor, rightCenterButtonText, 1, 0)
- writeTextToWindow(optionButtonWindow, optionButtonWindowInfo[3], optionButtonWindowInfo[4], buttonWindowBackgroundColor, buttonWindowTextColor, "Menü", 1, 0)
- writeTextToWindow(timeTextWindow, timeTextWindowInfo[3], timeTextWindowInfo[4], textWindowBackgroundColor, textWindowTextColor, dayTime, 0, 0, dateTime, 0, 0)
- writeTextToWindow(headerTextWindow, headerTextWindowInfo[3], headerTextWindowInfo[4], textWindowBackgroundColor, textWindowTextColor, "Stavros - Reaktorsteuerung", 2, 0, pageHeader, 2, 0)
- end),
- --[[
- In dieser Funktion wird die "Über den Autor" Seite geladen und angezeigt.
- ]]
- aboutAutor = (function()
- aboutAutorWindow.setBackgroundColor(colors.black)
- aboutAutorWindow.setTextColor(colors.white)
- aboutAutorWindow.clear()
- for i = 1, 14, 1 do
- aboutAutorWindow.setCursorPos(1 + (math.ceil((aboutAutorWindowInfo[3] - string.len(aboutAutorText[i])) / 2)), ((aboutAutorWindowInfo[4] - 14) / 2) + i)
- aboutAutorWindow.write(aboutAutorText[i])
- end
- end),
- optionMain = (function()
- foundationWindow.setBackgroundColor(colors.red)
- foundationWindow.clear()
- local counter1 = 1
- local counter2 = 1
- local colorBackground
- if currentOptionPage == 2 then
- counter1 = counter1 + 4
- elseif currentOptionPage == 3 then
- counter1 = counter1 + 8
- end
- for i = counter1, (counter1 + 3), 1 do
- if currentOptionPage == 1 or currentOptionPage == 3 then
- if (counter2 / 2) == math.ceil(counter2 / 2) then
- colorBackground = colors.gray
- else
- colorBackground = colors.black
- end
- elseif currentOptionPage == 2 then
- if (counter2 / 2) == math.ceil(counter2 / 2) then
- colorBackground = colors.black
- else
- colorBackground = colors.gray
- end
- end
- writeTextToWindow(optionMainWindow[counter2], optionMainWindowInfo[counter2][3], optionMainWindowInfo[counter2][4], colorBackground, colors.white, configTableInfo[i], "left", 0, configTableText[i][configTable[i]], 1, 0)
- counter2 = counter2 + 1
- end
- end),
- optionSettingEntry = (function(i)
- if currentOptionPage == 2 then
- i = i + 4
- elseif currentOptionPage == 3 then
- i = i + 8
- end
- if (configTable[i] + configTableManipulator) > (table.getn(configTableText[i])) then
- configTableManipulator = configTableManipulator - table.getn(configTableText[i])
- elseif (configTable[i] + configTableManipulator) < 1 then
- configTableManipulator = configTableManipulator + table.getn(configTableText[i])
- end
- foundationWindow.setBackgroundColor(colors.black)
- foundationWindow.clear()
- writeTextToWindow(optionSettingWindow, optionSettingWindowInfo[3], optionSettingWindowInfo[4], colors.black, colors.white, configTableInfo[i], 1, 0, configTableText[i][configTable[i] + configTableManipulator], 1, 0)
- selectedConfig = i
- newConfigValue = (configTable[i] + configTableManipulator)
- end),
- systemControl = (function()
- foundationWindow.setBackgroundColor(colors.white)
- foundationWindow.clear()
- for i = 1, 4, 1 do
- local setOff = 0
- local colorBackground = colors.black
- if i == 2 or i == 3 then
- colorBackground = colors.lightGray
- elseif SystemControlText[currentSettingsPage][i][1] == "Reaktor" and reactorActive == false then
- setOff = setOff + 1
- end
- writeTextToWindow(systemControlWindow[i], systemControlWindowInfo[i][3], systemControlWindowInfo[i][4], colorBackground, colors.white, SystemControlText[currentSettingsPage][i][1], 1, 0, SystemControlText[currentSettingsPage][i][2 + setOff], 1, 0)
- end
- end),
- pageMain = (function()
- foundationWindow.setBackgroundColor(colors.white)
- foundationWindow.clear()
- writeTextToWindow(paigeMainWindow1, paigeMainWindow1Info[3], paigeMainWindow1Info[4], paigeMainBackgroundColor, paigeMainTextColor, "Reaktor ist:", 0, 0, reactorActive, 0, 0)
- if activeCooling ~= true then
- writeTextToWindow(paigeMainWindow2, paigeMainWindow2Info[3], paigeMainWindow2Info[4], paigeMainBackgroundColor, paigeMainTextColor, "Reaktor arbeitet:", 0, 0, "Passiv gekühlt", 0, 0)
- else
- writeTextToWindow(paigeMainWindow2, paigeMainWindow2Info[3], paigeMainWindow2Info[4], paigeMainBackgroundColor, paigeMainTextColor, "Reaktor arbeitet:", 0, 0, "Aktiv gekühlt", 0, 0)
- end
- writeTextToWindow(paigeMainWindow3, paigeMainWindow3Info[3], paigeMainWindow3Info[4], paigeMainBackgroundColor, paigeMainTextColor, "Reaktorspeicher:", 0, 0, storedRF[1] .. storedRF[2] .. " gespeichert", 0, 0)
- writeTextToWindow(paigeMainWindow4, paigeMainWindow4Info[3], paigeMainWindow4Info[4], paigeMainBackgroundColor, paigeMainTextColor, "Reaktorspeicher zu:", 0, 0, math.ceil((storedRFRaw / capacityRFRaw) * 100) .. "% voll", 0, 0)
- writeTextToWindow(paigeMainWindow5, paigeMainWindow5Info[3], paigeMainWindow5Info[4], paigeMainBackgroundColor, paigeMainTextColor, "Brennstoff Verbrauch:", 0, 0, fuelburnedLastTick[1] .. fuelburnedLastTick[2], 0, 0)
- writeTextToWindow(paigeMainWindow6, paigeMainWindow6Info[3], paigeMainWindow6Info[4], paigeMainBackgroundColor, paigeMainTextColor, "Brennstoff-Effizienz:", 0, 0, passivEfficiency[1] .. passivEfficiency[2], 0, 0)
- writeTextToWindow(paigeMainWindow7, paigeMainWindow7Info[3], paigeMainWindow7Info[4], paigeMainBackgroundColor, paigeMainTextColor, "Brennstofffüllstand", 0, 0, fuelAmountPercent .. " % - " .. fuelAmount[1] .. fuelAmount[2], 0, 0)
- writeTextToWindow(paigeMainWindow8, paigeMainWindow8Info[3], paigeMainWindow8Info[4], paigeMainBackgroundColor, paigeMainTextColor, "Steuerstab-Einschub", 0, 0, "Zu " .. getControlRodLevel .. "% eingeschoben", 0, 0)
- end),
- pageRF = (function()
- foundationWindow.clear()
- writeTextToWindow(pageRFWindow[1], pageRFWindowInfo[1][3], pageRFWindowInfo[1][4], colors.black, colors.white, "100%", -2, "split", "0%" , -2, "split")
- pageRFWindow[2].setBackgroundColor(colors.lightGray)
- pageRFWindow[2].clear()
- pageRFWindow[3].setBackgroundColor(colors.red)
- pageRFWindow[3].clear()
- writeTextToWindow(pageRFWindow[4], pageRFWindowInfo[4][3], pageRFWindowInfo[4][4], colors.black, colors.white, "RF-Speicher", 1, 0)
- writeTextToWindow(pageRFWindow[5], pageRFWindowInfo[5][3], pageRFWindowInfo[5][4], colors.black, colors.white, "Energieproduktion", 1, 0, producedRFLastTick[1] .. producedRFLastTick[2] , 0, 0)
- writeTextToWindow(pageRFWindow[6], pageRFWindowInfo[6][3], pageRFWindowInfo[6][4], colors.black, colors.white, "Energiespeichergröße des Reaktors", 0, 0, capacityRF[1] .. capacityRF[2], 0, 0)
- writeTextToWindow(pageRFWindow[7], pageRFWindowInfo[7][3], pageRFWindowInfo[7][4], colors.black, colors.white, "RF-Produktion der letzten 5 Minuten", 1, 0, rfProducedHistorySum[1] .. rfProducedHistorySum[2] , 0, 0)
- end),
- pageFuel = (function()
- foundationWindow.clear()
- writeTextToWindow(pageFuelWindow[1], pageFuelWindowInfo[1][3], pageFuelWindowInfo[1][4], colors.black, colors.white, "100%", -2, "split", "0%" , -2, "split")
- pageFuelWindow[2].setBackgroundColor(colors.lightGray)
- pageFuelWindow[2].clear()
- pageFuelWindow[3].setBackgroundColor(colors.red)
- pageFuelWindow[3].clear()
- writeTextToWindow(pageFuelWindow[4], pageFuelWindowInfo[4][3], pageFuelWindowInfo[4][4], colors.black, colors.white, "Brennstoff", 1, 0)
- writeTextToWindow(pageFuelWindow[5], pageFuelWindowInfo[5][3], pageFuelWindowInfo[5][4], colors.black, colors.white, "Brennstoffverbrauch", 1, 0, fuelburnedLastTick[1] .. fuelburnedLastTick[2] , 0, 0)
- writeTextToWindow(pageFuelWindow[6], pageFuelWindowInfo[6][3], pageFuelWindowInfo[6][4], colors.black, colors.white, "Brennstoffaufnahme des Reaktors", 0, 0, fuelAmount[1] .. fuelAmount[2], 0, 0)
- writeTextToWindow(pageFuelWindow[7], pageFuelWindowInfo[7][3], pageFuelWindowInfo[7][4], colors.black, colors.white, "Brennstoffbedarf der letzten 5 Minuten", 1, 0, fuelBurnedHistorySum[1] .. fuelBurnedHistorySum[2] , 0, 0)
- end),
- pageEfficiency = (function()
- foundationWindow.setBackgroundColor(colors.white)
- foundationWindow.clear()
- local tempDifferenceValue
- local tempDifferenceText
- tempDifferenceValue = 1293 - fuelTemperature
- if reactorActive == true then
- if tempDifferenceValue < 0 then
- tempDifferenceText = "Reaktor arbeitet " .. (tempDifferenceValue * -1) .. " K über Soll-Temperatur"
- elseif tempDifferenceValue > 0 then
- tempDifferenceText = "Reaktor arbeitet " .. tempDifferenceValue .. " K unter Soll-Temperatur"
- else
- tempDifferenceText = "Reaktor arbeitet in der Soll-Temperatur"
- end
- else
- tempDifferenceText = "Der Reaktor ist im Moment ausgeschaltet"
- end
- writeTextToWindow(pageEfficiencyWindow[1], pageEfficiencyWindowInfo[1][3], pageEfficiencyWindowInfo[1][4], colors.black, colors.white, tempDifferenceText, 1, 0)
- writeTextToWindow(pageEfficiencyWindow[2], pageEfficiencyWindowInfo[2][3], pageEfficiencyWindowInfo[2][4], colors.black, colors.white, "Ist-Betriebstemperatur:", 1, 0, fuelTemperature .. " K", 1 ,0)
- writeTextToWindow(pageEfficiencyWindow[3], pageEfficiencyWindowInfo[3][3], pageEfficiencyWindowInfo[3][4], colors.black, colors.white, "Soll-Betriebstemperatur:", 1, 0, 1293 .. " K", 1 ,0)
- writeTextToWindow(pageEfficiencyWindow[4], pageEfficiencyWindowInfo[4][3], pageEfficiencyWindowInfo[4][4], colors.black, colors.white, "Brennstoff-Effizienz", 1, 0, string.format("%.1f", fuelReactivity * 100) .. " %", 1 ,0)
- writeTextToWindow(pageEfficiencyWindow[5], pageEfficiencyWindowInfo[5][3], pageEfficiencyWindowInfo[5][4], colors.black, colors.white, "Brennstoff-Verbrauch:", 1, 0, fuelburnedLastTick[1] .. fuelburnedLastTick[2], 1 ,0)
- end),
- }
- function touchCheck(input1, input2, infoTable, offSetY)
- if offSetY == nil then
- offSetY = 0
- end
- if input1 >= infoTable[1] and input1 <= (infoTable[1] + infoTable[3] - 1) and input2 >= (infoTable[2] + offSetY) and input2 <= (infoTable[2] + infoTable[4] - 1 + offSetY) then
- return true
- else
- return false
- end
- end
- function reactorAutostart()
- if autostart == true and reactorActive == false then
- setActive(true)
- end
- end
- function baseTask()
- timerID = os.startTimer(1)
- if debugLevel == 0 then
- handler(globalVariables)
- elseif debugLevel == 1 then
- globalVariables()
- end
- if debugLevel == 0 then
- handler(alarmTrigger)
- elseif debugLevel == 1 then
- alarmTrigger()
- end
- controlRodSteeringTimer = controlRodSteeringTimer + 1
- if controlRodSteeringTimer >= 4 then
- if debugLevel == 0 then
- handler(controlRodSteering)
- elseif debugLevel == 1 then
- controlRodSteering()
- end
- end
- end
- function handler(functionName)
- if pcall(functionName) then
- else
- term.clear()
- term.setCursorPos(1, 1)
- printError("Warnung\n\nFehler bei der Reaktoranbindung aufgetreten!\nBitte Verbindung überprüfen!\n\nSystem wird in 30 Sekunden neugestartet...")
- display.bootScreen("! Fehler bei Programmstart !")
- os.sleep(30)
- os.reboot()
- end
- end
- function pageCheck()
- if page < 1 then
- page = 4
- elseif page > 4 then
- page = 1
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement