# lausiv1024/h-elevatorlcdsimulator architecture

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

- Interactive diagram: https://gitdiagram.com/lausiv1024/h-elevatorlcdsimulator
- Repository: https://github.com/lausiv1024/h-elevatorlcdsimulator

## Overview

This project is a Windows desktop application (WPF) that emulates the LCD display of Hitachi’s UrbanAce elevators (6th & 7th generation). The project not only provides a simulation of the elevator’s display but also includes configurable content settings for various media types (custom news, media pages, YouTube embeds, Twitter timelines, etc.), along with sound playback functionality for voice announcements.

- User Interface (UI) Layer: This includes the application startup (App.xaml, MainWindow.xaml) and all configuration windows, such as the Setting.xaml and Emulation pages (FullScreen, WithContent) that control the simulation.
- Simulation/Emulation Core: The core logic for simulating the elevator display is housed under the “Emulation” folder. This includes handling themes (e.g., DarkTheme), design data, and page transitions for presenting the simulation.
- Content Settings Module: Under the “ContentSettings” folder, this module defines various content types – CustomNews, Media, RandomTL (for Twitter timeline integration), YouTubeEmbed, and UserTweet. This is one of the extension points where different kinds of content can be added dynamically.
- Custom Controls: Reusable UI components (e.g., NumericBox, TextBoxWithHeader) which enhance the interface’s consistency, found under “CustomControls.”
- Profiling/Configuration Logic: The “Profiling” and “Properties” directories encapsulate configurations and settings management (e.g., floor setup, application settings) necessary for elevator behavior and environment adaptation.
- External Service Integration: Illustrate the Twitter API authentication module (also reflected in TwitterAPIAuthData.cs) and any external libraries like Tweetinvi for Twitter, Microsoft.Web.WebView2 for web content, and NAudio for handling MP3 audio playback.

##### Inter-component relationships and interactions
- The UI Layer drives user interactions, invoking the simulation core to display elevator-specific content.
- Content Settings are configured via the UI and then propagated into the simulation logic to dynamically display the chosen content pieces (news, Twitter feeds, YouTube embeds, etc.).
- The simulation core uses configuration data (from floors and media settings) to generate the appropriate display including handling voice announcements managed by the audio subsystem (using NAudio).
- External APIs (e.g., Twitter API) interact directly with dedicated modules: configuration, key verification, and tweet retrieval, providing data to the simulation.
- Custom Controls are integrated into the UI forms so that data input and visual presentation remain consistent across the application.

##### Architectural patterns and design principles
- Separation of Concerns: Different responsibilities are cleanly separated into UI, business logic, content handling, and API integration modules.
- Modularity and Extensibility: The project organizes content types into separate classes (CustomNews, Media, etc.) enabling easy addition of new content types.
- Event-Driven UI: The WPF framework (App.xaml, MainWindow.xaml) supports reactive UI changes triggered by user interaction or automated simulation events.
- Maintainability via Configuration: Externalized settings (e.g., floor configurations, appearance themes) ensure that many elements of the UI and simulation behavior can be updated without altering core simulation code.

