Adaptive PLC code conversion method, device and electronic equipment

By building a preset PLC conversion database and automatically analyzing and converting the difference characteristics of PLC codes, the problem of tedious and time-consuming PLC code conversion is solved, and efficient cross-brand compatibility and accuracy are achieved.

CN118733035BActive Publication Date: 2025-10-03NINGBO HOLLYSHI INFORMATION SECURITY RES INST CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410908180.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-08
Publication Date
2025-10-03
Estimated Expiration
2044-07-08

AI Technical Summary

Technical Problem

In the existing technology, the PLC code conversion process is cumbersome and time-consuming, the conversion efficiency between cross-brand systems is low, it requires manual line-by-line inspection and relies on the in-depth knowledge and experience of developers.

Method used

By building a preset PLC conversion database, storing the code conversion features of multiple PLC systems, and automatically identifying and matching different features, adaptive conversion of PLC code is achieved, including automated analysis and conversion of programming languages, instruction sets, variable naming rules, and function library features.

Benefits of technology

It improves the efficiency of PLC code conversion, reduces manual errors, achieves compatibility of cross-brand PLC systems, simplifies the conversion process, and improves accuracy and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118733035B_ABST
    Figure CN118733035B_ABST
Patent Text Reader

Abstract

An adaptive PLC code conversion method, device, and electronic device relate to the field of communication technology. The method includes: in response to a user's PLC code conversion operation, obtaining a PLC code to be converted; obtaining a target PLC system corresponding to the PLC code to be converted, and obtaining a first PLC system in a preset PLC conversion database; if the target PLC system is confirmed to be the first PLC system, obtaining a first code conversion feature corresponding to the first PLC system in the preset PLC conversion database; obtaining a second PLC system and obtaining a second code conversion feature corresponding to the second PLC system in the preset PLC conversion database; obtaining a difference feature between the first code conversion feature and the second code conversion feature; and converting the PLC code to be converted into a target PLC code according to the difference feature, wherein the target PLC code is the PLC code corresponding to the second PLC system. The technical solution of the present application solves the problem that the manual conversion process is cumbersome and time-consuming, and there is a low efficiency problem in PLC code conversion between different systems.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to an adaptive PLC code conversion method, device and electronic device. Background Art

[0002] In industrial automation, the generation and conversion of Programmable Logic Controller (PLC) code is crucial for equipment efficiency and productivity.

[0003] Because PLCs of different brands / systems use different programming languages ​​and environments, industrial automation companies need to convert the PLC code of one system to that of another when upgrading equipment, modifying production lines, or integrating cross-brand compatibility. For example, converting Siemens PLC code to Rockwell Automation PLC code. Currently, PLC code conversion is typically performed manually by developers. Due to significant differences in programming languages, instruction sets, data types, and memory management between different brands / systems, manual conversion requires in-depth knowledge and experience with multi-brand PLC code. This means developers need to review the PLC code line by line to ensure that every logic and function is correctly implemented in the converted system. Consequently, the manual conversion process is cumbersome and time-consuming. Using only this method results in inefficient PLC code conversion between different systems.

[0004] Therefore, there is an urgent need for an adaptive PLC code conversion method, device and electronic equipment. Summary of the Invention

[0005] The present application provides an adaptive PLC code conversion method, device and electronic device, which solve the problem that the manual conversion process is cumbersome and time-consuming, and the PLC code conversion efficiency between different systems is low.

[0006] In a first aspect of the present application, an adaptive PLC code conversion method is provided, the method comprising: in response to a user's PLC code conversion operation, obtaining a PLC code to be converted; obtaining a target PLC system corresponding to the PLC code to be converted, and obtaining a first PLC system in a preset PLC conversion database, the preset PLC conversion database being used to store a plurality of preset PLC systems, the first PLC system being any one of the plurality of preset PLC systems; if it is confirmed that the target PLC system is the first PLC system, obtaining a first code conversion feature corresponding to the first PLC system in the preset PLC conversion database, the preset PLC conversion database being used to store the first PLC system and the first code conversion feature; A first correspondence between the features; obtaining a second PLC system, where the second PLC system is any PLC system other than the first PLC system in a preset PLC conversion database; obtaining a second code conversion feature corresponding to the second PLC system in the preset PLC conversion database, where the preset PLC conversion database is used to store a second correspondence between the second PLC system and the second code conversion feature; obtaining a difference feature between the first code conversion feature and the second code conversion feature, where the difference feature is a different control logic feature between the first code conversion feature and the second code conversion feature; converting the PLC code to be converted into a target PLC code according to the difference feature, where the target PLC code is the PLC code corresponding to the second PLC system.

[0007] By adopting the above technical solution, when the user performs a PLC code conversion operation, the PLC code to be converted is obtained, the target PLC system corresponding to the PLC code to be converted is obtained, and the first PLC system is obtained in the preset PLC conversion database. The preset PLC conversion database is used to store multiple preset PLC systems. The first PLC system is any one of the multiple preset PLC systems. If it is confirmed that the target PLC system is the first PLC system, the first code conversion feature corresponding to the first PLC system is obtained in the preset PLC conversion database. The preset PLC conversion database is used to store a first correspondence between the first PLC system and the first code conversion feature. At this time, the second PLC system is obtained. The second PLC system is any PLC system other than the first PLC system in the preset PLC conversion database. A second code conversion feature corresponding to the second PLC system is obtained from a preset PLC conversion database. The preset PLC conversion database is used to store a second correspondence between the second PLC system and the second code conversion feature, and obtain a difference feature between the first code conversion feature and the second code conversion feature. The difference feature is a different control logic feature between the first code conversion feature and the second code conversion feature. According to the difference feature, the PLC code to be converted is converted into a target PLC code. The target PLC code is the PLC code corresponding to the second PLC system, thereby improving the PLC code conversion efficiency through automated analysis and conversion, not only reducing errors generated during manual conversion, but also achieving compatibility across cross-brand PLC systems, thereby solving the problem that the manual conversion process is cumbersome and time-consuming, and the PLC code conversion efficiency between different systems is low.

