# kupipikuki/cross-task-library-example-rtac architecture

> Architecture diagram of the GitHub repository kupipikuki/cross-task-library-example-rtac, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kupipikuki/cross-task-library-example-rtac
- Repository: https://github.com/kupipikuki/cross-task-library-example-rtac

## Overview

1. This is an IEC-61131 SEL RTAC control project, stored as XML-based project artifacts. The repository is organized around a runtime controller configuration plus user logic, with separate folders for system setup, task programs, data structures, and visualization.

2. The core architectural boundary is the split between two cyclic execution contexts: the Main Task and the Automation Task. Each task has its own “business logic” program, and they do not directly share variables for cross-task data exchange.

3. Cross-task communication is implemented through the CrossTask library using two mutex-protected data channels. Mutex ID 1 carries data from the Automation Task to the Main Task, and mutex ID 2 carries data from the Main Task to the Automation Task. This is the central data-flow pattern in the example.

4. Each direction has a paired read/write program in each task:
   - Automation Task writes to mutex 1 and reads from mutex 2.
   - Main Task writes to mutex 2 and reads from mutex 1.
   This creates a bidirectional handshake-style exchange between the two task domains.

5. The user logic is split into task-specific programs and cross-task bridge programs. `prg_autoTask` and `prg_mainTask` represent the local logic executed within each task, while the `prg_CrossTask_*` programs isolate the synchronization and data transfer logic.

6. The data exchanged across tasks is defined separately in the `CrossTask/DataStructures` folder. The types `AutoMain_t` and `MainAuto_t` represent the payloads for each direction, while `CrossTaskData.xml` under the library folder likely centralizes the shared structure definitions used by the library and bridge programs.

7. The system layer under `SEL_RTAC/System` contains controller-level configuration and runtime integration points: the main controller, I/O contact setup, system tags, time control, and visualization manager. This is the boundary where application logic meets the RTAC runtime environment.

8. The `Advanced Read-in Items` folder holds device/runtime configuration artifacts such as Ethernet settings, host definitions, and website settings. These are infrastructure-level settings that support deployment and access, rather than control logic itself.

9. Visualization is included as an operator-facing subsystem. `CrossTaskView.xml` and `VisualizationManager.xml` indicate a UI used to set values and observe results, which fits the project’s purpose as an interactive example of cross-task data transfer.

10. The project also includes standard PLC project scaffolding in `POUs`, such as library management, global text lists, and project information. These are supporting assets for compilation, localization/messages, and project metadata rather than the main control architecture.

11. The overall data flow is:
   - Each task performs its own local calculation.
   - The result is written into that task’s outbound mutex-protected structure.
   - The opposite task reads the data from its inbound structure.
   This keeps synchronization explicit and confines shared-state access to the CrossTask subsystem.

12. In diagram terms, the key boxes are: Main Task, Automation Task, CrossTask Library, shared data structures, and Visualization/System configuration. The main architectural message of the repo is demonstrating safe bidirectional communication between two independent real-time PLC tasks using mutex-protected shared structures.

