Method and device for converting original ladder diagram into target ladder diagram
By splicing and identifying screenshots of ladder diagrams, a collection of connection relationships is constructed, which solves the problems of unclear pictures and difficult logical understanding in ladder diagram migration, and improves the accuracy and compatibility of the transformation.
Patent Information
- Application Number
- CN202411872399.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-18
- Publication Date
- 2025-04-11
AI Technical Summary
In the prior art, when migrating the ladder diagram program from one configuration software to another, there is a problem that the picture is unclear or incomplete, resulting in identification errors. At the same time, some tools cannot understand the internal logic of the ladder diagram, resulting in low conversion accuracy.
By obtaining multiple screenshots of the original ladder diagram and splicing them according to the overlapping areas between the screenshots, a complete original ladder diagram is formed. Then identify each element and connection relationship in the graph, build a set of connection relationships, and finally generate a target ladder diagram based on the set.
Improve the accuracy of ladder diagram conversion, solve the recognition errors caused by unclear or incomplete pictures, and generate target ladder diagrams that meet the target format specifications by understanding the internal logic of ladder diagrams.
Smart Images

Figure CN119810865A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to a technical field related to configuration software data migration, and in particular to a method and device for converting an original ladder diagram into a target ladder diagram. Background Art
[0002] Ladder diagram is an important graphical programming language in industrial automation. It represents control logic in a graphical form, which is easy to understand and maintain. However, unlike text-based programming languages, graphical programming languages cannot freely migrate ladder diagram program projects in multiple configuration software. By analyzing the existing ladder diagram data migration methods, it is found that there may be the following disadvantages:
[0003] On the one hand, when using the graphical import method, due to the large size of the ladder diagram project, the size of the captured or screenshot image is small, resulting in unclear or incomplete images, which causes the ladder diagram in the image to be missing, all of which can lead to recognition errors.
[0004] On the other hand, some ladder diagram import or migration tools may not understand the internal logic of the ladder diagram (such as connection relationships, etc.), resulting in frequent errors or non-compliance with specifications during the conversion process, resulting in low accuracy. For example, the conversion of connection relationships can only follow the format specifications of the original ladder diagram (such as: the first end of the first element is connected to the bus, and the first end of the second element is connected to the first end of the first element), and it is difficult to convert the target ladder diagram format specification to a connection method equivalent to the original connection relationship and the target ladder diagram format specification (such as: the first end of the first element is connected to the bus, and the first end of the second element is connected to the bus).
[0005] Therefore, how to provide a solution for converting an original ladder diagram into a target ladder diagram that can solve the above-mentioned technical problems and improve the accuracy of the conversion is a technical problem to be solved. Summary of the invention
[0006] In view of the above problems in the prior art, the present application provides a solution for converting an original ladder diagram into a target ladder diagram, which can improve the accuracy of ladder diagram conversion.
[0007] To achieve the above-mentioned object, the first aspect of the present application provides a method for converting an original ladder diagram into a target ladder diagram, comprising:
[0008] Acquire multiple screenshots of the original ladder diagram, each screenshot being a partial screenshot of the original ladder diagram, and any one of the screenshots at least has an overlapping area with an image in another screenshot;
[0009] According to the overlapping area, the plurality of screenshots are stitched together to generate a picture including the complete original ladder diagram;
[0010] Identify the elements in the original ladder diagram in the picture and the connection relationship between the elements, and construct a connection relationship set, wherein the connection relationship set records the connection relationship between the elements;
[0011] A target ladder diagram is generated according to the elements and the connection relationships between the elements recorded in the connection relationship set.
[0012] On the one hand, when using the graphical import method, due to the large size of the ladder diagram project, the size of the captured or screenshot image is small, resulting in unclear or incomplete images, which causes the ladder diagram in the image to be missing, all of which can lead to recognition errors.
[0013] On the other hand, some ladder diagram import or migration tools may not be able to understand the internal logic of the ladder diagram (such as connection relationships, etc.), resulting in frequent errors in the conversion process and low accuracy.
[0014] From the above, by directly processing the screenshots of each part of the complete original ladder diagram, a relatively clear image of each part of the original ladder diagram can be obtained, and then restored to the complete original ladder diagram by splicing, which solves the problem of missing ladder diagrams in the picture caused by unclear or incomplete pictures, and improves the accuracy of conversion. In addition, by generating each connection relationship set, the internal logic of the ladder diagram can be accurately understood based on each connection relationship set and the target ladder diagram can be generated accordingly, which improves the accuracy of conversion. On the other hand, it is also possible to reduce user operations and provide convenient services by automatically splicing pictures.
[0015] As a possible implementation manner of the first aspect, the connection relationship set records the elements and the connection relationships between the elements in the following manner:
[0016] Element item, each data record records the identifier of an element;
[0017] Connection relationship items, each piece of data represents a connection, recording the source element and target element of the connection.
[0018] From the above, by recording the element identifiers to quickly mark the identified element items, and by recording the connection relationship items to directly associate the elements to obtain the logical relationship between the elements, the target ladder diagram required by the format specification can be generated accordingly, thereby improving the accuracy of the conversion.
[0019] As a possible implementation manner of the first aspect, at least one of the data in the element item further records a port identifier of a port included in the element;
[0020] At least one of the data in the connection relationship item further records the port identifier of the port included in the source element of the connection or the port identifier of the port included in the target element.
[0021] From the above, since an element item may contain more than one port, the ports and port identifiers should also be recorded for multi-port elements and corresponding connection relationship items, which further improves the accuracy of ladder diagram conversion.
[0022] As a possible implementation manner of the first aspect, at least one of the data in the element item further records the type of the element or an associated variable.
[0023] From the above, by recording the element type and the associated variables to classify the element type, it is convenient for subsequent conversion. The associated variables are directly associated with the element items to avoid information loss, further improving the accuracy of ladder diagram conversion.
[0024] As a possible implementation manner of the first aspect, the element includes at least one of the following: a bus, a coil, a contact, a function block, a variable or a symbol.
[0025] From the above, the busbars, coils, contacts, function blocks, variables and symbols in the image can be identified.
[0026] As a possible implementation of the first aspect, in response to a user operation, the generated target ladder diagram overwrites the current file, overwrites the selected program segment, is added to the selected program segment, or is added to a new program segment.
[0027] From the above, the ladder diagram imported by the application of different insertion settings is convenient for users to meet their actual needs.
[0028] As a possible implementation manner of the first aspect, missing variables, missing functions or missing function blocks of related association table items of the target ladder diagram are created according to the connection relationship set.
[0029] From the above, it is possible to automatically supplement the missing contents in the associated table items in the target ladder diagram program without the need for the user to manually define these missing variables, functions or function blocks.
[0030] As a possible implementation of the first aspect, the multiple screenshots obtained are displayed in a certain orientation order, and can respond to user operations to perform one of the following: re-acquisition of any screenshot, adjustment of the position or angle of any screenshot, addition or deletion of any screenshot.
[0031] From the above, adjusting the screenshots in sequence can reduce the error rate in the image stitching process and improve efficiency.
[0032] A second aspect of the present application provides a device for converting an original ladder diagram into a target ladder diagram, comprising:
[0033] An image acquisition module, used to acquire multiple screenshots of the original ladder diagram, each screenshot being a partial screenshot of the original ladder diagram, and any one of the screenshots at least has an overlapping area with an image in another screenshot;
[0034] An image stitching module, used for stitching the plurality of screenshots together according to the overlapping area to generate an image including the complete original ladder diagram;
[0035] An image recognition module, used to recognize the elements in the original ladder diagram in the image and the connection relationship between the elements, and to construct a connection relationship set, wherein the connection relationship set records the connection relationship between the elements;
[0036] The ladder diagram generation module is used to generate a target ladder diagram according to the elements and the connection relationships between the elements recorded in the connection relationship set.
[0037] A third aspect of the present application provides a computing device, comprising: a processor, and a memory, on which program instructions are stored. When the program instructions are executed by the processor, the processor executes the method of converting an original ladder diagram into a target ladder diagram as described in any one of the first aspects. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 It is a flowchart of a first embodiment of a method for converting an original ladder diagram into a target ladder diagram of the present application;
[0039] Figure 2 is a flow chart of a second embodiment of the method for converting an original ladder diagram into a target ladder diagram of the present application;
[0040] Figure 3 is a schematic diagram of the original ladder diagram program provided in the second embodiment of the present application;
[0041] Figure 4 It is the first part of the original ladder diagram program screenshot provided in the second embodiment of the present application;
[0042] Figure 5 It is the second part of the original ladder diagram program screenshot provided in the second embodiment of the present application;
[0043] Figure 6 This is a schematic diagram of an interface for importing screenshots provided in the second embodiment of the present application;
[0044] Figure 7 It is a splicing schematic diagram of the imported screenshots provided in the second embodiment of the present application;
[0045] Figure 8 This is a schematic diagram of compatibility processing provided by the second embodiment of the present application;
[0046] Fig. 9It is a schematic diagram of a device for converting an original ladder diagram into a target ladder diagram provided by an embodiment of the present application;
[0047] Fig.10 It is a structural schematic diagram of a computing device provided in an embodiment of the present application.
[0048] It should be understood that the size and shape of each block diagram in the above structural diagram are for reference only and should not constitute an exclusive interpretation of the embodiment of the present invention. The relative position and inclusion relationship between the blocks presented in the structural diagram are only schematic representations of the structural association between the blocks, and do not limit the physical connection method of the embodiment of the present invention. DETAILED DESCRIPTION
[0049] The technical solution provided by the present application is further described below with reference to the accompanying drawings and examples. It should be understood that the system structure and business scenarios provided in the examples of the present application are mainly to illustrate the possible implementation methods of the technical solution of the present application and should not be interpreted as the only limitation on the technical solution of the present application. It is known to those of ordinary skill in the art that with the evolution of the system structure and the emergence of new business scenarios, the technical solution provided by the present application is also applicable to similar technical problems.
[0050] It should be understood that the scheme for converting the original ladder diagram into the target ladder diagram provided in the embodiment of the present application includes a method, device and computing device for converting the original ladder diagram into the target ladder diagram. Since the principles of solving the problems in these technical solutions are the same or similar, some repetitions may not be repeated in the introduction of the following specific embodiments, but it should be regarded as that these specific embodiments have been referenced to each other and can be combined with each other.
[0051] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of this application. In the event of any inconsistency, the meaning described in this specification or the meaning derived from the contents recorded in this specification shall prevail. In addition, the terms used herein are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application. In order to accurately describe the technical content in this application and to accurately understand the present invention, the following explanations or definitions are given to the terms used in this specification before describing the specific embodiments:
[0052] 1) ORB algorithm (Oriented FAST and Rotated BRIEF, ORB): It is a feature description algorithm that combines the FAST corner detection algorithm and the BRIEF descriptor algorithm. It is highly efficient and rotationally invariant, and is widely used in the field of computer vision.
[0053] 2) Open Source Computer Vision Library (OpenCV): is a cross-platform computer vision and machine learning software library that provides a large number of pre-built algorithms, functions, and APIs for developing real-time computer vision applications. The library supports multiple programming languages, including C++, Python, Java, etc., and can run on multiple operating systems, such as Windows, Linux, Mac OS X, iOS, Android, etc. OpenCV is widely used in image processing, video analysis, video capture, machine learning, real-time image analysis and other fields.
[0054] 3) Convolutional Neural Network (CNN): It is a deep learning model that is mainly used to process data with a grid-like structure, such as images. CNN simulates the working principle of the human visual system and uses convolutional layers to extract features automatically and layer by layer. This network structure is particularly suitable for tasks such as image recognition, video analysis, and image classification.
[0055] The scheme for converting the original ladder diagram into the target ladder diagram provided in the embodiment of the present application can obtain multiple screenshots of the original ladder diagram, and according to the overlapping areas between the multiple screenshots, stitch the multiple screenshots to generate a complete picture of the original ladder diagram; by identifying the connection relationship between the elements in the picture and the elements, a connection relationship set is constructed; finally, the target ladder diagram is generated according to the connection relationship set. This method can provide a scheme for converting the original ladder diagram into the target ladder diagram, which is simple and easy to understand for users to operate, can be efficiently imported in batches, and can generate a target ladder diagram that meets the specifications of the target ladder diagram program based on the connection relationship set, with high accuracy and good compatibility. The embodiment of the present application can be applied to ladder diagram recognition and migration in various fields such as industrial automation, electronics and electrical. The embodiments of the present application are described in detail below with reference to the accompanying drawings.
[0056] The first embodiment of the present application provides a method for converting an original ladder diagram into a target ladder diagram. Figure 1 , the implementation of each step of the method is specifically described, including steps S10-S40.
[0057] S10: Acquire multiple screenshots of the original ladder diagram, each screenshot being a partial screenshot of the original ladder diagram, and any one of the screenshots at least has an overlapping area with an image in another screenshot.
[0058] In some embodiments, a ladder diagram program project includes multiple graphical program segments; wherein the program segments have information such as names and notes; each of the program segments contains graphic elements such as coils, contacts, function blocks, variables, symbols, and connecting lines between the graphic elements.
[0059] In some embodiments, the screenshot formats of the ladder diagram program project may include PNG, JPG, PDF, SVG, etc. to meet the usage requirements in different scenarios.
[0060] In some embodiments, the screenshots may include the entire ladder diagram program project, or may include a part of the ladder diagram program project, and multiple screenshots together constitute a complete ladder diagram program project; wherein, multiple screenshots must contain a part of overlapping areas to facilitate the subsequent use of algorithms to identify adjacent screenshots for splicing.
[0061] In some embodiments, the multiple screenshots obtained are displayed in a certain orientation order, and can respond to user operations to perform one of the following: re-acquisition of any screenshot, adjustment of the position or angle of any screenshot, addition or deletion of any screenshot. Among them, the certain orientation order can be adjusted from left to right or from top to bottom. The order, position, direction, deformation, etc. of the pictures can also be adjusted by setting serial numbers, providing a visual management interface, etc., to ensure that the screenshots can be quickly spliced into a complete ladder diagram program project; the program can directly load pictures or select a folder and load the pictures in the folder in order.
[0062] In some embodiments, the imported screenshots of different resolutions can also be adjusted to meet the display and splicing requirements; the repeatedly inserted screenshots can also be automatically detected and removed to avoid errors.
[0063] In some embodiments, the screenshot image may also be pre-processed by grayscale conversion, equalization, normalization, filtering, denoising, etc. to improve the recognizability of the image.
[0064] S20: According to the overlapping area, the plurality of screenshots are spliced together to generate a picture including the complete original ladder diagram.
[0065] In some embodiments, the ORB algorithm can be used to identify feature points in the screenshots, and the screenshots are sequentially attempted to be spliced left and right, and top and bottom. The feature points of the two screenshots to be spliced are matched by descriptors, feature point positions, similarities, etc. If the feature matching of the two screenshots is successful, the splicing is successful; if the feature matching of the two screenshots is unsuccessful, the splicing is unsuccessful, and the default is top and bottom splicing; wherein, the top and bottom splicing can be performed by identifying the position of the busbar. According to the above principles, a complete screenshot image after splicing is finally obtained.
[0066] In some embodiments, automatic splicing, semi-automatic splicing or manual splicing may be provided to meet different needs; wherein semi-automatic splicing requires user assistance to confirm the splicing points.
[0067] In some embodiments, in addition to using the ORB algorithm, SIFT, SURF, AKAZE, BRISK, KAZE and other algorithms may also be used for feature point recognition and matching.
[0068] S30: identifying the elements in the original ladder diagram in the image and the connection relationships between the elements, and constructing a connection relationship set, wherein the connection relationship set records the connection relationships between the elements.
[0069] In some embodiments, the contour detection algorithm provided by OpenCV is used to detect the contours of each object (such as each element, connecting line) in the image; in addition, the edge detection function provided by tools such as MATLAB, PIL, Scikit-image, etc. can also be used to detect the contours of each object in the image.
[0070] In some embodiments, after obtaining the image outline, a pre-trained CNN model or other model is used to identify the primitive elements of the image. Among them, the pre-trained CNN model can be trained and verified by an image database that annotates the type, position, connection relationship, associated variables and other data of the primitive elements. The specific annotation content can be selected according to the recognition requirements; then the model's recognition accuracy of the primitives and connection relationships is improved by fine-tuning, adjusting parameters, etc. Among them, the variables and identifiers in the image (such as device identifiers, port identifiers, etc.) can also be obtained from the image through OCR text recognition.
[0071] In some embodiments, a connection relationship set is established based on the identified elements and connection lines, and is stored in a description method that can be recognized by the imported working environment, such as a general table method, XML format, etc. After obtaining the connection relationship set, a logic check can be performed on it, and a prompt for logical errors can be given. After the user makes modifications or confirmations, subsequent steps are executed; the correct element type and connection relationship can also be automatically corrected or inferred through the error prompt of the logical relationship.
[0072] In some embodiments, the connection relationship set records the connection relationships between the elements in the following manner: element items, each piece of data records the identifier of an element; connection relationship items, each piece of data represents a connection, recording the source element and target element of the connection.
[0073] In some embodiments, at least one of the data in the element items also records the port identifier of the port included in the element; at least one of the data in the connection relationship items also records the port identifier of the port included in the source element of the connection or the port identifier of the port included in the target element.
[0074] In some embodiments, at least one of the data items in the element item also records the type or variable of the element.
[0075] In some embodiments, the element includes at least one of: a bus, a coil, a contact, a function block, a variable, or a symbol.
[0076] In some embodiments, in the connection relationship set, each element recorded is traversed from the original ladder diagram from left to right and from top to bottom. The recorded connection relationship is traversed from the original ladder diagram from left to right and from top to bottom.
[0077] The logical relationship between elements is described by a connection relationship set, which shields different ways of drawing the same connection relationship. Figure 8 The left and right figures use two different drawing methods for the connection between element A, element C and the busbar, but the description of the connection relationship is the same, both of which are the left busbar connecting the input of element A and the left busbar connecting the input of element C.
[0078] S40: Generate a target ladder diagram according to the elements and the connection relationships between the elements recorded in the connection relationship set.
[0079] In some embodiments, a ladder diagram program is generated based on the identified connection relationship set, and the ladder diagram is displayed according to the display rules of the imported working environment. Figure 8 The right figure shown is the generated target ladder diagram, which is equivalent to the original ladder diagram (left figure), but is a ladder diagram that conforms to the display rules of the entered working environment (ie, the target ladder diagram program).
[0080] In some embodiments, the generated target ladder diagram can respond to the user's operation, and the generated target ladder diagram can overwrite the current file, overwrite the selected program segment, add to the selected program segment, or add to a new program segment. Among them, the operation can modify the existing file in the imported working environment.
[0081] In some embodiments, according to the created connection relationship set, the missing variables, missing functions or function blocks in the target ladder diagram related association table items are automatically created. Among them, the target ladder diagram related association table items may include a global variable table and a function block library. For example, in the element item of the connection relationship set, a certain data describes a function block, and there is no definition of such a function block in the function block library of the target ladder diagram, then according to the information such as the type, name, attribute, port, etc. of the function block recorded in the connection relationship set, the function block is created in the function block library of the target ladder diagram and its type, name, attribute, port, etc. are defined.
[0082] In some embodiments, after importing the ladder diagram program project, the ladder diagram can be manually modified in the interactive interface, including: adding, modifying primitives, parameters, connection relationships, comments, names, etc., and finally confirming. The imported ladder diagram program project can also be checked for logical relationships, syntax errors, etc., and a detailed error report can be provided.
[0083] The second embodiment of the present application provides a method for converting an original ladder diagram into a target ladder diagram. Figure 2 The method provided by the second embodiment includes the following steps S200-S250.
[0084] S200: Get the screenshot of the original ladder diagram program project.
[0085] by Figure 3 Taking the ladder diagram program shown in FIG. 1 as an example, the ladder diagram program includes multiple program segments, and the program segments have information such as names and comments. Each program segment contains several coils, contacts, function blocks, variables, symbols and other elements, as well as connecting lines between the elements.
[0086] Users can take screenshots of the original ladder diagram program, such as Figure 4 and Figure 5 As shown, if the screenshots cannot completely include the entire content of the program, the two adjacent screenshots must include a portion of the overlapping area.
[0087] Users can save screenshots in folders in order from left to right and from top to bottom.
[0088] S210: Adjust the screenshot order.
[0089] The user selects the specified pictures in order or selects the folder where the screenshots are located in the software to be imported through the interactive graphical interface. The program will load the screenshots selected by the user, such as Figure 6 As shown. Users can add, delete, and adjust the loaded screenshots in the interface so that the order of the screenshots is adjusted from left to right and from top to bottom; and ensure that the screenshots of the ladder diagram program contain all the contents of the original ladder diagram program, and the contents are correct and clearly visible.
[0090] S220: Using the ORB algorithm to identify and match feature points in the screenshots, and obtaining a spliced image based on the feature point matching.
[0091] by Figure 7 For example, there are 4 pictures representing a ladder diagram program. After graying and denoising the loaded pictures, the ORB algorithm is used to identify the characteristic point information in the pictures.
[0092] According to the stitching order given in the previous step, try to perform feature matching on two adjacent pictures. When the feature matching is successful, complete the stitching operation by adjusting the position of the pictures; when the feature matching is unsuccessful, the screenshots are stitched up and down by default.
[0093] Finally, we get a complete picture of the original ladder diagram program project after splicing.
[0094] S230: Use OpenCV to perform contour detection on the stitched image, and use CNN to perform primitive analysis on the detection result to obtain primitives, variables and connection relationships, and create a connection relationship set (LinkMap) based on them.
[0095] The complete ladder diagram program engineering picture obtained in step S220 is subjected to contour detection using OpenCV to obtain pixel data of various elements in the picture, such as points, lines, surfaces, blocks, and texts.
[0096] The pre-trained CNN model is used to detect the obtained pixel data, obtain the positions of the recognized primitives, variables and the positions of the connecting line endpoints, and use OCR text recognition technology to recognize and record the text information in the image. Text information, such as variables in the image (such as Figure 5 bool1, newvar1), etc., the identification information includes the device identification (such as Figure 5 FB1, etc.), port identification, etc. (such as Figure 5 Then, by reading the positions of the primitives and variables, the primitives and variables are associated; by reading the positions of the primitives and the endpoints of the connecting lines, the connection relationship between the primitives is obtained. Finally, all the results are organized into a connection relationship set (LinkMap).
[0097] A possible description of LinkMap can be as follows:
[0098]
[0099]
[0100] Among them, elements represents element items, id represents element id, type represents element type, inputs represents input ports, and outputs represents output ports. By default, a contact has only one input and one output, and variable represents an associated variable.
[0101] connections represents connection relationship items, source represents source element (port), and target represents target element (port).
[0102] by Figure 7For example, after contour detection and element analysis, the valid information obtained from the upper left part includes the normally closed contact and the FB1 function block. The normally closed contact is associated with the variable bool2, and the normally closed contact is connected to the FB1 function block. These element names and connection relationships are stored in the connection relationship set.
[0103] S240: Generate and display a target ladder diagram according to the connection relationship set.
[0104] Since the connection relationship set shields different drawing methods of the same connection relationship, a target ladder diagram that meets the target ladder diagram program specification requirements is generated based on the connection relationship set. For example, the original ladder diagram program is displayed as Figure 8 The ladder diagram on the left is generated by this application, but it meets the requirements of the target ladder diagram program specification (such as starting from the left busbar). Figure 8 The ladder diagram of the right form.
[0105] At this time, the generated ladder diagram may be displayed in a floating window, that is, in a preview manner.
[0106] S250: Select import settings, and import the ladder diagram program project according to the import settings.
[0107] The user can select different import settings, such as overwrite current file, overwrite selected program segment, add to selected program segment, add to new program segment, etc. to import the obtained connection relationship set into the existing working environment compatibly.
[0108] For example, the user may move the mouse cursor to a position in the ladder diagram of the current target ladder diagram program and select Add, and the target ladder diagram displayed in step S240 will be inserted into the position to achieve adding to the position of the selected program segment.
[0109] S260: Adjusting the imported ladder diagram program project.
[0110] The user can manually adjust the imported ladder diagram program project as needed, that is, the added target ladder diagram can be edited.
[0111] This embodiment can also provide functions such as automatically creating missing variables and automatically creating missing functions / function blocks, so as to achieve fast and efficient migration of the original ladder diagram project and reduce the migration cost of the user. For example, when the ladder diagram program is imported, a data in the element item in the created LinkMap is Temperature_sensor, and the connection relationship item records the relationship between the Temperature_sensor and another element, but the variable Temperature_sensor is not defined in the global variable table of the current ladder diagram program project, then the variable Temperature_sensor:REAL can be automatically defined and filled into the table item of the global variable in the form of an entry.
[0112] The third embodiment of the present application provides a device for converting an original ladder diagram into a target ladder diagram. The device can be used to implement the method for converting the original ladder diagram into the target ladder diagram in the above embodiment, such as Fig. 9 As shown, the device for converting the original ladder diagram into the target ladder diagram includes:
[0113] The image acquisition module is used to obtain multiple screenshots of the original ladder diagram, each screenshot is a partial screenshot of the original ladder diagram, and any one of the screenshots has at least an overlapping area with the image in another screenshot; specifically, the image acquisition module can be used to implement step S10 in the first embodiment and its optional embodiments.
[0114] The image stitching module is used to stitch the multiple screenshots together according to the overlapping area to generate a picture including the complete original ladder diagram; specifically, the image stitching module can be used to implement step S20 in the first embodiment and its optional embodiments.
[0115] An image recognition module is used to identify the elements in the original ladder diagram in the image and the connection relationships between the elements, and to construct a connection relationship set, which records the connection relationships between the elements. Specifically, the image recognition module can be used to implement step S30 in the first embodiment and its optional embodiments.
[0116] The ladder diagram generation module is used to generate a target ladder diagram according to the elements and the connection relationships between the elements recorded in the connection relationship set; specifically, the ladder diagram generation module can be used to implement step S40 in the first embodiment and its optional embodiments.
[0117] Fig.10 900 is a schematic structural diagram of a computing device 900 provided in an embodiment of the present application. The computing device can execute each optional embodiment of the above method, and the computing device can be a terminal, or a chip or chip system inside the terminal. Fig.10As shown, the computing device 900 includes: a processor 910 , a memory 920 , and a communication interface 930 .
[0118] It should be understood that Fig.10 The communication interface 930 in the computing device 900 shown may be used to communicate with other devices, and may specifically include one or more transceiver circuits or interface circuits.
[0119] The processor 910 may be connected to a memory 920. The memory 920 may be used to store the program code and data. Therefore, the memory 920 may be a storage unit inside the processor 910, or an external storage unit independent of the processor 910, or a component including a storage unit inside the processor 910 and an external storage unit independent of the processor 910.
[0120] Optionally, the computing device 900 may further include a bus. The memory 920 and the communication interface 930 may be connected to the processor 910 via the bus. The bus may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.10 A line without an arrow is used to represent the bus, but this does not mean that there is only one bus or one type of bus.
[0121] It should be understood that in the embodiment of the present application, the processor 910 may adopt a central processing unit (CPU). The processor may also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. Alternatively, the processor 910 may adopt one or more integrated circuits to execute relevant programs to implement the technical solutions provided in the embodiment of the present application.
[0122] The memory 920 may include a read-only memory and a random access memory, and provides instructions and data to the processor 910. A portion of the processor 910 may also include a nonvolatile random access memory. For example, the processor 910 may also store information on the device type.
[0123] When the computing device 900 is running, the processor 910 executes the computer-executable instructions in the memory 920 to perform any operation step of the above method and any optional embodiment thereof.
[0124] It should be understood that the computing device 900 according to the embodiment of the present application can correspond to the corresponding subjects in the methods according to the embodiments of the present application, and the above-mentioned and other operations and / or functions of each module in the computing device 900 are respectively for realizing the corresponding processes of each method of the present embodiment, which will not be repeated here for the sake of brevity.
[0125] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0126] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0127] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, 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 interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0128] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0129] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0130] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
Claims
1. A method for converting an original ladder diagram into a target ladder diagram, characterized in that: include: Acquire multiple screenshots of the original ladder diagram, each screenshot being a partial screenshot of the original ladder diagram, and any one of the screenshots at least has an overlapping area with an image in another screenshot; According to the overlapping area, the plurality of screenshots are stitched together to generate a picture including the complete original ladder diagram; Identify the elements in the original ladder diagram in the picture and the connection relationship between the elements, and construct a connection relationship set, wherein the connection relationship set records the connection relationship between the elements; A target ladder diagram is generated according to the elements and the connection relationships between the elements recorded in the connection relationship set.
2. The method according to claim 1, characterized in that The connection relationship set records the elements and the connection relationships between the elements in the following manner: Element item, each data record records the identifier of an element; Connection relationship items, each piece of data represents a connection, recording the source element and target element of the connection.
3. The method according to claim 2, characterized in that At least one of the data in the element item further records the port identifier of the port included in the element; At least one of the data in the connection relationship item further records the port identifier of the port included in the source element of the connection or the port identifier of the port included in the target element.
4. The method according to claim 2, characterized in that: At least one of the data items in the element item further records the type of the element or an associated variable.
5. The method according to claim 1, characterized in that The element includes at least one of the following: a bus, a coil, a contact, a function block, a variable or a symbol.
6. The method according to claim 1, characterized in that Also includes: In response to the user's operation, the generated target ladder diagram overwrites the current file, overwrites the selected program segment, is added to the selected program segment, or is added to a new program segment.
7. The method according to claim 6, characterized in that Also includes: According to the connection relationship set, missing variables, missing functions or missing function blocks of relevant association table items of the target ladder diagram are created.
8. The method according to claim 1, characterized in that The multiple screenshots obtained are displayed in a certain orientation order, and can respond to user operations to perform one of the following: re-obtaining any screenshot, adjusting the position or angle of any screenshot, adding or deleting any screenshot.
9. A device for converting an original ladder diagram into a target ladder diagram, characterized in that: include: An image acquisition module, used to acquire multiple screenshots of the original ladder diagram, each screenshot being a partial screenshot of the original ladder diagram, and any one of the screenshots at least has an overlapping area with an image in another screenshot; An image stitching module, used for stitching the plurality of screenshots together according to the overlapping area to generate an image including the complete original ladder diagram; An image recognition module, used to recognize the elements in the original ladder diagram in the image and the connection relationship between the elements, and to construct a connection relationship set, wherein the connection relationship set records the connection relationship between the elements; The ladder diagram generation module is used to generate a target ladder diagram according to the elements and the connection relationships between the elements recorded in the connection relationship set.
10. A computing device, characterized in that: include: processor, and A memory having program instructions stored thereon, wherein when the program instructions are executed by the processor, the processor executes the method for converting an original ladder diagram into a target ladder diagram as claimed in any one of claims 1 to 8.