[0008] Optionally, if it is confirmed that the target PLC system is the first PLC system, before obtaining the first code conversion feature corresponding to the first PLC system in the preset PLC conversion database, it is necessary to construct the preset PLC conversion database, specifically including: obtaining multiple preset PLC codes corresponding to multiple preset PLC systems, one preset PLC system corresponds to one or more preset PLC codes; performing preprocessing operations on the multiple preset PLC codes respectively, the preprocessing operations are used to obtain multiple preset code conversion features corresponding to the multiple preset PLC codes, the preset code conversion features include programming language features, instruction set features, variable naming rule features and function library features; constructing a correspondence between multiple preset PLC systems and multiple preset code conversion features, one preset PLC system corresponds to one or more preset code conversion features; storing the correspondence between multiple preset PLC systems and multiple preset code conversion features in the preset PLC conversion database.

[0009] By adopting the above technical solution, multiple preset PLC codes corresponding to multiple preset PLC systems are obtained, one preset PLC system corresponds to one or more preset PLC codes, and preprocessing operations are performed on the multiple preset PLC codes respectively. The preprocessing operations are used to obtain multiple preset code conversion features corresponding to the multiple preset PLC codes. The preset code conversion features include programming language features, instruction set features, variable naming rule features and function library features, and a correspondence between multiple preset PLC systems and multiple preset code conversion features is constructed. One preset PLC system corresponds to one or more preset code conversion features, and the correspondence between the multiple preset PLC systems and the multiple preset code conversion features is stored in a preset PLC conversion database, so that the code conversion features of the first PLC system and the second PLC system can be queried and matched through the correspondence stored in the preset PLC conversion database, thereby quickly realizing automatic conversion of PLC codes.

[0010] Optionally, if it is confirmed that the target PLC system is the first PLC system, before obtaining the first code conversion feature corresponding to the first PLC system in the preset PLC conversion database, the method also includes: if it is confirmed that the target PLC system is not the first PLC system, performing a preprocessing operation on the PLC code to be converted to obtain a third code conversion feature corresponding to the PLC code to be converted; and storing the correspondence between the first PLC system and the third code conversion feature in the preset PLC conversion database.

[0011] By adopting the above technical solution, if it is confirmed that the target PLC system is not the first PLC system, the PLC code to be converted is preprocessed to obtain the third code conversion feature corresponding to the PLC code to be converted, so as to store the correspondence between the first PLC system and the third code conversion feature in the preset PLC conversion database, thereby realizing the update of the preset PLC conversion database.

[0012] Optionally, the difference features include condition judgment difference features, control sequence difference features and loop structure difference features.

[0013] By adopting the above technical solution, by obtaining multiple difference features, including but not limited to conditional judgment difference features, control sequence difference features, and loop structure difference features, the differences between the PLC code to be converted and the target PLC code can be more comprehensively identified and processed, thereby increasing the accuracy and efficiency of converting the PLC code to be converted into the target PLC code.

[0014] Optionally, after converting the PLC code to be converted into the target PLC code according to the difference characteristics, the method also includes: obtaining the predicted data stream and the standard data stream corresponding to the target PLC code; obtaining the deviation data between the predicted data stream and the standard data stream, and calculating the target deviation value corresponding to the predicted data stream and the standard data stream based on the deviation data; judging whether the target deviation value is less than the preset deviation value; if the target deviation value is less than the preset deviation value, confirming that no conversion abnormality occurs in the PLC code conversion operation.

[0015] By adopting the above technical solution, the predicted data stream and standard data stream corresponding to the target PLC code are obtained, and the deviation data between the predicted data stream and the standard data stream is obtained, so that the target deviation value corresponding to the predicted data stream and the standard data stream can be calculated based on the deviation data, and it is judged whether the target deviation value is less than the preset deviation value. When the target deviation value is less than the preset deviation value, it is confirmed that there is no conversion abnormality in the PLC code conversion operation.

[0016] Optionally, after determining whether the target deviation value is less than the preset deviation value, the method further includes: if the target deviation value is greater than or equal to the preset deviation value, confirming that a conversion abnormality occurs in the PLC code conversion operation; obtaining the deviation type corresponding to the deviation data, and obtaining a deviation analysis report based on the deviation type; sending the deviation analysis report to the user, the deviation analysis report including the deviation type and a recommended modification plan corresponding to the deviation type.

[0017] By adopting the above technical solution, if the target deviation value is greater than or equal to the preset deviation value, it is confirmed that a conversion abnormality has occurred in the PLC code conversion operation, and the deviation type corresponding to the deviation data is obtained. A deviation analysis report is obtained based on the deviation type, and the deviation analysis report is sent to the user. The deviation analysis report includes the deviation type and the recommended modification plan corresponding to the deviation type, so that the user can promptly understand the problems in the code conversion operation, quickly locate and correct the target PLC code, and improve the accuracy and efficiency of the code conversion operation.

[0018] Optionally, the user performs PLC code conversion operations through a user interface, and the user interface is also used to view the target PLC code and the deviation analysis report.

[0019] By adopting the above technical solution and setting a user interface, the user can perform PLC code conversion operations and view the target PLC code and deviation analysis report through the user interface.

[0020] In a second aspect of the present application, an adaptive PLC code conversion device is provided, the device comprising an acquisition module and a processing module, wherein:

[0021] An acquisition module is configured to acquire a PLC code to be converted in response to a user's PLC code conversion operation; acquire a target PLC system corresponding to the PLC code to be converted, and acquire a first PLC system from a preset PLC conversion database, the preset PLC conversion database being used to store a plurality of preset PLC systems, the first PLC system being any one of the plurality of preset PLC systems; if the target PLC system is confirmed to be the first PLC system, acquire a first code conversion feature corresponding to the first PLC system from the preset PLC conversion database, the preset PLC conversion database being used to store a first correspondence between the first PLC system and the first code conversion feature; acquire a second PLC system, the second PLC system being any PLC system other than the first PLC system in the preset PLC conversion database; acquire a second code conversion feature corresponding to the second PLC system from the preset PLC conversion database, the preset PLC conversion database being used to store a second correspondence between the second PLC system and the second code conversion feature; and acquire a difference feature between the first code conversion feature and the second code conversion feature, the difference feature being a control logic feature that is different between the first code conversion feature and the second code conversion feature.

[0022] The processing module is used to convert the PLC code to be converted into a target PLC code according to the difference characteristics, where the target PLC code is the PLC code corresponding to the second PLC system.

