A flexible downloading method based on conditional compilation

By attaching conditional compilation tags to user programs, flexible downloading of industrial control programs is achieved, solving the personalized needs of different machine models and processes, reducing maintenance costs, and improving the flexibility and adaptability of programs.

CN113608743BActive Publication Date: 2026-03-20WUXI XINJIE ELECTRICAL
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-03
Publication Date
2026-03-20

AI Technical Summary

Technical Problem

Existing technologies are insufficient to meet the needs of flexible industrial control, especially due to the poor personalization and scalability of different control models and control processes, resulting in high user program maintenance costs and difficulty in management.

Method used

A flexible download method based on conditional compilation is adopted. By attaching conditional compilation tags to code segments paired with user programs, and utilizing tag management, editing, syntax checking, and download mode modules, users can control the selective compilation and flexible combination of programs based on conditions, supporting multi-device adaptation and complex business logic.

Benefits of technology

It improves the convenience and stickiness of user programs, reduces maintenance costs, supports diverse and personalized flexible control needs, and enables flexible program management and fast download.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113608743B_ABST
    Figure CN113608743B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of industrial control programming language, and particularly relates to a flexible downloading method based on conditional compilation, which comprises a label management module, a label editing module, a label syntax module, a conditional compilation module, a downloading mode module and a downloading program module, and a user realizes selective compilation of a user control program in a conditional mode by means of attaching a label to an existing matching program code segment, which can also serve as a code annotation function, different labels can define different meanings according to actual conditions, and complex conditional compilation business logic can be realized by means of flexible combination of the labels. The method can well satisfy the flexible control requirements of the user individualization and diversification, so as to realize adaptation of different control models and manufacturers, and achieve the purpose of individualization of control process. In addition, the conditional compilation can greatly improve the modularization compilation speed of the user program, the program supports multiple conditional mode adaptation, and is beneficial to long-term maintenance and management in the later period.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of industrial control programming language, and particularly relates to a flexible downloading method based on conditional compilation. BACKGROUND

[0002] As an important part of intelligent factory construction, programmable logic controller plays a crucial role as the "industrial control brain". In view of the new challenges of flexible intelligent manufacturing solution, it is urgent to develop a flexible downloading method based on conditional compilation, which can realize the diversity and flexibility of control programs.

[0003] One mode of industrial control program is difficult to meet the increasingly complex flexible control requirements, especially for personalized programs with different control models, different control processes, scalability and extensibility. At present, multiple versions of control programs need to be developed, and each version of program can only realize one business scenario logic. This mode is relatively single and inflexible, and the user program maintenance cost is extremely high and not easy to manage and save. At the same time, it also does not have flexibility and good scalability, so it is urgent to develop a flexible downloading method based on conditional compilation. SUMMARY

[0004] The present application aims to overcome the problems of the prior art and provides a flexible downloading method based on conditional compilation. The conditional compilation tag is added to the code segment of the user program. In particular, the ladder diagram, instruction table, structured text, sequential function chart, function block diagram, continuous function Figure Six Standard language can add conditional compilation tags to the program to selectively compile the user control program. The user can selectively compile the user control program by condition by adding tags to the existing paired program code segment, which can also serve as code comments. Different tags can define different meanings according to actual conditions, and complex conditional compilation business logic can be achieved through flexible combination of tags. It can quickly and conveniently solve the problems of user control program supporting multiple models, inflexibility, poor scalability, poor extensibility and other pain points, meet the development needs of user diversity, individualization and flexibility, greatly improve the convenience and stickiness of users, and reduce the maintenance cost of user control program and the complexity of business logic implementation.

[0005] The above object is achieved by the following technical solutions:

[0006] A flexible downloading method based on conditional compilation includes a tag management module, a tag editing module, a tag syntax module, a conditional compilation module, a download mode module and a download program module, and the steps are as follows:

[0007] Step S1: create tags for user program code segments by a tag management module, and generate a tag warehouse;

[0008] Step S2: freely insert tags in the tag warehouse into the program code segments at any position by a tag editing module, and generate tagged program codes;

[0009] Step S3: check the validity of the tags in the tagged program codes by a tag syntax module, and pass the valid tagged program codes for display in black, and fail the invalid tagged program code segments for display in gray;