- Feature of configurable settings – from floor setup to content module selection – as a distinct configuration component.
- Overall flow: Configuration (settings input by the user) → Simulation Logic (emulation core processing) → UI Rendering (display on FullScreen or WithContent pages) with external accesses (Twitter, YouTube, and audio).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        A["App.xaml"]:::frontend
        MW["MainWindow.xaml"]:::frontend
        S["Setting.xaml"]:::frontend
    end

    %% Application Logic
    subgraph "Application Logic"
        %% Simulation/Emulation Core
        subgraph "Simulation/Emulation Core"
            SC["SimulatingContext.cs"]:::logic
            DD["DesignData.cs"]:::logic
            FS["FullScreen.xaml"]:::logic
            WC["WithContent.xaml"]:::logic
        end

        %% Content Settings Module
        subgraph "Content Settings Module"
            CN["CustomNews"]:::logic
            MD["Media"]:::logic
            RT["RandomTL"]:::logic
            UT["UserTweet"]:::logic
            YT["YoutubeEmbed"]:::logic
            BC["UABaseContent"]:::logic
        end

        %% Custom Controls
        subgraph "Custom Controls"
            NB["NumericBox.cs"]:::logic
            TB["TextBoxWithHeader.cs"]:::logic
        end

        %% Profiling/Configuration
        subgraph "Profiling/Configuration"
            FS2["FloorSetting"]:::logic
            PR["Properties"]:::logic
        end
    end

    %% External Integrations
    subgraph "External Integrations"
        TA["Twitter API Auth"]:::integration
        TI["Tweetinvi"]:::integration
        WV["WebView2"]:::integration
        NA["NAudio"]:::integration
    end

    %% Inter-Component Relationships
    %% UI interactions drive simulation core
    MW -->|"triggers"| SC

    %% Configuration settings from the UI
    S -->|"configures"| CN
    S -->|"configures"| MD
    S -->|"configures"| RT
    S -->|"configures"| UT
    S -->|"configures"| YT
    S -->|"configures"| BC

    %% Simulation Core consumes Content Settings
    CN ---|"feeds"| SC
    MD ---|"feeds"| SC
    RT ---|"feeds"| SC
    UT ---|"feeds"| SC
    YT ---|"feeds"| SC
    BC ---|"feeds"| SC

    %% Simulation uses Profiling/Configuration
    SC -->|"loads"| FS2
    SC -->|"loads"| PR

    %% Simulation integrates with External Services
    SC -->|"fetchesTweets"| TA
    TA -->|"via"| TI
    SC -->|"audioPlayback"| NA
    SC -->|"mediaRendering"| WV

    %% Custom Controls used in UI
    NB -->|"integrated in"| MW
    TB -->|"integrated in"| MW

    %% Styling
    classDef frontend fill:#fef3bd,stroke:#333,stroke-width:2px;
    classDef logic fill:#b3e6ff,stroke:#333,stroke-width:2px;
    classDef integration fill:#d3ffce,stroke:#333,stroke-width:2px;

    %% Click Events for UI Layer
    click A "https://github.com/lausiv1024/h-elevatorlcdsimulator/blob/master/UrbanAce_7/App.xaml"
    click MW "https://github.com/lausiv1024/h-elevatorlcdsimulator/blob/master/UrbanAce_7/MainWindow.xaml"
    click S "https://github.com/lausiv1024/h-elevatorlcdsimulator/blob/master/UrbanAce_7/Setting.xaml"

    %% Click Events for Simulation/Emulation Core
    click SC "https://github.com/lausiv1024/h-elevatorlcdsimulator/blob/master/UrbanAce_7/Emulation/SimulatingContext.cs"
    click DD "https://github.com/lausiv1024/h-elevatorlcdsimulator/blob/master/UrbanAce_7/Emulation/DesignData.cs"
    click FS "https://github.com/lausiv1024/h-elevatorlcdsimulator/blob/master/UrbanAce_7/Emulation/Pages/FullScreen.xaml"
    click WC "https://github.com/lausiv1024/h-elevatorlcdsimulator/blob/master/UrbanAce_7/Emulation/Pages/WithContent.xaml"

    %% Click Events for Content Settings Module
    click CN "https://github.com/lausiv1024/h-elevatorlcdsimulator/blob/master/UrbanAce_7/ContentSettings/CustomNews.cs"
    click MD "https://github.com/lausiv1024/h-elevatorlcdsimulator/blob/master/UrbanAce_7/ContentSettings/Media.cs"
    click RT "https://github.com/lausiv1024/h-elevatorlcdsimulator/blob/master/UrbanAce_7/ContentSettings/RandomTL.cs"
    click UT "https://github.com/lausiv1024/h-elevatorlcdsimulator/blob/master/UrbanAce_7/ContentSettings/UserTweet.cs"
    click YT "https://github.com/lausiv1024/h-elevatorlcdsimulator/blob/master/UrbanAce_7/ContentSettings/YoutubeEmbed.cs"
    click BC "https://github.com/lausiv1024/h-elevatorlcdsimulator/blob/master/UrbanAce_7/ContentSettings/UABaseContent.cs"

    %% Click Events for Custom Controls
    click NB "https://github.com/lausiv1024/h-elevatorlcdsimulator/blob/master/UrbanAce_7/CustomControls/NumericBox.cs"
    click TB "https://github.com/lausiv1024/h-elevatorlcdsimulator/blob/master/UrbanAce_7/CustomControls/TextBoxWithHeader.cs"

    %% Click Events for Profiling/Configuration
    click FS2 "https://github.com/lausiv1024/h-elevatorlcdsimulator/blob/master/UrbanAce_7/Profiling/FloorSetting.cs"
    click PR "https://github.com/lausiv1024/h-elevatorlcdsimulator/tree/master/UrbanAce_7/Properties"

    %% Click Event for External Service Integration
    click TA "https://github.com/lausiv1024/h-elevatorlcdsimulator/blob/master/UrbanAce_7/TwitterAPIAuthData.cs"
```
