Operation method of PLC programming software and storage medium
Optimizing the memory usage of PLC programming software through memory multiplexing and dynamic loading strategies, solving the memory usage problem when editing large array variables, improving the system response speed and retaining the refined management capabilities of array variables.
Patent Information
- Application Number
- CN202510734672.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-04
- Publication Date
- 2025-07-08
- Estimated Expiration
- 2045-06-04
AI Technical Summary
Existing PLC programming software has increased significantly when editing large array variables, resulting in interface lag and even system crashes, and lacks the refined management capabilities of array variable sub-members.
Memory multiplexing technology and threshold-based dynamic loading strategy are adopted to create sub-variables corresponding to preset quantities, share memory data, and optimize memory usage when array variables expand and shrink, and combine the array variable interface optimization mechanism to realize array variable sub-member level memory sharing and refined management.
It significantly reduces the memory usage of the software in the online state, improves the system response speed, and solves the problem of interface lag, while retaining the refined management capabilities of array variable sub-members.
Smart Images

Figure CN120276739A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of software technology, and more particularly, to a method for running a PLC programming software and a storage medium. Background Art
[0002] For the tabular display of array variables, most PLC programming software has insufficient memory optimization for array variables in the online state. Especially for large arrays with more than ten thousand array members, when displaying all sub-members of large array variables, the software memory occupancy will increase sharply, subsequently causing interface lag or even system crashes. Summary of the Invention
[0003] The purpose of the embodiments of this application is to provide a method for running a PLC programming software and a storage medium, so as to reduce the memory occupancy when the PLC programming software edits array variables.
[0004] In a first aspect, this application provides a method for running a PLC programming software. The method includes responding to an array variable creation request and determining whether the requested number of sub-variables of the array variable indicated by the array variable creation request is less than or equal to a preset number; if so, creating sub-variables corresponding to the requested number, and the pointer of each sub-variable points to the first memory data; if not, creating sub-variables corresponding to the preset number, and the pointer of each sub-variable points to the second memory data.
[0005] Preferably, it further includes responding to a memory data modification request issued for a target sub-variable, and for each sub-variable in the array variable where the target sub-variable is located, determining whether the memory data of this sub-variable is consistent with the memory data of the adjacent sub-variable. If not, pointing the pointer of this sub-variable to the third memory data.
[0006] Preferably, the memory data at least includes variable type name, parameter value, comment value, and online value. The step of determining whether the memory data of this sub-variable is consistent with the memory data of the adjacent sub-variable for each sub-variable in the array variable where the target sub-variable is located specifically includes: Determining whether the variable type name, initial value, comment value, and online value between the current sub-variable and the previous sub-variable are all consistent; if so, determining whether the pointers between the current sub-variable and the previous sub-variable point to the same memory data; if not, determining that the memory data is inconsistent.
[0007] Preferably, if the pointers between the current sub-variable and the previous sub-variable do not point to the same memory data, modifying the corresponding pointer to point to the same memory data.
[0008] Preferably, the third memory data is determined by the following method: Determine the third memory data according to the content to be modified indicated by the memory data modification request and the initial value of the memory data, where the content to be modified includes the modification value corresponding to at least one of the variable type name, parameter value, comment value, and online value.
[0009] Preferably, it further includes responding to a query request issued for a target sub-variable to determine whether the pointer of the target sub-variable points to the memory data; if not, create a fourth memory data and point the pointer of the target sub-variable to the fourth memory data.
[0010] Preferably, the fourth memory data further includes a count value, and the step of creating the fourth memory data further includes setting the count value in the fourth memory data to 1.
[0011] Preferably, in response to a memory data modification request issued for a target sub-variable, determine whether the modification value indicated by the memory data modification request is consistent with the initial value; if so, set the count value in the fourth memory data to 0.
[0012] Preferably, in response to a memory data modification request issued for a target sub-variable, for each sub-variable in the array variable where the target sub-variable is located, it further includes determining whether the count value of the sub-variable is 0; if so, delete the fourth memory data corresponding to the sub-variable and point the pointer of the sub-variable to the second memory data.
[0013] In a second aspect, the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is run by a processor, it executes the steps of the running method of the PLC programming software as described above.
[0014] A running method and storage medium of a PLC programming software provided by the present application, where the method includes responding to an array variable creation request to determine whether the number of requests for sub-variables of the array variable indicated by the array variable creation request is less than or equal to a preset number; if so, create sub-variables corresponding to the number of requests, and the pointer of each sub-variable points to the first memory data; if not, create sub-variables corresponding to the preset number, and the pointer of each sub-variable points to the second memory data. Through the memory multiplexing technology, memory sharing at the sub-member level of array variables is achieved, and a dynamic loading strategy based on a threshold is designed to allocate memory only to the actually used sub-members of array variables. Compared with the prior art, it can significantly reduce the memory occupancy in the online state of the software and improve the system response speed. Description of the Drawings
[0015] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0016] Figure 1 A flowchart of a method for operating a PLC programming software provided in an embodiment of the present application; Figure 2 A schematic diagram of the first memory data structure provided in an embodiment of the present application; Figure 3 A schematic diagram of a second memory data structure provided in an embodiment of the present application; Figure 4 A schematic diagram of a third memory data structure provided in an embodiment of the present application; Figure 5 A flow chart of the change of the count value provided in the embodiment of the present application; Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0017] For the tabular display of array variables, the existing PLC programming software lacks the array variable expansion function in the editing state, and completely discards the memory data of the array variable sub-members. Although it reduces the static memory usage, the cost is the complete loss of the visualization ability of the array variable sub-members, and users cannot achieve refined management of the array sub-variables. When the existing PLC programming software is online, when the array variable is changed from the expanded state to the non-expanded state, the software's memory will not be released, and the memory optimization effect of the array variable is not enough. For large arrays with more than 10,000 array members, especially when all array variable sub-members need to be displayed, the software memory usage will increase sharply, which will cause the interface to freeze or even the system to crash.
[0018] Based on this, the present application provides an operating method and storage medium for a PLC programming software, so as to reduce the memory usage of the PLC programming software when editing array variables.
[0019] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0020] Embodiment 1 Figure 1 The following is a flow chart of a method for operating a PLC programming software provided in an embodiment of the present application. Figure 1 As shown, the present application provides a method for operating PLC programming software, wherein the method may include: S10. In response to a request for creating an array variable, determine whether the number of requests for sub-variables of the array variable indicated by the array variable creation request is less than or equal to a preset number.
[0021] S12. If so, create sub-variables corresponding to the number of requests, and the pointer of each sub-variable points to the first memory data.
[0022] S13. If not, create sub-variables corresponding to the preset number, and the pointer of each sub-variable points to the second memory data.
[0023] The PLC programming software here can be used to implement the editing function of array variables and provide an array variable editing interface. Users can issue an array variable creation instruction through the controls on the array variable editing interface, and input the type of array variable to be created and the number of sub-variables of the array variable. The array variable creation request is used to indicate the type of array variable to be created and the number of sub-variables of the array variable.
[0024] When the number of created sub-variables is less than or equal to the preset number, all sub-variables can share a memory data. The first memory data created here can include variable type name, parameter value, comment value, and online value. For example, the variable type name is String, the parameter value is 0, the comment value is empty, and the online value is 0. It is default that the initial memory data of all sub-variables is equal.
[0025] When the number of created sub-variables is greater than the preset number, only the second memory data of the preset number of sub-variables is created, and these sub-variables share a memory data, while the part of sub-variables exceeding the preset number is not created with memory data.
[0026] The created array variable can be displayed in tabular form through the array variable area. The array variable display area here can be displayed in the array variable editing interface or in an additional provided interface.
[0027] The array variable display area here includes array variable display sub-areas corresponding to the created array variables. Information of the array variable, such as the type of the array variable, the number of sub-variables of the array variable, and the creation time, etc., can be displayed in each array variable display sub-area.
[0028] When the user needs to expand the array variable, the array variable display sub-area can increase in area and display the specific sub-variables and the memory data corresponding to each sub-variable in tabular form.
[0029] Here, the interface data of the array variable display area can be generated by reading the corresponding memory data. When the sub-variable of the array variable changes from the non-expanded state to the expanded state, the interface data corresponding to the table of the sub-variable will be generated. When the sub-variable of the array variable changes from the expanded state to the non-expanded state, the interface data corresponding to the table can be deleted, thereby reducing the memory usage.
[0030] A method for operating a PLC programming software is provided in an embodiment of the present application. For the tabular display of array variables, the existing programming software lacks the array variable expansion function, and the user cannot perform fine management of the sub-members of the array variables; at the same time, the memory optimization of array variables in the PLC programming software in the prior art is insufficient, especially for large arrays with more than 10,000 array members. When displaying all array variable sub-members, the software memory usage will increase sharply, which will then cause interface freezes or even system crashes. The present application implements array variable sub-member-level memory sharing through memory reuse technology, combines the array variable interface optimization mechanism, and a threshold-based dynamic loading strategy to simultaneously solve the problems of memory redundancy and interface freezes while ensuring real-time performance.
[0031] Embodiment 2 In one embodiment of the present application, when a subvariable of an array variable changes from an unexpanded state to an expanded state that displays a corresponding table, a subvariable management function may also be provided, and a user may modify any subvariable as required.
[0032] At this time, the PLC programming software can respond to the memory data modification request issued for the target subvariable, and for each subvariable in the array variable where the target subvariable is located, determine whether the memory data of the subvariable is consistent with that of the adjacent subvariable. If not, the pointer of the subvariable is pointed to the third memory data.
[0033] For each subvariable in the array variable where the target subvariable is located, the step of determining whether the memory data of the subvariable is consistent with that of the adjacent subvariable specifically includes: determining whether the variable type name, initial value, annotation value and online value between the current subvariable and the previous subvariable are consistent; if so, determining whether the pointer between the current subvariable and the previous subvariable points to the same memory data; if not, determining that the memory data is inconsistent.
[0034] The memory data modification request here is used to modify a single target subvariable, including at least modifying parameter values and annotation values. The memory data modification request can include the name or label of the target subvariable to be modified, the name or label of the item to be modified (parameter value or annotation value), and the modified parameter value or annotation value.
[0035] Here, each time a sub-variable is modified, it is necessary to traverse all sub-variables in the current array variable. When the target sub-variable is traversed and it is found that there is data inconsistency (the initial values, comments, etc. are different) between the target sub-variable and its adjacent sub-members with shared memory data, it is necessary to split the memory data, that is, generate the third memory data for the target sub-variable.
[0036] Here, the third memory data can be determined in the following way: According to the content to be modified indicated by the memory data modification request and the initial value of the memory data, determine the third memory data, where the content to be modified includes at least one of the modified values corresponding to the variable type name, parameter value, comment value, and online value. The third memory data is generated by modifying the first memory data or the second memory data according to the modification content indicated by the memory data modification request.
[0037] Furthermore, during the traversal, for sub-variables with consistent memory data, if the pointer between the current sub-variable and the previous sub-variable does not point to the same memory data, modify the corresponding pointer to point to the same memory data, that is, merge the memory data to reduce memory occupancy.
[0038] Embodiment III In an embodiment of the present application, since the number of sub-variables in the array variable is large, when the sub-variables of the array variable are in an expanded state, a search function for sub-variables can also be provided. The array variable editing interface may include a search box. The user can enter the target sub-variable to be edited in the search box, and the display area of the array variable table can jump to the area where the target sub-variable is located. The system can respond to the query request issued for the target sub-variable to determine whether the pointer of the target sub-variable points to memory data; if not, create the fourth memory data and point the pointer of the target sub-variable to the fourth memory data. The fourth memory data here can be the initial value. If the pointer of the target sub-variable does not point to memory data, it is necessary to create a new fourth memory data to display the target sub-variable in the array variable display area.
[0039] Furthermore, the fourth memory data also includes a count value, and the step of creating the fourth memory data further includes setting the count value in the fourth memory data to 1.
[0040] In response to the memory data modification request issued for the target sub-variable, determine whether the modification value indicated by the memory data modification request is consistent with the initial value. If so, set the count value in the fourth memory data to 0.
[0041] In response to a memory data modification request for a target sub-variable, for each sub-variable in the array variable where the target sub-variable is located, it also includes determining whether the count value of the sub-variable is 0. If so, delete the fourth memory data corresponding to the sub-variable, and point the pointer of the sub-variable to the second memory data.
[0042] When the user modifies the target sub-variable, the count value corresponding to the target sub-variable is 1. When the target sub-variable is modified back to the initial value, the count value is decreased by 1. Moreover, for a sub-variable with a count value of 0, its pointer is pointed to the second memory data, and the corresponding fourth memory data is cleared.
[0043] Through a dynamic loading strategy combined with a threshold, on the premise of ensuring real-time performance, the operation method proposed in this application realizes the refined management ability of the sub-members of the array variable, and can also solve the problems of memory redundancy and interface lag.
[0044] Embodiment 4 In a specific embodiment of the present application, a method for tabular display of large array variables in a PLC programming software based on memory reuse and dynamic loading is provided. Here, the preset quantity can be 1000, and the memory data reuse can be achieved through the following steps: Create an array variable A containing 1002 INT types in the programming software, and the created memory structure is as Figure 2 shown. The pointers A[0]-A
[999] of the first 1000 sub-members point to the same memory data 1, and no corresponding memory data is generated for the sub-member part exceeding 1000. After creation, the initial values of these 1002 sub-members are defaulted to 0, and the initial values of the comments are defaulted to empty.
[0045] When modifying the array variable A, the programming software will split or merge the memory data shared by the sub-members in the array variable. When the user modifies the initial value of the sub-member in the programming software and sets A[1] and A[2] to 1 respectively, the programming software will linearly traverse each sub-member in the array A. When traversing to A[1], it is found that the initial value of A[1] is inconsistent with that of A[0]. At this time, memory data splitting is required to generate a new memory data 2. During the subsequent traversal, it is found that the initial values of A[2] and A[1] are the same, and memory data merging can be performed. The programming software will point the pointers of A[1] and A[2] to the memory data 2 at the same time. Similarly, A[3]-A
[999] will point to the same memory data 3. After setting the initial values, the memory structure of the array A is as Figure 3 shown.
[0046] For the part of array variable A whose number of sub-members exceeds the threshold, dynamic on-demand loading is used to generate memory data. Taking array variable A as an example, the user sets the initial value of sub-member A
[1001] of array A to 1 in the programming software. The programming software will query whether there is corresponding memory data through the name of the sub-member A
[1001] . If there is no corresponding memory data for A
[1001] , the programming software will create the corresponding memory data 4, and the reference count value of the memory data is set to 1. At this time, the memory structure of array A is as follows: Figure 4 shown.
[0047] Next, the reference count management, the user operates the relevant attribute value of A
[1001] , and the corresponding reference count value changes as follows Figure 5 As shown, first change the comment value of A
[1001] from empty to the non-default value "aa", then the reference count value RefNum corresponding to memory data 4 will increase by 1 and become 2, then the user sets the parameter value of A
[1001] to the default value 0, then the reference count value RefNum corresponding to memory data 4 will decrease by 1 and become 1, finally the user changes the comment value of A
[1001] to the default value empty, then the reference count value RefNum of memory data 4 will decrease by 1 and become 0, at this time, the programming software will clear the memory data corresponding to A
[1001] , and the memory structure of array A will be as follows Figure 3 shown.
[0048] Regarding array interface optimization, when array variable A is created, it is in the unexpanded state by default, and the programming software only generates the interface data corresponding to array variable A, and does not generate the interface data of its sub-members. When array variable A changes from the unexpanded state to the expanded state, the programming software will generate the interface data of the sub-members corresponding to array variable A. When array A variable changes from the expanded state to the unexpanded state, the programming software will clear the interface data of the sub-members corresponding to array variable A, and only retain the interface data corresponding to array variable A.
[0049] For the tabular display of array variables, existing programming software lacks the array variable expansion function in the editing state, and users cannot perform fine management of the sub-members of array variables. In the online state, the memory optimization of array variables is insufficient, especially for large arrays with more than 10,000 array members. When displaying all array variable sub-members, the software memory usage will increase sharply, which will cause the interface to freeze or even the system to crash. To address these problems, this application implements array variable sub-member-level memory sharing through memory reuse technology, combines the array variable interface optimization mechanism, and innovatively designs a threshold-based dynamic loading strategy. Under the premise of ensuring real-time performance, it simultaneously solves the problems of memory redundancy and interface freeze, while retaining the ability to finely manage array variable sub-members.
[0050] Embodiment 5 Please refer to Figure 6 , Figure 6 which is a schematic structural diagram of an electronic device provided by an embodiment of the present application. As shown in Figure 6 , the electronic device 600 includes a processor 610, a memory 620, and a bus 630.
[0051] The memory 620 stores machine-readable instructions executable by the processor 610. When the electronic device 600 runs, the processor 610 communicates with the memory 620 through the bus 630. When the machine-readable instructions are executed by the processor 610, the steps of a running method of a PLC programming software in the method embodiment as shown above Figure 1 can be executed. For the specific implementation manner, reference can be made to the method embodiment, which will not be elaborated here.
[0052] An embodiment of the present application also provides a computer-readable storage medium. A computer program is stored on the computer-readable storage medium. When the computer program is run by a processor, the steps of a running method of a PLC programming software in the method embodiment as shown above Figure 1 can be executed. For the specific implementation manner, reference can be made to the method embodiment, which will not be elaborated here.
[0053] 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 foregoing method embodiments, which will not be elaborated here.
[0054] In the embodiments provided by the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only illustrative. For example, the division of the units is only a logical function division, and there can be other division methods in actual implementation. For another example, 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 displayed or discussed couplings or direct couplings or communication connections to each other can be through some communication interfaces. The indirect couplings or communication connections of the devices or units can be in electrical, mechanical, or other forms.
[0055] In addition, the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they can be located in one place, or they can be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0056] Furthermore, in each embodiment of the present application, each functional module can be integrated together to form an independent part, or each module can exist alone, or two or more modules can be integrated to form an independent part.
[0057] It should be noted that if a function is implemented in the form of a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present application. The aforementioned storage medium includes: USB flash drives, mobile hard disks, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical discs and other various media that can store program codes.
[0058] In this text, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations.
[0059] The above are only the embodiments of the present application and are not used to limit the protection scope of the present application. For those skilled in the art, the present application can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A running method of a PLC programming software, characterized in that The method includes: In response to a request for creating an array variable, determining whether the number of requests for sub-variables of the array variable indicated by the array variable creation request is less than or equal to a preset number; If so, creating sub-variables corresponding to the number of requests, and the pointer of each sub-variable points to the first memory data; If not, creating sub-variables corresponding to the preset number, and the pointer of each sub-variable points to the second memory data.
2. The method according to claim 1, wherein It further includes: In response to a memory data modification request issued for a target sub-variable, for each sub-variable in the array variable where the target sub-variable is located, determining whether the memory data of this sub-variable is consistent with the memory data of the adjacent sub-variable. If not, pointing the pointer of this sub-variable to the third memory data.
3. The method according to claim 2, wherein The memory data at least includes a variable type name, a parameter value, a comment value, and an online value. The step of determining whether the memory data of each sub-variable in the array variable where the target sub-variable is located is consistent with the memory data of the adjacent sub-variable specifically includes: Determining whether the variable type name, initial value, comment value, and online value between the current sub-variable and the previous sub-variable are all consistent; If so, determining whether the pointers between the current sub-variable and the previous sub-variable point to the same memory data; If not, determining that the memory data is inconsistent.
4. The method according to claim 3, characterized in that If the pointers between the current sub-variable and the previous sub-variable do not point to the same memory data, modifying the corresponding pointer to point to the same memory data.
5. The method according to claim 2, wherein Determine the third memory data in the following manner: Determining the third memory data according to the content to be modified indicated by the memory data modification request and the initial value of the memory data, where the content to be modified includes a modification value corresponding to at least one of a variable type name, a parameter value, a comment value, and an online value.
6. The method according to claim 5, characterized in that, It further includes: In response to a query request issued for a target sub-variable, determining whether the pointer of the target sub-variable points to memory data; If not, creating a fourth memory data and pointing the pointer of the target sub-variable to the fourth memory data.
7. The method according to claim 6, wherein The fourth memory data further includes a count value. The step of creating the fourth memory data further includes setting the count value in the fourth memory data to 1.
8. The method according to claim 7, wherein In response to a memory data modification request issued for a target sub-variable, determining whether the modification value indicated by the memory data modification request is consistent with the initial value. If so, setting the count value in the fourth memory data to 0.
9. The method according to claim 8, wherein In response to a memory data modification request issued for a target sub-variable, for each sub-variable in the array variable where the target sub-variable is located, it further includes determining whether the count value of this sub-variable is 0. If so, deleting the fourth memory data corresponding to this sub-variable and pointing the pointer of this sub-variable to the second memory data.
10. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium. When the computer program is run by a processor, it executes the steps of the running method of the PLC programming software as described in any one of claims 1 to 9.
Citation Information
Patent Citations
Memory resource detection method and device, readable medium and electronic equipment
CN115827485A
PLC program compiling method and device based on array mapping memory address
CN117806607A
ST language-to-C language compiling method supporting IEC61131 (International Electrotechnical Commission 61131) standard
CN118092937A
Process communication method and device and electronic equipment
CN118860697A
Thread management
US20230267005A1