[0010] Step S4: compile the valid tagged program codes by a conditional compilation module, and generate machine executable codes;

[0011] Step S5: switch multiple download modes as needed by a download mode module, and different download modes match different defined tags, which can flexibly and intelligently conditionally compile user program code segments containing the defined tags;

[0012] Step S6: implement flexible downloading of the machine executable codes corresponding to the selected download mode by a download program module.

[0013] Further, the step S6 further includes a rule checking module, which checks and compiles the program codes to be downloaded before flexible downloading.

[0014] Further, the rule checking module mainly includes single-tag syntax checking, multi-tag expression syntax checking, user program syntax checking, and download data checking.

[0015] The single-tag syntax checking mainly checks whether the tag name is legal, and the naming rule is that only letters, numbers, and underscores are allowed, and the first word can only be a letter or an underscore.

[0016] The multi-tag syntax checking adds the checking of operators such as AND, OR, and NOT on the basis of the single-tag syntax checking.

[0017] The user program mainly checks whether the syntax and semantics are legal, and checks according to specific rules.

[0018] The download data checking mainly checks whether the user data is legal and effective.

[0019] Further, the creating label in step S1 includes label definition, label deletion and label modification; the label includes predefined label and self-defined label; the predefined label is predefined according to model information or specific condition in advance, and the user can directly use the predefined label without defining, the predefined label cannot be deleted, and the predefined label is mainly used for quickly binding model program to realize model differentiation control program; the self-defined label is completely controlled by the user without being limited by the predefined label.

[0020] Further, the label editing in step S2 supports single label or multi-label expression, the multi-label supports free and flexible combination of labels, and complex control program business demand can be realized through connection of AND or NOT connection symbol.

[0021] Further, the syntax rule checking in step S3 is specifically: the label syntax module defines parent-child label nesting rule and single label or multi-label syntax rule, and the paired program code section can support multi-layer nesting rule of parent-child labels;

[0022] If the parent-child label nesting rule is valid for the parent label, if the child label is also valid, the program code section matched by the child label is involved in conditional compilation, if the child label is invalid, the program code section matched by the child label is not involved in conditional compilation, and the parent-child label search supports recursive traversal search;

[0023] If the parent label is invalid, the child label of the parent label is not searched, all program code sections matched by the parent label are not involved in conditional compilation, and complex control program business logic can be realized through nested combination of parent-child labels;

[0024] The multi-label expression is composed of multiple single labels, and the single labels can be connected through AND or NOT connection symbol to realize complex combination condition relationship.

[0025] Further, the downloading mode module in step S5 is associated with the user-defined label, a matching mapping relationship table is established, one downloading mode can contain multiple labels and realize one-to-many logical relationship in single direction, and the downloading mode and the defined label are completely bound and matched; the editing of the downloading mode includes: self-defined addition, deletion and modification.

[0026] Further, the label retrieval module is further included, the label retrieval module can recursively traverse the label tree in sequence, and realize highlight matching and positioning of the label to be retrieved.

[0027] Further, the label retrieval mode in the label retrieval module mainly includes: accurate matching and fuzzy matching two retrieval modes, both of which can be set to be case sensitive or not, the accurate matching is completely matched according to the label name, and the fuzzy matching supports regular expression or wildcard fuzzy matching.

[0028] Further, the label retrieval module is operated as follows: the user inputs the label to be retrieved, the matched label is displayed in a highlight color, the scrolling is positioned to the best program visual area of the user, and finally the retrieval information is listed in a table form, the main information including label name, label position, program code segment reference, and double-clicking the table row can be positioned to the specific position.

[0029] Advantages

[0030] The flexible downloading method based on conditional compilation provided by the application can realize the selective compilation of the user-controlled program in a conditional manner by adding labels to the existing paired program code segments, can also serve as code annotation, different labels can define different meanings according to actual conditions, and can realize the complex conditional compilation business logic through the flexible combination of label editing. The method can well meet the flexible control requirements of the user personalization and diversification, can realize the adaptation of different control models and manufacturers, and can realize the control process personalization. In addition, the conditional compilation can greatly improve the modular compilation speed of the user program, the program supports multiple conditional mode adaptation, and is beneficial to the long-term maintenance and management in the later period. BRIEF DESCRIPTION OF DRAWINGS

