A state synchronization method of a virtual PLC
Patent Information
- Application Number
- CN202611054705.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-16
- Publication Date
- 2026-10-09
AI Technical Summary
[0010]针对现有技术的不足,本发明提供一种虚拟PLC的状态同步方法,旨在解决现有技术中虚拟PLC冗余能力不足、状态同步效率低、实时性难以保障的技术问题;
[0030](1)差异化同步策略提升效率:通过将虚拟PLC运行状态按实时性需求划分为三层,分别采用内存直接访问、变化触发和异步备份三种同步机制,避免了传统全量同步带来的带宽浪费和实时性干扰。控制执行状态的高频同步保障了控制连续性,通信协议状态的增量同步减少了无效传输,非实时数据的后台传输不影响控制任务。
Smart Images

Figure CN122883719A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of industrial automation control technology, and in particular to a method for synchronizing the state of a virtual PLC. Background Technology
[0002] Programmable Logic Controllers (PLCs) are core control devices in industrial automation systems, widely used in manufacturing, energy, transportation, and other fields. Traditional PLCs employ a dedicated hardware architecture, embedding control logic within a dedicated processor, offering high real-time performance and reliability. However, traditional PLCs suffer from high hardware costs, poor scalability, and significant vendor lock-in.
[0003] With the development of Industry 4.0 and intelligent manufacturing, virtual PLC (vPLC) technology has emerged. Virtual PLCs run PLC control logic on general-purpose computing platforms (such as industrial PCs, servers, or edge devices) through software, decoupling control functions from hardware. This offers advantages such as flexible deployment, convenient expansion, and controllable costs.
[0004] However, virtual PLCs have significant shortcomings in terms of redundancy and fault tolerance. Traditional PLCs achieve dual-machine hot standby through dedicated hardware, with switchover times controlled in the millisecond range. Virtual PLCs, on the other hand, run on a general-purpose operating system or virtualization layer, and their state synchronization faces the following technical challenges:
[0005] First, the operating state of a virtual PLC includes not only data values, but also runtime states such as program execution context, timer cumulative values, and communication session state machines. The synchronization complexity of these states is far higher than that of simple data copying.
[0006] Second, virtual PLCs have stringent real-time requirements. The control scan cycle is usually between 1 and 10 milliseconds, and the state synchronization process cannot interfere with the execution of normal control tasks.
[0007] Third, the amount of status data in virtual PLCs varies greatly. Control execution status requires high-frequency synchronization, while log data can be transmitted at low frequency. Adopting a unified synchronization strategy will lead to bandwidth waste or insufficient real-time performance.
[0008] Fourth, existing virtual machine state synchronization technologies (such as VMware vMotion and KVM live migration) are mainly designed for IT application scenarios and do not take into account the real-time, deterministic, and security requirements of industrial control, so they cannot be directly applied to the field of virtual PLC.
[0009] Therefore, there is an urgent need for a state synchronization method specifically designed for the characteristics of virtual PLCs, which can achieve efficient and reliable state synchronization between master and backup virtual PLCs while ensuring real-time control. Summary of the Invention
[0010] To address the shortcomings of existing technologies, this invention provides a virtual PLC state synchronization method, aiming to solve the technical problems of insufficient redundancy, low state synchronization efficiency, and difficulty in guaranteeing real-time performance in existing technologies. On one hand, the present invention provides a method for synchronizing the state of a virtual PLC, comprising the following steps: S1. Divide the operating status of the virtual PLC into control execution status, communication protocol status, and non-real-time data status.
[0011] The control execution state includes the program counter, register image, timer cumulative value, current counter value, interrupt enable flag, and I / O image refresh state; The communication protocol state includes the industrial Ethernet protocol session state machine, transaction identifier sequence, and connection management state; The non-real-time data status includes operation logs, historical trend data, and HMI screen cache.
[0012] S2. Periodically synchronize the control execution status using direct memory access.
[0013] The direct memory access methods include: Establish a shared memory region between the primary virtual PLC and the standby virtual PLC; At the end of each scan cycle, the control execution status is written to the shared memory area; The data in the shared memory area is transmitted to the corresponding memory address of the standby virtual PLC using remote direct memory access technology. The transmission delay is less than 10% of the virtual PLC scan cycle.
[0014] The shared memory region is partitioned according to the variable types in the IEC 61131-3 standard, including: The input image area is used to store the state of the physical input signals; The output image area is used to store the state of the physical output to be written. The internal register area is used to store intermediate calculation results; The timer and counter area is used to store the current cumulative value of time-related states.
[0015] S3. Incremental synchronization is performed by triggering changes in the communication protocol state.
[0016] The change triggering methods include: Establish a baseline snapshot of the communication protocol state; Detect the amount of change in the communication protocol status within each scan cycle; The incremental change data is packaged and transmitted to the backup virtual PLC only when the change exceeds a preset threshold. The backup virtual PLC updates the local communication protocol status based on the incremental change data.
[0017] The preset threshold is determined based on the industrial Ethernet protocol type: For the PROFINET protocol, the preset thresholds include changes in application relationship status and changes in device name; For the EtherCAT protocol, the preset thresholds include distributed clock offset and mailbox data update; For the Modbus TCP protocol, the preset thresholds include the transition of the transaction identifier sequence and the change of the unit identifier.
[0018] S4. The non-real-time data status is transmitted in the background using an asynchronous backup method.
[0019] The asynchronous backup method includes: Write non-real-time data status to a circular buffer; When the circular buffer reaches the preset capacity, or when the preset time interval is reached, the background transmission thread is triggered. Background transmission threads execute with the lowest priority and do not preempt synchronization resources that control the execution state.
[0020] The virtual PLC state synchronization method also includes: When the primary virtual PLC fails, the backup virtual PLC resumes the execution point from the control execution state, resumes the session context from the communication protocol state, and resumes historical data from the non-real-time data state; the recovery process is completed within a single scan cycle of the virtual PLC.
[0021] The virtual PLC runs in a containerized environment. The main virtual PLC and the backup virtual PLC are deployed in different container instances on the same physical server, or in container instances on different physical servers.
[0022] The synchronization period of the control execution state is consistent with the scanning period of the virtual PLC, the synchronization period of the communication protocol state is an integer multiple of the scanning period, and the synchronization period of the non-real-time data state is greater than a hundred times the scanning period.
[0023] The virtual PLC state synchronization method also includes: consistency verification, as follows: After the control execution status is synchronized, the main virtual PLC and the standby virtual PLC respectively calculate the checksum of the status data; The checksums of the two are compared, and if they do not match, a resynchronization mechanism is triggered.
[0024] The resynchronization mechanism specifically involves pausing the current scan cycle and retransmitting complete status data.
[0025] On the other hand, a virtual PLC state synchronization method is implemented based on the following virtual PLC redundancy system, including: The main virtual PLC unit runs the control logic and generates operating status; A backup virtual PLC unit receives and maintains a copy of the operating status; The state division module divides the operating state into control execution state, communication protocol state, and non-real-time data state. The first synchronization module uses a direct memory access method to periodically synchronize the control execution state; The second synchronization module uses a change-triggered method to incrementally synchronize the state of the communication protocol. The third synchronization module uses an asynchronous backup method to transmit the non-real-time data status in the background. The fault detection module monitors the health status of the main virtual PLC unit; The switching module promotes the backup virtual PLC unit to the main virtual PLC unit when the main virtual PLC unit fails.
[0026] The first synchronization module includes: A shared memory management unit allocates a shared memory region between the main virtual PLC unit and the standby virtual PLC unit; The RDMA transmission unit transmits the control execution status via remote direct memory access technology; The timing alignment unit aligns the transmission completion time of the RDMA transmission unit with the start point of the scan cycle of the virtual PLC.
[0027] Thirdly, this application proposes an electronic device comprising: one or more processors, and a memory for storing instructions that, when executed by the one or more processors, cause the one or more processors to execute the virtual PLC state synchronization method.
[0028] Fourthly, this application proposes a computer-readable storage medium storing executable instructions that, when executed, cause a processor to perform the virtual PLC state synchronization method.
[0029] The beneficial effects of adopting the above technical solution are as follows: This invention provides a method for synchronizing the state of a virtual PLC, which has the following beneficial effects:
[0030] (1) Differentiated synchronization strategy improves efficiency: By dividing the virtual PLC operating status into three layers according to real-time requirements, three synchronization mechanisms are adopted respectively: direct memory access, change triggering, and asynchronous backup, which avoids the bandwidth waste and real-time interference caused by traditional full synchronization. High-frequency synchronization of control execution status ensures control continuity, incremental synchronization of communication protocol status reduces invalid transmission, and background transmission of non-real-time data does not affect control tasks.
[0031] (2) RDMA technology ensures microsecond-level synchronization delay: For the control execution state, a shared memory combined with RDMA transmission method is adopted to bypass the operating system kernel protocol stack and realize microsecond-level data exchange between the main and backup virtual PLCs. The transmission delay can be controlled within 10% of the scan cycle, which meets the hard real-time requirements of industrial control.
[0032] (3) Industrial control semantic perception state division: The shared memory area is partitioned according to the variable type of IEC 61131-3 standard. The state synchronization is aligned with the PLC program structure, which makes it easy for the backup virtual PLC to quickly restore the execution context without re-parse the program logic.
[0033] (4) Protocol-aware incremental synchronization mechanism: Different change thresholds are designed for different industrial Ethernet protocols (PROFINET, EtherCAT, Modbus TCP) to synchronize only the protocol state changes that truly affect control behavior, thus avoiding the blindness of the general incremental synchronization strategy.
[0034] (5) Single-cycle fault recovery capability: When the standby virtual PLC takes over, it can restore the complete execution environment from the three-layer state within a single scan cycle, achieving a seamless switching effect comparable to the hot standby of traditional hardware PLC.
[0035] (6) Resource isolation and priority guarantee: Asynchronous backup tasks are executed with the lowest priority. Data is temporarily stored in a circular buffer to ensure that non-real-time data transmission will not preempt the synchronization resources of the control execution state and avoid control jitter. Attached Figure Description
[0036] Figure 1 A flowchart illustrating the virtual PLC status synchronization method provided in an embodiment of the present invention; Figure 2 A schematic diagram of the architecture of the three-layer state division and synchronization strategy provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of the shared memory region partitioning structure provided in an embodiment of the present invention; Figure 4A schematic diagram illustrating the process of incremental state synchronization of the communication protocol provided in an embodiment of the present invention; Figure 5 This is a schematic diagram of the structure of the virtual PLC redundancy system provided in an embodiment of the present invention; Figure 6 This is a timing diagram illustrating the state recovery process during fault switching, provided in an embodiment of the present invention. Detailed Implementation
[0037] The specific implementation methods of this application will be further described in detail below with reference to the accompanying drawings and embodiments.
[0038] Example 1:
[0039] Figure 1 This is a flowchart illustrating the virtual PLC state synchronization method provided in an embodiment of the present invention. Figure 1 As shown, a method for synchronizing the state of a virtual PLC includes the following steps: Step S101: State division: The operating status of the virtual PLC is divided into three levels: control execution status, communication protocol status, and non-real-time data status.
[0040] The control execution state refers to the runtime state that directly affects the control output of the current scan cycle, including but not limited to: Program Counter: Indicates the current position of the program being executed; Register Image: Includes the current values of the input image area (I), output image area (Q), and internal registers (M); Timer Accumulated Value: The time the timer has currently counted, not the set value; Counter Current Value: The current accumulated count value of the counter; Interrupt Enable Flag: The enabled / disabled status of various interrupts; I / O Image Refresh Status: Whether the I / O refresh has been completed in this round of scanning.
[0041] The communication protocol status refers to the protocol layer status when the virtual PLC communicates with external devices, including but not limited to: Industrial Ethernet protocol session state machines: such as PROFINET Application Relationship (AR) state and EtherCAT distributed clock state; Transaction identifier sequence: such as the current sequence number of the transaction identifier in Modbus TCP; Connection management status: TCP connection status, device connection / disconnection events.
[0042] The non-real-time data status refers to data that does not affect the current control execution and is mainly used for monitoring and analysis, including but not limited to: Operation logs: program execution logs, alarm records, operation records; Historical trend data: historical sampled values of process variables; HMI screen cache: A cache of data displayed on the human-machine interface.
[0043] Step S102: Control execution state synchronization: The control execution status is periodically synchronized using direct memory access.
[0044] like Figure 2 As shown, a shared memory region is established between the primary virtual PLC and the standby virtual PLC. This shared memory region is partitioned according to the variable types in the IEC 61131-3 standard, such as... Figure 3 As shown, it includes: Input image area (I area): Stores the digital and analog input status from physical input modules or remote I / O; Output image area (Q area): Stores the digital and analog output status to be written to physical output modules or remote I / O; Internal register area (M area): Stores intermediate calculation results, flag bits, and other internal variables; Timer / Counter Area (T / C Area): Stores the current accumulated value, preset value, enable status, etc. of timers and counters.
[0045] After the output refresh phase of each scan cycle ends, the main virtual PLC writes the aforementioned control execution status into the shared memory area. Subsequently, using Remote Direct Memory Access (RDMA) technology, the data in the shared memory area is directly transferred to the corresponding memory address of the standby virtual PLC.
[0046] RDMA transmission bypasses the operating system kernel protocol stack, allowing the network card to directly handle data transfer from memory to memory, with transmission latency controllable in the microsecond range. For example, for a virtual PLC with a scan cycle of 10 milliseconds, the RDMA transmission latency should be less than 1 millisecond (i.e., 10% of the scan cycle) to ensure that it does not affect the input sampling stage of the next scan cycle.
[0047] Step S103: Communication protocol state synchronization: Incremental synchronization is performed by triggering changes in the communication protocol state.
[0048] like Figure 4 As shown, a baseline snapshot of the communication protocol status is first established, recording the initial values of each protocol parameter. Then, changes in the communication protocol status are detected within each scan cycle. Only when the change exceeds a preset threshold is the incremental change data packaged and transmitted to the backup virtual PLC. Any change in application relationship status or device name indicates reaching the preset threshold and requires backup.
[0049] The preset threshold is determined based on the industrial Ethernet protocol type: For the PROFINET protocol, the thresholds include: Application relationship (AR) status change: such as from "established" to "disconnected"; Device name change: such as modifying the device name through the DCP protocol.
[0050] For the EtherCAT protocol, the thresholds include: Distributed clock (DC) offset: Synchronization is triggered when the clock offset between the master station and the slave station exceeds the preset tolerance (e.g., 1 microsecond). Mailbox data updates: such as read and write operations of SDO (Service Data Object).
[0051] For the Modbus TCP protocol, the thresholds include: Transaction identifier sequence jump: When a transaction identifier undergoes a non-sequential jump, it indicates that there are incomplete requests / responses; Unit identifier change: When the accessed slave address changes.
[0052] After receiving the incremental change data, the standby virtual PLC updates the corresponding local communication protocol status according to the protocol type identifier and change type identifier in the data packet.
[0053] Step S104: Non-real-time data status synchronization: For non-real-time data states, an asynchronous backup method is used for background transmission.
[0054] Non-real-time data such as operation logs and historical trend data are written to a circular buffer. This circular buffer has two trigger conditions: a preset capacity (e.g., 10MB) and a preset time interval (e.g., 1 second). When either condition is met, a background transmission thread is triggered to transmit the data in the circular buffer in batches to the standby virtual PLC.
[0055] The background transfer thread executes with the lowest priority, utilizing the remaining CPU time slice only after control execution state synchronization and communication protocol state synchronization are complete. If the circular buffer is full before the transfer thread has started executing, the oldest data is overwritten to ensure that control execution is not blocked.
[0056] Step S105: Consistency check: After the control execution status is synchronized, the primary virtual PLC and the standby virtual PLC each calculate the checksum (e.g., CRC32) of the status data. The two checksums are compared; if they do not match, a resynchronization mechanism is triggered. The status data may be the control execution status, the communication protocol status, or non-real-time data status. The resynchronization mechanism pauses the current scan cycle and retransmits complete status data until the checksum matches. During resynchronization, the master virtual PLC continues to execute control logic but pauses output refresh, resuming only after resynchronization is complete to avoid output jitter.
[0057] Example 2:
[0058] In another example, Figure 5 This is a schematic diagram of the structure of a virtual PLC redundancy system provided in an embodiment of the present invention. Figure 5 As shown, the system includes: Main Virtual PLC Unit 501: Runs control logic and generates operating status. The main virtual PLC unit is deployed in a containerized environment, such as a Docker container or Kubernetes Pod, and runs on an industrial server or edge computing device.
[0059] Backup Virtual PLC Unit 502: Receives and maintains a copy of the operating status of the primary virtual PLC unit. The backup virtual PLC unit can be deployed in different container instances on the same physical server as the primary virtual PLC unit (low latency scenario), or deployed in container instances on different physical servers (high availability scenario).
[0060] State partitioning module 503: Divides the operating state into control execution state, communication protocol state, and non-real-time data state. Based on the IEC 61131-3 program structure and the real-time requirements of industrial control, the state partitioning module automatically identifies the type and synchronization priority of each state variable.
[0061] First synchronization module 504: Uses direct memory access to periodically synchronize the control execution state. The first synchronization module includes a shared memory management unit, an RDMA transmission unit, and a timing alignment unit. The shared memory management unit allocates and manages shared memory regions; the RDMA transmission unit performs remote direct memory access transmissions; the timing alignment unit aligns the RDMA transmission completion time with the start point of the virtual PLC's scan cycle to ensure that the transmission does not cross the scan cycle boundary.
[0062] The second synchronization module 505 uses a change-triggered method to perform incremental synchronization of the communication protocol state. The second synchronization module includes a reference snapshot unit, a change detection unit, and an incremental transmission unit. The reference snapshot unit records the initial value of the protocol state; the change detection unit compares the current state with the reference snapshot; and the incremental transmission unit packages and sends incremental data when the difference exceeds a threshold.
[0063] The third synchronization module 506: Employs asynchronous backup to perform background transmission of non-real-time data. The third synchronization module includes a circular buffer unit and a background transmission thread unit. The circular buffer unit temporarily stores non-real-time data; the background transmission thread unit performs batch transmissions with the lowest priority.
[0064] Fault Detection Module 507: Monitors the health status of the main virtual PLC unit. The fault detection module determines whether the main virtual PLC unit is faulty through heartbeat mechanisms, scan cycle timeout detection, and memory anomaly detection.
[0065] Switching module 508: In the event of a failure of the primary virtual PLC unit, the backup virtual PLC unit is promoted to the primary virtual PLC unit. The switching module triggers the backup virtual PLC unit to resume its execution environment from the third-level state and completes the switchover within a single scan cycle.
[0066] Example 3:
[0067] Figure 6 This is a timing diagram illustrating the state recovery process during fault switching, provided in an embodiment of the present invention. Figure 6 As shown, the fault switching process includes the following timing sequence: At time T0: The main virtual PLC is running normally, completing the control logic execution and output refresh of the current scan cycle, and writing the control execution status into the shared memory area.
[0068] At time T1: The main virtual PLC transmits the control execution status to the standby virtual PLC via RDMA, with a transmission delay of Δt1 (Δt1 < scan cycle × 10%).
[0069] At time T2: The main virtual PLC malfunctions (such as process crash or hardware failure), and the fault detection module confirms the fault after detecting a heartbeat timeout.
[0070] At time T3: The switching module triggers the backup virtual PLC to take over. The backup virtual PLC reads the control execution status from the shared memory area, restores the program counter, register image, timer cumulative value, etc., and continues execution from the breakpoint.
[0071] At time T4: The standby virtual PLC resumes the communication protocol state and re-establishes the protocol session with the external device or reuses the existing session context.
[0072] At time T5: The standby virtual PLC completes input sampling, logic execution, and output refresh for the first scan cycle, and the switching is complete. The time difference between T5 and T2 is the switching delay, which should be less than a single scan cycle.
[0073] At time T6 and thereafter: the standby virtual PLC runs as the new master virtual PLC, and the original master virtual PLC can be added to the redundant system as a new standby virtual PLC after being repaired.
[0074] Example 4:
[0075] This embodiment proposes an electronic device, including: one or more processors, and a memory, wherein the memory is used to store instructions, and when the instructions are executed by the one or more processors, the one or more processors execute the virtual PLC state synchronization method.
[0076] The electronic device can be a mobile phone, computer, or tablet computer, etc., and includes a memory and a processor. The memory stores a computer program, which, when executed by the processor, implements the virtual PLC state synchronization method as described in the embodiments. It is understood that the electronic device may also include input / output (I / O) interfaces and communication components.
[0077] The processor is used to execute all or part of the steps in the virtual PLC state synchronization method described in the above embodiments. The memory is used to store various types of data, which may include, for example, instructions for any application or method in the electronic device, as well as application-related data.
[0078] The processor can be implemented as an Application Specific Integrated Circuit (ASIC), Digital Signal Processor (DSP), Programmable Logic Device (PLD), Field Programmable Gate Array (FPGA), controller, microcontroller, microprocessor, or other electronic components, and is used to execute the virtual PLC state synchronization method described in the above embodiments.
[0079] Example 5:
[0080] This embodiment proposes a computer-readable storage medium that stores executable instructions. When these instructions are executed, if they are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium.
[0081] The computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the virtual PLC state synchronization method described in the various embodiments of this application.
[0082] The aforementioned storage media include: flash memory, hard disk, multimedia card, card-type memory (e.g., SD (Secure Digital Memory Card) or DX (Memory Data Register, MDR) memory, random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic storage, disk, optical disk, server, APP (Application) application store, and other media capable of storing program verification codes, on which computer programs are stored. When the computer program is executed by the processor, it can implement the various steps of the virtual PLC state synchronization method described above.
[0083] Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or part of the technical solution, can be embodied in the form of a computer program product.
[0084] The various embodiments in this application are described in a progressive manner. The same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on describing the differences from other embodiments.
[0085] The scope of protection of this application is not limited to the embodiments described above. Obviously, those skilled in the art can make various modifications and variations to this disclosure without departing from the scope and spirit of this disclosure. If such modifications and variations fall within the scope of the methods disclosed herein and their equivalents, then the intent of this disclosure also includes such modifications and variations.
Claims
1. A method for synchronizing the state of a virtual PLC, characterized in that, Includes the following steps: Includes the following steps: S1. Divide the operating status of the virtual PLC into control execution status, communication protocol status, and non-real-time data status; S2. Periodically synchronize the control execution status using direct memory access. S3. Incremental synchronization is performed by using a change-triggered method to control the state of the communication protocol. S4. The non-real-time data status is transmitted in the background using an asynchronous backup method.
2. The virtual PLC state synchronization method according to claim 1, characterized in that, The control execution state described in S1 includes the program counter, register image, timer cumulative value, current counter value, interrupt enable flag, and I / O image refresh state; The communication protocol state includes the industrial Ethernet protocol session state machine, transaction identifier sequence, and connection management state; The non-real-time data status includes operation logs, historical trend data, and HMI screen cache.
3. The virtual PLC state synchronization method according to claim 1, characterized in that, Includes the following steps: The direct memory access methods described in S2 include: Establish a shared memory region between the primary virtual PLC and the standby virtual PLC; At the end of each scan cycle, the control execution status is written to the shared memory area; The data in the shared memory area is transmitted to the corresponding memory address of the standby virtual PLC using remote direct memory access technology. The transmission delay is less than 10% of the virtual PLC scan cycle.
4. The virtual PLC state synchronization method according to claim 1, characterized in that, The change triggering methods described in S3 include: Establish a baseline snapshot of the communication protocol state; Detect the amount of change in the communication protocol status within each scan cycle; The incremental change data is packaged and transmitted to the backup virtual PLC only when the change exceeds a preset threshold. The backup virtual PLC updates the local communication protocol status based on the incremental change data.
5. The virtual PLC state synchronization method according to claim 1, characterized in that, The asynchronous backup methods described in S4 include: Write non-real-time data status to a circular buffer; When the circular buffer reaches the preset capacity, or when the preset time interval is reached, the background transmission thread is triggered. Background transmission threads execute with the lowest priority and do not preempt synchronization resources that control the execution state.
6. The virtual PLC state synchronization method according to claim 3, characterized in that, The shared memory region is partitioned according to the variable types in the IEC 61131-3 standard, including: The input image area is used to store the state of the physical input signals; The output image area is used to store the state of the physical output to be written. The internal register area is used to store intermediate calculation results; The timer and counter area is used to store the current cumulative value of time-related states.
7. The virtual PLC state synchronization method according to claim 4, characterized in that, The preset threshold is determined based on the industrial Ethernet protocol type: For the PROFINET protocol, the preset thresholds include changes in application relationship status and changes in device name; For the EtherCAT protocol, the preset thresholds include distributed clock offset and mailbox data update; For the Modbus TCP protocol, the preset thresholds include the transition of the transaction identifier sequence and the change of the unit identifier.
8. The virtual PLC state synchronization method according to claim 4, characterized in that, The virtual PLC state synchronization method also includes: When the primary virtual PLC fails, the backup virtual PLC resumes the execution point from the control execution state, resumes the session context from the communication protocol state, and resumes historical data from the non-real-time data state; the recovery process is completed within a single scan cycle of the virtual PLC. The virtual PLC runs in a containerized environment. The main virtual PLC and the backup virtual PLC are deployed in different container instances on the same physical server, or in container instances on different physical servers. The synchronization period of the control execution state is consistent with the scanning period of the virtual PLC, the synchronization period of the communication protocol state is an integer multiple of the scanning period, and the synchronization period of the non-real-time data state is greater than a hundred times the scanning period. The virtual PLC state synchronization method also includes: consistency verification, as follows: After the control execution status is synchronized, the main virtual PLC and the standby virtual PLC respectively calculate the checksum of the status data; Compare the two checksums; if they do not match, trigger the resynchronization mechanism. The resynchronization mechanism specifically involves pausing the current scan cycle and retransmitting complete status data.
9. The virtual PLC state synchronization method according to claim 1, implemented based on a virtual PLC redundancy system, is characterized in that... include: The main virtual PLC unit runs the control logic and generates operating status; A backup virtual PLC unit receives and maintains a copy of the operating status; The state division module divides the operating state into control execution state, communication protocol state, and non-real-time data state. The first synchronization module uses a direct memory access method to periodically synchronize the control execution state; The second synchronization module uses a change-triggered method to incrementally synchronize the state of the communication protocol. The third synchronization module uses an asynchronous backup method to transmit the non-real-time data status in the background. The fault detection module monitors the health status of the main virtual PLC unit; The switching module promotes the backup virtual PLC unit to the main virtual PLC unit when the main virtual PLC unit fails.
10. The virtual PLC state synchronization method according to claim 9, characterized in that, The first synchronization module includes: A shared memory management unit allocates a shared memory region between the main virtual PLC unit and the standby virtual PLC unit; The RDMA transmission unit transmits the control execution status via remote direct memory access technology; The timing alignment unit aligns the transmission completion time of the RDMA transmission unit with the start point of the scan cycle of the virtual PLC.