How kupipikuki/cross-task-library-example-rtac works
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: Main Controller.xml Main Controller · CrossTaskData.xml CrossTaskData · prg_mainTask.xml Main Task · prg_autoTask.xml Automation Task
Components 21
System
Controller runtime, I/O, and visualization integration.
- Main Controller · Core controller runtime configuration.
SEL_RTAC/System/Main Controller.xml - I/O Contact · I/O contact configuration boundary.
SEL_RTAC/System/Contact I_O.xml - System Tags · System-level tags exposed to runtime logic.
SEL_RTAC/System/SystemTags.xml - Time Control · Controller time and scheduling integration.
SEL_RTAC/System/System_Time_Control.xml - Viz Manager · Visualization runtime manager.
SEL_RTAC/System/VisualizationManager.xml
User Logic
Task programs and cross-task bridge logic.
- Main Task · Primary business-logic execution context.
SEL_RTAC/User Logic/Main Task Programs/prg_mainTask.xml - Automation Task · Secondary business-logic execution context.
SEL_RTAC/User Logic/Automation Task Program/prg_autoTask.xml - M→A Write · 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 · 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 · 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 · 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 · Data structure sent from Automation Task to Main Task.
SEL_RTAC/User Logic/CrossTask/DataStructures/AutoMain_t.xml - MainAuto_t · Data structure sent from Main Task to Automation Task.
SEL_RTAC/User Logic/CrossTask/DataStructures/MainAuto_t.xml - CrossTaskData · Shared CrossTask library data definitions.
SEL_RTAC/User Logic/CrossTask/Library/CrossTaskData.xml
Operator UI
Visualization and access configuration for the example.
- CrossTask View · Operator-facing screen for observing and setting values.
SEL_RTAC/CrossTaskView.xml - Ethernet Settings · Network configuration for the controller.
SEL_RTAC/Advanced Read-in Items/Ethernet Settings.xml - Hosts · Host definitions for runtime access and deployment.
SEL_RTAC/Advanced Read-in Items/Hosts.xml - Website Settings · 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 · Project library dependencies and references.
POUs/Library Manager.xml - Project Info · Project metadata and identification.
POUs/Project Information.xml - Text List · Shared strings and messages for the project.
POUs/GlobalTextList.xml
Connections 21
- 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.