[0023] In the third aspect of the present application, an electronic device is provided, including a processor, a memory, a user interface and a network interface, the memory is used to store instructions, the user interface and the network interface are used to communicate with other devices, and the processor is used to execute the instructions stored in the memory so that the electronic device performs any of the methods described above.

[0024] In a fourth aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and the computer program is executed by a processor to perform any of the above methods.

[0025] One or more technical solutions provided in the embodiments of this application have at least the following technical effects or advantages:

[0026] 1. When the user performs a PLC code conversion operation, the PLC code to be converted is obtained, the target PLC system corresponding to the PLC code to be converted is obtained, and the first PLC system is obtained in the preset PLC conversion database. The preset PLC conversion database is used to store multiple preset PLC systems. The first PLC system is any one of the multiple preset PLC systems. If it is confirmed that the target PLC system is the first PLC system, the first code conversion feature corresponding to the first PLC system is obtained in the preset PLC conversion database. The preset PLC conversion database is used to store the first correspondence between the first PLC system and the first code conversion feature. At this time, the second PLC system is obtained. The second PLC system is any PLC system other than the first PLC system in the preset PLC conversion database. A second code conversion feature corresponding to the second PLC system is obtained from the conversion database. The preset PLC conversion database is used to store a second correspondence between the second PLC system and the second code conversion feature, and a difference feature between the first code conversion feature and the second code conversion feature is obtained. The difference feature is the different control logic feature in the first code conversion feature and the second code conversion feature. According to the difference feature, the PLC code to be converted is converted into a target PLC code. The target PLC code is the PLC code corresponding to the second PLC system, thereby improving the PLC code conversion efficiency through automated analysis and conversion, not only reducing the errors generated during manual conversion, but also achieving compatibility across cross-brand PLC systems, thereby solving the problem that the manual conversion process is cumbersome and time-consuming, and the PLC code conversion efficiency between different systems is low.

[0027] 2. Obtain multiple preset PLC codes corresponding to multiple preset PLC systems, one preset PLC system corresponds to one or more preset PLC codes, and perform preprocessing operations on the multiple preset PLC codes respectively, the preprocessing operations are used to obtain multiple preset code conversion features corresponding to the multiple preset PLC codes, the preset code conversion features include programming language features, instruction set features, variable naming rule features and function library features, and construct a correspondence between multiple preset PLC systems and multiple preset code conversion features, one preset PLC system corresponds to one or more preset code conversion features, and store the correspondence between the multiple preset PLC systems and the multiple preset code conversion features in a preset PLC conversion database, so as to query and match the code conversion features of the first PLC system and the second PLC system through the correspondence stored in the preset PLC conversion database, and quickly realize the automatic conversion of PLC codes.

[0028] 3. If it is confirmed that the target PLC system is not the first PLC system, a preprocessing operation is performed on the PLC code to be converted to obtain a third code conversion feature corresponding to the PLC code to be converted, so as to store the correspondence between the first PLC system and the third code conversion feature in a preset PLC conversion database, thereby realizing the update of the preset PLC conversion database. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] Figure 1 1 is a flow chart of an adaptive PLC code conversion method provided in an embodiment of the present application;

[0030] Figure 2 This is a module diagram of an adaptive PLC code conversion device provided by an embodiment of the present application;

[0031] Figure 3 This is a structural diagram of an electronic device provided in an embodiment of the present application.

[0032] Explanation of the reference numerals: 21, acquisition module; 22, processing module; 301, processor; 302, communication bus; 303, user interface; 304, network interface; 305, memory. DETAILED DESCRIPTION

[0033] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this application, not all of the embodiments.

[0034] The terms used in the following examples of the present application are only for the purpose of describing specific embodiments and are not intended to limit the present application. As used in the specification of the present application, the singular expressions "a", "an", "said", "above", "the", and "this" are intended to include plural expressions as well, unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used in the present application refers to and includes any or all possible combinations of one or more of the listed items.

[0035] In the following, the terms "first" and "second" are used for descriptive purposes only and should not be understood to imply or suggest relative importance or implicitly indicate the number of the technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of this application, unless otherwise specified, "plurality" means two or more.

[0036] In order to enable those skilled in the art to better understand the technical solution of the present invention, the present invention will be further described in detail below with reference to the accompanying drawings.

[0037] In industrial automation, the generation and conversion of Programmable Logic Controller (PLC) code is crucial for equipment efficiency and productivity.

[0038] Because PLCs of different brands / systems use different programming languages ​​and environments, industrial automation companies need to convert the PLC code of one system to that of another when upgrading equipment, modifying production lines, or integrating cross-brand compatibility. For example, converting Siemens PLC code to Rockwell Automation PLC code. Currently, PLC code conversion is typically performed manually by developers. Due to significant differences in programming languages, instruction sets, data types, and memory management between different brands / systems, manual conversion requires in-depth knowledge and experience with multi-brand PLC code. This means developers need to review the PLC code line by line to ensure that every logic and function is correctly implemented in the converted system. Consequently, the manual conversion process is cumbersome and time-consuming. Using only this method results in inefficient PLC code conversion between different systems.

[0039] Therefore, there is an urgent need for an adaptive PLC code conversion method, device and electronic equipment.

[0040] Please refer to Figure 1 , which shows a flow chart of an adaptive PLC code conversion method provided by an embodiment of the present application. The method is applied to a PLC code conversion model. The flow chart mainly includes the following steps: S101 to S107.

[0041] Step S101: In response to a PLC code conversion operation by a user, a PLC code to be converted is obtained.

[0042] Specifically, when a user performs a PLC code conversion operation, the PLC code conversion model obtains the PLC code to be converted input by the user. The PLC code to be converted is the PLC code specified by the user for PCL code conversion. The user can perform the PLC code conversion operation through a user interface. The user interface can be a user interface on a variety of operating terminals, including but not limited to desktop computers, laptops, tablets, smartphones, etc. In this application, the scenarios in which users perform PLC code conversion are mainly divided into two types. One is when users update the PLC systems of a large number of devices, the user's company will face the task of updating the PLC systems of a large number of devices. When the PLC systems of a large number of devices need to be updated, manually converting the PLC code of each device is a time-consuming and labor-intensive task; the other is when integrating PLC systems, the user's company needs to convert the PLC codes in different PLC systems to each other to achieve compatibility and collaborative work between PLC systems. For example, multiple brands of PLC equipment are used in a production line, and they need to communicate and coordinate with each other. PLC systems of different brands use different PCL codes. Manual conversion is not only complicated but also prone to compatibility issues. In the integration process, PLC codes need to be responded to and deployed quickly, that is, the PLC codes in different PLC systems need to be quickly converted to ensure the continuity of the production line.

[0043] Step S102: obtaining a target PLC system corresponding to the PLC code to be converted, and obtaining a first PLC system from a preset PLC conversion database, the preset PLC conversion database being used to store a plurality of preset PLC systems, the first PLC system being any one of the plurality of preset PLC systems.

[0044] Specifically, the PLC code conversion model obtains the target PLC system corresponding to the PLC code to be converted, and obtains the first PLC system in the preset PLC conversion database. The preset PLC conversion database is used to store all preset PLC systems in the user's enterprise, and the first PLC system is any one of the multiple preset PLC systems. The multiple preset PLC systems in the PLC conversion database are all PLC systems produced by different types of manufacturers. The PLC code conversion model constructs a unique corresponding identifier for each different preset PLC system in the preset PLC conversion database. By identifying different identifiers, the PLC code conversion model can identify different preset PLC systems. When judging whether the target PLC system corresponding to the converted PLC code is a preset PLC system in the database, the PLC code conversion model can obtain the identifier corresponding to the target PLC system and judge whether the identifier corresponding to the target PLC system is the identifier stored in the preset PLC conversion database. If the identifier corresponding to the target PLC system is the identifier stored in the preset PLC conversion database, it is confirmed that the target PLC system corresponding to the converted PLC code is the preset PLC system in the database. The PLC code conversion model can confirm the preset PLC system corresponding to the target PLC system in the preset PLC conversion database based on the correspondence between different identifiers and different preset PLC systems. If the identifier corresponding to the target PLC system is the same identifier as the identifier corresponding to the first PLC system, it is confirmed that the target PLC system is the first PLC system.

[0045] Step S103: If it is confirmed that the target PLC system is the first PLC system, a first code conversion feature corresponding to the first PLC system is obtained from a preset PLC conversion database, where the preset PLC conversion database is used to store a first correspondence between the first PLC system and the first code conversion feature.

[0046] Specifically, when the PLC code conversion model confirms that the target PLC system is the first PLC system, that is, when the PLC code conversion model confirms that the target PLC system has a corresponding preset PLC system in the preset PLC conversion database, the PLC code conversion model obtains the first code conversion feature corresponding to the first PLC system in the preset PLC conversion database. The preset PLC conversion database is also used to store the first correspondence between the first PLC system and the first code conversion feature.

[0047] In a possible embodiment, step S103 also includes: obtaining multiple preset PLC codes corresponding to multiple preset PLC systems, one preset PLC system corresponds to one or more preset PLC codes; performing preprocessing operations on the multiple preset PLC codes respectively, the preprocessing operations being used to obtain multiple preset code conversion features corresponding to the multiple preset PLC codes, the preset code conversion features including programming language features, instruction set features, variable naming rule features and function library features; constructing a correspondence between multiple preset PLC systems and multiple preset code conversion features, one preset PLC system corresponds to one or more preset code conversion features; and storing the correspondence between the multiple preset PLC systems and the multiple preset code conversion features in a preset PLC conversion database.

[0048] Specifically, the preset PLC conversion database is a pre-built database. Before building the preset PLC conversion database, it is necessary to obtain all the preset PLC systems in the user's enterprise and one or more preset PLC codes corresponding to each preset PLC system, and perform preprocessing operations on each preset PLC code separately to obtain one or more preset code conversion features corresponding to each preset PLC code through the PLC code conversion model. The extractable preset code conversion features include but are not limited to: programming language features, instruction set features, variable naming rule features, and function library features, etc., and the correspondence between multiple preset PLC systems and multiple preset code conversion features is constructed, and the correspondence between multiple preset PLC systems and multiple preset code conversion features is stored in the preset PLC conversion database.

[0049] For example, suppose a user's manufacturer has PLC devices produced by Manufacturer A, Manufacturer B, and Manufacturer C. The multiple preset PLC systems obtained are System A, System B, and System C. The corresponding preset PLC codes are obtained. Assume that the codes for System A, System B, and System C are: System A: Code A1, Code A2, and Code A3; System B: Code B1, Code B2; and System C: Code C1, Code C2, and Code C3. Each preset PLC code is preprocessed and may correspond to one or more preset code conversion features. Programming language features: For example, System A uses Ladder Diagram, System B uses Structured Text, and System C uses Function Block Diagram. Instruction set features: For example, System A uses a specific logic and arithmetic instruction set, System B uses a different instruction set, and System C may have its own unique instruction set. Variable naming rule characteristics: Each system may have its own unique variable naming rules. For example, System A's variable naming rule is prefix plus type, System B may use all lowercase letters, and System C may use a different rule. Function library characteristics: Different systems may use different function libraries to implement specific functions. If, through preprocessing, the correspondence between each preset PLC code extracted and one or more preset code conversion features is: A1 code: Feature 1, Feature 2; A2 code: Feature 1, Feature 3; A3 code: Feature 2, Feature 3; B1 code: Feature 4, Feature 5; B2 code: Feature 6, Feature 7; C1 code: Feature 7, Feature 8; C2 code: Feature 8, Feature 9; C3 code: Feature 7, Feature 9, then the correspondence between multiple preset PLC systems and multiple preset code conversion features is: System A: Feature 1, Feature 2, Feature 3; System B: Feature 4, Feature 5, Feature 6, Feature 7; System C: Feature 7, Feature 8, Feature 9. It should be noted that this embodiment does not limit the number of PLC systems from different manufacturers simultaneously owned by the user's enterprise, the number of multiple preset PLC codes contained in multiple PLC systems, or the number of multiple preset code conversion features that can be extracted from multiple preset PLC codes. The number of preset code conversion features that can be extracted from a single preset PLC code is related to the richness of the preset PLC code itself and the performance of the PLC code conversion model. The richness of the preset PLC code determines the diversity of features contained therein, such as programming language features, instruction set features, variable naming rule features, and function library features. Complex and rich codes usually contain more feature identifiers, allowing the PLC code conversion model to extract more valuable conversion features.The PLC code conversion model, trained on a large amount of experimental data, is able to extract most of the preset code conversion features. The richer the preset PLC code, the greater the number of preset code conversion features the PLC code conversion model can extract from a single preset PLC code. This extensive experimental data includes, but is not limited to, the following: 1. PLC code from various brands and models, such as Siemens PLC code: including sample code in different programming languages; Rockwell Automation PLC code: including code examples covering different programming environments and instruction sets; Schneider Electric PLC code: including code examples for different types of control logic and function libraries; and PLC code from other brands, such as Mitsubishi, Omron, and ABB. 2. PLC code of varying complexity, such as simple control logic: basic switch control, simple logical operations, timer and counter applications; and medium-complexity logic: including multi-input and multi-output control, sequential control, and state machine design. Complex control logic: such as PID control, complex algorithm implementation, multi-task scheduling, and communication protocol implementation (such as Modbus and Ethernet / IP). 3. Real-world industrial application cases, such as production line control system code: covering the control logic of various production lines, such as automotive manufacturing, food processing, and packaging. Process control system code: such as PLC code for process control systems in chemical production, pharmaceutical processing, and energy management. Equipment automation code: such as the control logic of equipment such as robotic control, machine tool control, and warehouse automation. 4. Code with detailed comments and documentation, such as code comments: containing detailed explanations of the function and logic of each code segment to help models understand the code structure. Technical documentation: such as design specifications, control flow charts, and system architecture diagrams, providing background information and design principles for the code. 5. Diverse variables and naming conventions, such as variables with different naming conventions: code examples using various variable naming conventions, such as prefix plus type, all lowercase naming, and camel case naming. Diverse variable types: such as the use of variables with different data types, such as Boolean, integer, floating point, and string. 6. Extensive library usage examples, such as standard library functions: basic mathematical operations, logical operations, timer and counter functions. Custom functions: complex user-defined functions and function blocks, demonstrating how to expand and apply custom logic.

[0050] In a possible embodiment, step S103 also includes: if it is confirmed that the target PLC system is not the first PLC system, performing a preprocessing operation on the PLC code to be converted, the preprocessing operation is used to obtain a third code conversion feature corresponding to the PLC code to be converted, and the third code conversion feature is not any code conversion feature in the preset PLC conversion database; and storing the correspondence between the first PLC system and the third code conversion feature in the preset PLC conversion database.

[0051] Specifically, if it is confirmed that the target PLC system is not the first PLC system, that is, when the PLC code conversion model confirms that the target PLC system does not exist in the preset PLC conversion database and there is a corresponding preset PLC system that can match it, the PLC code conversion model performs a preprocessing operation on the PLC code to be converted. The preprocessing operation is used to obtain the third code conversion feature corresponding to the PLC code to be converted, that is, the PLC code conversion model analyzes the content and features of the PLC code to be converted through the preprocessing operation, and attempts to automatically identify the target PLC system corresponding to the PLC code to be converted. The third code conversion feature of the PLC code to be converted includes but is not limited to the programming language features, instruction set features, variable naming rule features, and function library features corresponding to the PLC code to be converted. In the above steps, the target PLC system does not exist in the preset PLC conversion database. There is a corresponding preset PLC system that can match it, which can be divided into two situations: 1. There is no identifier of any PLC system in the PLC code to be converted. At this time, the PLC code conversion model sends a preset PLC conversion database update request to the user. The user can manually add a new PLC system, an identifier corresponding to the new PLC system, and a third code conversion feature corresponding to the new PLC system; 2. The PLC system and the corresponding identifier existing in the PLC code to be converted are unknown identifiers corresponding to unknown PLC systems. The PLC code conversion model can automatically update the above-mentioned unknown PLC system, the identifier corresponding to the unknown PLC system, and the third code conversion feature corresponding to the unknown PLC system to the preset PLC conversion database.

[0052] Step S104 : Acquire a second PLC system, where the second PLC system is any PLC system in a preset PLC conversion database except the first PLC system.

[0053] Specifically, a second PLC system is obtained, where the second PLC system is a PLC system specified by the user for conversion. The user can select any PLC system other than the first PLC system in a preset PLC conversion database to perform code conversion operations on the PLC code to be converted.

[0054] Step S105 : obtaining a second code conversion feature corresponding to the second PLC system from a preset PLC conversion database, where the preset PLC conversion database is used to store a second correspondence between the second PLC system and the second code conversion feature.

[0055] Specifically, the second code conversion feature corresponding to the second PLC system is obtained in the preset PLC conversion database: the second PLC system can be any PLC system other than the first PLC system, which is stored in the preset PLC conversion database in advance according to the method in step S103, and the second code conversion feature corresponding to the second PLC system is obtained according to the corresponding relationship constructed in step S103.

[0056] Step S106: obtaining a difference feature between the first code conversion feature and the second code conversion feature, where the difference feature is a different control logic feature between the first code conversion feature and the second code conversion feature.

[0057] Specifically, the difference features between the first code conversion feature and the second code conversion feature are obtained. The above difference features are mainly reflected in different control logic features, that is, the different features between the two in condition judgment difference features, control sequence difference features, loop structure difference features, etc. are identified.

[0058] Step S107 : converting the PLC code to be converted into a target PLC code according to the difference characteristics, where the target PLC code is the PLC code corresponding to the second PLC system.

[0059] Specifically, a code conversion operation is performed according to the difference characteristics, and the PLC code to be converted is converted into a target PLC code, where the target PLC code is a PLC code corresponding to the second PLC system.

[0060] For example, assuming the first PLC system is a Siemens system, and the first code conversion features include: Programming language features: Ladder Diagram Instruction set features: LD, A, O and other logical instructions, comparison instructions (==, >, <) Variable naming rule features: Prefix plus type (such as I0.0 for input, Q0.0 for output) Function library features: Timer and counter functions; assuming the second PLC system is a Rockwell Automation system, the second code conversion features include: Programming language features: Structured text The system analyzes and obtains difference features, that is, compares the first code conversion features and the second code conversion features corresponding to the Siemens system and the Rockwell system respectively, and identifies the following difference features: Programming language feature differences: Siemens uses ladder diagrams, and Rockwell uses structured text; Instruction set differences: Siemens' instruction set includes logic instructions such as LD, A, and O, and Rockwell's instruction set includes logic instructions such as IF, AND, and OR; Variable naming rule differences: Siemens system uses a variable naming rule of prefix plus type, and Rockwell system uses all lowercase letters; Function library differences: Siemens system uses timer and counter functions, and Rockwell system uses string processing functions and mathematical operation functions. Then, based on the identified difference features, the code conversion logic is adjusted to ensure that the converted second code conversion feature is correctly executed in the second PLC system. It should be noted that this embodiment does not limit the type of the first PLC system, the type of the second PLC system, and the type of the difference between the first code conversion feature and the second code conversion feature.

