From b8a59a58ebfb87186a68e565155ad6600e424a8e Mon Sep 17 00:00:00 2001 From: Deborah Date: Fri, 5 Dec 2025 12:21:14 +1030 Subject: [PATCH 1/2] oceantv broadcast: renamed 'camera' field in broadcastContext to 'hardware' all of the instances where the camera field has been called (and the broadcastContext field) have been edited to read 'hardware' not 'camera'. --- cmd/oceanbench/package-lock.json | 9 ++++++ cmd/oceantv/broadcast_hardware_machine.go | 28 +++++++++---------- .../broadcast_hardware_machine_test.go | 4 +-- cmd/oceantv/broadcast_machine_test.go | 6 ++-- cmd/oceantv/broadcast_states.go | 14 +++++----- cmd/oceantv/broadcast_test.go | 2 +- cmd/oceantv/system.go | 2 +- 7 files changed, 37 insertions(+), 28 deletions(-) diff --git a/cmd/oceanbench/package-lock.json b/cmd/oceanbench/package-lock.json index 3e2204b9..46745b8d 100644 --- a/cmd/oceanbench/package-lock.json +++ b/cmd/oceanbench/package-lock.json @@ -56,6 +56,7 @@ "version": "7.23.7", "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.23.7.tgz", "integrity": "sha512-+UpDgowcmqe36d4NwqvKsyPMlOLNGMsfMmQ5WGCu+siCe3t3dfe9njrzGfdN4qq+bcNUt0+Vw6haRxBOycs4dw==", + "peer": true, "dependencies": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.23.5", @@ -1649,6 +1650,7 @@ "url": "https://opencollective.com/csstools" } ], + "peer": true, "engines": { "node": "^14 || ^16 || >=18" }, @@ -1671,6 +1673,7 @@ "url": "https://opencollective.com/csstools" } ], + "peer": true, "engines": { "node": "^14 || ^16 || >=18" } @@ -2487,6 +2490,7 @@ "url": "https://github.com/sponsors/ai" } ], + "peer": true, "dependencies": { "caniuse-lite": "^1.0.30001565", "electron-to-chromium": "^1.4.601", @@ -3277,6 +3281,7 @@ "version": "2.79.1", "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.1.tgz", "integrity": "sha512-uKxbd0IhMZOhjAiD5oAFp7BqvkA4Dv47qpOCtaNvng4HBwdbWtdOh8f5nZNuk2rp51PMGk3bzfWu5oayNEuYnw==", + "peer": true, "bin": { "rollup": "dist/bin/rollup" }, @@ -4965,6 +4970,7 @@ "url": "https://github.com/sponsors/ai" } ], + "peer": true, "dependencies": { "nanoid": "^3.3.7", "picocolors": "^1.0.0", @@ -5001,6 +5007,7 @@ "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.15.tgz", "integrity": "sha512-rEYkQOMUCEMhsKbK66tbEU9QVIxbhN18YiniAwA7XQYTVBqrBy+P2p5JcdqsHgKM2zWylp8d7J6eszocfds5Sw==", "dev": true, + "peer": true, "dependencies": { "cssesc": "^3.0.0", "util-deprecate": "^1.0.2" @@ -5398,6 +5405,7 @@ "version": "3.29.4", "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.29.4.tgz", "integrity": "sha512-oWzmBZwvYrU0iJHtDmhsm662rC15FRXmcjCk1xD771dFDx5jJ02ufAQQTn0etB2emNk4J9EZg/yWKpsn9BWGRw==", + "peer": true, "bin": { "rollup": "dist/bin/rollup" }, @@ -6127,6 +6135,7 @@ "version": "4.9.5", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" diff --git a/cmd/oceantv/broadcast_hardware_machine.go b/cmd/oceantv/broadcast_hardware_machine.go index 157a9bc7..86b4d922 100644 --- a/cmd/oceantv/broadcast_hardware_machine.go +++ b/cmd/oceantv/broadcast_hardware_machine.go @@ -199,7 +199,7 @@ func (s *hardwareRestarting) handleHardwareShutdownFailedEvent(event hardwareShu } func (s *hardwareRestarting) cameraIsReporting() bool { - up, err := s.camera.isUp(s.broadcastContext, model.MacDecode(s.cfg.CameraMac)) + up, err := s.hardware.isUp(s.broadcastContext, model.MacDecode(s.cfg.CameraMac)) if err != nil { s.bus.publish(invalidConfigurationEvent{fmt.Errorf("could not get camera reporting status: %w", err)}) return false @@ -230,12 +230,12 @@ func (s *hardwareStarting) enter() { s.LastEntered = time.Now() // A MAC of 0 indicates it is invalid or unset, proceed with starting the camera. if s.cfg.ControllerMAC == 0 { - s.camera.start(s.broadcastContext) + s.hardware.start(s.broadcastContext) return } // The first check for any known hardware error states. - hwErr, err := s.camera.error(s.broadcastContext) + hwErr, err := s.hardware.error(s.broadcastContext) if err != nil { errWrapped := fmt.Errorf("could not get hardware error state: %w", err) s.log(errWrapped.Error()) @@ -263,7 +263,7 @@ func (s *hardwareStarting) enter() { // we have a controller that doesn't have the latest firmware. } - voltage, err := s.camera.voltage(s.broadcastContext) + voltage, err := s.hardware.voltage(s.broadcastContext) if err != nil { errWrapped := fmt.Errorf("could not get hardware voltage: %w", err) s.log(errWrapped.Error()) @@ -271,7 +271,7 @@ func (s *hardwareStarting) enter() { return } - alarmVoltage, err := s.camera.alarmVoltage(s.broadcastContext) + alarmVoltage, err := s.hardware.alarmVoltage(s.broadcastContext) if err != nil { errWrapped := fmt.Errorf("could not get alarm voltage: %w", err) s.log(errWrapped.Error()) @@ -279,7 +279,7 @@ func (s *hardwareStarting) enter() { return } - controllerIsOn, err := s.camera.isUp(s.broadcastContext, model.MacDecode(s.cfg.ControllerMAC)) + controllerIsOn, err := s.hardware.isUp(s.broadcastContext, model.MacDecode(s.cfg.ControllerMAC)) if err != nil { errWrapped := fmt.Errorf("could not get controller status: %w", err) s.log(errWrapped.Error()) @@ -314,8 +314,8 @@ func (s *hardwareStarting) enter() { } // Controller is reporting and we're above streaming voltage, let's power - // on the camera. - s.camera.start(s.broadcastContext) + // on the hardware. + s.hardware.start(s.broadcastContext) } func (s *hardwareStarting) exit() {} @@ -436,7 +436,7 @@ func newHardwareShuttingDown(ctx *broadcastContext) *hardwareShuttingDown { } func (s *hardwareShuttingDown) enter() { s.LastEntered = time.Now() - s.camera.shutdown(s.broadcastContext) + s.hardware.shutdown(s.broadcastContext) } func (s *hardwareShuttingDown) exit() {} @@ -500,7 +500,7 @@ func newHardwarePoweringOff(ctx *broadcastContext) *hardwarePoweringOff { } func (s *hardwarePoweringOff) enter() { s.LastEntered = time.Now() - s.camera.stop(s.broadcastContext) + s.hardware.stop(s.broadcastContext) } func (s *hardwarePoweringOff) exit() {} @@ -683,7 +683,7 @@ func (s *hardwareStopping) handleHardwarePowerOffFailedEvent(event hardwarePower } func (s *hardwareStopping) cameraIsReporting() bool { - up, err := s.camera.isUp(s.broadcastContext, model.MacDecode(s.cfg.CameraMac)) + up, err := s.hardware.isUp(s.broadcastContext, model.MacDecode(s.cfg.CameraMac)) if err != nil { s.bus.publish(invalidConfigurationEvent{fmt.Errorf("could not get camera reporting status: %w", err)}) return false @@ -843,7 +843,7 @@ func (sm *hardwareStateMachine) handleEvent(event event) error { func (sm *hardwareStateMachine) handleTimeEvent(t timeEvent) { sm.log("handling time event") eventIfStatus := func(e event, status bool) { - sm.ctx.camera.publishEventIfStatus(sm.ctx, e, status, sm.ctx.cfg.CameraMac, sm.ctx.store, sm.log, sm.ctx.bus.publish) + sm.ctx.hardware.publishEventIfStatus(sm.ctx, e, status, sm.ctx.cfg.CameraMac, sm.ctx.store, sm.log, sm.ctx.bus.publish) } switch sm.currentState.(type) { case *hardwareStarting: @@ -866,7 +866,7 @@ func (sm *hardwareStateMachine) handleTimeEvent(t timeEvent) { return } - voltage, err := sm.ctx.camera.voltage(sm.ctx) + voltage, err := sm.ctx.hardware.voltage(sm.ctx) if err != nil { errWrapped := fmt.Errorf("could not get hardware voltage: %v", err) sm.log(errWrapped.Error()) @@ -963,7 +963,7 @@ func (sm *hardwareStateMachine) handleHardwareStartRequestEvent(event hardwareSt case *hardwareOff, *hardwareRestarting: sm.transition(newHardwareStarting(sm.ctx)) case *hardwareStarting: - sm.ctx.camera.publishEventIfStatus(sm.ctx, hardwareStartedEvent{}, true, sm.ctx.cfg.CameraMac, sm.ctx.store, sm.log, sm.ctx.bus.publish) + sm.ctx.hardware.publishEventIfStatus(sm.ctx, hardwareStartedEvent{}, true, sm.ctx.cfg.CameraMac, sm.ctx.store, sm.log, sm.ctx.bus.publish) case *hardwareStopping: // Ignore and log. sm.log("ignoring hardware start request event since hardware is still stopping") diff --git a/cmd/oceantv/broadcast_hardware_machine_test.go b/cmd/oceantv/broadcast_hardware_machine_test.go index 03894e2a..a6f5c858 100644 --- a/cmd/oceantv/broadcast_hardware_machine_test.go +++ b/cmd/oceantv/broadcast_hardware_machine_test.go @@ -21,7 +21,7 @@ func TestGetHardwareStateStorage(t *testing.T) { }{ {"test hardware off", newHardwareOff()}, {"test hardware on", newHardwareOn()}, - {"test hardware starting", newHardwareStarting(&broadcastContext{camera: &dummyHardwareManager{}, logOutput: t.Log, notifier: newMockNotifier()})}, + {"test hardware starting", newHardwareStarting(&broadcastContext{hardware: &dummyHardwareManager{}, logOutput: t.Log, notifier: newMockNotifier()})}, {"test hardware stopping", newHardwareStopping(minimalMockBroadcastContext(t))}, {"test hardware restarting", newHardwareRestarting(minimalMockBroadcastContext(t))}, } @@ -361,7 +361,7 @@ func (h hardwareSystem) withForwardingService(fs ForwardingService) hardwareSyst func (h hardwareSystem) withHardwareManager(hm hardwareManager) hardwareSystemOption { return func(bs *hardwareSystem) error { - bs.ctx.camera = hm + bs.ctx.hardware = hm return nil } } diff --git a/cmd/oceantv/broadcast_machine_test.go b/cmd/oceantv/broadcast_machine_test.go index 81031f77..e6a0b1f7 100644 --- a/cmd/oceantv/broadcast_machine_test.go +++ b/cmd/oceantv/broadcast_machine_test.go @@ -1264,7 +1264,7 @@ func TestBroadcastStart(t *testing.T) { ) bCtx.man = newDummyManager(t, tt.cfg) - bCtx.camera = tt.hardwareMan + bCtx.hardware = tt.hardwareMan bCtx.fwd = newDummyForwardingService() bCtx.cfg = tt.cfg bCtx.bus = bus @@ -1293,10 +1293,10 @@ func TestBroadcastStart(t *testing.T) { } // Check that the hardware manager start was called/not called as expected. - startCalled := bCtx.camera.(*dummyHardwareManager).startCalled + startCalled := bCtx.hardware.(*dummyHardwareManager).startCalled if tt.expectHardwareStartCall != startCalled { t.Errorf("hardware manager start was/was not called as expected, expected: %v, got: %v", - tt.expectHardwareStartCall, bCtx.camera.(*dummyHardwareManager).startCalled) + tt.expectHardwareStartCall, bCtx.hardware.(*dummyHardwareManager).startCalled) } // Check that the broadcast manager start was called/not called as expected. diff --git a/cmd/oceantv/broadcast_states.go b/cmd/oceantv/broadcast_states.go index 8952d63a..87b0abc0 100644 --- a/cmd/oceantv/broadcast_states.go +++ b/cmd/oceantv/broadcast_states.go @@ -14,13 +14,13 @@ import ( ) type broadcastContext struct { - cfg *BroadcastConfig - man BroadcastManager - store Store - svc BroadcastService - fwd ForwardingService - bus eventBus - camera hardwareManager + cfg *BroadcastConfig + man BroadcastManager + store Store + svc BroadcastService + fwd ForwardingService + bus eventBus + hardware hardwareManager // When nil, defaults to log.Println. Useful to plug in test implementation. logOutput func(v ...any) diff --git a/cmd/oceantv/broadcast_test.go b/cmd/oceantv/broadcast_test.go index e2bcb74c..e6c7c08e 100644 --- a/cmd/oceantv/broadcast_test.go +++ b/cmd/oceantv/broadcast_test.go @@ -524,7 +524,7 @@ func standardMockBroadcastContext(t *testing.T, hardwareHealthy bool) *broadcast return &broadcastContext{ store: &dummyStore{}, svc: &dummyService{}, - camera: &dummyHardwareManager{hardwareHealthy: hardwareHealthy}, + hardware: &dummyHardwareManager{hardwareHealthy: hardwareHealthy}, notifier: newMockNotifier(), logOutput: t.Log, } diff --git a/cmd/oceantv/system.go b/cmd/oceantv/system.go index baf87983..4c0cb6b3 100644 --- a/cmd/oceantv/system.go +++ b/cmd/oceantv/system.go @@ -48,7 +48,7 @@ func withForwardingService(fs ForwardingService) broadcastSystemOption { func withHardwareManager(hm hardwareManager) broadcastSystemOption { return func(bs *broadcastSystem) error { - bs.ctx.camera = hm + bs.ctx.hardware = hm return nil } } From 44ecea2a1761dfc6a451d3cc4606c76d0461d6ae Mon Sep 17 00:00:00 2001 From: Deborah Date: Fri, 5 Dec 2025 12:35:46 +1030 Subject: [PATCH 2/2] remove file that shouldn't have been edited --- cmd/oceanbench/package-lock.json | 9 --------- 1 file changed, 9 deletions(-) diff --git a/cmd/oceanbench/package-lock.json b/cmd/oceanbench/package-lock.json index 46745b8d..3e2204b9 100644 --- a/cmd/oceanbench/package-lock.json +++ b/cmd/oceanbench/package-lock.json @@ -56,7 +56,6 @@ "version": "7.23.7", "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.23.7.tgz", "integrity": "sha512-+UpDgowcmqe36d4NwqvKsyPMlOLNGMsfMmQ5WGCu+siCe3t3dfe9njrzGfdN4qq+bcNUt0+Vw6haRxBOycs4dw==", - "peer": true, "dependencies": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.23.5", @@ -1650,7 +1649,6 @@ "url": "https://opencollective.com/csstools" } ], - "peer": true, "engines": { "node": "^14 || ^16 || >=18" }, @@ -1673,7 +1671,6 @@ "url": "https://opencollective.com/csstools" } ], - "peer": true, "engines": { "node": "^14 || ^16 || >=18" } @@ -2490,7 +2487,6 @@ "url": "https://github.com/sponsors/ai" } ], - "peer": true, "dependencies": { "caniuse-lite": "^1.0.30001565", "electron-to-chromium": "^1.4.601", @@ -3281,7 +3277,6 @@ "version": "2.79.1", "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.1.tgz", "integrity": "sha512-uKxbd0IhMZOhjAiD5oAFp7BqvkA4Dv47qpOCtaNvng4HBwdbWtdOh8f5nZNuk2rp51PMGk3bzfWu5oayNEuYnw==", - "peer": true, "bin": { "rollup": "dist/bin/rollup" }, @@ -4970,7 +4965,6 @@ "url": "https://github.com/sponsors/ai" } ], - "peer": true, "dependencies": { "nanoid": "^3.3.7", "picocolors": "^1.0.0", @@ -5007,7 +5001,6 @@ "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.15.tgz", "integrity": "sha512-rEYkQOMUCEMhsKbK66tbEU9QVIxbhN18YiniAwA7XQYTVBqrBy+P2p5JcdqsHgKM2zWylp8d7J6eszocfds5Sw==", "dev": true, - "peer": true, "dependencies": { "cssesc": "^3.0.0", "util-deprecate": "^1.0.2" @@ -5405,7 +5398,6 @@ "version": "3.29.4", "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.29.4.tgz", "integrity": "sha512-oWzmBZwvYrU0iJHtDmhsm662rC15FRXmcjCk1xD771dFDx5jJ02ufAQQTn0etB2emNk4J9EZg/yWKpsn9BWGRw==", - "peer": true, "bin": { "rollup": "dist/bin/rollup" }, @@ -6135,7 +6127,6 @@ "version": "4.9.5", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver"