A resource management method, system and device for PLC program download and a medium

By introducing a download prediction model and early warning mechanism into the PLC system, the problems of long PLC program download time, uncontrollable resource consumption, and high failure risk are solved, achieving a more efficient and stable program download process.

CN121151382BActive Publication Date: 2026-02-27SHANGHAI BAOSIGHT SOFTWARE CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202511666958.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-11-14
Publication Date
2026-02-27
Estimated Expiration
2045-11-14

AI Technical Summary

Technical Problem

Existing PLC systems suffer from problems such as long and unpredictable download times, uncontrollable resource consumption, and high risk of failure with serious consequences during program download, especially in large and complex projects.

Method used

By compiling and converting the PLC source program and extracting features in the host computer integrated development environment, a preset download prediction model is used to predict download time, storage space and memory growth. Based on the comparison between the predicted values ​​and the lower computer resource safety threshold, the download operation is selected to be executed or an early warning mechanism is triggered. The model parameters are optimized by combining historical data.

Benefits of technology

It significantly improves the success rate of PLC program download, reduces invalid waiting time, ensures stable operation of the production system, improves resource utilization, reduces system maintenance costs, and improves prediction accuracy through machine learning.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121151382B_ABST
    Figure CN121151382B_ABST
Patent Text Reader

Abstract

The application discloses a kind of resource management methods, systems, equipment and medium of PLC program download, the method is first by host computer integrated development environment, obtains the PLC source program that user writes, subsequently to the PLC source program obtained Compiling conversion, to generate standardized intermediate code, then to the intermediate code generated Feature extraction, to obtain corresponding quantization characteristic index, then the quantization characteristic index extracted is input into preset download prediction model, to obtain the prediction value of target variable, finally the prediction value of target variable is compared with the resource safety threshold of target variable that corresponding host computer is preset, and according to the comparison result selection executes PLC program download operation or triggers early warning mechanism.The method is through the innovative download prediction model and control mechanism, significantly improve the success rate of program download, optimize the efficiency of engineering debugging, and greatly reduce the risk of system collapse, realize intelligent resource management in all directions.
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 automation control, and in particular to a resource management method, system, device and medium for PLC program download. BACKGROUND

[0002] In the technical field of industrial automation control, the programmable logic controller (PLC) system occupies a core position. At present, the existing PLC system generally adopts the architecture mode of host computer-slave computer. The host computer undertakes the writing and compiling of the PLC program, and the slave computer is responsible for executing the corresponding control logic.

[0003] In the PLC development process, engineers will use professional host computer software to write control programs using programming languages such as structured text (ST), ladder diagram (LD), sequential function chart (SFC), and continuous function chart (CFC). After the program is written, the host computer will compile it into target code that can be directly executed by the slave computer (i.e., PLC hardware), and then download the target code to the slave computer through the network or data line to realize the control function.

[0004] However, with the continuous improvement of industrial automation, the complexity of PLC projects is growing exponentially, the program size is increasingly large, and the number of function modules is also increasing. This change brings many serious challenges to the program download process. First, the download time is long and unpredictable. Large PLC project downloads may take several minutes or even longer, which seriously affects the efficiency of engineering debugging and causes serious economic losses in production line debugging or emergency maintenance scenarios. Second, resource occupation is uncontrollable. The download process will consume a large amount of computing, storage, and communication resources of the slave computer, and the existing system cannot predict in advance, which is particularly prominent on resource-limited embedded PLC devices. Third, the failure risk is high and the impact is serious. When the slave computer resources are insufficient, the download may fail and trigger the transaction rollback mechanism, not only wasting a lot of time, but also affecting the stability of the production system, and even causing production line downtime in continuous production environments, causing huge economic losses. SUMMARY

[0005] The purpose of the present application is to provide a resource management method, system, device and medium for PLC program download. The method constructs an intelligent early warning and active control mechanism, uses advanced resource evaluation methods, and combines historical data analysis and machine learning technology to effectively solve the technical problems of long and unpredictable download time, uncontrollable resource occupation, and high failure risk and serious impact in the program download process of the existing PLC system.

[0006] To solve the above technical problems, the present application is realized by the following technical solutions:

[0007] The present application provides a resource management method for PLC program download, comprising:

[0008] Obtaining the PLC source program written by the user through the integrated development environment of the upper computer;

