diff --git a/pocket/ui/apps/control.lua b/pocket/ui/apps/control.lua index 3e835cb..ab70b69 100644 --- a/pocket/ui/apps/control.lua +++ b/pocket/ui/apps/control.lua @@ -34,16 +34,21 @@ local cpair = core.cpair local APP_ID = pocket.APP_ID -local lu_col = style.label_unit_pair -local text_fg = style.text_fg -local mode_states = style.icon_states.mode_states +local label_fg_bg = style.label +local lu_col = style.label_unit_pair +local text_fg = style.text_fg -local hzd_fg_bg = cpair(colors.white, colors.gray) -local dis_colors = cpair(colors.white, colors.lightGray) +local mode_states = style.icon_states.mode_states + +local btn_active = cpair(colors.white, colors.black) +local hzd_fg_bg = style.hzd_fg_bg +local hzd_dis_colors = style.hzd_dis_colors -- new unit control page view ---@param root Container parent local function new_view(root) + local btn_fg_bg = cpair(colors.green, colors.black) + local db = iocontrol.get_db() local frame = Div{parent=root,x=1,y=1} @@ -60,9 +65,6 @@ local function new_view(root) app.set_sidebar({ { label = " # ", tall = true, color = core.cpair(colors.black, colors.green), callback = db.nav.go_home } }) - local btn_fg_bg = cpair(colors.green, colors.black) - local btn_active = cpair(colors.white, colors.black) - local page_div = nil ---@type Div|nil -- set sidebar to display unit-specific fields based on a specified unit @@ -138,12 +140,12 @@ local function new_view(root) u_div.line_break() - TextBox{parent=u_div,y=8,text="CMD",width=4,fg_bg=cpair(colors.lightGray,colors.black)} - TextBox{parent=u_div,x=14,y=8,text="mB/t",width=4,fg_bg=cpair(colors.lightGray,colors.black)} - local burn_cmd = NumberField{parent=u_div,x=5,y=8,width=8,default=0.01,min=0.01,max_frac_digits=2,max_chars=8,allow_decimal=true,align_right=true,fg_bg=cpair(colors.white,colors.gray),dis_fg_bg=cpair(colors.gray,colors.lightGray)} + TextBox{parent=u_div,y=8,text="CMD",width=4,fg_bg=label_fg_bg} + TextBox{parent=u_div,x=14,y=8,text="mB/t",width=4,fg_bg=label_fg_bg} + local burn_cmd = NumberField{parent=u_div,x=5,y=8,width=8,default=0.01,min=0.01,max_frac_digits=2,max_chars=8,allow_decimal=true,align_right=true,fg_bg=style.field,dis_fg_bg=style.field_disable} local set_burn = function () unit.set_burn(burn_cmd.get_value()) end - local set_burn_btn = PushButton{parent=u_div,x=19,y=8,text="SET",min_width=5,fg_bg=cpair(colors.green,colors.black),active_fg_bg=cpair(colors.white,colors.black),dis_fg_bg=cpair(colors.gray,colors.black),callback=set_burn} + local set_burn_btn = PushButton{parent=u_div,x=19,y=8,text="SET",min_width=5,fg_bg=cpair(colors.green,colors.black),active_fg_bg=cpair(colors.white,colors.black),dis_fg_bg=style.btn_disable,callback=set_burn} -- enable/disable controls based on group assignment (start button is separate) burn_cmd.register(u_ps, "auto_group_id", function (gid) @@ -156,10 +158,10 @@ local function new_view(root) burn_cmd.register(u_ps, "burn_rate", burn_cmd.set_value) burn_cmd.register(u_ps, "max_burn", burn_cmd.set_max) - local start = HazardButton{parent=u_div,x=2,y=11,text="START",accent=colors.lightBlue,dis_colors=dis_colors,callback=unit.start,timeout=3,fg_bg=hzd_fg_bg} - local ack_a = HazardButton{parent=u_div,x=12,y=11,text="ACK \x13",accent=colors.orange,dis_colors=dis_colors,callback=unit.ack_alarms,timeout=3,fg_bg=hzd_fg_bg} - local scram = HazardButton{parent=u_div,x=2,y=15,text="SCRAM",accent=colors.yellow,dis_colors=dis_colors,callback=unit.scram,timeout=3,fg_bg=hzd_fg_bg} - local reset = HazardButton{parent=u_div,x=12,y=15,text="RESET",accent=colors.red,dis_colors=dis_colors,callback=unit.reset_rps,timeout=3,fg_bg=hzd_fg_bg} + local start = HazardButton{parent=u_div,x=2,y=11,text="START",accent=colors.lightBlue,callback=unit.start,timeout=3,fg_bg=hzd_fg_bg,dis_colors=hzd_dis_colors} + local ack_a = HazardButton{parent=u_div,x=12,y=11,text="ACK \x13",accent=colors.orange,callback=unit.ack_alarms,timeout=3,fg_bg=hzd_fg_bg,dis_colors=hzd_dis_colors} + local scram = HazardButton{parent=u_div,x=2,y=15,text="SCRAM",accent=colors.yellow,callback=unit.scram,timeout=3,fg_bg=hzd_fg_bg,dis_colors=hzd_dis_colors} + local reset = HazardButton{parent=u_div,x=12,y=15,text="RESET",accent=colors.red,callback=unit.reset_rps,timeout=3,fg_bg=hzd_fg_bg,dis_colors=hzd_dis_colors} unit.start_ack = start.on_response unit.ack_alarms_ack = ack_a.on_response @@ -192,8 +194,8 @@ local function new_view(root) TextBox{parent=f_div,y=1,text="Facility Commands",alignment=ALIGN.CENTER} - local scram = HazardButton{parent=f_div,x=5,y=6,text="FAC SCRAM",accent=colors.yellow,dis_colors=dis_colors,callback=process.fac_scram,timeout=3,fg_bg=hzd_fg_bg} - local ack_a = HazardButton{parent=f_div,x=7,y=11,text="ACK \x13",accent=colors.orange,dis_colors=dis_colors,callback=process.fac_ack_alarms,timeout=3,fg_bg=hzd_fg_bg} + local scram = HazardButton{parent=f_div,x=5,y=6,text="FAC SCRAM",accent=colors.yellow,dis_colors=hzd_dis_colors,callback=process.fac_scram,timeout=3,fg_bg=hzd_fg_bg} + local ack_a = HazardButton{parent=f_div,x=7,y=11,text="ACK \x13",accent=colors.orange,dis_colors=hzd_dis_colors,callback=process.fac_ack_alarms,timeout=3,fg_bg=hzd_fg_bg} db.facility.scram_ack = scram.on_response db.facility.ack_alarms_ack = ack_a.on_response diff --git a/pocket/ui/apps/process.lua b/pocket/ui/apps/process.lua index bfe0f1f..ccc2423 100644 --- a/pocket/ui/apps/process.lua +++ b/pocket/ui/apps/process.lua @@ -36,14 +36,19 @@ local border = core.border local APP_ID = pocket.APP_ID +local label_fg_bg = style.label local lu_col = style.label_unit_pair local text_fg = style.text_fg + +local field_fg_bg = style.field +local field_dis_fg_bg = style.field_disable + local red_ind_s = style.icon_states.red_ind_s local yel_ind_s = style.icon_states.yel_ind_s local grn_ind_s = style.icon_states.grn_ind_s local wht_ind_s = style.icon_states.wht_ind_s -local hzd_fg_bg = cpair(colors.white, colors.gray) +local hzd_fg_bg = style.hzd_fg_bg local dis_colors = cpair(colors.white, colors.lightGray) -- new process control page view @@ -59,15 +64,12 @@ local function new_view(root) local main = Div{parent=frame,x=1,y=1} TextBox{parent=load_div,y=12,text="Loading...",alignment=ALIGN.CENTER} - WaitingAnim{parent=load_div,x=math.floor(main.get_width()/2)-1,y=8,fg_bg=cpair(colors.green,colors._INHERIT)} + WaitingAnim{parent=load_div,x=math.floor(main.get_width()/2)-1,y=8,fg_bg=cpair(colors.purple,colors._INHERIT)} local load_pane = MultiPane{parent=main,x=1,y=1,panes={load_div,main}} app.set_sidebar({ { label = " # ", tall = true, color = core.cpair(colors.black, colors.green), callback = db.nav.go_home } }) - local btn_fg_bg = cpair(colors.green, colors.black) - local btn_active = cpair(colors.white, colors.black) - local page_div = nil ---@type Div|nil -- load the app (create the elements) @@ -108,9 +110,9 @@ local function new_view(root) TextBox{parent=u_div,y=1,text="Reactor Unit #"..i,alignment=ALIGN.CENTER} - TextBox{parent=u_div,y=3,text="Auto Rate Limit",fg_bg=cpair(colors.lightGray,colors.black)} - rate_limits[i] = NumberField{parent=u_div,x=1,y=4,width=16,default=0.01,min=0.01,max_frac_digits=2,max_chars=8,allow_decimal=true,align_right=true,fg_bg=cpair(colors.white,colors.gray),dis_fg_bg=cpair(colors.gray,colors.lightGray)} - TextBox{parent=u_div,x=18,y=4,text="mB/t",width=4,fg_bg=cpair(colors.lightGray,colors.black)} + TextBox{parent=u_div,y=3,text="Auto Rate Limit",fg_bg=label_fg_bg} + rate_limits[i] = NumberField{parent=u_div,x=1,y=4,width=16,default=0.01,min=0.01,max_frac_digits=2,max_chars=8,allow_decimal=true,align_right=true,fg_bg=field_fg_bg,dis_fg_bg=field_dis_fg_bg} + TextBox{parent=u_div,x=18,y=4,text="mB/t",width=4,fg_bg=label_fg_bg} rate_limits[i].register(unit.unit_ps, "max_burn", rate_limits[i].set_max) rate_limits[i].register(unit.unit_ps, "burn_limit", rate_limits[i].set_value) @@ -134,7 +136,7 @@ local function new_view(root) local function _set_group(value) process.set_group(i, value) end - local group = RadioButton{parent=u_div,y=10,options=types.AUTO_GROUP_NAMES,callback=_set_group,radio_colors=cpair(colors.lightGray,colors.gray),select_color=colors.purple,dis_fg_bg=cpair(colors.gray,colors.black)} + local group = RadioButton{parent=u_div,y=10,options=types.AUTO_GROUP_NAMES,callback=_set_group,radio_colors=cpair(colors.lightGray,colors.gray),select_color=colors.purple,dis_fg_bg=style.btn_disable} -- can't change group if auto is engaged regardless of if this unit is part of auto control group.register(f_ps, "auto_active", function (auto_active) @@ -144,7 +146,7 @@ local function new_view(root) group.register(u_ps, "auto_group_id", function (gid) group.set_value(gid + 1) end) TextBox{parent=u_div,y=16,text="Assigned Group",fg_bg=style.label} - local auto_grp = TextBox{parent=u_div,text="Manual",width=11,fg_bg=cpair(colors.white,colors.gray)} + local auto_grp = TextBox{parent=u_div,text="Manual",width=11,fg_bg=text_fg} auto_grp.register(u_ps, "auto_group", auto_grp.set_value) @@ -167,17 +169,17 @@ local function new_view(root) mode.register(f_ps, "process_mode", mode.set_value) - TextBox{parent=o_div,y=9,text="Burn Rate Target",fg_bg=cpair(colors.lightGray,colors.black)} - local b_target = NumberField{parent=o_div,x=1,y=10,width=15,default=0.01,min=0.01,max_frac_digits=2,max_chars=8,allow_decimal=true,align_right=true,fg_bg=cpair(colors.white,colors.gray),dis_fg_bg=cpair(colors.gray,colors.lightGray)} - TextBox{parent=o_div,x=17,y=10,text="mB/t",fg_bg=cpair(colors.lightGray,colors.black)} + TextBox{parent=o_div,y=9,text="Burn Rate Target",fg_bg=label_fg_bg} + local b_target = NumberField{parent=o_div,x=1,y=10,width=15,default=0.01,min=0.01,max_frac_digits=2,max_chars=8,allow_decimal=true,align_right=true,fg_bg=field_fg_bg,dis_fg_bg=field_dis_fg_bg} + TextBox{parent=o_div,x=17,y=10,text="mB/t",fg_bg=label_fg_bg} - TextBox{parent=o_div,y=12,text="Charge Level Target",fg_bg=cpair(colors.lightGray,colors.black)} - local c_target = NumberField{parent=o_div,x=1,y=13,width=15,default=0,min=0,max_chars=16,align_right=true,fg_bg=cpair(colors.white,colors.gray),dis_fg_bg=cpair(colors.gray,colors.lightGray)} - TextBox{parent=o_div,x=17,y=13,text="M"..db.energy_label,fg_bg=cpair(colors.lightGray,colors.black)} + TextBox{parent=o_div,y=12,text="Charge Level Target",fg_bg=label_fg_bg} + local c_target = NumberField{parent=o_div,x=1,y=13,width=15,default=0,min=0,max_chars=16,align_right=true,fg_bg=field_fg_bg,dis_fg_bg=field_dis_fg_bg} + TextBox{parent=o_div,x=17,y=13,text="M"..db.energy_label,fg_bg=label_fg_bg} - TextBox{parent=o_div,y=15,text="Generation Target",fg_bg=cpair(colors.lightGray,colors.black)} - local g_target = NumberField{parent=o_div,x=1,y=16,width=15,default=0,min=0,max_chars=16,align_right=true,fg_bg=cpair(colors.white,colors.gray),dis_fg_bg=cpair(colors.gray,colors.lightGray)} - TextBox{parent=o_div,x=17,y=16,text="k"..db.energy_label.."/t",fg_bg=cpair(colors.lightGray,colors.black)} + TextBox{parent=o_div,y=15,text="Generation Target",fg_bg=label_fg_bg} + local g_target = NumberField{parent=o_div,x=1,y=16,width=15,default=0,min=0,max_chars=16,align_right=true,fg_bg=field_fg_bg,dis_fg_bg=field_dis_fg_bg} + TextBox{parent=o_div,x=17,y=16,text="k"..db.energy_label.."/t",fg_bg=label_fg_bg} b_target.register(f_ps, "process_burn_target", b_target.set_value) c_target.register(f_ps, "process_charge_target", c_target.set_value) @@ -209,8 +211,8 @@ local function new_view(root) db.energy_convert_to_fe(g_target.get_value()), limits) end - local start = HazardButton{parent=c_div,x=2,y=9,text="START",accent=colors.lightBlue,dis_colors=dis_colors,callback=_start_auto,timeout=3,fg_bg=hzd_fg_bg} - local stop = HazardButton{parent=c_div,x=13,y=9,text="STOP",accent=colors.red,dis_colors=dis_colors,callback=process.process_stop,timeout=3,fg_bg=hzd_fg_bg} + local start = HazardButton{parent=c_div,x=2,y=9,text="START",accent=colors.lightBlue,callback=_start_auto,timeout=3,fg_bg=hzd_fg_bg,dis_colors=dis_colors} + local stop = HazardButton{parent=c_div,x=13,y=9,text="STOP",accent=colors.red,callback=process.process_stop,timeout=3,fg_bg=hzd_fg_bg,dis_colors=dis_colors} db.facility.start_ack = start.on_response db.facility.stop_ack = stop.on_response @@ -267,17 +269,17 @@ local function new_view(root) local auto_scram = IconIndicator{parent=a_div,y=3,label="Automatic SCRAM",states=red_ind_s} - TextBox{parent=a_div,y=5,text="Induction Matrix",fg_bg=cpair(colors.lightGray,colors.black)} + TextBox{parent=a_div,y=5,text="Induction Matrix",fg_bg=label_fg_bg} local matrix_dc = IconIndicator{parent=a_div,label="Disconnected",states=yel_ind_s} local matrix_fill = IconIndicator{parent=a_div,label="Charge High",states=red_ind_s} - TextBox{parent=a_div,y=9,text="Assigned Units",fg_bg=cpair(colors.lightGray,colors.black)} + TextBox{parent=a_div,y=9,text="Assigned Units",fg_bg=label_fg_bg} local unit_crit = IconIndicator{parent=a_div,label="Critical Alarm",states=red_ind_s} - TextBox{parent=a_div,y=12,text="Facility",fg_bg=cpair(colors.lightGray,colors.black)} + TextBox{parent=a_div,y=12,text="Facility",fg_bg=label_fg_bg} local fac_rad_h = IconIndicator{parent=a_div,label="Radiation High",states=red_ind_s} - TextBox{parent=a_div,y=15,text="Generation Rate Mode",fg_bg=cpair(colors.lightGray,colors.black)} + TextBox{parent=a_div,y=15,text="Generation Rate Mode",fg_bg=label_fg_bg} local gen_fault = IconIndicator{parent=a_div,label="Control Fault",states=yel_ind_s} auto_scram.register(f_ps, "auto_scram", auto_scram.update) diff --git a/pocket/ui/style.lua b/pocket/ui/style.lua index 4a06de7..ff7fc9b 100644 --- a/pocket/ui/style.lua +++ b/pocket/ui/style.lua @@ -10,12 +10,19 @@ local cpair = core.cpair -- GLOBAL -- -style.root = cpair(colors.white, colors.black) -style.header = cpair(colors.white, colors.gray) -style.text_fg = cpair(colors.white, colors._INHERIT) -style.label = cpair(colors.lightGray, colors.black) +style.root = cpair(colors.white, colors.black) +style.header = cpair(colors.white, colors.gray) +style.text_fg = cpair(colors.white, colors._INHERIT) + +style.label = cpair(colors.lightGray, colors.black) style.label_unit_pair = cpair(colors.lightGray, colors.lightGray) +style.field = cpair(colors.white, colors.gray) +style.field_disable = cpair(colors.gray, colors.lightGray) +style.btn_disable = cpair(colors.gray, colors.black) +style.hzd_fg_bg = cpair(colors.white, colors.gray) +style.hzd_dis_colors = cpair(colors.white, colors.lightGray) + style.colors = { { c = colors.red, hex = 0xdf4949 }, { c = colors.orange, hex = 0xffb659 },