[0031] Figure 1 The flowchart of the flexible downloading method based on conditional compilation;

[0032] Figure 2 The functional module diagram of the flexible downloading method based on conditional compilation;

[0033] Figure 3 The label management module operation schematic diagram of the flexible downloading method based on conditional compilation;

[0034] Figure 4 The label editing module operation schematic diagram of the flexible downloading method based on conditional compilation;

[0035] Figure 5 The label syntax module operation schematic diagram of the flexible downloading method based on conditional compilation;

[0036] Figure 6 The conditional compilation module operation schematic diagram of the flexible downloading method based on conditional compilation;

[0037] Figure 7 The downloading mode module operation schematic diagram of the flexible downloading method based on conditional compilation;

[0038] Figure 8 The downloading program module operation schematic diagram of the flexible downloading method based on conditional compilation;

[0039] Figure 9 The operation schematic diagram of the rule checking module of the flexible downloading method based on conditional compilation according to the present application;

[0040] Figure 10 The operation schematic diagram of the label searching module of the flexible downloading method based on conditional compilation according to the present application. DETAILED DESCRIPTION

[0041] The present application will be further described in detail below according to the accompanying drawings and embodiments. The described embodiments are only a part of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative efforts fall within the scope of protection of the present application.

[0042] As shown in Figure 1 and 2 , a flexible downloading method based on conditional compilation, a flexible downloading method based on conditional compilation, comprising a label management module, a label editing module, a label syntax module, a conditional compilation module, a downloading mode module and a downloading program module, the steps are as follows:

[0043] Step S1: creating labels for user program matching code segments through the label management module, and generating a label warehouse;

[0044] Step S2: freely inserting labels in the label warehouse into the program code segments at any position through the label editing module, and generating labeled matching program codes;

[0045] Step S3: checking the validity of the labels of the labeled matching program codes through the label syntax module, and passing the valid labeled matching program codes for display in black, and not passing the invalid labeled matching program code segments for display in gray;

[0046] Step S4: compiling the valid labeled matching program codes through the conditional compilation module, and generating machine executable codes;

[0047] Step S5: quickly switching multiple downloading modes on demand through the downloading mode module, different downloading modes matching corresponding defined labels, and intelligently compiling user program code segments containing the defined labels;

[0048] Step S6: realizing flexible downloading of the corresponding machine executable codes under the selected downloading mode through the downloading program module.

[0049] Specifically, as shown in Figure 9As shown, the step S6 also includes a rule checking module, and the program code to be downloaded is checked and compiled by the rule checking module before flexible downloading.

[0050] The rule checking module mainly includes single-tag syntax checking, multi-tag expression syntax checking, user program syntax checking, and download data checking.

[0051] The single-tag syntax checking mainly checks whether the tag name is legal, and the naming rule is that only letters, numbers and underscores are allowed, and the first word can only be a letter or an underscore.

[0052] The multi-tag syntax checking adds the checking of operators such as AND, OR and NOT on the basis of the single-tag syntax checking.

[0053] The user program mainly checks whether the syntax and semantics are legal, and checks according to specific rules.

[0054] The download data checking mainly checks whether the user data is legal and effective.

[0055] As shown in Figure 3 The tag management module manages all tag information in step S1, and the creation of tags includes tag definition, tag deletion and tag modification, etc. When defining a tag, the user can attach meaningful explanatory information, the tag name does not support repetition and must follow specific naming rules.

[0056] The tag definition method mainly includes predefinition and self-definition. The pre-defined tags are pre-defined according to the model information or specific conditions, and the user can directly use them without the need for definition. The pre-defined tags cannot be deleted, and are mainly used for quickly binding model programs to achieve the purpose of model differentiation control program. The user can define tags, which are completely controlled by the user and are not limited by pre-definition, for example, binding program code segments of specific manufacturers and conditions, and realizing conditional compilation through single-tag or multi-tag expression.

