How aoufnihed/selconnect works
1. What this repo is
- A Python automation toolkit for SEL relay configuration.
- Its main job is to turn centralized relay settings into per-relay configuration artifacts, especially QuickSet-compatible RDB files and SCL XML files.
2. Core architecture
- The repo is organized as a small pipeline: ingest settings, parse or extract relay data, transform it into templates or structured relay files, then emit outputs per relay.
- The main package is selprotopy, with command-line entry points layered over the generation logic.
3. Primary input sources
- relay_settings.csv and the sample CSVs under samples/ are the main configuration inputs.
- samples/mapping_710.json suggests relay-specific field mapping is part of the extraction path.
- samples/sample_710.rdb is an example source relay file used for parsing/extraction workflows.
4. Parsing and extraction boundary
- rdb_parser.py is the low-level parser for RDB content, using regex-style parsing according to the README.
- extractor.py sits above that parser and maps parsed relay fields into a normalized configuration model, likely using the JSON mapping definitions.
- This is the “read existing relay file and recover settings” side of the system.
5. Generation boundary
- rdb_generator.py and enhanced_rdb_generator.py are the “write new relay file” side.
- The enhanced generator is the key architectural piece: it uses the official SEL_RDB library to produce compound RDB files that QuickSet can read directly.
- This separates the project from plain text templating and makes the output format itself a first-class dependency.
6. Batch orchestration
- multi_generator.py is the batch coordinator for generating many relays from a master dataset.
- The out_relays/RelayXX folders show the intended unit of deployment: one output directory per relay, each containing its own generated files.
- This is the multi-relay boundary of the system and the main scaling mechanism.
7. Template and reporting support
- template_generator.py and generated_template.txt indicate a templating layer exists for producing relay-specific text artifacts or intermediate representations.
- csv_report.py generates summary/reporting outputs from processed relay data, supporting auditability and traceability of what values were generated.
- These modules are auxiliary, but they help explain how the pipeline stays transparent.
8. Command-line surface
- cli.py is the user-facing entry point for running extract/generate operations.
- The README also mentions a selprotopy-extract command, so the package is designed to be invoked as a CLI tool rather than a library only.
9. Outputs and integration targets
- The repo produces at least three important artifact types:
- QuickSet-compatible perfect RDB files
- SCL XML files for RTAC / SEL Architect integration
- text templates / reports for inspection and standardization
- The generated out_relays/* directories are example outputs demonstrating the expected packaging of these artifacts per relay.
10. Data flow at a glance
- Master CSV / sample RDB / mapping JSON in → parser/extractor or generator logic → normalized relay settings → per-relay output files.
- There are two main directions: “extract from existing relay file” and “generate new relay configuration from centralized data.”
11. Project boundaries and dependencies
- This is a Python 3.9+ package managed with pyproject.toml.
- The only external dependency called out as architecturally important is the official SEL_RDB library, because it determines the fidelity and compatibility of generated RDB files.
- QuickSet, SEL Architect, and RTAC are external consumers of the outputs, not runtime dependencies of the code itself.
12. Test structure
- tests/ covers the major functional seams: CSV reporting, extraction, RDB parsing, and RDB generation.
- That test layout mirrors the architecture well: each stage of the pipeline is tested separately rather than only through end-to-end scenarios.
13. How to diagram it
- A clean architecture diagram should show:
- input data sources at the left
- parser/extractor and generator modules in the middle
- batch orchestration above them
- output artifacts to the right
- external consumers like QuickSet and Architect consuming those outputs
- The most important internal boundary is between “normalized relay data” and “format-specific file generation.”
Main entry points: out_relays Relay outputs · multi_generator.py Batch gen · extractor.py Extractor · cli.py CLI
Components 21
Inputs
Centralized settings, sample relay data, and field mappings
- Master CSV · Centralized relay settings used to drive batch generation
samples/Master.csv - Relay settings · Primary configuration spreadsheet for generation workflows
relay_settings.csv - Sample RDB · Example source relay file used for parsing and extraction
samples/sample_710.rdb - Field map · Relay-specific field mapping used by extraction and normalization
samples/mapping_710.json - Config CSV · Sample CSV input used in generation and reporting examples
samples/config_input.csv
Core pipeline
CLI, extraction, transformation, and generation modules
- CLI · User-facing command entry for extract and generate workflows
selprotopy/cli.py - Batch gen · Coordinates generation across many relays from a master dataset
selprotopy/multi_generator.py - Extractor · Maps parsed relay fields into a normalized configuration model
selprotopy/extractor.py - RDB parser · Low-level parser for existing RDB content
selprotopy/rdb_parser.py - RDB gen · Builds standard RDB relay files from structured settings
selprotopy/rdb_generator.py - Enhanced RDB · Uses SEL_RDB to produce QuickSet-compatible compound RDB files
selprotopy/enhanced_rdb_generator.py - Template gen · Produces relay-specific text templates and intermediate artifacts
selprotopy/template_generator.py - CSV report · Summarizes processed relay data into audit-friendly reports
selprotopy/csv_report.py - Relay model · Intermediate relay settings model shared across generation paths
Outputs
Per-relay artifacts and reporting outputs
- Relay outputs · One output directory per relay containing generated artifacts
out_relays - Templates · Per-relay generated template text files
generated_template.txt - SCL XML · Per-relay SCL XML outputs for downstream integration
out_relays/Relay01/Relay01.scl.xml
External consumers
Downstream tools that consume generated artifacts
- QuickSet · Consumes generated RDB artifacts
- SEL Architect · Consumes SCL XML artifacts
- RTAC · Downstream integration target for SCL artifacts
- SEL_RDB · Official library used by the enhanced generator for compatible RDB output
Connections 25
- CLI → Batch gen: batch run · CLI invokes multi-relay generation workflows
- CLI → Extractor: extract · CLI can launch extraction from existing relay files
- CLI → RDB gen: generate · CLI can trigger file generation from normalized settings
- Master CSV → Batch gen: drive batch · Master relay settings feed the batch coordinator
- Relay settings → Batch gen: inputs · Central settings input for generation runs
- Config CSV → CSV report: summarize · CSV inputs feed reporting and audit outputs
- Sample RDB → RDB parser: parse · Existing relay file is parsed into structured fields
- Field map → Extractor: map fields · Field mapping guides extraction and normalization
- RDB parser → Extractor: parsed fields · Extractor consumes parsed relay data
- Extractor → Relay model: normalize · Recovered relay values are assembled into a shared model
- Batch gen → Relay model: prepare · Batch orchestration produces relay-specific normalized inputs
- Relay model → RDB gen: render · Structured settings are turned into standard RDB output
- Relay model → Enhanced RDB: render · Structured settings are turned into QuickSet-compatible compound RDB output
- Relay model → Template gen: template · Normalized relay data can be rendered as text templates
- Relay model → CSV report: report · Normalized data is summarized for traceability
- Enhanced RDB → SEL_RDB: uses · Enhanced generation depends on the official SEL_RDB library
- RDB gen → Relay outputs: emit · Generated relay artifacts are written into per-relay output folders
- Enhanced RDB → Relay outputs: emit · Compound RDB outputs are placed in per-relay folders
- Template gen → Templates: write · Template text artifacts are produced for inspection and reuse
- Batch gen → Relay outputs: package · Batch flow packages outputs one directory per relay
- Relay outputs → QuickSet: consume · QuickSet reads generated RDB artifacts
- Relay outputs → SEL Architect: consume · SEL Architect consumes generated SCL XML artifacts
- Relay outputs → RTAC: consume · RTAC consumes SCL XML integration artifacts
- Templates → Relay outputs: co-locate · Template artifacts live alongside other relay outputs
- CSV report → Relay outputs: summaries · Reports are written as part of the generated relay output set