[0009] Compiling and converting the obtained PLC source program to generate standardized intermediate code;

[0010] Extracting features from the generated intermediate code to obtain corresponding quantitative feature indicators;

[0011] Inputting the extracted quantitative feature indicators into a preset download prediction model to obtain the predicted value of the target variable, wherein the target variable includes download time consumption, code storage space size, and process memory growth;

[0012] Comparing the predicted value of the target variable with the corresponding target variable resource safety threshold preset by the lower computer, and selecting to execute the PLC program download operation or triggering the early warning mechanism according to the comparison result.

[0013] In an embodiment of the present application, the PLC source program is a code text composed of a plurality of different PLC programming languages, including structured text, ladder diagram, sequential function chart, and continuous function chart.

[0014] In an embodiment of the present application, the feature extraction from the generated intermediate code to obtain the corresponding quantitative feature indicators comprises:

[0015] Pretreating the intermediate code, and the pretreatment content includes uniform code format, eliminating redundant information, and implementing symbol standardization;

[0016] Performing static analysis on the pretreated intermediate code, and then extracting the corresponding quantitative feature indicators, including the total number of instructions of the intermediate code, the number and complexity of functions or function blocks, the complexity of loop structure and branch structure, and the number of global variables and static variables and the total memory size occupied.

[0017] In an embodiment of the present application, the preset download prediction model includes a plurality of independent prediction sub-models, and the inputting of the extracted quantitative feature indicators into the preset download prediction model to obtain the predicted value of the target variable comprises:

[0018] Normalizing the extracted quantitative feature indicators to construct a feature vector meeting the input requirements of the preset download prediction model;

[0019] The constructed feature vector is input into the preset download prediction model, a plurality of independent prediction sub-models inside the model are used for respectively performing prediction operation, and finally a prediction value of the target variable is output.

[0020] In an embodiment of the present application, the prediction value of the target variable includes a predicted download time consumption, a predicted code storage space size, and a predicted process memory growth amount, and the preset resource safety threshold of the target variable of the lower machine includes a maximum download time consumption threshold, a maximum available code storage space threshold, and a maximum available runtime memory space threshold.

[0021] In an embodiment of the present application, the comparison of the prediction value of the target variable with the preset resource safety threshold of the corresponding target variable of the lower machine and the selection of the execution of the PLC program download operation or the triggering of the early warning mechanism according to the comparison result include:

[0022] The prediction value of the target variable is compared with the preset resource safety threshold of the corresponding target variable of the lower machine.

[0023] If the prediction value of all target variables does not exceed the preset resource safety threshold of the corresponding target variable of the lower machine, the PLC program download operation is immediately executed.

[0024] If the prediction value of any target variable exceeds the preset resource safety threshold of the corresponding target variable of the lower machine, the early warning mechanism is immediately triggered.

[0025] In an embodiment of the present application, the method further includes:

[0026] After the actual execution of the download operation and the completion of the download task, the real value of the target variable is collected.

[0027] The real value of the target variable is compared and analyzed with the prediction value of the corresponding target variable output by the preset download prediction model, so as to construct a training data pair for model training.

[0028] The constructed training data pair is input into the preset download prediction model, the model parameters of the preset download prediction model are optimized through the way of incremental learning, and the prediction accuracy of the preset download prediction model is further improved.

[0029] Based on the same inventive concept, another embodiment of the present application further provides a resource management system for PLC program download, which is implemented by using the resource management method for PLC program download according to any of the above embodiments, and includes:

[0030] A program acquisition module is configured to acquire a PLC source program written by a user through a host computer integrated development environment.

[0031] The compiling conversion module is configured to compile and convert the obtained PLC source program to generate standardized intermediate code.

[0032] The feature extraction module is configured to extract features from the generated intermediate code to obtain corresponding quantitative feature indicators.

[0033] The download prediction module is configured to input the extracted quantitative feature indicators into a preset download prediction model to obtain predicted values of target variables, wherein the target variables include download time consumption, code storage space size, and process memory growth.

[0034] The decision warning module is configured to compare the predicted values of the target variables with corresponding target variable resource safety thresholds preset by the lower machine, and select to perform a PLC program download operation or trigger a warning mechanism according to a comparison result.

[0035] Based on the same inventive concept, another embodiment of the present application further provides an electronic device, which comprises:

[0036] One or more processors;

[0037] A storage device configured to store one or more programs, which, when executed by the one or more processors, cause the electronic device to implement the resource management method for PLC program download according to any one of the above embodiments.

[0038] Based on the same inventive concept, another embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor of a computer, causes the computer to perform the resource management method for PLC program download according to any one of the above embodiments.

[0039] As described above, the present application provides a resource management method for PLC program download, which acquires a PLC source program written by a user through an upper computer integrated development environment, compiles and converts the acquired PLC source program to generate standardized intermediate code, extracts features from the generated intermediate code to obtain corresponding quantitative feature indicators, inputs the extracted quantitative feature indicators into a preset download prediction model to obtain predicted values of target variables, wherein the target variables include download time consumption, code storage space size, and process memory growth, compares the predicted values of the target variables with resource safety thresholds of corresponding lower computers, and selects to perform a PLC program download operation or trigger an early warning mechanism according to the comparison result. This method can significantly improve the success rate of PLC program download through accurate resource prediction and active control mechanism, effectively avoid download failure and transaction rollback problems caused by insufficient resources, and the effect of this method is particularly prominent in the program download scene of large and complex projects. The system has accurate time prediction function, and engineers can reasonably arrange the debugging plan according to this function, which can greatly reduce the invalid waiting time and improve the work efficiency. At the same time, through the hierarchical early warning and forced control mechanism, the PLC lower computer system crash problem caused by excessive download can be completely eliminated, which effectively guarantees the stable operation of the production system. In addition, this method can also provide optimization suggestions (such as module splitting, function simplification, etc.) according to the prediction results, which helps developers optimize the program structure and improve resource utilization. In terms of improving prediction accuracy, this method uses machine learning algorithm and combines multi-dimensional feature analysis, compared with the traditional simple prediction method based on file size, the prediction accuracy is greatly improved, and with the continuous accumulation of historical data, the prediction accuracy will continue to improve. Furthermore, through preventive control measures, the device restart, system recovery and other operations caused by download failure can be avoided, which significantly reduces the system maintenance cost and workload. The intuitive early warning prompt and detailed resource analysis report enable developers to clearly understand the resource demand in the download process, so as to make more scientific and reasonable decisions and improve the development experience. Finally, through the feedback learning mechanism, the system can continuously learn from the actual download data, automatically adjust the prediction model, realize the continuous improvement of the prediction ability, and form a benign self-evolution mechanism. Of course, any product implementing the present application does not necessarily need to achieve all the advantages described above at the same time. BRIEF DESCRIPTION OF DRAWINGS

[0040] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without creative labor.

[0041] Figure 1A flowchart of a resource management method for PLC program download according to an example embodiment of the present application.

[0042] Figure 2 An architecture diagram of a resource management system for PLC program download according to an example embodiment of the present application.

[0043] Figure 3 A structure diagram of a resource management system for PLC program download according to another example embodiment of the present application.

[0044] Figure 4 A structure diagram of an electronic device according to another example embodiment of the present application. DETAILED DESCRIPTION

[0045] The present application is herein described, by way of example only, with reference to the accompanying drawings, wherein:

[0046] It is to be understood that the above-mentioned arrangements are only illustrative of the basic idea of the present application, and thus the drawings only show the components related to the present application, rather than the actual number, shape and size of the components, and the actual implementation of the components can be changed arbitrarily, and the layout of the components can be more complex.

[0047] In the following description, numerous specific details are discussed in order to provide a thorough understanding of the embodiments of the present application. However, those skilled in the relevant arts will recognize that the embodiments of the present application can be practiced without these specific details. In other instances, well-known structures and devices are not described in detail in order to avoid obscuring the embodiments of the present application.

[0048] In order to solve the technical problems of long and unpredictable download time, uncontrollable resource occupation, high failure risk and serious influence of the existing PLC system in the program download process, the application innovatively proposes a resource management method for PLC program download. The method introduces a download prediction model in the host computer, evaluates the success probability of the download before the download operation is executed, and takes graded control measures such as early warning prompt or forced interception according to the risk level, so as to avoid invalid download behavior and the system risk that may be caused. At the same time, the method analyzes the instruction number of the intermediate code, the complexity of the function or functional module, the variable scale and other multi-dimensional characteristic indexes, constructs a precise quantitative evaluation model, and then realizes the accurate prediction of resource occupation. In addition, the method makes full use of historical download data and continuously collects key data such as real download time consumption, resource occupation and memory growth, and continuously optimizes the model parameters of the download prediction model, forming an intelligent prediction mechanism with self-learning and continuous improvement ability, so as to significantly improve the prediction accuracy.