Main entry points: [`SEL_RTAC/System/Main Controller.xml`](https://github.com/kupipikuki/cross-task-library-example-rtac/blob/HEAD/SEL_RTAC/System/Main%20Controller.xml) (Main Controller), [`SEL_RTAC/User Logic/CrossTask/Library/CrossTaskData.xml`](https://github.com/kupipikuki/cross-task-library-example-rtac/blob/HEAD/SEL_RTAC/User%20Logic/CrossTask/Library/CrossTaskData.xml) (CrossTaskData), [`SEL_RTAC/User Logic/Main Task Programs/prg_mainTask.xml`](https://github.com/kupipikuki/cross-task-library-example-rtac/blob/HEAD/SEL_RTAC/User%20Logic/Main%20Task%20Programs/prg_mainTask.xml) (Main Task), [`SEL_RTAC/User Logic/Automation Task Program/prg_autoTask.xml`](https://github.com/kupipikuki/cross-task-library-example-rtac/blob/HEAD/SEL_RTAC/User%20Logic/Automation%20Task%20Program/prg_autoTask.xml) (Automation Task)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_system["System"]
  node_n_main_controller["Main Controller<br/>rtac system"]
  node_n_contact_io["I/O Contact<br/>rtac system<br/>[Contact I_O.xml]"]
  node_n_system_tags["System Tags<br/>rtac system<br/>[SystemTags.xml]"]
  node_n_time_control["Time Control<br/>rtac system"]
  node_n_viz_manager["Viz Manager<br/>rtac system"]
end

subgraph group_logic["User Logic"]
  node_n_main_task["Main Task<br/>cyclic task<br/>[prg_mainTask.xml]"]
  node_n_auto_task["Automation Task<br/>cyclic task<br/>[prg_autoTask.xml]"]
  node_n_main_to_auto_write["M→A Write<br/>bridge program"]
  node_n_main_to_auto_read["M→A Read<br/>bridge program"]
  node_n_auto_to_main_write["A→M Write<br/>bridge program"]
  node_n_auto_to_main_read["A→M Read<br/>bridge program"]
end

subgraph group_data["Shared Data"]
  node_n_auto_main_t["AutoMain_t<br/>payload type<br/>[AutoMain_t.xml]"]
  node_n_main_auto_t["MainAuto_t<br/>payload type<br/>[MainAuto_t.xml]"]
  node_n_cross_task_data["CrossTaskData<br/>library data<br/>[CrossTaskData.xml]"]
end

subgraph group_ops["Operator UI"]
  node_n_cross_task_view["CrossTask View<br/>operator view<br/>[CrossTaskView.xml]"]
  node_n_eth_settings["Ethernet Settings<br/>deploy config"]
  node_n_hosts["Hosts<br/>deploy config<br/>[Hosts.xml]"]
  node_n_website_settings["Website Settings<br/>deploy config"]
end

subgraph group_scaffold["Project Support"]
  node_n_library_manager["Library Manager<br/>project support"]
  node_n_project_info["Project Info<br/>project support"]
  node_n_global_text_list["Text List<br/>project support<br/>[GlobalTextList.xml]"]
end

node_n_main_controller -->|"schedules"| node_n_main_task
node_n_main_controller -->|"schedules"| node_n_auto_task
node_n_main_controller -->|"binds I/O"| node_n_contact_io
node_n_main_controller -->|"exposes tags"| node_n_system_tags
node_n_main_controller -->|"uses time"| node_n_time_control
node_n_viz_manager -->|"hosts view"| node_n_cross_task_view
node_n_cross_task_view -->|"observes"| node_n_main_controller
node_n_main_task -->|"produces"| node_n_main_to_auto_write
node_n_main_to_auto_write -->|"writes"| node_n_main_auto_t
node_n_main_auto_t -->|"reads"| node_n_main_to_auto_read
node_n_main_to_auto_read -->|"delivers"| node_n_auto_task
node_n_auto_task -->|"produces"| node_n_auto_to_main_write
node_n_auto_to_main_write -->|"writes"| node_n_auto_main_t
node_n_auto_main_t -->|"reads"| node_n_auto_to_main_read
node_n_auto_to_main_read -->|"delivers"| node_n_main_task
node_n_cross_task_data -->|"defines"| node_n_main_auto_t
node_n_cross_task_data -->|"defines"| node_n_auto_main_t
node_n_library_manager -->|"imports"| node_n_cross_task_data
node_n_eth_settings -->|"configures"| node_n_main_controller
node_n_hosts -->|"configures"| node_n_main_controller
node_n_website_settings -->|"configures"| node_n_viz_manager

click node_n_main_controller "https://github.com/kupipikuki/cross-task-library-example-rtac/blob/main/SEL_RTAC/System/Main Controller.xml"
click node_n_contact_io "https://github.com/kupipikuki/cross-task-library-example-rtac/blob/main/SEL_RTAC/System/Contact I_O.xml"
click node_n_system_tags "https://github.com/kupipikuki/cross-task-library-example-rtac/blob/main/SEL_RTAC/System/SystemTags.xml"
click node_n_time_control "https://github.com/kupipikuki/cross-task-library-example-rtac/blob/main/SEL_RTAC/System/System_Time_Control.xml"
click node_n_viz_manager "https://github.com/kupipikuki/cross-task-library-example-rtac/blob/main/SEL_RTAC/System/VisualizationManager.xml"
click node_n_main_task "https://github.com/kupipikuki/cross-task-library-example-rtac/blob/main/SEL_RTAC/User Logic/Main Task Programs/prg_mainTask.xml"
click node_n_auto_task "https://github.com/kupipikuki/cross-task-library-example-rtac/blob/main/SEL_RTAC/User Logic/Automation Task Program/prg_autoTask.xml"
click node_n_main_to_auto_write "https://github.com/kupipikuki/cross-task-library-example-rtac/blob/main/SEL_RTAC/User Logic/CrossTask/MainToAuto/Main Task Write/prg_CrossTask_MainAuto_Write.xml"
click node_n_main_to_auto_read "https://github.com/kupipikuki/cross-task-library-example-rtac/blob/main/SEL_RTAC/User Logic/CrossTask/MainToAuto/Automation Task Read/prg_CrossTask_MainAuto_Read.xml"
click node_n_auto_to_main_write "https://github.com/kupipikuki/cross-task-library-example-rtac/blob/main/SEL_RTAC/User Logic/CrossTask/AutoToMain/Automation Task Write/prg_CrossTask_AutoMain_Write.xml"
click node_n_auto_to_main_read "https://github.com/kupipikuki/cross-task-library-example-rtac/blob/main/SEL_RTAC/User Logic/CrossTask/AutoToMain/Main Task Read/prg_CrossTask_AutoMain_Read.xml"
click node_n_auto_main_t "https://github.com/kupipikuki/cross-task-library-example-rtac/blob/main/SEL_RTAC/User Logic/CrossTask/DataStructures/AutoMain_t.xml"
click node_n_main_auto_t "https://github.com/kupipikuki/cross-task-library-example-rtac/blob/main/SEL_RTAC/User Logic/CrossTask/DataStructures/MainAuto_t.xml"
click node_n_cross_task_data "https://github.com/kupipikuki/cross-task-library-example-rtac/blob/main/SEL_RTAC/User Logic/CrossTask/Library/CrossTaskData.xml"
click node_n_cross_task_view "https://github.com/kupipikuki/cross-task-library-example-rtac/blob/main/SEL_RTAC/CrossTaskView.xml"
click node_n_eth_settings "https://github.com/kupipikuki/cross-task-library-example-rtac/blob/main/SEL_RTAC/Advanced Read-in Items/Ethernet Settings.xml"
click node_n_hosts "https://github.com/kupipikuki/cross-task-library-example-rtac/blob/main/SEL_RTAC/Advanced Read-in Items/Hosts.xml"
click node_n_website_settings "https://github.com/kupipikuki/cross-task-library-example-rtac/blob/main/SEL_RTAC/Advanced Read-in Items/Website Settings.xml"
click node_n_library_manager "https://github.com/kupipikuki/cross-task-library-example-rtac/blob/main/POUs/Library Manager.xml"
click node_n_project_info "https://github.com/kupipikuki/cross-task-library-example-rtac/blob/main/POUs/Project Information.xml"
click node_n_global_text_list "https://github.com/kupipikuki/cross-task-library-example-rtac/blob/main/POUs/GlobalTextList.xml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_n_main_controller,node_n_contact_io,node_n_system_tags,node_n_time_control,node_n_viz_manager toneBlue
class node_n_main_task,node_n_auto_task,node_n_main_to_auto_write,node_n_main_to_auto_read,node_n_auto_to_main_write,node_n_auto_to_main_read toneAmber
class node_n_auto_main_t,node_n_main_auto_t,node_n_cross_task_data toneMint
class node_n_cross_task_view,node_n_eth_settings,node_n_hosts,node_n_website_settings toneRose
class node_n_library_manager,node_n_project_info,node_n_global_text_list toneIndigo
```

## Components

### System

Controller runtime, I/O, and visualization integration.

- [Main Controller](https://github.com/kupipikuki/cross-task-library-example-rtac/blob/HEAD/SEL_RTAC/System/Main%20Controller.xml): rtac system · Core controller runtime configuration. · `SEL_RTAC/System/Main Controller.xml`
- [I/O Contact](https://github.com/kupipikuki/cross-task-library-example-rtac/blob/HEAD/SEL_RTAC/System/Contact%20I_O.xml): rtac system · I/O contact configuration boundary. · `SEL_RTAC/System/Contact I_O.xml`
- [System Tags](https://github.com/kupipikuki/cross-task-library-example-rtac/blob/main/SEL_RTAC/System/SystemTags.xml): rtac system · System-level tags exposed to runtime logic. · `SEL_RTAC/System/SystemTags.xml`
- [Time Control](https://github.com/kupipikuki/cross-task-library-example-rtac/blob/main/SEL_RTAC/System/System_Time_Control.xml): rtac system · Controller time and scheduling integration. · `SEL_RTAC/System/System_Time_Control.xml`
- [Viz Manager](https://github.com/kupipikuki/cross-task-library-example-rtac/blob/main/SEL_RTAC/System/VisualizationManager.xml): rtac system · Visualization runtime manager. · `SEL_RTAC/System/VisualizationManager.xml`

### User Logic

Task programs and cross-task bridge logic.

- [Main Task](https://github.com/kupipikuki/cross-task-library-example-rtac/blob/HEAD/SEL_RTAC/User%20Logic/Main%20Task%20Programs/prg_mainTask.xml): cyclic task · Primary business-logic execution context. · `SEL_RTAC/User Logic/Main Task Programs/prg_mainTask.xml`
- [Automation Task](https://github.com/kupipikuki/cross-task-library-example-rtac/blob/HEAD/SEL_RTAC/User%20Logic/Automation%20Task%20Program/prg_autoTask.xml): cyclic task · Secondary business-logic execution context. · `SEL_RTAC/User Logic/Automation Task Program/prg_autoTask.xml`
- [M→A Write](https://github.com/kupipikuki/cross-task-library-example-rtac/blob/HEAD/SEL_RTAC/User%20Logic/CrossTask/MainToAuto/Main%20Task%20Write/prg_CrossTask_MainAuto_Write.xml): bridge program · Main Task writes outbound data for Automation Task. · `SEL_RTAC/User Logic/CrossTask/MainToAuto/Main Task Write/prg_CrossTask_MainAuto_Write.xml`
- [M→A Read](https://github.com/kupipikuki/cross-task-library-example-rtac/blob/HEAD/SEL_RTAC/User%20Logic/CrossTask/MainToAuto/Automation%20Task%20Read/prg_CrossTask_MainAuto_Read.xml): bridge program · Automation Task reads inbound data from Main Task. · `SEL_RTAC/User Logic/CrossTask/MainToAuto/Automation Task Read/prg_CrossTask_MainAuto_Read.xml`
- [A→M Write](https://github.com/kupipikuki/cross-task-library-example-rtac/blob/HEAD/SEL_RTAC/User%20Logic/CrossTask/AutoToMain/Automation%20Task%20Write/prg_CrossTask_AutoMain_Write.xml): bridge program · Automation Task writes outbound data for Main Task. · `SEL_RTAC/User Logic/CrossTask/AutoToMain/Automation Task Write/prg_CrossTask_AutoMain_Write.xml`
- [A→M Read](https://github.com/kupipikuki/cross-task-library-example-rtac/blob/HEAD/SEL_RTAC/User%20Logic/CrossTask/AutoToMain/Main%20Task%20Read/prg_CrossTask_AutoMain_Read.xml): bridge program · Main Task reads inbound data from Automation Task. · `SEL_RTAC/User Logic/CrossTask/AutoToMain/Main Task Read/prg_CrossTask_AutoMain_Read.xml`

### Shared Data

Payload types and library data used for task exchange.

- [AutoMain_t](https://github.com/kupipikuki/cross-task-library-example-rtac/blob/HEAD/SEL_RTAC/User%20Logic/CrossTask/DataStructures/AutoMain_t.xml): payload type · Data structure sent from Automation Task to Main Task. · `SEL_RTAC/User Logic/CrossTask/DataStructures/AutoMain_t.xml`
- [MainAuto_t](https://github.com/kupipikuki/cross-task-library-example-rtac/blob/HEAD/SEL_RTAC/User%20Logic/CrossTask/DataStructures/MainAuto_t.xml): payload type · Data structure sent from Main Task to Automation Task. · `SEL_RTAC/User Logic/CrossTask/DataStructures/MainAuto_t.xml`
- [CrossTaskData](https://github.com/kupipikuki/cross-task-library-example-rtac/blob/HEAD/SEL_RTAC/User%20Logic/CrossTask/Library/CrossTaskData.xml): library data · Shared CrossTask library data definitions. · `SEL_RTAC/User Logic/CrossTask/Library/CrossTaskData.xml`

### Operator UI

Visualization and access configuration for the example.

- [CrossTask View](https://github.com/kupipikuki/cross-task-library-example-rtac/blob/main/SEL_RTAC/CrossTaskView.xml): operator view · Operator-facing screen for observing and setting values. · `SEL_RTAC/CrossTaskView.xml`
- [Ethernet Settings](https://github.com/kupipikuki/cross-task-library-example-rtac/blob/HEAD/SEL_RTAC/Advanced%20Read-in%20Items/Ethernet%20Settings.xml): deploy config · Network configuration for the controller. · `SEL_RTAC/Advanced Read-in Items/Ethernet Settings.xml`
- [Hosts](https://github.com/kupipikuki/cross-task-library-example-rtac/blob/HEAD/SEL_RTAC/Advanced%20Read-in%20Items/Hosts.xml): deploy config · Host definitions for runtime access and deployment. · `SEL_RTAC/Advanced Read-in Items/Hosts.xml`
- [Website Settings](https://github.com/kupipikuki/cross-task-library-example-rtac/blob/HEAD/SEL_RTAC/Advanced%20Read-in%20Items/Website%20Settings.xml): deploy config · Web access configuration for the RTAC environment. · `SEL_RTAC/Advanced Read-in Items/Website Settings.xml`

### Project Support

PLC project metadata and supporting scaffolding.

- [Library Manager](https://github.com/kupipikuki/cross-task-library-example-rtac/blob/HEAD/POUs/Library%20Manager.xml): project support · Project library dependencies and references. · `POUs/Library Manager.xml`
- [Project Info](https://github.com/kupipikuki/cross-task-library-example-rtac/blob/HEAD/POUs/Project%20Information.xml): project support · Project metadata and identification. · `POUs/Project Information.xml`
- [Text List](https://github.com/kupipikuki/cross-task-library-example-rtac/blob/main/POUs/GlobalTextList.xml): project support · Shared strings and messages for the project. · `POUs/GlobalTextList.xml`

## Connections

- Main Controller → Main Task: schedules · Controller runtime executes the main cyclic task.
- Main Controller → Automation Task: schedules · Controller runtime executes the automation cyclic task.
- Main Controller → I/O Contact: binds I/O · Controller configuration connects to I/O contacts.
- Main Controller → System Tags: exposes tags · Runtime system tags are made available to application logic.
- Main Controller → Time Control: uses time · Runtime timing and scheduling are configured at system level.
- Viz Manager → CrossTask View: hosts view · Visualization manager serves the operator screen.
- CrossTask View → Main Controller: observes · Operator view reads and sets controller-facing values.
- Main Task → M→A Write: produces · Main Task produces data for the outbound bridge.
- M→A Write → MainAuto_t: writes · Bridge program serializes Main→Automation payload.
- MainAuto_t → M→A Read: reads · Automation-side bridge consumes Main→Automation payload.
- M→A Read → Automation Task: delivers · Automation Task receives inbound data from Main Task.
- Automation Task → A→M Write: produces · Automation Task produces data for the outbound bridge.
- A→M Write → AutoMain_t: writes · Bridge program serializes Automation→Main payload.
- AutoMain_t → A→M Read: reads · Main-side bridge consumes Automation→Main payload.
- A→M Read → Main Task: delivers · Main Task receives inbound data from Automation Task.
- CrossTaskData → MainAuto_t: defines · Shared library data underpins the Main→Automation structure.
- CrossTaskData → AutoMain_t: defines · Shared library data underpins the Automation→Main structure.
- Library Manager → CrossTaskData: imports · Project libraries provide the CrossTask shared definitions.
- Ethernet Settings → Main Controller: configures · Network settings support controller deployment.
- Hosts → Main Controller: configures · Host definitions support runtime connectivity.
- Website Settings → Viz Manager: configures · Web/visualization settings support operator access.