[0057] The pre-defined tags and self-defined tags constitute a tag warehouse, and when editing a tag, the user is filtered and screened, and is intelligently prompted, which is a prerequisite for supporting user control of program conditional compilation, and provides strong support for the tag editing module.

[0058] As shown in Figure 4 The position of the tag editing module in step S2 must be attached to the paired program code segment. The conditional compilation tag gives the user program specific conditional compilation attributes, and when the tag is input, the intelligent drop-down prompt and screening filter defined by the tag library are used to improve the editing speed and efficiency. When the tag list is dropped down, detailed tag information can be displayed for the user to refer to and select, and syntax guide information can be displayed through a shortcut key.

[0059] The label definition editing supports single label or multi-label expression, the multi-label supports free and flexible combination of labels, and complex control program business requirements can be realized through the connection of AND or NOT connection.

[0060] After the label editing is completed, it is checked whether the label is legal, and if the label is legal, it is passed.

[0061] If the label is illegal, a friendly information prompt is given, and the color of the label editing can show whether the label is legal.

[0062] Specifically, the label editing module editing mode is mainly label manual input, and users can conveniently and freely edit single label or multi-label expression at a specific program code segment position. The label input can only be attached to the matched program code segment. When editing the label, an input label intelligent prompt is popped up to help users quickly filter and prompt the label detailed information. After the label editing is completed, it is checked whether the label conforms to the syntax rule through the label syntax check. Only the legal single label or multi-label expression can pass the syntax check. The illegal single label or multi-label expression gives a friendly prompt to the user to realize the humanized interaction. The multi-labels can be connected through AND or NOT operators. The program code segment matched with the effective label is displayed in black, and the program code segment matched with the invalid label is displayed in gray and faded, which is convenient for users to browse.

[0063] As shown in Figure 5 The syntax rule check in step S3 is: the label syntax module defines parent-child label nesting rules and single label or multi-label syntax rules. The matched program code segment can support multi-layer nesting rules of parent-child labels.

[0064] If the parent-child label nesting rule is valid for the parent label, if the child label is also valid, the program code segment matched with the child label is involved in conditional compilation, if the child label is invalid, the program code segment matched with the child label is not involved in conditional compilation, and the parent-child label search supports recursive traversal and search.

[0065] If the parent label is invalid, the child label is not searched, and all program code segments matched with the parent label are not involved in conditional compilation. Through the nested combination of parent-child labels, complex control program business logic can be realized.

[0066] The multi-label expression is composed of multiple single labels, and the single labels can be connected through AND or NOT connection to realize complex combination conditions.

[0067] Specifically, the tag syntax module defines tag naming and operator connection rules between multiple tags, parent-child tag nesting relationship, etc. Single tag naming follows the rule that only characters, numbers and underscores can be included, and the first word of a tag can only be a character or an underscore. Multiple tags can be connected by operators such as AND, OR and NOT, but must comply with the multiple tag expression definition rules. The parent-child tag nesting rule is that if the parent tag is valid, the program code segment matched by the child tag will be involved in conditional compilation if the child tag is also valid, and if the child tag is invalid, the program code segment matched by the child tag will not be involved in conditional compilation. The parent-child tag search supports recursive traversal and search. If the parent tag is invalid, the parent tag matching all program code segments will not be involved in conditional compilation. Through the nested combination of parent-child tags, complex control program business logic can be achieved. A multiple tag expression is composed of multiple single tags, which can be combined in complex ways through AND, OR and NOT operators, and complex nested conditional compilation can be achieved through the nested combination of parent-child tags, which can basically meet the complex control needs of users.

[0068] As shown in Figure 6 The conditional compilation module selectively conditionally compiles the user program according to whether the tags in the paired program code segment are valid, and finally generates machine executable code.

[0069] Conditional compilation specifically refers to the user program code segment containing valid tags. The program filters the user program code segment containing invalid tag matching while converting into the corresponding abstract syntax tree, and only the user program code segment contained in the valid tag participates in the compilation.

[0070] The compilation process mainly includes code preprocessing, compilation process, assembly process and linking process, and finally generates machine executable code. Conditional compilation selectively compiles user program code segments according to user individual needs, and a set of user programs can realize diverse and individual complex business logic, support multi-model information adaptation, greatly reduce user program maintenance cost, and at the same time reduce the size of user program, improve modular compilation speed and download speed.