[0049] Please refer to Figure 1 In an exemplary embodiment of the present application, the resource management method for PLC program download includes the following steps:

[0050] S100: Obtain the PLC source program written by the user through the host computer integrated development environment;

[0051] S200: Compile and convert the obtained PLC source program to generate standardized intermediate code;

[0052] S300: Feature extraction is performed on the generated intermediate code to obtain corresponding quantitative feature indexes;

[0053] S400: Input the extracted quantitative feature indexes into a preset download prediction model to obtain the predicted value of the target variable, wherein the target variable includes download time consumption, code occupied storage space size and process memory growth;

[0054] S500: Compare the predicted value of the target variable with the corresponding target variable resource safety threshold preset by the lower computer, and select to execute the PLC program download operation or trigger the early warning mechanism according to the comparison result.

[0055] It should be noted that in the present embodiment, the preset download prediction model is obtained through a large amount of historical download data collection and deep training and repeated optimization using a machine learning algorithm. The preset download prediction model can accurately predict subsequent download conditions based on the rules and patterns in the historical data. At the same time, the target variable resource security threshold preset by the lower machine can be flexibly and reasonably set according to the hardware configuration (such as storage space, memory capacity, etc.) and actual use requirements (such as the urgency of production tasks, the requirement for system stability, etc.) of different lower machines.

[0056] The steps of the resource management method for PLC program download will be described in detail below.

[0057] First, step S100 is executed, that is, the PLC source program written by the user is obtained through the upper machine integrated development environment.

[0058] It should be noted that the upper machine integrated development environment provides a convenient and efficient programming platform for users, and users can write PLC source programs according to their actual needs and design logic in this environment. In the present embodiment, the PLC source program is a code text composed of a plurality of different PLC programming languages, including structured text (ST), ladder diagram (LD), sequential function chart (SFC) and continuous function chart (CFC). Among them, the structured text (ST) has powerful data processing and logical operation ability, is suitable for writing complex algorithms and control logic, the ladder diagram (LD) uses graphical symbols similar to relay control circuits, is intuitive and visual, the sequential function chart (SFC) can clearly describe the sequential control process of the control system, making the program structure more hierarchical, and the continuous function chart (CFC) can be used for programming of continuous control systems to meet the demand for continuous variable control.

[0059] Next, step S200 is executed, that is, the obtained PLC source program is compiled and converted to generate standardized intermediate code. It should be noted that in the present embodiment, the intermediate code is not the final executable file that can be directly run by the lower machine, and its essence is an intermediate file including instruction list and memory allocation information and other important contents, providing a basis for subsequent quantitative analysis.

[0060] Next, step S300 is executed, that is, the generated intermediate code is feature extracted to obtain corresponding quantitative feature indicators.

[0061] In an exemplary embodiment of the present application, step S300 further includes the following steps:

[0062] S310: preprocessing the intermediate code, the preprocessing content including uniform code format, eliminating redundant information and implementing symbol standardization;

[0063] S320: performing static analysis on the preprocessed intermediate code, and then extracting corresponding quantitative feature indicators, the quantitative feature indicators including the total number of instructions of the intermediate code, the number and complexity of functions or functional blocks, the complexity of loop structure and branch structure, the number of global variables and static variables and the total memory size occupied by them.

