Skip to content

Commit 4c87baf

Browse files
Enhance entity flow features with body control support
- Added new CSS styles for body control elements, including gradients for visual distinction. - Updated JavaScript to handle body state changes and integrate body control actions into the entity flow logic. - Introduced new mappings and extraction methods for body control messages in the intellicenter mappings. - Enhanced documentation to reflect new body state actions and their descriptions in the message documentation. - Improved message handling to differentiate between command requests and actual state broadcasts for body controls.
1 parent 02a2ed9 commit 4c87baf

6 files changed

Lines changed: 646 additions & 7 deletions

File tree

AGENTS.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Agent Guidelines for nodejs-poolcontroller-dashpanel
2+
3+
This document provides guidance for AI agents working on this codebase.
4+
5+
## Project Overview
6+
7+
This is the **dashboard/web UI** for nodejs-poolController, providing:
8+
- Message Manager for protocol analysis and debugging
9+
- Entity Flow Analyzer for entity-centric packet analysis
10+
- Real-time pool equipment monitoring interface
11+
12+
## Key Documentation
13+
14+
### Protocol & Entity Flow Analysis
15+
16+
When working with **Message Manager**, **Entity Flow**, **packet parsing**, or **protocol analysis**:
17+
18+
**ALWAYS READ FIRST**:
19+
- `.plan/ENTITY_FLOW_ANALYZER.md` - Complete guide to entity types, byte offsets, and extraction logic
20+
21+
This document contains:
22+
- Packet → Entity mapping tables with exact byte offsets
23+
- Circuit/Feature/Body state extraction logic
24+
- Flow Timeline (flame graph) span types
25+
- Step-by-step guide for adding new entity types
26+
- Common bugs and fixes (e.g., Action 2 circuit offset is 2, not 3)
27+
28+
### Message Documentation
29+
30+
When working with **packet structures** or **protocol messages**:
31+
- `server/messages/docs/messageDoc.json` - Detailed packet documentation
32+
- `server/messages/docs/entityFlow.json` - Entity type definitions and matchers
33+
- `server/messages/docs/constants.json` - Device address names and constants
34+
35+
### Key Source Files
36+
37+
| Area | Files |
38+
|------|-------|
39+
| Entity Flow Widget | `scripts/messages/entityFlow/entityFlow.widget.js` |
40+
| Entity Extraction | `scripts/messages/entityFlow/intellicenterMappings.js` |
41+
| Entity Flow Styles | `scripts/messages/entityFlow/entityFlow.css` |
42+
| Message List Widget | `scripts/messages/messageList/messageList.widget.js` |
43+
| Main Page | `pages/messageManager.html` |
44+
45+
## Critical Implementation Notes
46+
47+
### IntelliCenter Circuit Offsets
48+
49+
**Action 2 (Status Broadcast)** payload layout:
50+
```
51+
[0] = hours
52+
[1] = minutes
53+
[2] = circuits 1-8 ← Spa = bit 0, Pool = bit 5
54+
[3] = circuits 9-16
55+
[4] = circuits 17-24
56+
[5] = circuits 25-32
57+
[6] = circuits 33-40
58+
[7] = circuit groups (lower) + features 129-132 (upper nibble)
59+
...
60+
```
61+
62+
**Action 30/15 and 168/15** have circuits starting at byte 3 (different from Action 2).
63+
64+
### Body State Extraction
65+
66+
Body ON/OFF state is derived from circuit state:
67+
- **Spa** = Circuit 1 (bodyId=2 maps to circuitId=1)
68+
- **Pool** = Circuit 6 (bodyId=1 maps to circuitId=6)
69+
70+
### State Display: Command vs Actual
71+
72+
- `→ON` / `→OFF` = **Command** (request, WL→OCP or outbound)
73+
- `ON` / `OFF` = **Actual** state (Action 2 broadcast, OCP→Broadcast)
74+
75+
### Action 184 Body Control (v3.004+)
76+
77+
Payload layout: `[channelId, seq, format, reserved, targetHi, targetLo, data0, data1, data2, data3]`
78+
79+
| Target ID | Name | Byte 6 Meaning |
80+
|-----------|------|----------------|
81+
| `168,237` | Body Toggle | 0=OFF, 1=ON |
82+
| `212,182` | Body Context | Pre-toggle context |
83+
| `114,145` | Body Select | 0=Pool, 1=Spa |
84+
85+
### Flow Timeline Spans
86+
87+
The flame graph detects these span types:
88+
- **Config sweep** - Extended 222→30 sessions
89+
- **Config item** - Individual 222→30 pairs
90+
- **Set circuit** - 168/184 → ACK → state readback
91+
- **Body ctrl** - Action 184 with body target IDs (168,237 / 212,182 / 114,145 / 94,131 / 108,225)
92+
93+
## Related Projects
94+
95+
- `nodejs-poolController` - The main pool controller server (protocol handling, equipment control)
96+
- Protocol documentation: `/Users/rgoldin/Programming/nodejs-poolController/.plan/` directory
97+
98+
## Testing Changes
99+
100+
After modifying entity extraction or flow timeline logic:
101+
1. Load a replay ZIP with packet logs
102+
2. Select the relevant entity type
103+
3. Verify state extraction matches expected values
104+
4. Check that byte offsets shown in "Relevant Bytes" column are correct
105+
5. Test Flow Timeline spans appear for the expected packet sequences
106+

scripts/messages/entityFlow/entityFlow.css

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,9 @@
505505
.flow-span-set-circuit {
506506
background: linear-gradient(180deg, #a78bfa 0%, #8b5cf6 100%);
507507
}
508+
.flow-span-body-control {
509+
background: linear-gradient(180deg, #22c55e 0%, #16a34a 100%);
510+
}
508511

509512
/* Tick marks */
510513
.flow-tick {
@@ -532,6 +535,7 @@
532535
.swatch-config-sweep { background: #10b981; }
533536
.swatch-config-item { background: #3b82f6; }
534537
.swatch-set-circuit { background: #8b5cf6; }
538+
.swatch-body-control { background: #16a34a; }
535539
.swatch-bcast-2 { background: #f59e0b; }
536540
.swatch-bcast-204 { background: #ef4444; }
537541

@@ -889,6 +893,19 @@
889893
color: #64748b; /* Muted text */
890894
}
891895

896+
/* Muted rows: ACK packets and OCP→Broadcast 184 echoes (less important context) */
897+
.entity-timeline-table tbody tr.row-muted {
898+
opacity: 0.55;
899+
}
900+
901+
.entity-timeline-table tbody tr.row-muted:hover {
902+
opacity: 0.85;
903+
}
904+
905+
.entity-timeline-table tbody tr.row-muted td {
906+
color: #94a3b8; /* Lighter gray text */
907+
}
908+
892909
/* Column widths and colors */
893910
.col-time {
894911
width: 90px;
@@ -934,6 +951,11 @@
934951
color: var(--error-color, #ef4444);
935952
}
936953

954+
.state-command {
955+
font-style: italic;
956+
color: var(--warning-color, #f59e0b);
957+
}
958+
937959
/* Byte display */
938960
.byte-display {
939961
display: inline-flex;

0 commit comments

Comments
 (0)