Adapt boiler display for shared main shaft
This commit is contained in:
@@ -21,8 +21,8 @@ werden ergaenzt, sobald die Peripherie- und Methodennamen der gebauten Anlagen f
|
||||
|
||||
## Einfache Create-Boiler-Anzeige
|
||||
|
||||
Fuer die erste Kraftwerksanzeige werden ein Monitor, pro Boiler ein Create-Speedometer,
|
||||
ein Create-Stressometer an der Hauptwelle und optional pro Boiler ein Block Reader aus
|
||||
Fuer die erste Kraftwerksanzeige werden ein Monitor, ein Create-Speedometer und
|
||||
ein Create-Stressometer an der gemeinsamen Hauptwelle sowie pro Boiler ein Block Reader aus
|
||||
Advanced Peripherals ueber Wired Modems mit dem Computer verbunden. Installation und Start:
|
||||
|
||||
```lua
|
||||
@@ -30,11 +30,11 @@ wget https://git.peli-server.de/Dystroyer8/ATM10_CC_Codes/raw/branch/main/create
|
||||
create_boiler_display
|
||||
```
|
||||
|
||||
Das Programm zeigt pro Boiler Online-Status, RPM und - mit Block Reader - den Heizmodus.
|
||||
Zusaetzlich zeigt es Kapazitaet, Verbrauch und Auslastung der Hauptwelle. Die Zuordnung erfolgt
|
||||
nach den internen Peripheral-Namen; Speedometer und Block Reader sollten deshalb jeweils in der
|
||||
Reihenfolge Boiler 1 bis 3 an das Wired Network angeschlossen werden. Jeder Block Reader muss
|
||||
auf den Controller-Tank des zugeordneten Boiler-Multiblocks zeigen.
|
||||
Das Programm liest Online-Status und Heizmodus jedes Boilers ueber dessen Block Reader.
|
||||
Drehzahl, Kapazitaet, Verbrauch und Auslastung werden fuer die gemeinsame Hauptwelle angezeigt.
|
||||
Die Boiler-Zuordnung erfolgt nach den internen Peripheral-Namen; die drei Block Reader sollten
|
||||
deshalb in der Reihenfolge Boiler 1 bis 3 an das Wired Network angeschlossen werden. Jeder Block
|
||||
Reader muss auf den Controller-Tank des zugeordneten Boiler-Multiblocks zeigen.
|
||||
|
||||
## Struktur
|
||||
|
||||
|
||||
+53
-31
@@ -1,9 +1,9 @@
|
||||
-- Create boiler status board for CC:Tweaked.
|
||||
-- Hardware:
|
||||
-- * one monitor
|
||||
-- * one Create Speedometer per boiler
|
||||
-- * one Create Speedometer on the shared main shaft
|
||||
-- * one Create Stressometer on the main shaft
|
||||
-- * optionally one Advanced Peripherals Block Reader per boiler controller
|
||||
-- * one Advanced Peripherals Block Reader per boiler controller
|
||||
-- Everything must be connected to the computer, preferably using Wired Modems.
|
||||
|
||||
local EXPECTED_BOILERS = 3
|
||||
@@ -76,39 +76,53 @@ local function findBoilerData(data, visited)
|
||||
return nil
|
||||
end
|
||||
|
||||
local function readHeatMode(readerName)
|
||||
if not readerName then return "UNKNOWN" end
|
||||
local function readBoiler(readerName)
|
||||
if not readerName then return "MISSING", "UNKNOWN", colors.red end
|
||||
local ok, data = pcall(peripheral.call, readerName, "getBlockData")
|
||||
if not ok then return "ERROR" end
|
||||
if not ok then return "ERROR", "UNKNOWN", colors.red end
|
||||
|
||||
local boiler = findBoilerData(data)
|
||||
if not boiler then return "UNKNOWN" end
|
||||
if not boiler then return "NO DATA", "UNKNOWN", colors.red end
|
||||
|
||||
local passive = getValueIgnoringCase(boiler, { "PassiveHeat", "passive" })
|
||||
local heat = tonumber(getValueIgnoringCase(boiler,
|
||||
{ "Heat", "activeHeat", "actualHeat", "boilerLevel", "level" }))
|
||||
{ "Heat", "activeHeat", "actualHeat" }))
|
||||
local supply = tonumber(getValueIgnoringCase(boiler,
|
||||
{ "Supply", "waterSupply", "gatheredSupply" }))
|
||||
local engines = tonumber(getValueIgnoringCase(boiler,
|
||||
{ "Engines", "attachedEngines" }))
|
||||
local active = getValueIgnoringCase(boiler,
|
||||
{ "Active", "isActive", "prevActive" })
|
||||
|
||||
if passive == true or passive == 1 then return "CAMPFIRE" end
|
||||
if heat and heat >= 18 then return "SUPERHEATED" end
|
||||
if heat and heat > 0 then return "HEATED" end
|
||||
return "COLD"
|
||||
local heatMode
|
||||
if passive == true or passive == 1 then
|
||||
heatMode = "CAMPFIRE"
|
||||
elseif heat and heat >= 18 then
|
||||
heatMode = "SUPERHEATED"
|
||||
elseif heat and heat > 0 then
|
||||
heatMode = "HEATED"
|
||||
else
|
||||
heatMode = "COLD"
|
||||
end
|
||||
|
||||
local function readBoiler(name, readerName)
|
||||
if not name then
|
||||
return "MISSING", 0, "UNKNOWN", colors.red
|
||||
if active == nil then
|
||||
local hasHeat = heatMode ~= "COLD"
|
||||
local hasWater = supply == nil or supply > 0
|
||||
local hasEngines = engines == nil or engines > 0
|
||||
active = hasHeat and hasWater and hasEngines
|
||||
end
|
||||
|
||||
local ok, speed = pcall(peripheral.call, name, "getSpeed")
|
||||
if not ok or type(speed) ~= "number" then
|
||||
return "ERROR", 0, "UNKNOWN", colors.red
|
||||
if active == true or active == 1 then
|
||||
return "ONLINE", heatMode, colors.lime
|
||||
end
|
||||
return "STANDBY", heatMode, colors.orange
|
||||
end
|
||||
|
||||
speed = math.abs(speed)
|
||||
if speed < 0.5 then
|
||||
return "STANDBY", 0, readHeatMode(readerName), colors.orange
|
||||
end
|
||||
return "ONLINE", speed, readHeatMode(readerName), colors.lime
|
||||
local function readMainSpeed(speedometerName)
|
||||
if not speedometerName then return nil end
|
||||
local ok, speed = pcall(peripheral.call, speedometerName, "getSpeed")
|
||||
if not ok or type(speed) ~= "number" then return nil end
|
||||
return math.abs(speed)
|
||||
end
|
||||
|
||||
local function formatInteger(value)
|
||||
@@ -147,28 +161,36 @@ local function render()
|
||||
center(1, "CREATE KRAFTWERK", colors.cyan)
|
||||
local firstRow = 3
|
||||
for index = 1, EXPECTED_BOILERS do
|
||||
local state, speed, heatMode, color = readBoiler(speedometers[index], readers[index])
|
||||
local state, heatMode, color = readBoiler(readers[index])
|
||||
local row = firstRow + index - 1
|
||||
if row <= height then
|
||||
center(row, ("BOILER %d %-7s %5.1f RPM %s")
|
||||
:format(index, state, speed, heatMode), color)
|
||||
center(row, ("BOILER %d %-7s %s")
|
||||
:format(index, state, heatMode), color)
|
||||
end
|
||||
end
|
||||
|
||||
local speed = readMainSpeed(speedometers[1])
|
||||
local capacity, usage, load = readMainShaft(stressometers[1])
|
||||
if height >= 7 then center(7, "MAIN SHAFT", colors.cyan) end
|
||||
if height >= 8 then
|
||||
if speed then
|
||||
center(8, ("Speed: %.1f RPM"):format(speed), speed > 0 and colors.lime or colors.orange)
|
||||
else
|
||||
center(8, "Speedometer nicht gefunden", colors.red)
|
||||
end
|
||||
end
|
||||
if capacity then
|
||||
if height >= 8 then center(8, "Capacity: " .. formatInteger(capacity) .. " SU", colors.white) end
|
||||
if height >= 9 then center(9, "Usage: " .. formatInteger(usage) .. " SU", colors.white) end
|
||||
if height >= 10 then
|
||||
if height >= 9 then center(9, "Capacity: " .. formatInteger(capacity) .. " SU", colors.white) end
|
||||
if height >= 10 then center(10, "Usage: " .. formatInteger(usage) .. " SU", colors.white) end
|
||||
if height >= 11 then
|
||||
local loadText = ("Load: %.1f %%"):format(load):gsub("%.", ",")
|
||||
center(10, loadText, load >= 90 and colors.red or load >= 70 and colors.orange or colors.lime)
|
||||
center(11, loadText, load >= 90 and colors.red or load >= 70 and colors.orange or colors.lime)
|
||||
end
|
||||
else
|
||||
if height >= 8 then center(8, "Stressometer nicht gefunden", colors.red) end
|
||||
if height >= 9 then center(9, "Stressometer nicht gefunden", colors.red) end
|
||||
end
|
||||
|
||||
if height >= 12 then
|
||||
if height >= 13 then
|
||||
center(height, "Nur Anzeige - keine Steuerung", colors.gray)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user