diff --git a/Client/debugger/cmd_gate_test.go b/Client/debugger/controller/cmd_gate_test.go similarity index 98% rename from Client/debugger/cmd_gate_test.go rename to Client/debugger/controller/cmd_gate_test.go index 1ca0ad5..da9b010 100644 --- a/Client/debugger/cmd_gate_test.go +++ b/Client/debugger/controller/cmd_gate_test.go @@ -1,4 +1,4 @@ -package main +package controller import ( "testing" diff --git a/Client/debugger/martecontrol.go b/Client/debugger/controller/martecontrol.go similarity index 98% rename from Client/debugger/martecontrol.go rename to Client/debugger/controller/martecontrol.go index 1896cda..a925bb3 100644 --- a/Client/debugger/martecontrol.go +++ b/Client/debugger/controller/martecontrol.go @@ -1,4 +1,9 @@ -package main +// Package controller implements MarteController, the shared TCP/UDP client +// logic that drives a running MARTe2 DebugService+TCPLogger instance. It is +// consumed both by the Client/debugger browser-facing WebSocket server +// (package main, via NewMarteController) and headlessly by the +// Test/E2E/suite/debugclient E2E test tool (via NewHeadlessMarteController). +package controller import ( "bufio" @@ -21,9 +26,9 @@ import ( // Command safety gate (CR-4) // --------------------------------------------------------------------------- -// dangerousCommandsEnabled gates commands that mutate the RT application state +// DangerousCommandsEnabled gates commands that mutate the RT application state // (FORCE, PAUSE, RESUME, STEP, BREAK, MSG). Set via --enable-dangerous-commands. -var dangerousCommandsEnabled = false +var DangerousCommandsEnabled = false // dangerousCommands is the set of MARTe2 commands that can change signal values // or alter execution flow. Without --enable-dangerous-commands these are blocked @@ -319,7 +324,7 @@ func (m *MarteController) HandleBrowserCommand(msg []byte) { // (DISCOVER, TREE, INFO, LS, VALUE, TRACE, UNTRACE, STEP_STATUS) are // forwarded to the MARTe2 TCP control connection. if isDangerousCommand(cmd) { - if !dangerousCommandsEnabled { + if !DangerousCommandsEnabled { m.sink(map[string]any{ "type": "log", "time": time.Now().Format("15:04:05.000"), "level": "WARNING", diff --git a/Client/debugger/main.go b/Client/debugger/main.go index f9156ce..c6dd32f 100644 --- a/Client/debugger/main.go +++ b/Client/debugger/main.go @@ -10,6 +10,8 @@ import ( "net/http" "os" + "marte2debugger/controller" + "marte2/common/wshub" ) @@ -21,7 +23,7 @@ var staticFiles embed.FS func main() { addr := flag.String("addr", ":7777", "HTTP listen address") sourcesFile := flag.String("sources-file", "", "JSON file for persistent source list") - flag.BoolVar(&dangerousCommandsEnabled, "enable-dangerous-commands", false, + flag.BoolVar(&controller.DangerousCommandsEnabled, "enable-dangerous-commands", false, "Allow FORCE/PAUSE/RESUME/STEP/BREAK/MSG commands from the browser (CR-4 safety gate)") flag.Parse() @@ -29,7 +31,7 @@ func main() { sm := wshub.NewSourceManager(hub, *sourcesFile) hub.SetSourceManager(sm) - ctrl := NewMarteController(hub) + ctrl := controller.NewMarteController(hub) go hub.Run()