Skip to content

Mermaid Diagram Examples

flowchart TD
    A[Start] --> B{Active alarm?}
    B -->|Yes| C[Notify HMI]
    B -->|No| D[Monitor]
    C --> E{Acknowledged?}
    E -->|Yes| D
    E -->|No| C
    D --> B

sequenceDiagram
    Actor Op as Alarm
    Op->>Bit: Alarm triggered
    Bit->>Group: Notify alarm
    Group->>Super: Propagate alarm
    Super->>Global: Propagate alarm

classDiagram
    class FB_AbstractAlarmData {
        <<abstract>>
        +BOOL bEnable
        +INT iLevel
        +Run()*
        +Reset()*
    }
    class FB_AlarmBit {
        +BOOL bInput
        +Run()
        +Reset()
    }
    class FB_AlarmBitWithOM {
        +BOOL bOM
        +Run()
        +Reset()
    }

    FB_AbstractAlarmData <|-- FB_AlarmBit
    FB_AbstractAlarmData <|-- FB_AlarmBitWithOM

stateDiagram-v2
    [*] --> Inactive
    Inactive --> Active : Condition detected
    Active --> Acknowledged : Operator ACK
    Acknowledged --> Inactive : Condition resolved
    Active --> Inactive : Forced reset
    Acknowledged --> Active : Condition persists

erDiagram
    GROUP ||--o{ OBJECT : contains
    OBJECT ||--o{ ALARM : generates
    ALARM {
        int id
        string message
        int level
        datetime timestamp
    }
    OBJECT {
        int id
        string name
        string description
    }
    GROUP {
        int id
        string name
    }

gantt
    title Alarm implementation planning
    dateFormat  YYYY-MM-DD
    section Design
    Define hierarchy     :done,    d1, 2026-01-01, 7d
    Define levels        :done,    d2, after d1, 5d
    section Development
    FB_AlarmBit          :active,  a1, 2026-01-13, 10d
    FB_AlarmBitWithOM    :         a2, after a1, 10d
    Trace system         :         a3, after a2, 14d
    section Testing
    Unit test            :         t1, after a3, 7d
    Integration test     :         t2, after t1, 7d

pie title Alarm distribution by level
    "Critical"   : 15
    "High"       : 28
    "Medium"     : 40
    "Low"        : 17

gitGraph
    commit id: "Init"
    branch develop
    checkout develop
    commit id: "FB_AlarmBit"
    commit id: "FB_AlarmBitWithOM"
    branch feature/trace
    checkout feature/trace
    commit id: "Trace v1"
    commit id: "Trace v2"
    checkout develop
    merge feature/trace
    checkout main
    merge develop id: "Release 1.0"

mindmap
  root((PLC Alarms))
    Types
      AlarmBit
      AlarmBitWithOM
      AlarmBitForSafety
    Levels
      Critical
      High
      Medium
      Low
    Tracing
      Group
      Object
      Alarm
    HMI
      Visualization
      Acknowledgment
      History

timeline
    title Alarm module history
    2023 : Initial version
         : Basic FB_AlarmBit
    2024 : FB_AlarmBitWithOM
         : Multilingual support
    2025 : FB_AlarmBitForSafety
         : Trace system
    2026 : Advanced HMI integration
         : Trace v2

journey
    title Alarm lifecycle
    section Detection
      Condition active: 5: PLC
      Generate alarm: 5: FB_AlarmBit
    section Notification
      Send to HMI: 4: PLC
      Show to operator: 3: HMI
    section Resolution
      Review cause: 2: Operator
      Acknowledge alarm: 4: Operator, HMI
      Resolve condition: 3: Operator
      Clear alarm: 5: PLC, HMI

quadrantChart
    title Alarms by frequency vs impact
    x-axis Low frequency --> High frequency
    y-axis Low impact --> High impact
    quadrant-1 "Critical"
    quadrant-2 Annoying
    quadrant-3 Ignore
    quadrant-4 Monitor
    Motor fault: [0.8, 0.9]
    "Low pressure": [0.6, 0.7]
    Temperature: [0.5, 0.4]
    Door open: [0.3, 0.2]
    Low level: [0.7, 0.5]

requirementDiagram
    requirement req_alarm {
        id: 1
        text: The system must generate alarms in less than 100ms
        risk: high
        verifymethod: test
    }
    requirement req_ack {
        id: 2
        text: The operator must be able to acknowledge alarms from HMI
        risk: medium
        verifymethod: demonstration
    }
    element FB_AlarmBit {
        type: component
    }
    FB_AlarmBit - satisfies -> req_alarm
    FB_AlarmBit - satisfies -> req_ack

block-beta

  columns 4
    Input:1 space:1 Output:1
    space
    PLC["PLC S7-1x00"]:3
    space:2
    _alarmBit:3
    space:2
    _trace:3
    space
    _hmi:3

    Input --> PLC
    PLC --> Output
    PLC --> _alarmBit
    _alarmBit --> _trace
    _trace --> _hmi

xychart-beta
    title "Alarms per hour"
    x-axis ["00h","02h","04h","06h","08h","10h","12h","14h","16h","18h","20h","22h"]
    y-axis "Number of alarms" 0 --> 50
    bar [5, 3, 2, 4, 12, 28, 45, 38, 42, 30, 15, 8]
    line [5, 3, 2, 4, 12, 28, 45, 38, 42, 30, 15, 8]