[0061] In a possible embodiment, step S107 also includes: obtaining a predicted data stream and a standard data stream corresponding to the target PLC code; obtaining deviation data between the predicted data stream and the standard data stream, and calculating a target deviation value corresponding to the predicted data stream and the standard data stream based on the deviation data; determining whether the target deviation value is less than a preset deviation value; if the target deviation value is less than the preset deviation value, confirming that no conversion abnormality occurs in the PLC code conversion operation.

[0062] Specifically, a predicted data flow and a standard data flow corresponding to the target PLC code are obtained. The predicted data flow is the data flow generated by the target PLC code through execution path simulation operations, and the standard data flow is the data flow generated by the target PLC code during normal operation. The standard data flow is the data flow originally generated by the code to be converted during operation. The historical operation data of the PLC code to be converted in the actual operating environment can be used as the standard data flow. That is, the PLC code conversion model constructs a simulated operation scenario corresponding to the target PLC code. This scenario can be simulated in various ways, including but not limited to software simulation and virtual debugging platform simulation. Software simulation involves using PLC simulation software to simulate the actual PLC operating environment, executing the target PLC code, and generating a predicted data flow. Virtual debugging platform simulation involves using a virtual debugging platform (such as digital twin technology) to create a virtual production environment, executing the target PLC code to simulate actual operation and obtain a predicted data flow. This embodiment does not limit the construction method of the simulated operation scenario. The predicted data flow is obtained by executing the target PLC code in the simulated operation scenario. Calculate the data deviation between the predicted data stream and the corresponding data stream in the standard data stream, and based on the data deviation, calculate the overall deviation level. For example, statistical methods such as mean square error (MSE) or mean absolute error (MAE) can be used to determine a target deviation value between the predicted data stream and the standard data stream. If the target deviation value is less than the preset deviation value, it confirms that the PLC code conversion operation has not experienced any conversion anomalies, indicating that the converted code can function normally in actual operation.

[0063] In one possible embodiment, step S107 also includes: if the target deviation value is greater than or equal to the preset deviation value, confirming that a conversion abnormality occurs in the PLC code conversion operation; obtaining a deviation type corresponding to the deviation data, and obtaining a deviation analysis report based on the deviation type; sending the deviation analysis report to the user, the deviation analysis report including the deviation type and a recommended modification plan corresponding to the deviation type.

[0064] Specifically, if the target deviation value is greater than or equal to the preset deviation value, it is confirmed that a conversion abnormality occurs in the PLC code conversion operation. At this time, the PLC code conversion model obtains the deviation type corresponding to the deviation data, and obtains a deviation analysis report based on the deviation type, and sends the deviation analysis report to the user. The user can view the target PLC code and the deviation analysis report through the user interface in step S101. The deviation analysis report includes the deviation type and the recommended modification plan corresponding to the deviation type. The recommended modification plan needs to be constructed in advance based on the abnormalities that may occur in the conversion process of the PLC code to be converted. The problems that may occur in the conversion process of the PLC code to be converted include but are not limited to: code missing, instruction incompatibility, communication protocol mismatch, etc., among which, code missing: some code fragments are not correctly converted or lost during the conversion process; instruction incompatibility: some instructions in the first PLC system are not supported or behave differently in the second PLC system; communication protocol mismatch: the communication protocols used between the first system and the second system are different, resulting in data transmission problems. The recommended modification plans include but are not limited to code completion suggestions, logic adjustment suggestions, communication protocol configuration guidance, etc. Among them, code completion suggestions: provide completion plans or alternative methods for missing codes in the target PLC code for user reference; logic adjustment suggestions: provide examples of adjusted logic structures to ensure that the target PLC code implements the same control logic in the second system; communication protocol configuration guidance: provides detailed steps for configuring and using the corresponding communication protocol in the second system.

[0065] The present application adopts the above method. When the user performs a PLC code conversion operation, the PLC code to be converted is obtained, the target PLC system corresponding to the PLC code to be converted is obtained, and the first PLC system is obtained in the preset PLC conversion database. The preset PLC conversion database is used to store multiple preset PLC systems. The first PLC system is any one of the multiple preset PLC systems. If it is confirmed that the target PLC system is the first PLC system, the first code conversion feature corresponding to the first PLC system is obtained in the preset PLC conversion database. The preset PLC conversion database is used to store a first correspondence between the first PLC system and the first code conversion feature. At this time, the second PLC system is obtained. The second PLC system is any PLC system other than the first PLC system in the preset PLC conversion database. A second code conversion feature corresponding to the second PLC system is obtained from a preset PLC conversion database. The preset PLC conversion database is used to store a second correspondence between the second PLC system and the second code conversion feature, and obtain a difference feature between the first code conversion feature and the second code conversion feature. The difference feature is a different control logic feature between the first code conversion feature and the second code conversion feature. According to the difference feature, the PLC code to be converted is converted into a target PLC code. The target PLC code is the PLC code corresponding to the second PLC system, thereby improving the PLC code conversion efficiency through automated analysis and conversion, not only reducing errors generated during manual conversion, but also achieving compatibility across cross-brand PLC systems, thereby solving the problem that the manual conversion process is cumbersome and time-consuming, and the PLC code conversion efficiency between different systems is low.

[0066] Please refer to Figure 2 , which shows a module schematic diagram of an adaptive PLC code conversion device provided by an embodiment of the present application. The device is a PLC code conversion model. The PLC code conversion model includes an acquisition module 21 and a processing module 22, wherein,