[0064] Specifically, first, the intermediate code is preprocessed, and the preprocessing content includes uniform code format, eliminating redundant information and implementing symbol standardization. In actual application scenarios, different developers may use different tools to generate intermediate code, resulting in uneven code format. Uniform code format can make the code have consistent appearance and structure, which is convenient for subsequent processing. Redundant information may include repeated instructions, useless comments or temporarily generated intermediate data, etc. By eliminating redundant information, the data amount can be reduced, and the processing efficiency can be improved. Symbol standardization is used to ensure that various symbols used in the code, such as variable names, function names, etc., comply with uniform standards and specifications, avoiding errors or causing confusion in understanding due to inconsistent symbols. Then, the preprocessed intermediate code is statically analyzed. It should be noted that static analysis is a method of in-depth analysis of code without actually running the code. Through static analysis, a series of key quantitative feature indicators are extracted. In this embodiment, the quantitative feature indicators include but are not limited to the total number of instructions of the intermediate code, the number and complexity of functions or functional blocks, the complexity of loop structure and branch structure, the number of global variables and static variables and the total memory size occupied by them. Among them, the total number of instructions of the intermediate code can reflect the size of the code, the number and complexity of functions or functional blocks can reflect the logic level and implementation difficulty of the code, the complexity of loop structure and branch structure will affect the execution efficiency of the program, and the number of global variables and static variables and the total memory size occupied by them will affect the allocation and management of system resources. For example, in actual operation, by reading and analyzing the preprocessed intermediate code, all operation instructions and their operands can be clearly listed, then the instruction list is traversed and counted, and finally a key quantitative feature indicator of the intermediate code, i.e. the total number of instructions of the intermediate code, is obtained.

[0065] Then, step S400 is performed, i.e. the extracted quantitative feature indicators are input into a preset download prediction model to obtain the predicted value of the target variable, wherein the target variable includes download time consumption, code storage space size and process memory growth amount.

[0066] In an example embodiment of the present application, the preset download prediction model comprises a plurality of independent prediction sub-models, and step S400 further comprises the following steps:

[0067] S410: normalizing the extracted quantitative feature indicators to construct feature vectors meeting the input requirements of the preset download prediction model;

[0068] S420: inputting the constructed feature vectors into the preset download prediction model, performing prediction operation by the plurality of independent prediction sub-models in the model respectively, and finally outputting the predicted values of the target variables.

[0069] It should be noted that the predicted values of the target variables include predicted download time, predicted code storage space size, and predicted process memory growth.

[0070] Specifically, the extracted quantitative feature indicators are first normalized to construct feature vectors meeting the input requirements of the preset download prediction model. Taking the instruction number of the intermediate code as an example, it is taken as a core feature variable X_ins and input into the preset download prediction model. In the present embodiment, the preset download prediction model is a multiple linear regression model, which is composed of three independent prediction sub-models for predicting three key target variables, i.e., download time, code storage space size, and process memory growth. The prediction formula of the download time is: _time = W_t0 + W_t1 × X_ins, _time represents the predicted download time, and W_t0 and W_t1 are weight parameters of the prediction sub-model, which are obtained by training historical data. The prediction formula of the code storage space is: _codesize = W_s0 + W_s1 × X_ins, _codesize represents the predicted code storage space size, and W_s0 and W_s1 are weight parameters of the prediction sub-model, which are obtained by training historical data. The prediction formula of the process memory growth is: _memory = W_m0 + W_m1 × X_ins, _memory represents the predicted process memory growth, and W_m0 and W_m1 are weight parameters of the prediction sub-model, which are obtained by training historical data.

[0071] Finally, step S500 is performed, i.e., comparing the predicted values of the target variables with the corresponding target variable resource safety thresholds preset by the lower computer, and selecting to perform the PLC program download operation or triggering the early warning mechanism according to the comparison result.

[0072] In an exemplary embodiment of this application, step S500 further includes the following steps:

[0073] S510: Compare the predicted value of the target variable with the resource security threshold of the target variable preset by the corresponding lower-level machine;

[0074] S520: If the predicted values ​​of all target variables do not exceed the resource safety threshold of the corresponding target variable preset by the lower-level machine, then immediately execute the PLC program download operation;

[0075] S530: If the predicted value of any target variable exceeds the resource security threshold of the corresponding target variable preset by the lower-level machine, the early warning mechanism will be triggered immediately.