[0071] The conditional compilation module searches for user program paired tag code segments. Program code segments not containing conditional compilation tags are by default all involved in the compilation, program code segments containing conditional compilation tags are first subjected to tag syntax checking, parent-child tags support recursive hierarchical search, and program code segments matched by valid parent-child tags are involved in the compilation. If the parent tag is valid, the program code segment matched by the parent tag will be involved in the compilation process, and if the parent tag is invalid, it will not be involved in the compilation process. The compilation process of the child tag nested in the parent tag is the same as described above. The advantage of conditional compilation is to support selective compilation of programs according to user actual needs, greatly improving the flexibility of user programs and supporting user development of diverse and individual control needs.

[0072] As Figure 7 shown, the download mode module in step S5 is associated with the user-defined tags to establish a matching mapping table, one download mode can contain multiple tags and implement one-way one-to-many logical relationship, and the download mode and the defined tags are completely bound and matched; the editing of the download mode includes: self-defined increase, deletion, modification, and notes of the corresponding explanations of the download mode. The user does not need to manually input to improve the matching speed and time. The user can control the effectiveness of the corresponding tags through the quick switching of the download mode, that is, whether the user program code segment participates in conditional compilation, helping the user program to achieve the purpose of flexible, personalized, and diversified quick download, while greatly reducing the code maintenance cost.

[0073] As Figure 8 shown, the download program module can achieve flexible download by quickly switching the download mode, and different download modes match different defined tags, which can flexibly and intelligently conditionally compile the user program code segment containing the defined tags.

[0074] The rule check is automatically called before downloading to compile and download the final machine executable code, which simplifies the user program and greatly reduces the program size and execution time.

[0075] As Figure 9 shown, the rule check module mainly includes single-tag syntax check, multi-tag expression syntax check, user program syntax check, and download data check.

[0076] The single-tag syntax check mainly checks whether the tag name is legal, and the naming rule is that only letters, numbers, and underscores can be included, and the first word can only be letters and underscores;

[0077] The multi-tag syntax check adds the check of operators such as AND, OR, and NOT on the basis of the single-tag syntax check;

[0078] The user program mainly checks whether the syntax and semantics are legal and checks according to specific rules;

[0079] The download data check mainly checks whether the user data is legal and effective.

[0080] As Figure 10The label retrieval module also includes a label retrieval module which mainly helps the user to quickly locate the position of the label and replace the label function, and can recursively traverse the label tree in order, and realize the highlight matching and positioning of the label to be retrieved. The label retrieval mode in the label retrieval module mainly includes two retrieval modes: exact matching and fuzzy matching, both of which can be set to be case-sensitive or not. The exact matching is a complete matching according to the label name, and the fuzzy matching supports regular expression or wildcard fuzzy matching. The operation of the label retrieval module is: the user inputs the label to be retrieved, and after matching, the label is displayed in a highlight color, and the scroll is positioned to the best program visual area of the user, and finally the retrieval information is listed in a table form, and the main information includes the label name, the label position, the program code segment reference, and double-clicking the table row can position to the specific position.

[0081] Specifically, the label retrieval method is to recursively search the leaf node from the root of the label tree in order, and the label corresponding to the program code segment can be obtained after the label to be matched is retrieved. The retrieval rule supports exact retrieval and fuzzy retrieval of the label. The exact retrieval needs to match the label name completely, but can set whether to distinguish the case of the label name. The fuzzy retrieval can support regular expression, wildcard and other retrieval modes. The user can select a specific label retrieval rule according to the specific application mode, especially when the user program code amount is large, the specific position of the label can be matched and positioned quickly, and double-clicking the label name can quickly position and browse the related program code segment.