[0067] The acquisition module 21 is configured to acquire the PLC code to be converted in response to a user's PLC code conversion operation; acquire a target PLC system corresponding to the PLC code to be converted, and acquire a first PLC system from a preset PLC conversion database, the preset PLC conversion database being used to store a plurality of preset PLC systems, the first PLC system being any one of the plurality of preset PLC systems; if the target PLC system is confirmed to be the first PLC system, acquire a first code conversion feature corresponding to the first PLC system from the preset PLC conversion database, the preset PLC conversion database being used to store a first correspondence between the first PLC system and the first code conversion feature; acquire a second PLC system, the second PLC system being any PLC system other than the first PLC system in the preset PLC conversion database; acquire a second code conversion feature corresponding to the second PLC system from the preset PLC conversion database, the preset PLC conversion database being used to store a second correspondence between the second PLC system and the second code conversion feature; and acquire a difference feature between the first code conversion feature and the second code conversion feature, the difference feature being a control logic feature that is different between the first code conversion feature and the second code conversion feature.

[0068] The processing module 22 is configured to convert the PLC code to be converted into a target PLC code according to the difference characteristics, where the target PLC code is a PLC code corresponding to the second PLC system.

[0069] In one possible embodiment, the acquisition module 21 is used to, if it is confirmed that the target PLC system is the first PLC system, before obtaining the first code conversion feature corresponding to the first PLC system in the preset PLC conversion database, it is necessary to construct a preset PLC conversion database, specifically including: obtaining multiple preset PLC codes corresponding to multiple preset PLC systems, one preset PLC system corresponds to one or more preset PLC codes; performing preprocessing operations on the multiple preset PLC codes respectively, the preprocessing operations are used to obtain multiple preset code conversion features corresponding to the multiple preset PLC codes, the preset code conversion features include programming language features, instruction set features, variable naming rule features and function library features; constructing a correspondence between multiple preset PLC systems and multiple preset code conversion features, one preset PLC system corresponds to one or more preset code conversion features; storing the correspondence between multiple preset PLC systems and multiple preset code conversion features in the preset PLC conversion database.

[0070] In one possible embodiment, the acquisition module 21 is used to, if it is confirmed that the target PLC system is the first PLC system, before obtaining the first code conversion feature corresponding to the first PLC system in the preset PLC conversion database, the method also includes: if it is confirmed that the target PLC system is not the first PLC system, performing a preprocessing operation on the PLC code to be converted to obtain a third code conversion feature corresponding to the PLC code to be converted; and storing the correspondence between the first PLC system and the third code conversion feature in the preset PLC conversion database.

[0071] In a possible implementation, the difference features include condition judgment difference features, control sequence difference features, and loop structure difference features.

[0072] In one possible embodiment, the processing module 22 is used to convert the PLC code to be converted into the target PLC code according to the difference characteristics, and the method also includes: obtaining the predicted data stream and the standard data stream corresponding to the target PLC code; obtaining the deviation data between the predicted data stream and the standard data stream, and calculating the target deviation value corresponding to the predicted data stream and the standard data stream based on the deviation data; judging whether the target deviation value is less than the preset deviation value; if the target deviation value is less than the preset deviation value, confirming that no conversion abnormality occurs in the PLC code conversion operation.

[0073] In one possible embodiment, the processing module 22 is used to determine whether the target deviation value is less than the preset deviation value, and the method also includes: if the target deviation value is greater than or equal to the preset deviation value, confirming that a conversion abnormality occurs in the PLC code conversion operation; obtaining the deviation type corresponding to the deviation data, and obtaining a deviation analysis report based on the deviation type; sending the deviation analysis report to the user, the deviation analysis report including the deviation type and a recommended modification plan corresponding to the deviation type.

[0074] In a possible implementation, the user performs a PLC code conversion operation through a user interface, and the user interface is also used to view the target PLC code and the deviation analysis report.

[0075] It should be noted that the above embodiments provide devices that implement their functions using only the division of the above functional modules as examples. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiments are based on the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.

[0076] This application also provides an electronic device. Figure 3 , Figure 33 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present application. The electronic device may include: at least one processor 301, at least one communication bus 302, a user interface 303, at least one network interface 304, and a memory 305.

[0077] The communication bus 302 is used to implement the connection and communication between these components.

[0078] The user interface 303 may include a display screen (Display) and a camera (Camera). Optionally, the user interface 303 may also include a standard wired interface and a wireless interface.

[0079] The network interface 304 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface).

[0080] The processor 301 may include one or more processing cores. Using various interfaces and circuits, the processor 301 connects various components within the PLC code conversion model. It executes instructions, programs, code sets, or instruction sets stored in the memory 305, as well as accesses data stored in the memory 305, to perform various functions of the PLC code conversion model and process data. Optionally, the processor 301 may be implemented using at least one of the following hardware forms: a digital signal processing (DSP), a field-programmable gate array (FPGA), or a programmable logic array (PLA). The processor 301 may integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. The CPU primarily processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing content displayed on the display screen; and the modem handles wireless communications. It is understood that the modem may also be implemented independently of the processor 301 and implemented as a separate chip.

[0081] Among them, the memory 305 may include a random access memory (RAM) or a read-only memory (Read-Only Memory). Optionally, the memory 305 includes a non-transitory computer-readable storage medium. The memory 305 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 305 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 305 may also optionally be at least one storage device located away from the aforementioned processor 301. Refer to Figure 3 , the memory 305 as a computer storage medium may include an operating system, a network communication module, a user interface module and an adaptive PLC code conversion application.

[0082] exist Figure 3 In the electronic device shown, the user interface 303 is mainly used to provide an input interface for the user and obtain the data input by the user; and the processor 301 can be used to call the adaptive PLC code conversion application stored in the memory 305. When executed by one or more processors 301, the electronic device executes one or more of the methods described in the above embodiments. It should be noted that for the aforementioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should know that this application is not limited to the described order of actions, because according to this application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required for this application.

[0083] The present application also provides a computer-readable storage medium storing instructions, which, when executed by one or more processors, enable an electronic device to execute one or more of the methods described in the above embodiments.

[0084] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0085] In the several embodiments provided in this application, it should be understood that the disclosed devices can be implemented in other ways. For example, the device embodiments described above are merely schematic, such as the division of units, which is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some service interface, and the indirect coupling or communication connection of devices or units can be electrical or other forms.

[0086] Units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.

[0087] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0088] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of this application, or the portion that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions for causing a computer device (which can be a personal computer, a PLC code conversion model, or a network device, etc.) to execute all or part of the steps of the various embodiments of the method of this application. The aforementioned memory includes various media that can store program code, such as USB flash drives, mobile hard drives, magnetic disks, or optical disks.