[0076] Specifically, firstly, the predicted value of the target variable (i.e., the predicted download time) is... _time, the size of the predicted code's storage space _codesize and predicted process memory growth The resource security thresholds (T_memory) are compared with the target variable preset by the lower-level machine. These thresholds include the maximum download time threshold T_time, the maximum available code storage space threshold T_codesize, and the maximum available runtime memory space threshold T_memory. During the threshold comparison process, if... _time≤T_time and _codesize≤T_codesize and If _memory ≤ T_memory, meaning all predicted values ​​do not exceed the corresponding resource security threshold, the current download operation is considered safe, and the process will continue normally. Conversely, if any predicted value exceeds the corresponding resource security threshold, the download operation will proceed normally. _time>T_time、 _codesize > T_codesize or If any of the following conditions is met (e.g., _memory > T_memory), the download operation is deemed risky. Once a risk is identified, an early warning process is immediately triggered, sending a command to the user's graphical interface and displaying an early warning dialog box. This dialog box clearly and intuitively displays the exceeded resource items and their corresponding predicted values. The user is also provided with two options: "Cancel" and "Force Download," allowing them to decide based on the actual situation. If the user selects the "Cancel" option, the download process is terminated to avoid potential resource exceeding issues. If the user chooses the "Force Download" option after weighing the options, the host computer will download the final generated target machine code to the PLC slave computer via the communication interface to complete the download operation. For example, in a real-world production scenario, when the predicted download time... When the download time exceeds the preset maximum download time threshold T_time of the lower-level machine, if the production task is urgent, the user may choose to force the download after comprehensively weighing the urgency of the production task and the potential risks to ensure the continuity of the production process. It should be noted that in this embodiment, the early warning mechanism is not limited to displaying the exceeded resource items and their corresponding predicted values ​​through an early warning dialog box; it can also provide users with practical optimization suggestions (such as module splitting, function simplification, etc.) based on the prediction results. Its purpose is to help users solve the resource overrun problem at its root. For example, when the predicted maximum increase in runtime memory of the lower-level machine during compilation is... When `_memory` exceeds the maximum available runtime memory threshold `T_memory`, the system strongly recommends that the user split the program. Understandably, breaking down a large program into multiple relatively independent and functionally simple modules can effectively reduce the runtime memory usage of each individual module.

[0077] It should be noted that, in an exemplary embodiment of this application, the resource management method for PLC program download further includes: after the actual download operation is performed and the download task is completed, collecting the true value of the target variable; comparing and analyzing the true value of the target variable with the predicted value of the corresponding target variable output by the preset download prediction model to construct a training data pair for model training; inputting the constructed training data pair into the preset download prediction model, and optimizing the model parameters of the preset download prediction model through incremental learning, thereby improving the prediction accuracy of the preset download prediction model.

[0078] Specifically, please refer to Figure 2As shown, after the actual download operation is performed and the download task is completed, the system will immediately start the data collection process to accurately collect the real resource consumption data in this download process. These data include the actual download time Y_time, the actual occupied code storage space Y_codesize, and the actual monitored peak memory growth Y_memory. After the data collection is completed, the system will construct the relevant data of this download process into a data quadruple (X_ins, Y_time, Y_codesize, Y_memory) and regard it as a new training sample and include it into the existing historical data set. Then, the system will update and optimize the weight parameters W_t0, W_t1, W_s0, W_s1, W_m0, W_m1 of the preset download prediction model by using the online least square method. By continuously adjusting these weight parameters, the preset download prediction model can more accurately fit the actual data, thereby improving the prediction accuracy of the resource consumption in the future download process.

[0079] To sum up, the application provides a resource management method for PLC program download, which acquires a PLC source program written by a user through an upper computer integrated development environment, compiles and converts the acquired PLC source program to generate standardized intermediate code, extracts features from the generated intermediate code to acquire corresponding quantitative feature indexes, inputs the extracted quantitative feature indexes into a preset download prediction model to acquire predicted values of target variables, wherein the target variables include download time consumption, code storage space size, and process memory growth, compares the predicted values of the target variables with resource safety thresholds of corresponding lower computers, and selects to perform a PLC program download operation or trigger an early warning mechanism according to a comparison result. The method can significantly improve the success rate of PLC program download, effectively avoid download failure and transaction rollback problems caused by insufficient resources, and has particularly prominent effects in the program download scene of large and complex projects. The system has accurate time prediction function, and engineers can reasonably arrange a debugging plan according to the function, greatly reduce invalid waiting time, and improve work efficiency. Meanwhile, through a hierarchical early warning and forced control mechanism, the PLC lower computer system collapse problem caused by excessive download can be completely eliminated, and the stable operation of the production system is effectively ensured. In addition, the method can also provide optimization suggestions (such as module splitting and function simplification) according to the prediction results, help developers optimize program structure, and improve resource utilization. In terms of improving prediction accuracy, the method uses a machine learning algorithm and combines multi-dimensional feature analysis, and compared with a traditional simple prediction method based on file size, the prediction accuracy is greatly improved, and the prediction accuracy will continue to improve as historical data is continuously accumulated. Furthermore, through preventive control measures, equipment restart, system recovery and other operations caused by download failure can be avoided, and system maintenance cost and workload are significantly reduced. Intuitive early warning prompts and detailed resource analysis reports enable developers to clearly understand resource requirements in the download process, so as to make more scientific and reasonable decisions and improve development experience. Finally, through a feedback learning mechanism, the system can continuously learn from actual download data, automatically adjust the prediction model, realize continuous improvement of the prediction ability, and form a benign self-evolution mechanism.

