From 3e194dea6a1512af28283080cffcd32b7022ec67 Mon Sep 17 00:00:00 2001 From: Thomas Ball Date: Tue, 30 Sep 2025 11:54:53 -0700 Subject: [PATCH 1/7] power consumption example --- sim/dalboard.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sim/dalboard.ts b/sim/dalboard.ts index c4af045ef57..263e76a42ba 100644 --- a/sim/dalboard.ts +++ b/sim/dalboard.ts @@ -133,6 +133,11 @@ namespace pxsim { } + // power consumption + powerConsumption(): number { + return 0.0 + } + initAsync(msg: SimulatorRunMessage): Promise { super.initAsync(msg); From 4ed7a13ec0162978b0e96cc26b5c5c6d98abfb2e Mon Sep 17 00:00:00 2001 From: Thomas Ball Date: Wed, 1 Oct 2025 12:10:19 -0700 Subject: [PATCH 2/7] count # of yields --- sim/dalboard.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sim/dalboard.ts b/sim/dalboard.ts index 263e76a42ba..a8760067cd7 100644 --- a/sim/dalboard.ts +++ b/sim/dalboard.ts @@ -36,6 +36,8 @@ namespace pxsim { // board hardware version hardwareVersion = 1; + yieldCount = 0 + constructor() { super() @@ -132,10 +134,8 @@ namespace pxsim { } } - - // power consumption - powerConsumption(): number { - return 0.0 + onEveryYield() { + console.log(`yield count = ${this.yieldCount++}`) } initAsync(msg: SimulatorRunMessage): Promise { From b5860b1eff92107507b8135417dd35e5e18394c4 Mon Sep 17 00:00:00 2001 From: Thomas Ball Date: Wed, 1 Oct 2025 12:41:59 -0700 Subject: [PATCH 3/7] print count of leds --- sim/dalboard.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sim/dalboard.ts b/sim/dalboard.ts index a8760067cd7..43949267ad7 100644 --- a/sim/dalboard.ts +++ b/sim/dalboard.ts @@ -135,7 +135,11 @@ namespace pxsim { } onEveryYield() { - console.log(`yield count = ${this.yieldCount++}`) + let count = 0 + const data = this.ledMatrixState.image.data + for (let i = 0; i < data.length; ++i) + if (data[i]) count++ + console.log(`led count = ${count}`) } initAsync(msg: SimulatorRunMessage): Promise { From 890367da488e0bc98d330c15d10bbcb724831b75 Mon Sep 17 00:00:00 2001 From: Thomas Ball Date: Wed, 1 Oct 2025 12:55:07 -0700 Subject: [PATCH 4/7] use data vis --- sim/dalboard.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sim/dalboard.ts b/sim/dalboard.ts index 43949267ad7..1a67a069a71 100644 --- a/sim/dalboard.ts +++ b/sim/dalboard.ts @@ -139,7 +139,7 @@ namespace pxsim { const data = this.ledMatrixState.image.data for (let i = 0; i < data.length; ++i) if (data[i]) count++ - console.log(`led count = ${count}`) + pxsim.control.__log(1, `leds: ${count}\n`) } initAsync(msg: SimulatorRunMessage): Promise { From 8fe08f5250b83aaec1db6fbe20d423ecfe83e49d Mon Sep 17 00:00:00 2001 From: Thomas Ball Date: Tue, 2 Dec 2025 11:01:13 -0800 Subject: [PATCH 5/7] update dal board --- sim/dalboard.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sim/dalboard.ts b/sim/dalboard.ts index 1a67a069a71..a4c7c5bf48a 100644 --- a/sim/dalboard.ts +++ b/sim/dalboard.ts @@ -134,12 +134,21 @@ namespace pxsim { } } + private energyVariables: Variables = { + ledCount: 0 + } + + getVariables() { + return this.energyVariables + } + onEveryYield() { let count = 0 const data = this.ledMatrixState.image.data for (let i = 0; i < data.length; ++i) if (data[i]) count++ - pxsim.control.__log(1, `leds: ${count}\n`) + this.energyVariables.ledCount = count + pxsim.control.__log(0,`${this.energyVariables}`) } initAsync(msg: SimulatorRunMessage): Promise { From 8e29de59b76b52160c74e91e1686cde1ef91cb50 Mon Sep 17 00:00:00 2001 From: Thomas Ball Date: Wed, 3 Dec 2025 12:38:50 -0800 Subject: [PATCH 6/7] set variable --- sim/dalboard.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sim/dalboard.ts b/sim/dalboard.ts index a4c7c5bf48a..73b50059e52 100644 --- a/sim/dalboard.ts +++ b/sim/dalboard.ts @@ -138,7 +138,11 @@ namespace pxsim { ledCount: 0 } - getVariables() { + setBoardVariable(name: string, value: number) { + this.energyVariables[name] = value + } + + getBoardVariables() { return this.energyVariables } From 1053a0081f631e8e9524f3a0260007954737a5c2 Mon Sep 17 00:00:00 2001 From: Thomas Ball Date: Mon, 27 Apr 2026 13:45:44 -0700 Subject: [PATCH 7/7] add setTimeout --- sim/dalboard.ts | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/sim/dalboard.ts b/sim/dalboard.ts index 73b50059e52..fb19dbcbd5c 100644 --- a/sim/dalboard.ts +++ b/sim/dalboard.ts @@ -125,6 +125,14 @@ namespace pxsim { this.builtinPartVisuals["microservo"] = (xy: visuals.Coord) => visuals.mkMicroServoPart(xy); this.samplesState = new samples.SamplesState(); + + const computeCount = () => { + const cnt = this.energyVariables.ledCountLast100ms = this.getLedCount() + if (cnt > 0) + pxsim.control.__log(0,`100ms: led count = ${cnt}\n`) + setTimeout(computeCount, 100) + } + setTimeout(computeCount,100) } ensureHardwareVersion(version: number) { @@ -135,7 +143,8 @@ namespace pxsim { } private energyVariables: Variables = { - ledCount: 0 + ledCount: 0, + ledCountLast100ms: 0 } setBoardVariable(name: string, value: number) { @@ -146,13 +155,17 @@ namespace pxsim { return this.energyVariables } - onEveryYield() { + + getLedCount() { let count = 0 const data = this.ledMatrixState.image.data for (let i = 0; i < data.length; ++i) if (data[i]) count++ - this.energyVariables.ledCount = count - pxsim.control.__log(0,`${this.energyVariables}`) + return count + } + onEveryYield() { + this.energyVariables.ledCount = this.getLedCount() + pxsim.control.__log(0,`yield: ${this.energyVariables}`) } initAsync(msg: SimulatorRunMessage): Promise {