|
1 | 1 | # plcviz |
2 | 2 |
|
3 | | -PLC code visualization library for Rust. |
| 3 | +PLC code visualization tool - generate SVG diagrams from L5X files. |
4 | 4 |
|
5 | | -Generate SVG diagrams from L5X files: |
6 | | -- Call graphs (routine → routine) |
7 | | -- Tag dataflow |
8 | | -- AOI dependencies |
9 | | -- Program structure |
| 5 | +## Features |
| 6 | + |
| 7 | +- **Structure graphs**: Program → Routine containment hierarchy |
| 8 | +- **Call graphs**: JSR (Jump to Subroutine) relationships between routines |
| 9 | +- **Combined graphs**: Structure + call edges together |
| 10 | +- **Multiple export types**: Controller, Program, and AOI exports |
| 11 | + |
| 12 | +## Installation |
| 13 | + |
| 14 | +```bash |
| 15 | +cargo install --path . |
| 16 | +``` |
10 | 17 |
|
11 | 18 | ## Usage |
12 | 19 |
|
13 | | -```rust |
14 | | -use l5x::L5xFile; |
15 | | -use plcviz::{CallGraph, SvgRenderer}; |
| 20 | +```bash |
| 21 | +# Generate structure graph (default) |
| 22 | +plcviz project.L5X > structure.svg |
| 23 | + |
| 24 | +# Generate call graph |
| 25 | +plcviz -t call project.L5X > calls.svg |
16 | 26 |
|
17 | | -let project = L5xFile::parse_file("project.l5x")?; |
18 | | -let graph = CallGraph::from_project(&project); |
19 | | -let svg = SvgRenderer::new().render(&graph); |
| 27 | +# Generate combined graph (structure + calls) |
| 28 | +plcviz -t combined project.L5X > combined.svg |
20 | 29 |
|
21 | | -std::fs::write("call_graph.svg", svg)?; |
| 30 | +# Include AOIs in the graph |
| 31 | +plcviz -a project.L5X > with_aois.svg |
| 32 | + |
| 33 | +# Generate example graph (no L5X file needed) |
| 34 | +plcviz example > example.svg |
22 | 35 | ``` |
23 | 36 |
|
| 37 | +## Graph Types |
| 38 | + |
| 39 | +| Type | Description | |
| 40 | +|------|-------------| |
| 41 | +| `structure` | Containment hierarchy (Programs → Routines) | |
| 42 | +| `call` | JSR calls between routines | |
| 43 | +| `dataflow` | Tag read/write relationships (example only) | |
| 44 | +| `combined` | Structure + call edges | |
| 45 | + |
| 46 | +## Supported L5X Export Types |
| 47 | + |
| 48 | +- **Controller**: Full project exports (multiple programs) |
| 49 | +- **Program**: Single program exports |
| 50 | +- **AddOnInstructionDefinition**: AOI exports with internal routines |
| 51 | + |
24 | 52 | ## License |
25 | 53 |
|
26 | 54 | MIT |
0 commit comments