[0080] Based on the same inventive concept, please refer to Figure 3 Another embodiment of the application also provides a resource management system 100 for PLC program download, which is implemented by using the resource management method for PLC program download according to any one of the above embodiments, and includes:

[0081] A program acquisition module 110 is configured to acquire a PLC source program written by a user through an upper computer integrated development environment.

[0082] The compiling and converting module 120 is configured to compile and convert the obtained PLC source program to generate standardized intermediate code.

[0083] The feature extraction module 130 is configured to extract features from the generated intermediate code to obtain corresponding quantitative feature indicators.

[0084] The download prediction module 140 is configured to input the extracted quantitative feature indicators into a preset download prediction model to obtain predicted values of target variables, wherein the target variables include download time consumption, code storage space size, and process memory growth.

[0085] The decision warning module 150 is configured to compare the predicted values of the target variables with corresponding target variable resource safety thresholds preset by the lower machine, and select to perform a PLC program download operation or trigger a warning mechanism according to a comparison result.

[0086] It should be noted that the resource management system 100 for PLC program download includes the resource management method for PLC program download in any of the above embodiments. Since the resource management system 100 for PLC program download provided in the embodiment belongs to the same inventive concept as the resource management method for PLC program download provided in any of the above embodiments, it at least has the same beneficial effects, and here will not be repeated.

[0087] Based on the same inventive concept, please refer to Figure 4 The electronic device 11 can include a memory 111, a processor 112, and a bus, and can further include a computer program, such as a resource management program for PLC program download, stored in the memory 111 and executable on the processor 112. It should be noted that the memory 111 can be a volatile memory, a non-volatile memory, or a combination of the two.

[0088] The memory 111 includes at least one type of readable storage medium, such as a flash memory, a mobile hard disk, a multimedia card, a card-type memory (e.g., an SD or DX memory, etc.), a magnetic memory, a disk, an optical disk, etc. In some embodiments, the memory 111 can be an internal storage unit of the electronic device 11, such as a mobile hard disk of the electronic device 11. In other embodiments, the memory 111 can also be an external storage device of the electronic device 11, such as a plug-in mobile hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. Further, the memory 111 can include both an internal storage unit and an external storage device of the electronic device 11. The memory 111 can be used to store application software and various data installed in the electronic device 11, such as resource management code for PLC program downloading, and can also be used to temporarily store data that has been output or will be output.

[0089] The processor 112 can be composed of an integrated circuit in some embodiments, such as a single packaged integrated circuit or a plurality of packaged integrated circuits with the same or different functions, including one or more combinations of a central processing unit (CPU), a microprocessor, a digital processing chip, a graphics processor, and various control chips, etc. The processor 112 is a control unit of the electronic device 11, and is connected to various components of the electronic device 11 through various interfaces and lines. The processor 112 executes programs or modules stored in the memory 111 (e.g., resource management programs for PLC program downloading, etc.) and calls data stored in the memory 111 to perform various functions and process data of the electronic device 11.

[0090] The processor 112 executes an operating system and various application programs installed in the electronic device 11. The processor 112 executes the application programs to implement the steps in the resource management method for PLC program downloading described above.

[0091] For example, the computer program can be divided into one or more modules, which are stored in the memory 111 and executed by the processor 112 to complete the present application. The one or more modules can be a series of computer program instruction segments capable of completing a specific function, which are used to describe the execution process of the computer program in the electronic device 11. For example, the computer program can be divided into a program acquisition module 110, a compilation conversion module 120, a feature extraction module 130, a download prediction module 140, and a decision warning module 150.

