Skip to content

Commit e85720e

Browse files
committed
Add PID blocks to syncPorts, update README with routing and port sync docs
1 parent 3fa7049 commit e85720e

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ src/
5959
│ │ ├── core/ # Constants, types, utilities
6060
│ │ ├── processing/ # Data processing, render queue
6161
│ │ └── renderers/ # Plotly and SVG renderers
62+
│ ├── routing/ # Orthogonal wire routing (A* pathfinding)
6263
│ ├── pyodide/ # Python runtime (backend, bridge)
6364
│ │ └── backend/ # Modular backend system (registry, state, types)
6465
│ │ └── pyodide/ # Pyodide Web Worker implementation
@@ -120,6 +121,19 @@ Worker (10 Hz) Main Thread UI (10 Hz)
120121
- **Non-blocking**: Simulation never waits for plot rendering
121122
- **extendTraces**: Scope plots append data incrementally instead of full re-render
122123

124+
### Wire Routing
125+
126+
PathView uses Simulink-style orthogonal wire routing with A* pathfinding:
127+
128+
- **Automatic routing**: Wires route around nodes with 90° bends only
129+
- **User waypoints**: Press `\` on selected edge to add manual waypoints
130+
- **Draggable waypoints**: Drag waypoint markers to reposition, double-click to delete
131+
- **Segment dragging**: Drag segment midpoints to create new waypoints
132+
- **Incremental updates**: Spatial indexing (O(1) node updates) for smooth dragging
133+
- **Hybrid routing**: Routes through user waypoints: Source → A* → W1 → A* → Target
134+
135+
Key files: `src/lib/routing/` (pathfinder, grid builder, route calculator)
136+
123137
### Key Abstractions
124138

125139
| Layer | Purpose | Key Files |
@@ -203,6 +217,27 @@ This generates TypeScript files in `src/lib/*/generated/` with:
203217

204218
Start the dev server and check that your block appears in the Block Library panel.
205219

220+
### Port Synchronization
221+
222+
Some blocks process inputs as parallel paths where each input has a corresponding output (e.g., Integrator, Amplifier, Sin). For these blocks, the UI only shows input port controls and outputs auto-sync.
223+
224+
Configure in `src/lib/nodes/uiConfig.ts`:
225+
226+
```typescript
227+
export const syncPortBlocks = new Set([
228+
'Integrator',
229+
'Differentiator',
230+
'Delay',
231+
'PID',
232+
'PID_Antiwindup',
233+
'Amplifier',
234+
'Sin', 'Cos', 'Tan', 'Tanh',
235+
'Abs', 'Sqrt', 'Exp', 'Log', 'Log10',
236+
'Mod', 'Clip', 'Pow',
237+
'SampleHold'
238+
]);
239+
```
240+
206241
---
207242

208243
## Adding New Toolboxes
@@ -448,6 +483,7 @@ Press `?` to see all shortcuts in the app. Key shortcuts:
448483
| **Transform** | `R` | Rotate 90° |
449484
| | `X` / `Y` | Flip H/V |
450485
| | `Arrows` | Nudge selection |
486+
| **Wires** | `\` | Add waypoint to selected edge |
451487
| **View** | `F` | Fit view |
452488
| | `H` | Go to root |
453489
| | `T` | Toggle theme |

src/lib/nodes/uiConfig.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export const syncPortBlocks = new Set([
1313
'Integrator',
1414
'Differentiator',
1515
'Delay',
16+
'PID',
17+
'PID_Antiwindup',
1618

1719
// Algebraic blocks (element-wise operations)
1820
'Amplifier',

0 commit comments

Comments
 (0)