mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#93 added reset RPS command to iocontrol/gui
This commit is contained in:
parent
62ac993dae
commit
9d60777223
@ -44,6 +44,11 @@ function iocontrol.init(conf, comms)
|
||||
log.debug(util.c("sent unit ", i, ": SCRAM"))
|
||||
end,
|
||||
|
||||
reset_rps = function ()
|
||||
comms.send_command(i, CRDN_COMMANDS.RESET_RPS)
|
||||
log.debug(util.c("sent unit ", i, ": RESET_RPS"))
|
||||
end,
|
||||
|
||||
set_burn = function (rate)
|
||||
comms.send_command(i, CRDN_COMMANDS.SET_BURN, rate)
|
||||
log.debug(util.c("sent unit ", i, ": SET_BURN = ", rate))
|
||||
|
@ -16,7 +16,7 @@ local config = require("coordinator.config")
|
||||
local coordinator = require("coordinator.coordinator")
|
||||
local renderer = require("coordinator.renderer")
|
||||
|
||||
local COORDINATOR_VERSION = "alpha-v0.5.0"
|
||||
local COORDINATOR_VERSION = "alpha-v0.5.1"
|
||||
|
||||
local print = util.print
|
||||
local println = util.println
|
||||
|
@ -19,10 +19,9 @@ local DataIndicator = require("graphics.elements.indicators.data")
|
||||
local IndicatorLight = require("graphics.elements.indicators.light")
|
||||
local TriIndicatorLight = require("graphics.elements.indicators.trilight")
|
||||
|
||||
local HazardButton = require("graphics.elements.controls.hazard_button")
|
||||
local MultiButton = require("graphics.elements.controls.multi_button")
|
||||
local PushButton = require("graphics.elements.controls.push_button")
|
||||
local SCRAMButton = require("graphics.elements.controls.scram_button")
|
||||
local StartButton = require("graphics.elements.controls.start_button")
|
||||
local SpinboxNumeric = require("graphics.elements.controls.spinbox_numeric")
|
||||
|
||||
local TEXT_ALIGN = core.graphics.TEXT_ALIGN
|
||||
@ -240,8 +239,9 @@ local function init(parent, id)
|
||||
|
||||
-- reactor controls --
|
||||
|
||||
StartButton{parent=main,x=12,y=44,callback=unit.start,fg_bg=scram_fg_bg}
|
||||
SCRAMButton{parent=main,x=22,y=44,callback=unit.scram,fg_bg=scram_fg_bg}
|
||||
HazardButton{parent=main,x=2,y=44,text="START",accent=colors.lightBlue,callback=unit.start,fg_bg=scram_fg_bg}
|
||||
HazardButton{parent=main,x=12,y=44,text="SCRAM",accent=colors.yellow,callback=unit.scram,fg_bg=scram_fg_bg}
|
||||
HazardButton{parent=main,x=22,y=44,text="RESET",accent=colors.red,callback=unit.reset_rps,fg_bg=scram_fg_bg}
|
||||
|
||||
local burn_control = Div{parent=main,x=12,y=40,width=19,height=3,fg_bg=cpair(colors.gray,colors.white)}
|
||||
local burn_rate = SpinboxNumeric{parent=burn_control,x=2,y=1,whole_num_precision=4,fractional_precision=1,arrow_fg_bg=cpair(colors.gray,colors.white),fg_bg=cpair(colors.black,colors.white)}
|
||||
|
@ -1,13 +1,13 @@
|
||||
-- SCRAM Button Graphics Element
|
||||
-- Hazard-bordered Button Graphics Element
|
||||
|
||||
local tcd = require("scada-common.tcallbackdsp")
|
||||
|
||||
local core = require("graphics.core")
|
||||
local element = require("graphics.element")
|
||||
|
||||
local accent = colors.yellow
|
||||
|
||||
---@class scram_button_args
|
||||
---@field text string text to show on button
|
||||
---@field accent color accent color for hazard border
|
||||
---@field callback function function to call on touch
|
||||
---@field parent graphics_element
|
||||
---@field id? string element id
|
||||
@ -19,23 +19,25 @@ local accent = colors.yellow
|
||||
---@param args scram_button_args
|
||||
---@return graphics_element element, element_id id
|
||||
local function scram_button(args)
|
||||
assert(type(args.callback) == "function", "graphics.elements.controls.scram_button: callback is a required field")
|
||||
assert(type(args.text) == "string", "graphics.elements.controls.hazard_button: text is a required field")
|
||||
assert(type(args.accent) == "number", "graphics.elements.controls.hazard_button: accent is a required field")
|
||||
assert(type(args.callback) == "function", "graphics.elements.controls.hazard_button: callback is a required field")
|
||||
|
||||
-- static dimensions
|
||||
args.height = 3
|
||||
args.width = 9
|
||||
args.width = string.len(args.text) + 4
|
||||
|
||||
-- create new graphics element base object
|
||||
local e = element.new(args)
|
||||
|
||||
-- write the button text
|
||||
e.window.setCursorPos(3, 2)
|
||||
e.window.write("SCRAM")
|
||||
e.window.write(args.text)
|
||||
|
||||
-- draw border
|
||||
|
||||
-- top
|
||||
e.window.setTextColor(accent)
|
||||
e.window.setTextColor(args.accent)
|
||||
e.window.setBackgroundColor(args.fg_bg.bkg)
|
||||
e.window.setCursorPos(1, 1)
|
||||
e.window.write("\x99\x89\x89\x89\x89\x89\x89\x89\x99")
|
||||
@ -43,17 +45,17 @@ local function scram_button(args)
|
||||
-- center left
|
||||
e.window.setCursorPos(1, 2)
|
||||
e.window.setTextColor(args.fg_bg.bkg)
|
||||
e.window.setBackgroundColor(accent)
|
||||
e.window.setBackgroundColor(args.accent)
|
||||
e.window.write("\x99")
|
||||
|
||||
-- center right
|
||||
e.window.setTextColor(args.fg_bg.bkg)
|
||||
e.window.setBackgroundColor(accent)
|
||||
e.window.setBackgroundColor(args.accent)
|
||||
e.window.setCursorPos(9, 2)
|
||||
e.window.write("\x99")
|
||||
|
||||
-- bottom
|
||||
e.window.setTextColor(accent)
|
||||
e.window.setTextColor(args.accent)
|
||||
e.window.setBackgroundColor(args.fg_bg.bkg)
|
||||
e.window.setCursorPos(1, 3)
|
||||
e.window.write("\x99\x98\x98\x98\x98\x98\x98\x98\x99")
|
@ -1,78 +0,0 @@
|
||||
-- SCRAM Button Graphics Element
|
||||
|
||||
local tcd = require("scada-common.tcallbackdsp")
|
||||
|
||||
local core = require("graphics.core")
|
||||
local element = require("graphics.element")
|
||||
|
||||
local accent = colors.lightBlue
|
||||
|
||||
---@class start_button_args
|
||||
---@field callback function function to call on touch
|
||||
---@field parent graphics_element
|
||||
---@field id? string element id
|
||||
---@field x? integer 1 if omitted
|
||||
---@field y? integer 1 if omitted
|
||||
---@field fg_bg? cpair foreground/background colors
|
||||
|
||||
-- new start button
|
||||
---@param args start_button_args
|
||||
---@return graphics_element element, element_id id
|
||||
local function start_button(args)
|
||||
assert(type(args.callback) == "function", "graphics.elements.controls.start_button: callback is a required field")
|
||||
|
||||
-- static dimensions
|
||||
args.height = 3
|
||||
args.width = 9
|
||||
|
||||
-- create new graphics element base object
|
||||
local e = element.new(args)
|
||||
|
||||
-- write the button text
|
||||
e.window.setCursorPos(3, 2)
|
||||
e.window.write("START")
|
||||
|
||||
-- draw border
|
||||
|
||||
-- top
|
||||
e.window.setTextColor(accent)
|
||||
e.window.setBackgroundColor(args.fg_bg.bkg)
|
||||
e.window.setCursorPos(1, 1)
|
||||
e.window.write("\x99\x89\x89\x89\x89\x89\x89\x89\x99")
|
||||
|
||||
-- center left
|
||||
e.window.setCursorPos(1, 2)
|
||||
e.window.setTextColor(args.fg_bg.bkg)
|
||||
e.window.setBackgroundColor(accent)
|
||||
e.window.write("\x99")
|
||||
|
||||
-- center right
|
||||
e.window.setTextColor(args.fg_bg.bkg)
|
||||
e.window.setBackgroundColor(accent)
|
||||
e.window.setCursorPos(9, 2)
|
||||
e.window.write("\x99")
|
||||
|
||||
-- bottom
|
||||
e.window.setTextColor(accent)
|
||||
e.window.setBackgroundColor(args.fg_bg.bkg)
|
||||
e.window.setCursorPos(1, 3)
|
||||
e.window.write("\x99\x98\x98\x98\x98\x98\x98\x98\x99")
|
||||
|
||||
-- handle touch
|
||||
---@param event monitor_touch monitor touch event
|
||||
---@diagnostic disable-next-line: unused-local
|
||||
function e.handle_touch(event)
|
||||
-- call the touch callback
|
||||
args.callback()
|
||||
end
|
||||
|
||||
-- set the value
|
||||
---@param val boolean new value
|
||||
function e.set_value(val)
|
||||
if val then e.handle_touch(core.events.touch("", 1, 1)) end
|
||||
end
|
||||
|
||||
return e.get()
|
||||
end
|
||||
|
||||
return start_button
|
Loading…
Reference in New Issue
Block a user