[0092] The integrated units in the form of software function modules described above can be stored in a computer readable storage medium, which can be non-volatile or volatile. The software function modules described above are stored in a storage medium, including a plurality of instructions for enabling a computer device (which can be a personal computer, a computer device, or a network device, etc.) or a processor to execute part of the functions of the resource management method for PLC program download described in the embodiments of the present application.

[0093] The above embodiments are only illustrative of the principles and effects of the present application, and are not intended to limit the present application. Any person skilled in the art can modify or change the above embodiments without departing from the spirit and scope of the present application. Therefore, all equivalent modifications or changes made by those skilled in the art without departing from the spirit and technical ideas disclosed in the present application should be covered by the claims of the present application.

Claims

1. A resource management method for PLC program downloading, characterized in that, include: The PLC source code written by the user is obtained through the host computer integrated development environment; The obtained PLC source program is compiled and converted to generate standardized intermediate code; The intermediate code is preprocessed, including unifying the code format, eliminating redundant information, and standardizing symbols. Static analysis is then performed on the preprocessed intermediate code to extract corresponding quantitative feature indicators. These quantitative feature indicators include the total number of instructions in the intermediate code, the number and complexity of functions or functional blocks, the complexity of loop and branch structures, and the number and total memory size of global and static variables. The extracted quantitative feature indicators are standardized to construct a feature vector that meets the input requirements of the preset download prediction model. The constructed feature vector is input into the preset download prediction model, and multiple independent prediction sub-models within the model are used to perform prediction calculations. Finally, the predicted value of the target variable is output, where the target variable includes download time, code storage space size, and process memory growth. The predicted value of the target variable is compared with the corresponding preset resource safety threshold of the target variable in the lower-level machine. If the predicted value of all target variables does not exceed the corresponding preset resource safety threshold of the target variable in the lower-level machine, the PLC program download operation is executed immediately. If the predicted value of any target variable exceeds the corresponding preset resource safety threshold of the target variable in the lower-level machine, the early warning mechanism is triggered immediately.

2. The resource management method for PLC program downloading according to claim 1, characterized in that, The PLC source program is a code text composed of a mixture of various PLC programming languages, including structured text, ladder diagrams, sequential function charts, and continuous function charts.

3. The resource management method for PLC program downloading according to claim 1, characterized in that, The predicted values ​​of the target variables include predicted download time, predicted code storage space size, and predicted process memory growth. The resource security thresholds of the target variables preset by the lower-level machine include the maximum download time threshold, the maximum available code storage space threshold, and the maximum available runtime memory space threshold.

4. The resource management method for PLC program downloading according to claim 1, characterized in that, The method further includes: After the actual download operation is performed and the download task is completed, the actual value of the target variable is collected; The true value of the target variable is compared and analyzed with the predicted value of the corresponding target variable output by the preset download prediction model in order to construct training data pairs for model training; The constructed training data is input into the preset download prediction model. Through incremental learning, the model parameters of the preset download prediction model are optimized, thereby improving the prediction accuracy of the preset download prediction model.

5. A resource management system for PLC program downloading, characterized in that, The resource management method for PLC program download as described in any one of claims 1 to 4 is adopted, comprising: The program acquisition module is used to acquire the PLC source program written by the user through the host computer integrated development environment; The compilation and conversion module is used to compile and convert the acquired PLC source program to generate standardized intermediate code; The feature extraction module is used to extract features from the generated intermediate code to obtain corresponding quantitative feature indicators; The download prediction module is used to input the extracted quantitative feature indicators into a preset download prediction model to obtain the predicted values ​​of target variables, wherein the target variables include download time, code storage space size, and process memory growth. The decision-making and early warning module is used to compare the predicted value of the target variable with the resource security threshold of the target variable preset by the corresponding lower-level machine, and select to execute the PLC program download operation or trigger the early warning mechanism based on the comparison result.

6. An electronic device, characterized in that, The electronic device includes: One or more processors; A storage device for storing one or more programs, which, when executed by one or more processors, cause the electronic device to implement the resource management method for PLC program download as described in any one of claims 1 to 4.

7. A computer-readable storage medium, characterized in that, It stores a computer program, which, when executed by the computer's processor, causes the computer to perform the resource management method for PLC program download as described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Measurement feature extraction method and system based on PLC graphical language

    CN116893804A

  • Code downloading method and device, equipment and storage medium

    CN117499377A

  • Resource management method and device, electronic equipment and storage medium

    CN120762897A