[0089] The foregoing description is merely an exemplary embodiment of the present disclosure and does not limit the scope of the present disclosure. In other words, any equivalent variations and modifications made based on the teachings of the present disclosure are still within the scope of the present disclosure. Those skilled in the art will readily conceive of other embodiments of the present disclosure after considering the disclosure and practical experience.

[0090] This application is intended to cover any modifications, uses or adaptations disclosed in this application, which follow the general principles disclosed in this application and include common knowledge or customary technical means in the technical field not disclosed in this application.

Claims

1. An adaptive PLC code conversion method, characterized in that: Applied to the PLC code conversion model, the method includes: In response to a PLC code conversion operation by a user, obtaining a PLC code to be converted; Obtaining a target PLC system corresponding to the PLC code to be converted, and obtaining a first PLC system from a preset PLC conversion database, wherein the preset PLC conversion database is used to store multiple preset PLC systems, and the first PLC system is any one of the multiple preset PLC systems; If it is confirmed that the target PLC system is the first PLC system, obtaining a first code conversion feature corresponding to the first PLC system in a preset PLC conversion database, wherein the preset PLC conversion database is used to store a first correspondence between the first PLC system and the first code conversion feature; Acquire a second PLC system, where the second PLC system is any PLC system in the preset PLC conversion database except the first PLC system; obtaining a second code conversion feature corresponding to the second PLC system in the preset PLC conversion database, wherein the preset PLC conversion database is used to store a second correspondence between the second PLC system and the second code conversion feature; obtaining a difference feature between the first code conversion feature and the second code conversion feature, where the difference feature is a different control logic feature between the first code conversion feature and the second code conversion feature; According to the difference characteristics, the PLC code to be converted is converted into a target PLC code, and the target PLC code is a PLC code corresponding to the second PLC system.

2. The method according to claim 1, characterized in that If it is confirmed that the target PLC system is the first PLC system, before obtaining the first code conversion feature corresponding to the first PLC system in the preset PLC conversion database, it is necessary to construct the preset PLC conversion database, specifically including: Acquire a plurality of preset PLC codes corresponding to the plurality of preset PLC systems, wherein one preset PLC system corresponds to one or more preset PLC codes; performing a preprocessing operation on each of the plurality of preset PLC codes, wherein the preprocessing operation is used to obtain a plurality of preset code conversion features corresponding to the plurality of preset PLC codes, the preset code conversion features including programming language features, instruction set features, variable naming rule features, and function library features; Establishing a correspondence between a plurality of the preset PLC systems and a plurality of the preset code conversion features, wherein one preset PLC system corresponds to one or more preset code conversion features; The correspondence between the plurality of the preset PLC systems and the plurality of the preset code conversion features is stored in the preset PLC conversion database.

3. The method according to claim 2, characterized in that If it is confirmed that the target PLC system is the first PLC system, before obtaining the first code conversion feature corresponding to the first PLC system in the preset PLC conversion database, the method further includes: If it is determined that the target PLC system is not the first PLC system, performing the preprocessing operation on the PLC code to be converted to obtain a third code conversion feature corresponding to the PLC code to be converted; The correspondence between the first PLC system and the third code conversion feature is stored in the preset PLC conversion database.

4. The method according to claim 1, wherein The difference features include condition judgment difference features, control sequence difference features and loop structure difference features.

5. The method according to claim 1, wherein After converting the to-be-converted PLC code into a target PLC code according to the difference characteristics, the method further includes: Obtaining a predicted data stream and a standard data stream corresponding to the target PLC code; Obtaining deviation data between the predicted data stream and the standard data stream, and calculating a target deviation value corresponding to the predicted data stream and the standard data stream based on the deviation data; Determining whether the target deviation value is less than a preset deviation value; If the target deviation value is smaller than the preset deviation value, it is confirmed that no conversion abnormality occurs in the PLC code conversion operation.

6. The method according to claim 5, characterized in that After determining whether the target deviation value is less than a preset deviation value, the method further includes: If the target deviation value is greater than or equal to the preset deviation value, it is confirmed that the conversion abnormality occurs in the PLC code conversion operation; Obtaining a deviation type corresponding to the deviation data, and obtaining a deviation analysis report based on the deviation type; The deviation analysis report is sent to the user, where the deviation analysis report includes the deviation type and a recommended modification solution corresponding to the deviation type.

7. The method according to claim 6, characterized in that The user performs the PLC code conversion operation through a user interface, and the user interface is also used to view the target PLC code and the deviation analysis report.

8. An adaptive PLC code conversion device, characterized in that: The device comprises an acquisition module (21) and a processing module (22), wherein: The acquisition module (21) is used to acquire the PLC code to be converted in response to the user's PLC code conversion operation; acquire the target PLC system corresponding to the PLC code to be converted, and acquire a first PLC system in a preset PLC conversion database, the preset PLC conversion database is used to store multiple preset PLC systems, and the first PLC system is any one of the multiple preset PLC systems; if it is confirmed that the target PLC system is the first PLC system, acquire the first code conversion feature corresponding to the first PLC system in the preset PLC conversion database, the preset PLC conversion database is used to store a first corresponding relationship between the first PLC system and the first code conversion feature; acquire a second PLC system, the second PLC system is any PLC system other than the first PLC system in the preset PLC conversion database; acquire a second code conversion feature corresponding to the second PLC system in the preset PLC conversion database, the preset PLC conversion database is used to store a second corresponding relationship between the second PLC system and the second code conversion feature; acquire a difference feature between the first code conversion feature and the second code conversion feature, the difference feature being a different control logic feature between the first code conversion feature and the second code conversion feature; The processing module (22) is used to convert the PLC code to be converted into a target PLC code according to the difference characteristics, and the target PLC code is the PLC code corresponding to the second PLC system.

9. An electronic device, characterized in that: The electronic device comprises a processor (301), a communication bus (302), a user interface (303), a network interface (304) and a memory (305), wherein the memory (305) is used to store instructions, the user interface (303) and the network interface (304) are used to communicate with other devices, and the processor (301) is used to execute the instructions stored in the memory (305) so that the electronic device executes the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores instructions, and when the instructions are executed, the method according to any one of claims 1 to 7 is performed.

Citation Information

Patent Citations

  • Code conversion method and device used for numerical control system

    CN101794140A

  • PLC application package generation method, PLC application execution method and related device and system

    CN114706590A