Fix direct clutch output polarity
This commit is contained in:
@@ -67,7 +67,9 @@ Der erste lokale Create-Produktionscontroller ueberwacht einen Zink-Nugget-Vault
|
|||||||
Andesite-Alloy-Vault und die per Clutch getrennte Maschinenwelle. Die beiden Vaults muessen
|
Andesite-Alloy-Vault und die per Clutch getrennte Maschinenwelle. Die beiden Vaults muessen
|
||||||
jeweils direkt ueber einen aktivierten Wired Modem Full Block als Inventory-Peripheral mit dem
|
jeweils direkt ueber einen aktivierten Wired Modem Full Block als Inventory-Peripheral mit dem
|
||||||
Computer verbunden sein. Ein Advanced-Peripherals Block Reader zeigt auf das Stressometer der
|
Computer verbunden sein. Ein Advanced-Peripherals Block Reader zeigt auf das Stressometer der
|
||||||
Maschinenwelle. Der Redstone-Ausgang `left` steuert die Clutch ueber einen Fail-safe-Inverter.
|
Maschinenwelle. Der Redstone-Ausgang `left` steuert die Clutch in der aktuellen Installation
|
||||||
|
direkt: Redstone `ON` stoppt die Welle und Redstone `OFF` gibt sie frei. Die Polaritaet ist im
|
||||||
|
Programm ueber `OUTPUT_LEVEL_WHEN_RUNNING` konfigurierbar.
|
||||||
|
|
||||||
Installation und erster Start:
|
Installation und erster Start:
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ local REFRESH_SECONDS = 1
|
|||||||
local MIN_WIDTH = 28
|
local MIN_WIDTH = 28
|
||||||
local MIN_HEIGHT = 13
|
local MIN_HEIGHT = 13
|
||||||
local CLUTCH_OUTPUT_SIDE = "left"
|
local CLUTCH_OUTPUT_SIDE = "left"
|
||||||
|
-- This installation drives the Clutch directly: powered means stopped.
|
||||||
|
-- Change to true if a redstone-torch inverter is installed later.
|
||||||
|
local OUTPUT_LEVEL_WHEN_RUNNING = false
|
||||||
local STATE_FILE = "create_andesite_state.txt"
|
local STATE_FILE = "create_andesite_state.txt"
|
||||||
local DEVICE_FILE = "create_andesite_devices.txt"
|
local DEVICE_FILE = "create_andesite_devices.txt"
|
||||||
|
|
||||||
@@ -39,8 +42,13 @@ local requestedRunning = loadText(STATE_FILE) == "RUNNING"
|
|||||||
local devices = textutils.unserialize(loadText(DEVICE_FILE) or "") or {}
|
local devices = textutils.unserialize(loadText(DEVICE_FILE) or "") or {}
|
||||||
local capacityCache = {}
|
local capacityCache = {}
|
||||||
|
|
||||||
|
local function setMachineRunning(running)
|
||||||
|
local level = running and OUTPUT_LEVEL_WHEN_RUNNING or not OUTPUT_LEVEL_WHEN_RUNNING
|
||||||
|
redstone.setOutput(CLUTCH_OUTPUT_SIDE, level)
|
||||||
|
end
|
||||||
|
|
||||||
-- Fail safe while peripherals are being discovered.
|
-- Fail safe while peripherals are being discovered.
|
||||||
redstone.setOutput(CLUTCH_OUTPUT_SIDE, false)
|
setMachineRunning(false)
|
||||||
|
|
||||||
local monitor = peripheral.find("monitor")
|
local monitor = peripheral.find("monitor")
|
||||||
if not monitor then
|
if not monitor then
|
||||||
@@ -241,7 +249,7 @@ local function evaluate()
|
|||||||
local allowed = not missing and not noMaterial and not outputFull and not overstressed
|
local allowed = not missing and not noMaterial and not outputFull and not overstressed
|
||||||
local effectiveRunning = requestedRunning and allowed
|
local effectiveRunning = requestedRunning and allowed
|
||||||
|
|
||||||
redstone.setOutput(CLUTCH_OUTPUT_SIDE, effectiveRunning)
|
setMachineRunning(effectiveRunning)
|
||||||
|
|
||||||
local status, color = "STOPPED", colors.red
|
local status, color = "STOPPED", colors.red
|
||||||
if requestedRunning then
|
if requestedRunning then
|
||||||
@@ -336,7 +344,7 @@ end
|
|||||||
local function safeRender()
|
local function safeRender()
|
||||||
local ok, reason = pcall(render)
|
local ok, reason = pcall(render)
|
||||||
if not ok then
|
if not ok then
|
||||||
redstone.setOutput(CLUTCH_OUTPUT_SIDE, false)
|
setMachineRunning(false)
|
||||||
monitor.setBackgroundColor(colors.black)
|
monitor.setBackgroundColor(colors.black)
|
||||||
monitor.clear()
|
monitor.clear()
|
||||||
center(1, "CONTROLLER ERROR", colors.red)
|
center(1, "CONTROLLER ERROR", colors.red)
|
||||||
@@ -371,5 +379,5 @@ local function run()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local ok, reason = pcall(run)
|
local ok, reason = pcall(run)
|
||||||
redstone.setOutput(CLUTCH_OUTPUT_SIDE, false)
|
setMachineRunning(false)
|
||||||
if not ok then error(reason, 0) end
|
if not ok then error(reason, 0) end
|
||||||
|
|||||||
Reference in New Issue
Block a user