[0082] The above only describes the embodiments of the present application, and is not used to limit the present application. For those skilled in the art, any modification, equivalent replacement, improvement, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A flexible download method based on conditional compilation, characterized in that, It includes a tag management module, a tag editing module, a tag syntax module, a conditional compilation module, a download mode module, and a download program module. The steps are as follows: S1 creates tags for user program paired code segments through the tag management module and generates a tag repository. The programming languages ​​corresponding to the user program paired code segments are six standard languages ​​written by the International Electrotechnical Commission: ladder diagram, instruction list, structure text, sequential function chart, function block diagram, and continuous function chart. The tag creation includes tag definition, tag deletion, and tag modification. When defining tags, users can add meaningful explanatory information. Tag names do not support repetition and must follow specific naming rules. The tags include predefined tags and custom tags. Predefined tags are predefined according to machine model information or specific conditions. Users can use them directly without defining them. Predefined tags cannot be deleted and are mainly used for quickly binding the machine model's program. Custom tags can be bound to control process parameters. S2 allows users to freely insert tags from the tag repository at any location in the program code segment using the tag editing module, generating program code with matching tags. Tag editing supports single-tag or multi-tag expressions, and multiple tags can be freely and flexibly combined. Complex control program business requirements can be achieved by connecting tags using AND, OR, and NOT connectors. S3 uses the tag syntax module to perform a syntax rule check on the validity of the tags in the program code matched by the tags. If the program code matches a valid tag, it passes and is displayed in black; if the program code matches an invalid tag, it fails and is displayed in gray. The syntax rule check specifically involves the tag syntax module defining parent-child tag nesting rules and single-tag or multi-tag syntax rules. Paired program code segments can support multi-level nesting rules for parent-child tags. If the parent-child tag nesting rule is valid, and the child tags are also valid, the program code segments matched by the child tags will participate in conditional compilation. If the child tags are invalid, the program code segments matched by the child tags will not participate in conditional compilation. Parent-child tag search supports recursive traversal. If the parent tag is invalid, its child tags will not be searched, and all program code segments matched by the parent tag will not participate in conditional compilation. Complex control program business logic can be implemented through the nesting combination of parent-child tags. Multi-tag expressions are composed of multiple single tags, and complex combination conditional relationships can be achieved by connecting single tags with AND, OR, and NOT connectors. S4 compiles the program code that matches the valid tags through the conditional compilation module to generate code that the machine can ultimately execute; During compilation, graphical modules corresponding to invalid tags are automatically removed; and code segments that do not contain conditional compilation tags are all included in the compilation process by default. S5 uses a download mode module to quickly switch between multiple download modes as needed. Different download modes match different defined tags. The download mode module is associated with user-defined tags and establishes a matching mapping table. A download mode can contain multiple tags and realize a one-way one-to-many logical relationship, realizing complete binding and matching between download modes and defined tags. Users can control the validity of corresponding tags and control whether user program code segments participate in conditional compilation by quickly switching download modes. S6 achieves flexible downloading of the final executable code for the machine corresponding to the selected download mode through the download program module; it also includes a rule checking module, which simplifies the user program before flexible downloading; the rule checking module mainly includes single-tag syntax checking, multi-tag expression syntax checking, user program syntax checking, and download data checking; the single-tag syntax checking mainly checks whether the tag name is valid; the multi-tag expression syntax checking adds AND, OR, NOT, and other operator rules to the single-tag syntax checking; the user program mainly checks whether the syntax and semantics are valid, according to specific rules; the download data checking mainly checks whether the user data is valid and effective.

2. The flexible download method based on conditional compilation according to claim 1, characterized in that, It also includes a tag retrieval module, which can recursively traverse the tag tree in sequence to achieve highlight matching and positioning of the tags to be retrieved.

3. The flexible download method based on conditional compilation according to claim 2, characterized in that, The tag retrieval module mainly includes two tag retrieval methods: exact matching and fuzzy matching. Both can be preset to be case-sensitive. Exact matching is a complete match based on the tag name, while fuzzy matching supports regular expressions or wildcard fuzzy matching.

4. The flexible download method based on conditional compilation according to claim 3, characterized in that, The operation of the tag retrieval module is as follows: the user inputs the tag to be retrieved, and after matching, it is displayed in a highlighted color and positioned and scrolled to the user's best program viewing area. Finally, the retrieval information is listed in a table, and the main information includes the tag name, tag position, and program code segment reference. Double-clicking a table row can locate the specific position.