# kutukvpavel/mechatrolinkparser architecture

> Architecture diagram of the GitHub repository kutukvpavel/mechatrolinkparser, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kutukvpavel/mechatrolinkparser
- Repository: https://github.com/kutukvpavel/mechatrolinkparser

## Overview

##### Main Components
- MechatrolinkParser Application:
- Command Line Interface (CLI): The entry point (Program.cs) that initiates the parsing process, dispatching input data.
- Data Decoders:
∘ Manchester Decoder (HDLCManchesterDecoder.cs): Handles Manchester decoding.
∘ HDLC Parser: Likely integrated in or called by HDLCManchesterDecoder or separate error handling modules like ErrorListener.cs.
- Data Structures and Logic:
∘ MechatrolinkStructures.cs, EncoderStructures.cs: Define the communication protocol’s data representations.
∘ LogicAnalyzerData.cs: Stores and processes raw logic analyzer exports.
- Database/Command Engine:
∘ DatabaseEngine.cs, MechatrolinkCommandDatabase.cs, MechatrolinkParameterDatabase.cs, EncoderCommandDatabase.cs: Serve as in-memory or on-disk repositories mapping commands and parameters to their definitions.
- Data Reporter and Bulk Processing:
∘ DataReporter.cs, BulkProcessing.cs: Likely aggregate and format output data for reporting or further processing.

- AnalysisHelper:
- A supporting project (AnalysisHelper.csproj) that might be used for auxiliary analysis functions or testing support. Its existence indicates a layered design where the core parsing logic is separated from secondary or helper analyses.

- External Dependencies:
- NuGet Package: HashFunction.CRC for FCS (checksum) calculations.
- Configuration files: App.config files in both projects for specifying settings.

- External Interfaces:
- Input: Logic analyzer exports (via text import and possible real-time data input).
- Output: Generated reports/presentations (as hinted by the README example image).

##### Relationships and Interactions
- The CLI (Program.cs) in MechatrolinkParser acts as the coordinator: it accepts data input then sequentially or in a pipeline calls the Manchester decoder and HDLC parser.
- Once decoding is done, the data flows into the command/field database engine, where commands are looked up and further processed.
- The BulkProcessing and DataReporter components gather the processed data and prepare output reports.
- AnalysisHelper may either provide additional analysis tasks or testing utilities that can be invoked by MechatrolinkParser, suggesting a modular interaction between both projects.
- The configuration files (App.config) are essential at the initialization stage to configure decoders, reference external dependencies, and adjust logging or other parameters.

##### Architectural Patterns and Design Principles
- Modular Design: Different aspects (decoding, processing, reporting) are separated into standalone modules/files.
- Separation of Concerns: The existence of a separate AnalysisHelper project indicates a clear separation between primary functionality and auxiliary or testing support.
- Use of External Libraries/Configurations: Highlighting the use of a NuGet package for CRC calculation and App.config for environment setup.

## Diagram (Mermaid)

```mermaid
flowchart TD
    externalInput["Logic Analyzer Export"]:::external
    externalOutput["Reports"]:::external

    subgraph "MechatrolinkParser"
        cli["CLI"]:::cli
        subgraph "Decoders"
            mDec["Manchester Decoder"]:::decoder
            errHandler["HDLC Error Handler"]:::decoder
        end
        subgraph "Data Structures"
            mlStruct["Mechatrolink Structures"]:::structure
            encStruct["Encoder Structures"]:::structure
            laData["Logic Analyzer Data"]:::structure
        end
        subgraph "Database/Command Engine"
            dbEngine["Database Engine"]:::database
            cmdDB["Command Database"]:::database
            paramDB["Parameter Database"]:::database
            encCmdDB["Encoder Command Database"]:::database
        end
        subgraph "Reporting & Bulk Processing"
            dataRep["Data Reporter"]:::reporting
            bulkProc["Bulk Processing"]:::reporting
        end
    end

    analysis["AnalysisHelper"]:::aux

    externalInput -->|"providesData"| cli
    cli -->|"dispatches"| mDec
    cli -->|"handlesErrors"| errHandler
    mDec -->|"sendsDecodedData"| dbEngine
    errHandler -->|"sendsDecodedData"| dbEngine
    dbEngine -->|"queriesData"| cmdDB
    dbEngine -->|"queriesData"| paramDB
    dbEngine -->|"queriesData"| encCmdDB
    cmdDB -->|"lookupCommands"| dataRep
    paramDB -->|"lookupParameters"| dataRep
    encCmdDB -->|"experimentalSupport"| dataRep
    dbEngine -->|"processesData"| bulkProc
    dataRep -->|"generates"| externalOutput
    bulkProc -->|"aggregates"| externalOutput

    cli -->|"supports"| analysis

    click cli "https://github.com/kutukvpavel/mechatrolinkparser/blob/master/MechatrolinkParser/Program.cs"
    click mDec "https://github.com/kutukvpavel/mechatrolinkparser/blob/master/MechatrolinkParser/HDLCManchesterDecoder.cs"
    click errHandler "https://github.com/kutukvpavel/mechatrolinkparser/blob/master/MechatrolinkParser/ErrorListener.cs"
    click mlStruct "https://github.com/kutukvpavel/mechatrolinkparser/blob/master/MechatrolinkParser/MechatrolinkStructures.cs"
    click encStruct "https://github.com/kutukvpavel/mechatrolinkparser/blob/master/MechatrolinkParser/EncoderStructures.cs"
    click laData "https://github.com/kutukvpavel/mechatrolinkparser/blob/master/MechatrolinkParser/LogicAnalyzerData.cs"
    click dbEngine "https://github.com/kutukvpavel/mechatrolinkparser/blob/master/MechatrolinkParser/DatabaseEngine.cs"
    click cmdDB "https://github.com/kutukvpavel/mechatrolinkparser/blob/master/MechatrolinkParser/MechatrolinkCommandDatabase.cs"
    click paramDB "https://github.com/kutukvpavel/mechatrolinkparser/blob/master/MechatrolinkParser/MechatrolinkParameterDatabase.cs"
    click encCmdDB "https://github.com/kutukvpavel/mechatrolinkparser/blob/master/MechatrolinkParser/EncoderCommandDatabase.cs"
    click dataRep "https://github.com/kutukvpavel/mechatrolinkparser/blob/master/MechatrolinkParser/DataReporter.cs"
    click bulkProc "https://github.com/kutukvpavel/mechatrolinkparser/blob/master/MechatrolinkParser/BulkProcessing.cs"
    click analysis "https://github.com/kutukvpavel/mechatrolinkparser/blob/master/AnalysisHelper/AnalysisHelper.csproj"

    classDef cli fill:#ccf2ff,stroke:#007acc,stroke-width:2px;
    classDef decoder fill:#d4edda,stroke:#28a745,stroke-width:2px;
    classDef structure fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
    classDef database fill:#fff3cd,stroke:#ffc107,stroke-width:2px;
    classDef reporting fill:#ffe5b4,stroke:#ff8c00,stroke-width:2px;
    classDef external fill:#f8d7da,stroke:#dc3545,stroke-width:2px;
    classDef aux fill:#e0ccff,stroke:#800080,stroke-width:2px;
```
