From 774d0d2e42b0dc25b8cd099034f8b14361b8ed8b Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Sun, 19 Mar 2023 17:05:03 +0100 Subject: [PATCH] Add running state --- logic/collector.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/logic/collector.lua b/logic/collector.lua index 6083952..f5568d5 100644 --- a/logic/collector.lua +++ b/logic/collector.lua @@ -21,9 +21,12 @@ local logic = techage.logic local CYCLE_TIME = 1 -local tStates = {stopped = 0, running = 0, standby = 1, blocked = 2, nopower = 3, fault = 4} +-- The numbering seems strange here, but I had to add the "running" state +-- afterwards without changing the behavior of the block. +local tStates = {stopped = 0, running = 1, standby = 2, blocked = 3, fault = 4, defect = 5} +local tDropdownPos = {["1 standby"] = 1, ["2 blocked"] = 2, ["3 fault"] = 3, ["4 defect"] = 4} +local lStates = {[0] = "stopped", "running", "standby", "blocked", "fault", "defect"} local tDropdownPos = {["1 standby"] = 1, ["2 blocked"] = 2, ["3 nopower"] = 3, ["4 fault"] = 4} -local lStates = {[0] = "stopped", "standby", "blocked", "nopower", "fault"} local TaStates = {running = 1, blocked = 2, standby = 3, nopower = 4, fault = 5, stopped = 6} local function formspec(nvm, meta) @@ -50,7 +53,7 @@ local function send_event(nvm, meta) if event_number ~= "" then local severity = meta:get_int("dropdown_pos") local own_number = meta:get_string("own_number") - if nvm.common_state >= severity then + if nvm.common_state > severity then techage.send_multi(own_number, event_number, "on") else techage.send_multi(own_number, event_number, "off")