update emulator
This commit is contained in:
@@ -34,9 +34,10 @@ const (
|
||||
|
||||
// Model is the main Bubble Tea model
|
||||
type Model struct {
|
||||
state *device.DeviceState
|
||||
logBuffer *LogBuffer
|
||||
notifyCh chan string // Channel to send alarm notifications
|
||||
state *device.DeviceState
|
||||
logBuffer *LogBuffer
|
||||
notifyCh chan string // Channel to send alarm notifications
|
||||
disconnectCh chan struct{} // Channel to trigger disconnect all clients
|
||||
|
||||
controls []Control
|
||||
focusedCtrl int
|
||||
@@ -51,11 +52,12 @@ type Model struct {
|
||||
}
|
||||
|
||||
// NewModel creates a new TUI model
|
||||
func NewModel(state *device.DeviceState, logBuffer *LogBuffer, notifyCh chan string) Model {
|
||||
func NewModel(state *device.DeviceState, logBuffer *LogBuffer, notifyCh chan string, disconnectCh chan struct{}) Model {
|
||||
m := Model{
|
||||
state: state,
|
||||
logBuffer: logBuffer,
|
||||
notifyCh: notifyCh,
|
||||
disconnectCh: disconnectCh,
|
||||
focusedCtrl: 0,
|
||||
focusedPanel: PanelControls,
|
||||
logOffset: 0,
|
||||
@@ -84,13 +86,19 @@ func NewModel(state *device.DeviceState, logBuffer *LogBuffer, notifyCh chan str
|
||||
Type: ControlButton,
|
||||
Action: func() {
|
||||
state.TriggerAlarm("TAMPER")
|
||||
logBuffer.Info("Tamper alarm triggered manually")
|
||||
logBuffer.Info("Tamper alarm triggered - disconnecting all clients")
|
||||
if notifyCh != nil {
|
||||
select {
|
||||
case notifyCh <- "ALARM: TAMPER":
|
||||
default:
|
||||
}
|
||||
}
|
||||
if disconnectCh != nil {
|
||||
select {
|
||||
case disconnectCh <- struct{}{}:
|
||||
default:
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user