Add unified Rockwell PLC file parser supporting L5X, L5K, and ACD formats#1
Open
Add unified Rockwell PLC file parser supporting L5X, L5K, and ACD formats#1
Conversation
Extends the ontology ingestion pipeline beyond L5X-only to handle all Rockwell/Allen-Bradley PLC file formats with auto-detection. New parsers: - l5k_parser.py: Parses L5K ASCII text projects (CONTROLLER/DATATYPE/ TAG/PROGRAM/ROUTINE blocks) into SCFile objects - acd_parser.py: Parses ACD binary archives via acd-tools library with fallback XML extraction when library is unavailable - rockwell_export.py: Unified entry point that auto-detects format from extension/content and routes to the appropriate parser Enhanced L5X support: - Full project parsing (Programs, controller-scoped Tags, FBD/SFC routines) - L5XParser class returns SCFile objects directly for pipeline integration - New _export_program_from_l5x and _export_controller_tags functions Pipeline integration: - ontology_analyzer.py: --rockwell flag, auto-detection for .L5X/.L5K/.ACD - analyze_rockwell_file() and analyze_rockwell_directory() methods - Frontend file dialogs updated to accept L5K and ACD formats - Backend IPC handler passes --rockwell for native Rockwell files Also includes: - rockwell-ingest.ps1: Unified PowerShell driver for all Rockwell formats - Sample L5K and L5X full-project test files (water treatment, conveyor) https://claude.ai/code/session_01EwxozRVY1P6ZfDHtQbNHQk
…ssing) - Add 7 real Rockwell L5X files from GitHub (AOI_DEBOUNCER, AOI_RAMP_BASIC, AOI_CV_CONTROL, AOI_AVERAGE, AOI_METER_ORIFICE, Op_Interlock, Op_Permissive) - Create comprehensive test suite covering format detection, L5X parsing, L5K parsing, unified parser, and .sc export with 30 automated tests - Fix multi-line description/comment handling in .sc export (_sanitize_comment) - Tests verify: tag extraction, rung/comment parsing, structured text content, multi-component files, UDT dependencies, and round-trip export https://claude.ai/code/session_01EwxozRVY1P6ZfDHtQbNHQk
…ional array parsing New test samples (7 TargetTypes covered): - Controller: basetest (1756-L75), EXAMPLE_FACTORY (1769-L33ER), L5x_Creation (minimal + populated) - Program: pycomm3 (467KB, comprehensive tags), Buffertank ISA-88 (1MB), CIP (950KB), Snake Game - Routine: PushButton (Ladder), Ladder minimal, TimeAndDate (Structured Text) - Rung: PackML state handler single rung - Module: Pilz Safety module config - DataType: Sample UDT - AOI: ISA-88 PackML state machine Parser fix: Handle multi-dimensional array Dimensions attributes (e.g. "10 10", "2 4") which are space-separated in L5X, generating proper "0..9,0..9" bounds notation. All 30 tests passing with 22 subtests (one per L5X file). https://claude.ai/code/session_01EwxozRVY1P6ZfDHtQbNHQk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds comprehensive support for parsing Rockwell/Allen-Bradley PLC files in multiple formats (L5X, L5K, ACD) into the ontology pipeline. Previously, only pre-exported
.scfiles were supported. Now the system can directly ingest native Rockwell project files and automatically detect their format.Key Changes
New L5K Parser (
scripts/l5k_parser.py): Full ASCII text project file parser that converts L5K format into SCFile objects. Handles controller definitions, data types, tags, programs, routines, and add-on instructions with proper scope tracking.New ACD Parser (
scripts/acd_parser.py): Binary project file parser with fallback support. Usesacd-toolslibrary when available, otherwise extracts embedded XML from the ACD archive and parses with L5X parser.Unified Rockwell Handler (
scripts/rockwell_export.py): Auto-detection and routing system that identifies file format (L5X, L5K, ACD, RSS) and dispatches to appropriate parser. Provides consistent interface for single files and directory processing.Enhanced L5X Parser (
scripts/l5x_export.py): Extended to handle full-project L5X files (not just component exports). Added extraction of controller-scoped tags, programs, tasks, and routines with proper hierarchy preservation.Ontology Pipeline Integration (
scripts/ontology_analyzer.py): Newanalyze_rockwell_file()method integrates Rockwell file analysis into the existing ontology workflow. Auto-detects format and processes through standard SCFile pipeline.Comprehensive Test Suite (
tests/test_rockwell_parsers.py): 434-line test suite covering format detection, parsing of real-world L5X/L5K samples, tag extraction, routine parsing, and cross-format consistency.Real-World Test Samples: Added 8 real L5X files from GitHub (AOI_AVERAGE, AOI_DEBOUNCER, AOI_CV_CONTROL, AOI_RAMP_BASIC, AOI_METER_ORIFICE, Op_Interlock, Op_Permissive) plus synthetic L5X/L5K samples for comprehensive coverage.
UI Updates: Updated Electron UI file filters and labels to reflect support for L5X, L5K, and ACD formats.
PowerShell Ingestion Script (
rockwell-ingest.ps1): Windows automation script for batch processing Rockwell files with format auto-detection.Implementation Details
All parsers output to the same SCFile data structure, enabling seamless integration with existing ontology analysis, Claude AI processing, and Neo4j storage.
https://claude.ai/code/session_01EwxozRVY1P6ZfDHtQbNHQk