An open controller runtime transient data snapshot and recovery method and system
Patent Information
- Application Number
- CN202610871226.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-16
- Publication Date
- 2026-10-20
AI Technical Summary
[0007]本申请的目的在于提供一种开放式控制器运行时瞬态数据快照与复原方法和系统,解决现有核电仪控仿真平台在进行工况切换、状态回退或虚拟调试时,因依赖通信层轮询而导致的控制周期数据撕裂、大规模数据读写引发控制器看门狗超时、以及快照实时性差的问题
本申请实现强一致性的“逻辑断面”高保真复原。突破了传统异步通信读写的局限,严格限定在控制周期执行完毕的毫秒级空闲间隙进行内存锁定与抓取。彻底消除了“数据撕裂”现象,确保了核电复杂逻辑(如反应堆保护联锁、汽轮机顺控步序)在时域与逻辑域上的绝对一致性,极大提升了全范围模拟机(FSS)仿真测试的逼真度。
Smart Images

Figure FT_1 
Figure FT_2 
Figure FT_3
Abstract
Description
Technical Field
[0001] This application belongs to the field of nuclear power plant control system simulation technology, and in particular relates to a method and system for snapshotting and restoring transient data during the operation of an open controller. Background Technology
[0002] In the design, development, virtual commissioning, and construction of the full-range simulator (FSS) for nuclear power plants, accurate simulation and state reenactment of the control system are crucial. Nuclear power plant process systems are vast, with complex and variable operating conditions. To fully verify the response characteristics of safety-level and non-safety-level control logic under various normal operating conditions, transient disturbance conditions, and severe accident conditions, the simulation platform needs powerful capabilities for "initial condition (IC) saving" and "unimpeded backtracking." This requires the simulation environment or test bench to perform high-frequency, high-precision snapshot access and restoration of massive amounts of transient data during controller operation (including all I / O image areas, global variables, locally retained variables, internal states of function block instances, timer and counter contexts, etc.).
[0003] Traditional industrial controllers (such as early closed DCS or dedicated PLCs) typically employ a "black box" proprietary hardware architecture and closed memory management mechanisms, making their memory structure opaque to the user. Under this architecture, external simulation systems often rely on traditional industrial communication protocols (such as OPC DA / UA, Modbus, or proprietary fieldbuses) to extract or write runtime context data, performing asynchronous polling or message reading / writing at the application layer. However, nuclear power plant control logic is massive, with a single control station typically involving tens of thousands of variable interactions. Data access based on communication protocols is not only extremely time-consuming and consumes significant network bandwidth, but also suffers from a fatal flaw—data asynchronicity and cycle tearing. Because communication tasks and control logic scan cycles are typically scheduled asynchronously, external read commands often span multiple control cycles. This results in the acquired snapshot data no longer being on the same logical segment in terms of time slices (i.e., the "data tearing" phenomenon occurs). If such non-strongly consistent data is injected during the restoration of operating conditions, it is very easy to cause the complex interlocking protection logic of nuclear power to be falsely triggered, the PID integral term to suddenly change, or the sequential control step sequence to be disordered, resulting in serious distortion of the simulation and loss of verification value.
[0004] In recent years, with the rapid development of software-defined industrial control technology and the advancement of domestic substitution, open controllers conforming to the IEC 61131-3 standard (such as control platforms based on general-purpose real-time operating systems and soft PLC architectures) have been increasingly widely used in the field of non-safety-level control and simulation in nuclear power plants. These open runtime systems offer higher access permissions to the system's underlying layers and memory visibility, providing an opportunity to solve the problem of accessing transient data.
[0005] However, within the existing open controller technology framework, achieving lossless snapshotting and restoration of massive amounts of state data still faces significant technical bottlenecks. Industrial control tasks have extremely stringent real-time requirements (typically requiring control cycles in the range of milliseconds to tens of milliseconds, with minimal task jitter). If threads are forcibly suspended during control task execution for large-scale memory copying, it can easily lead to control cycle timeouts (overruns) and trigger watchdog actions, causing the controller to crash or become unresponsive.
[0006] Therefore, how to achieve precise freezing and lossless extraction of megabyte (MB)-level massive transient data at the millisecond or even microsecond level within a specific control cycle boundary without interrupting the real-time control process or causing task jitter, and how to achieve absolute synchronous restoration of the state stack at any specified moment, has become a key challenge that urgently needs to be overcome in the deep integration of high-fidelity simulation and open instrumentation and control technology in nuclear power. Summary of the Invention
[0007] The purpose of this application is to provide a method and system for snapshotting and restoring transient data during the operation of an open controller, which solves the problems of control cycle data tearing, controller watchdog timeout caused by large-scale data reading and writing, and poor snapshot real-time performance caused by the reliance on communication layer polling in existing nuclear power instrumentation and control simulation platforms when performing operating condition switching, state rollback, or virtual debugging.
[0008] To achieve the above objectives, this application provides the following technical solution: In a first aspect, this application provides a method for snapshotting and restoring transient data during the runtime of an open controller, comprising the following steps: S1: Map the discrete physical memory regions inside the controller into contiguous virtual memory blocks and build a snapshot index table; S2: Suspend after receiving the snapshot command, and lock the virtual memory block when the periodic free gap after the control scan cycle ends is identified; S3: While in a locked state, data is zero-copied to a high-speed snapshot buffer via direct memory access or copy-on-write mechanism, the lock is released, and the data is asynchronously serialized and stored as a snapshot file by a background thread; S4: After receiving the recovery command, suspend the main control task, load the snapshot file into the recovery buffer, overwrite the data into the dynamic data area at the absolute start of the next control cycle, and reset the watchdog and clock context.
[0009] As an implementable approach, S1 includes: S101: Parse the application logic symbol table and physical memory allocation table; S102: Locates the discrete physical memory region containing the input / output image area, global variable area, local persistent variable stack, function block instance state, and timer / counter context, and maps it into one or more contiguous virtual memory blocks in kernel mode; S103: Establish and maintain a snapshot index table in kernel mode, and statically register the starting base address, relative offset and data block size of each dynamic data area.
[0010] As an implementable approach, in S2, the periodic idle gap is a microsecond-level time gap between the sequential execution of write output operations and the start of read input operations in the next scan cycle within a complete control scan cycle.
[0011] As an implementable approach, in S3, the zero-copy extraction process involves calling the underlying direct memory access channel or triggering the copy-on-write mechanism of memory pages to rapidly mirror the full data in the locked virtual memory block to a high-speed snapshot buffer pre-allocated in kernel mode.
[0012] As an implementable approach, in S3, the asynchronous serialization process is as follows: a low-priority asynchronous persistence thread residing in the background of the operating system takes over the high-speed snapshot buffer, performs serialization operations on the data therein, aligns the current operating condition timestamp with the system running status identifier, and then writes it in batches to non-volatile storage media.
[0013] As an implementable approach, S4 includes: S401: Upon receiving the condition restoration command, all subsequent logical operation scheduling will be forcibly suspended after the current control cycle ends. S402: Retrieve the historical snapshot file with the corresponding operating condition timestamp from the storage medium, read it and unpack it into the kernel-mode independent recovery buffer; S403: Suspend and wait for the absolute start of the next control cycle. When the time point is reached, restore the complete context data in the buffer and accurately overwrite the registered dynamic data area in one go. S404: Before releasing the main control task from the suspended state, force refresh the watchdog timer and synchronously reset all standard timers and system clock contexts in the underlying runtime environment.
[0014] Secondly, this application provides an open controller runtime transient data snapshot and recovery system, comprising: The memory mapping module is used to map scattered physical memory regions into contiguous virtual memory blocks and build a snapshot index table during the controller initialization phase. The periodic synchronization locking module is used to receive transient snapshot instructions, suspend the instructions, listen to the real-time task scheduling tick, and trigger an interrupt or spinlock to lock the virtual memory block when a periodic idle gap is identified. The zero-copy snapshot module is used to zero-copy the data in a virtual memory block to a high-speed snapshot buffer in kernel mode while the virtual memory block is locked, and release the lock after the data transfer is complete. The asynchronous persistence module is used to asynchronously serialize the data in the high-speed snapshot buffer and write it to a non-volatile storage medium to generate a fixed snapshot file. The recovery module is used to suspend the main control task after receiving the working condition recovery command, asynchronously load and deserialize the specified snapshot file into an independent recovery buffer, overwrite the context data in the recovery buffer into the dynamic data area at the absolute start of the next control cycle, and reset the watchdog timer and clock context.
[0015] As one feasible approach, the memory-mapped module includes: The symbol table resolution unit is used to parse the application logic symbol table and physical memory allocation table generated by the running system. The contiguous mapping unit is used to map discrete physical memory regions such as the input / output image area, global variable area, local persistent variable stack, function block instance state, and timer / counter context into contiguous virtual memory blocks in the operating system kernel mode. The index table construction unit is used to build and maintain the snapshot index table in kernel mode, and statically register the starting base address, relative offset and data block size of each dynamic data area.
[0016] As an implementable approach, the zero-copy snapshot module rapidly mirrors the full data in the locked virtual memory block to a high-speed snapshot buffer pre-allocated in kernel mode by calling the underlying direct memory access channel or triggering the copy-on-write mechanism of memory pages.
[0017] As an feasible approach, the recovery module includes: The task suspension unit is used to forcibly suspend all subsequent logical operation scheduling after the current execution control cycle ends; The deserialization unit is used to retrieve historical snapshot files with corresponding operating condition timestamps from the storage medium, read them and unpack them into a kernel-mode independent restoration buffer; The memory overwrite unit is used to suspend and wait for the absolute start of the next control cycle. When the time point is reached, the complete context data in the recovery buffer is accurately overwritten to the registered dynamic data area in one go through memory pointer redirection or high-speed memory block overwrite interface. The context reset unit is used to forcibly refresh the watchdog timer before releasing the main control task from the suspended state, and to synchronously reset all standard timers and system clock contexts in the underlying runtime environment.
[0018] Compared with existing technologies, the open controller runtime transient data snapshot and recovery method and system provided in this application have the following advantages: This application achieves high-fidelity restoration of strongly consistent "logical cross-sections." It overcomes the limitations of traditional asynchronous communication read / write, strictly limiting memory locking and fetching to millisecond-level idle intervals after control cycle execution. This completely eliminates "data tearing," ensuring absolute consistency of complex nuclear power logic (such as reactor protection interlocks and turbine sequential control steps) in both the time and logical domains, significantly improving the realism of full-range simulator (FSS) simulation tests.
[0019] This application achieves microsecond-level extremely low overhead and high real-time performance. It innovatively introduces memory mapping pre-allocation, copy-on-write / DMA high-speed extraction, and background asynchronous persistence mechanisms. This compresses the blocking time of core logic to the microsecond level (μs), effectively avoiding interference from snapshot operations on the main control loop and eliminating the risk of controller crashes or station failures due to watchdog timeouts. It perfectly meets the high-frequency transient condition recording requirements of nuclear power plants.
[0020] This application achieves high portability and compatibility with domestically developed platforms. It eliminates dependence on specific closed controller hardware architectures, and its methodology is widely applicable to open software and hardware platforms based on general-purpose real-time operating systems (such as the domestically developed real-time Linux system) and standard runtime environments. It provides crucial underlying technical support for the smooth migration of nuclear power plant digital instrumentation and control systems to new open architectures, as well as for large-scale virtualization deployment and simulation verification. Attached Figure Description
[0021] To more clearly illustrate the technical solution of this application, the accompanying drawings used in the technical description will be briefly introduced below.
[0022] Figure 1 A flowchart illustrating the method for capturing and restoring transient data during runtime of the open controller provided in this application; Figure 2 This application provides a schematic diagram of the open controller memory mapping and snapshot data flow architecture. Figure 3The timing diagram for task scheduling and snapshot execution based on control cycle boundaries provided in this application. Detailed Implementation
[0023] The following detailed description provides further details on specific implementation methods.
[0024] This application provides a method for snapshotting and restoring transient data during the runtime of an open controller, including the following steps: Step 1, Runtime memory region mapping and address registration: Map the discrete physical memory regions inside the controller into contiguous virtual memory blocks and build a snapshot index table; Step 2, Triggering and Synchronization Locking Based on Control Cycle Boundaries: After receiving the snapshot instruction, suspend the instruction and lock the virtual memory block when the "cycle idle gap" after the end of the control scan cycle is identified; Step 3, Zero-copy high-speed snapshot and asynchronous persistence: In the locked state, the data is zero-copyed to the high-speed snapshot buffer through direct memory access or copy-on-write mechanism, and then the lock is released and the data is asynchronously serialized and stored as a snapshot file by a background thread; Step 4, Transient Data Restoration and State Reconstruction: After receiving the restoration command, suspend the main control task, load the snapshot file into the restoration buffer, overwrite the dynamic data area with data at the absolute start of the next control cycle, and reset the watchdog and clock context.
[0025] Step 1 specifically includes: Step 101: Parse the application logic symbol table and physical memory allocation table generated by the open controller's operating system; Step 102: Locate the discrete physical memory region containing the input / output image area, global variable area, local persistent variable stack, function block instance state, and timer / counter context, and map it into one or more contiguous virtual memory blocks in the operating system kernel mode; Step 103: Establish and maintain a snapshot index table in kernel mode, and statically register the starting base address, relative offset, and data block size of each dynamic data area.
[0026] In step 2, "cycle idle gap" refers to the microsecond-level time gap between the sequential execution of the "write output" operation and the start of the "read input" operation in the next scan cycle within a complete control scan cycle.
[0027] In step 2, the zero-copy extraction process does not involve data copying operations by the central processing unit.
[0028] In step 2, asynchronous persistence is completed by a low-priority background thread, and the data is written in batches to non-volatile storage media after aligning with the working condition timestamps.
[0029] In step 3, the zero-copy extraction process is as follows: the system calls the underlying direct memory access channel or triggers the copy-on-write mechanism of memory pages to quickly mirror the full data in the locked virtual memory block to a high-speed snapshot buffer pre-allocated in kernel mode. This process does not involve data copying operations by the central processing unit.
[0030] In step 3, asynchronous persistence specifically involves a low-priority asynchronous persistence thread residing in the background of the operating system taking over the high-speed snapshot buffer, serializing the data within it, aligning the current operating condition timestamp with the system running status identifier, and then writing it in batches to a non-volatile storage medium.
[0031] In step 4, the absolute starting point of the next control cycle is the precise time reference point determined by the system's real-time task scheduler to begin executing the first instruction of the next scan cycle, and the memory block overwrite operation is strictly aligned with this time reference point.
[0032] Step 4 specifically includes: Step 401: Upon receiving the condition restoration command, forcibly suspend all subsequent logical operation scheduling after the current control cycle ends; Step 402: The background deserialization module retrieves the historical snapshot file with the corresponding operating condition timestamp from the storage medium, reads it and unpacks it into the kernel-mode independent restoration buffer; Step 403: The system suspends and waits for the absolute start of the next control cycle. When the time point is reached, the complete context data in the restoration buffer is accurately overwritten to the registered dynamic data area in one go through memory pointer redirection or high-speed memory block overwrite interface. Step 404: Before releasing the main control task from the suspended state, force refresh the watchdog timer and simultaneously reset all standard timers and system clock contexts in the underlying runtime environment.
[0033] Example 1 This embodiment discloses a method for capturing and restoring transient data during the runtime of an open controller, such as... Figures 1 to 3 As shown, the specific steps include: Step 1: Runtime memory region mapping and address registration.
[0034] Step 1 is mainly completed during the controller power-on initialization and control logic loading phase to establish the data boundaries for subsequent snapshots. Specifically, it includes: Step 101: System Initialization and Symbol Table Resolution. During the startup phase of the open controller's runtime system, the underlying memory management module intercepts and resolves the application logic symbol table and physical memory allocation table generated by the runtime.
[0035] Step 102: Continuous mapping from physical memory to virtual memory. Based on the results of Step 101, locate discrete physical memory regions including the input / output (I / O) image area, global variable area, local persistent variable stack, function block (FB) instance state, and timer / counter context, and map these discrete regions into one or more contiguous virtual memory blocks in the kernel mode of the operating system.
[0036] Step 103: Construct Snapshot Index Table and Address Registration. A structured snapshot index table is established and maintained in kernel mode, statically registering the starting base address, relative offset, and data block size of the aforementioned dynamic data area in virtual memory, providing a static index for subsequent high-speed addressing. This step is performed only during the initialization phase and does not incur system overhead during the controller's cyclic operation.
[0037] Step 2: Triggering and synchronization locking based on control cycle boundaries.
[0038] Step 2 aims to avoid the "data tearing" phenomenon caused by asynchronous data communication polling, and specifically includes: Step 201: Receiving and Suspending Transient Snapshot Instructions. When the system receives a "transient snapshot" instruction through an external interface or debug bus, the master scheduler does not immediately interrupt the ongoing control logic operation task, but suspends the instruction in the kernel queue.
[0039] Step 202: Monitor the control cycle status to identify "cycle idle gaps". The real-time operating system kernel continuously monitors the real-time task scheduling tick of the controller. Within a complete control scan cycle, the logic executes "read input", "main control logic operation", and "write output" sequentially. The kernel closely monitors the execution flow to accurately identify the microsecond-level "cycle idle gap" between the completion of "write output" and the start of the next cycle's "read input".
[0040] Step 203: Trigger a system interrupt and lock the dynamic data area. Once the system enters the aforementioned "periodic idle gap," the kernel immediately triggers the highest-priority hardware interrupt or activates a system-level spinlock, instantly locking the virtual memory block registered in step 103. At this time, the control logic is in a strictly dormant, non-operational state, ensuring that the locked memory data is in the same absolutely static logical section.
[0041] Step 3: Zero-Copy high-speed snapshots and asynchronous persistence.
[0042] Step 3 is used to complete the extraction of massive amounts of data within a very short idle interval to prevent triggering the controller watchdog timeout. Specifically, it includes: Step 301: High-speed snapshot extraction based on zero-copy technology. With the memory area locked, the system invokes the underlying Direct Memory Access (DMA) channel or triggers the Copy-on-Write (CoW) mechanism to rapidly mirror the virtual memory block data mapped in Step 102 to a pre-allocated high-speed snapshot buffer in kernel mode using a "zero-copy" method. The time taken for this process is strictly controlled to the microsecond (μs) or even nanosecond (ns) level.
[0043] Step 302: Release memory lock and resume control cycle scheduling. Once the data transfer in Step 301 is complete, the kernel immediately releases the spinlock and exits the high-priority interrupt, allowing the controller's main task to smoothly and timely enter the next scan cycle according to the predetermined time rhythm. The snapshot action constitutes "zero interference" to the main control logic.
[0044] Step 303: Background low-priority thread asynchronous serialization and disk writing. A low-priority asynchronous persistence thread residing in the operating system background takes over the subsequent work. This thread serializes the data in the high-speed snapshot buffer, strictly aligns the current operating condition timestamp with the system running status identifier, and then writes it in batches to non-volatile storage media (such as solid-state drives) to generate solidified snapshot files.
[0045] Step 4: Transient data restoration and state reconstruction.
[0046] This step is performed when the simulation system needs to perform a non-disruptive rollback of operating conditions or an initial condition injection. Specifically, it includes: Step 401: Receive the recovery command and suspend the main control task. Upon receiving the "operating condition recovery" command, the main control scheduler forcibly suspends all subsequent logical operation scheduling after the current control cycle ends.
[0047] Step 402: Asynchronous loading and deserialization of historical snapshot files. The background deserialization module retrieves the historical snapshot file with the corresponding operating condition timestamp from the storage medium, reads it, and unpacks it into a kernel-mode independent restoration buffer.
[0048] Step 403: Cycle Start Alignment and Precise Memory Block Overwrite. The system suspends and waits for the absolute start of the next control cycle. When this point is reached, the kernel layer directly uses a memory pointer redirection mechanism or a high-speed memory block overwrite interface (such as Memcpy) to precisely overwrite the complete context data in the recovery buffer into the dynamic data area registered in step 103 in one go.
[0049] Step 404: Reset the system watchdog timer and clock context. Before releasing the main control task from suspension, the system forcibly refreshes the watchdog timer in the operating environment to prevent false alarms. Simultaneously, due to a jump in external operating time, the system synchronously resets all standard timers (such as TON and TOF timers) and the system clock context in the underlying operating environment. Finally, the controller smoothly resumes the execution of control tasks, achieving high-fidelity reconstructing of the operating state.
[0050] As can be seen, this embodiment achieves continuous mapping of panoramic data based on the IEC 61131-3 standard. During the initialization phase, the system uniformly maps the scattered I / O images, various variables, function block states, and timer contexts into contiguous virtual memory blocks within the kernel, and constructs a snapshot index table. This not only achieves seamless coverage of all running data but also lays the underlying foundation for subsequent high-speed data extraction.
[0051] This embodiment proposes a strongly consistent profile capture mechanism based on "periodic idle gaps." The system listens to task ticks, suspending external snapshot commands and delaying their execution until the current scan cycle ends and background tasks have not yet started. Combined with brief memory locking, this ensures that only complete logical profiles without dirty data writes are captured, effectively avoiding data tearing issues.
[0052] This embodiment employs an architecture that decouples zero-copy fetching from asynchronous persistence. During the extremely short lock period, the system uses copy-on-write or DMA technology to rapidly transfer data to the kernel buffer, and then immediately releases resources to ensure the controller's strong real-time performance. Time-consuming serialization and disk writing are handled asynchronously by low-priority background threads, completely eliminating the blocking of the snapshot process on the system clock.
[0053] This embodiment implements a non-intrusive context reconstruction technique with cycle start-point alignment. When restoring the operating condition, the system first parses historical snapshots into an independent buffer, waiting for the absolute start of the next scheduling cycle before performing a one-time precise overwrite. Simultaneously, the watchdog timer is forcibly refreshed and the system clock and timer contexts are reset synchronously, avoiding logical errors caused by data mutations and ensuring smooth recovery of control tasks.
[0054] Example 2 Based on the method of Embodiment 1 above, this embodiment also provides an open controller runtime transient data snapshot and recovery system. This embodiment is a system example with the capability of open controller runtime transient data snapshot and recovery, including: The memory mapping module is used to map scattered physical memory regions into contiguous virtual memory blocks during the controller initialization phase, and to build a snapshot index table containing the starting base address, offset, and data block size. The periodic synchronization locking module is used to suspend the instruction after receiving the transient snapshot instruction, listen to the real-time task scheduling tick, and trigger an interrupt or spinlock to lock the virtual memory block when the "periodic idle gap" is identified. The zero-copy snapshot module is used to zero-copy data in a virtual memory block to a high-speed snapshot buffer in kernel mode through direct memory access or copy-on-write mechanism when the virtual memory block is locked, and release the lock after the data transfer is completed; The asynchronous persistence module is used to asynchronously serialize the data in the high-speed snapshot buffer and write it to non-volatile storage medium through a background low-priority thread, generating a fixed snapshot file. The recovery module is used to suspend the main control task after receiving the working condition recovery command, asynchronously load and deserialize the specified snapshot file into an independent recovery buffer, overwrite the context data in the recovery buffer into the dynamic data area at the absolute start of the next control cycle, reset the watchdog timer and clock context of the running system, and finally release the main control task from suspension to resume the execution of the control task.
[0055] Furthermore, the memory mapping module includes: The symbol table resolution unit is used to parse the application logic symbol table and physical memory allocation table generated by the running system. The contiguous mapping unit is used to map discrete physical memory regions such as the input / output image area, global variable area, local persistent variable stack, function block instance state, and timer / counter context into contiguous virtual memory blocks in the operating system kernel mode. The index table construction unit is used to build and maintain the snapshot index table in kernel mode, and statically register the starting base address, relative offset and data block size of each dynamic data area.
[0056] The "cycle idle gap" identified by the cycle synchronization locking module specifically refers to the microsecond-level time gap between the completion of the "write output" operation and the start of the "read input" operation in the next scan cycle within a complete control scan cycle.
[0057] Among them, the spinlock is a system-level spinlock, and the interrupt is a hardware interrupt with the highest priority.
[0058] The zero-copy snapshot module rapidly mirrors the full data in the locked virtual memory block to a high-speed snapshot buffer pre-allocated in kernel mode by calling the underlying direct memory access channel or triggering the copy-on-write mechanism for memory pages.
[0059] The asynchronous persistence module serializes the data in the buffer and writes it in batches to non-volatile storage medium after aligning the current operating condition timestamp with the system running status identifier.
[0060] Furthermore, the restoration module includes: The task suspension unit is used to forcibly suspend all subsequent logical operation scheduling after the current execution control cycle ends; The deserialization unit is used to retrieve historical snapshot files with corresponding operating condition timestamps from the storage medium, read them and unpack them into a kernel-mode independent restoration buffer; The memory overwrite unit is used to suspend and wait for the absolute start of the next control cycle. When the time point is reached, the complete context data in the recovery buffer is accurately overwritten to the registered dynamic data area in one go through memory pointer redirection or high-speed memory block overwrite interface. The context reset unit is used to forcibly refresh the watchdog timer before releasing the main control task from the suspended state, and to synchronously reset all standard timers and system clock contexts in the underlying runtime environment.
[0061] In this embodiment, the open controller is a soft logic control platform based on the IEC 61131-3 standard and running on a general-purpose real-time operating system. The system is used for virtual commissioning of digital instrumentation and control systems in nuclear power plants, rollback of operating conditions in full-range simulators, or saving and restoring the initial conditions of safety-level and non-safety-level control logic without disturbance.
[0062] The open controller runtime transient data snapshot and recovery system provided in this embodiment can realize the technical solutions described in the above method embodiments. The specific implementation principles of each module or unit can be found in the corresponding content in the above method embodiments, and will not be repeated here.
[0063] The above description is only a specific embodiment of this application, but the protection scope of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the protection scope of this application.
Claims
1. A method for capturing and restoring transient data during the operation of an open controller, characterized in that, include: S1: Map the discrete physical memory regions inside the controller into contiguous virtual memory blocks and build a snapshot index table; S2: Suspend after receiving the snapshot command, and lock the virtual memory block when the periodic idle gap after the control scan cycle ends is identified; S3: While in a locked state, data is zero-copied to a high-speed snapshot buffer via direct memory access or copy-on-write mechanism, the lock is released, and the data is asynchronously serialized and stored as a snapshot file by a background thread; S4: After receiving the recovery command, suspend the main control task, load the snapshot file into the recovery buffer, overwrite the data into the dynamic data area at the absolute start of the next control cycle, and reset the watchdog and clock context.
2. The method for capturing and restoring transient data during the operation of an open controller according to claim 1, characterized in that, S1 includes: S101: Parse the application logic symbol table and physical memory allocation table; S102: Locates the discrete physical memory region containing the input / output image area, global variable area, local persistent variable stack, function block instance state, and timer / counter context, and maps it into one or more contiguous virtual memory blocks in kernel mode; S103: Establish and maintain a snapshot index table in kernel mode, and statically register the starting base address, relative offset, and data block size of each dynamic data area.
3. The method for snapshotting and restoring transient data during the operation of an open controller according to claim 1, characterized in that, In S2, the cycle idle gap is a microsecond-level time gap between the sequential execution of write output operations and the start of read input operations in the next scan cycle within a complete control scan cycle.
4. The method for snapshotting and restoring transient data during the operation of an open controller according to claim 1, characterized in that, In S3, the zero-copy extraction process is as follows: calling the underlying direct memory access channel or triggering the copy-on-write mechanism of memory pages to rapidly mirror the full data in the locked virtual memory block to a high-speed snapshot buffer pre-allocated in kernel mode.
5. The method for snapshotting and restoring transient data during the operation of an open controller according to claim 1, characterized in that, In S3, the asynchronous serialization process is as follows: a low-priority asynchronous persistence thread residing in the background of the operating system takes over the high-speed snapshot buffer, performs serialization operations on the data in it, and after aligning the current working condition timestamp with the system running status identifier, writes it in batches to the non-volatile storage medium.
6. The method for snapshotting and restoring transient data during the operation of an open controller according to claim 1, characterized in that, S4 include: S401: Upon receiving the condition restoration command, all subsequent logical operation scheduling will be forcibly suspended after the current control cycle ends. S402: Retrieve the historical snapshot file with the corresponding operating condition timestamp from the storage medium, read it and unpack it into the kernel-mode independent recovery buffer; S403: Suspend and wait for the absolute start of the next control cycle. When the time point is reached, restore the complete context data in the buffer and accurately overwrite the registered dynamic data area in one go. S404: Before releasing the main control task from the suspended state, force refresh the watchdog timer and simultaneously reset all standard timers and system clock contexts in the underlying runtime environment.
7. A system for capturing and restoring transient data during the operation of an open controller, characterized in that, include: The memory mapping module is used to map scattered physical memory regions into contiguous virtual memory blocks and build a snapshot index table during the controller initialization phase. The periodic synchronization locking module is used to receive transient snapshot instructions, suspend the instructions, listen to the real-time task scheduling tick, and trigger an interrupt or spinlock to lock the virtual memory block when a periodic idle gap is identified. The zero-copy snapshot module is used to zero-copy the data in a virtual memory block to a high-speed snapshot buffer in kernel mode while the virtual memory block is locked, and release the lock after the data transfer is complete. The asynchronous persistence module is used to asynchronously serialize the data in the high-speed snapshot buffer and write it to a non-volatile storage medium to generate a fixed snapshot file. The recovery module is used to suspend the main control task after receiving the working condition recovery command, asynchronously load and deserialize the specified snapshot file into an independent recovery buffer, overwrite the context data in the recovery buffer into the dynamic data area at the absolute start of the next control cycle, and reset the watchdog timer and clock context.
8. The open controller runtime transient data snapshot and recovery system according to claim 7, characterized in that, The memory mapping module includes: The symbol table resolution unit is used to parse the application logic symbol table and physical memory allocation table generated by the running system. The contiguous mapping unit is used to map discrete physical memory regions such as the input / output image area, global variable area, local persistent variable stack, function block instance state, and timer / counter context into contiguous virtual memory blocks in the operating system kernel mode. The index table construction unit is used to build and maintain the snapshot index table in kernel mode, and statically register the starting base address, relative offset and data block size of each dynamic data area.
9. The open controller runtime transient data snapshot and recovery system according to claim 7, characterized in that, The zero-copy snapshot module rapidly mirrors the full data in the locked virtual memory block to a high-speed snapshot buffer pre-allocated in kernel mode by calling the underlying direct memory access channel or triggering the copy-on-write mechanism for memory pages.
10. The open controller runtime transient data snapshot and recovery system according to claim 7, characterized in that, The restoration module includes: The task suspension unit is used to forcibly suspend all subsequent logical operation scheduling after the current execution control cycle ends; The deserialization unit is used to retrieve historical snapshot files with corresponding operating condition timestamps from the storage medium, read them and unpack them into a kernel-mode independent restoration buffer; The memory overwrite unit is used to suspend and wait for the absolute start of the next control cycle. When the time point is reached, the complete context data in the recovery buffer is accurately overwritten to the registered dynamic data area in one go through memory pointer redirection or high-speed memory block overwrite interface. The context reset unit is used to forcibly refresh the watchdog timer before releasing the main control task from the suspended state, and to synchronously reset all standard timers and system clock contexts in the underlying runtime environment.
