A running method of a PLC programming software and a storage medium
By employing memory reuse and dynamic loading strategies, the PLC programming software achieves memory sharing at the sub-member level of array variables, solving the memory consumption problem when editing large array variables, improving system response speed, and retaining fine-grained management capabilities.
Patent Information
- Application Number
- CN202510734672.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-04
- Publication Date
- 2026-01-02
- Estimated Expiration
- 2045-06-04
AI Technical Summary
Existing PLC programming software experiences a sharp increase in memory usage when editing large array variables, leading to interface lag or even system crashes, and lacks the ability to fine-grained manage array variable sub-members.
By employing memory reuse technology and a threshold-based dynamic loading strategy, the system creates and manages pointers to sub-variables of array variables. It determines the number of sub-variables by responding to array variable creation requests, merges or splits memory data, and achieves memory sharing at the sub-member level of array variables. Combined with an array variable interface optimization mechanism, it dynamically loads memory.
It significantly reduces the memory usage of PLC programming software in online mode, improves system response speed, retains the fine-grained management capability of array variable sub-members, and solves the interface lag problem.
Smart Images

Figure CN120276739B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the software technical field, in particular to a PLC programming software running method and a storage medium. BACKGROUND
[0002] For tabular display of array variables, most PLC programming software is not optimized in memory in 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 occupation will sharply rise, and then cause interface lag or even system crash. SUMMARY
[0003] The purpose of the embodiments of the present application is to provide a PLC programming software running method and a storage medium, to reduce the memory occupation of the PLC programming software when editing array variables.
[0004] In a first aspect, the present application provides a PLC programming software running method, which comprises: in response to an array variable creation request, determining whether the 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 yes, creating sub-variables corresponding to the number of sub-variables, and the pointer of each sub-variable points to first memory data; if no, creating sub-variables corresponding to the preset number, and the pointer of each sub-variable points to second memory data.
[0005] Preferably, the method further comprises: in response to a memory data modification request for a target sub-variable, for each sub-variable in the array variable in which the target sub-variable is located, determining whether the memory data of the sub-variable and the adjacent sub-variable is consistent, if not, modifying the pointer of the sub-variable to point to third memory data.
[0006] Preferably, the memory data at least includes variable type name, parameter value, comment value and online value, and the step of determining whether the memory data of each sub-variable in the array variable in which the target sub-variable is located and the adjacent sub-variable is consistent, specifically comprises:
[0007] determining whether the variable type name, initial value, comment value and online value between the current sub-variable and the previous sub-variable are consistent; if yes, determining whether the pointers between the current sub-variable and the previous sub-variable point to the same memory data; if no, determining that the memory data is inconsistent.
[0008] Preferably, if the pointers between the current sub-variable and the previous sub-variable do not point to the same memory data, the corresponding pointer is modified to point to the same memory data.
[0009] Preferably, the third memory data is determined by the following way:
[0010] According to the to-be-modified content indicated by the memory data modification request and the initial value of the memory data, third memory data is determined, wherein the to-be-modified content includes at least one of a modification value corresponding to a variable type name, a parameter value, a comment value, and an online value.
[0011] Preferably, the method further comprises, in response to a query request issued for the target sub-variable, determining whether the pointer of the target sub-variable points to the memory data; if not, creating fourth memory data and pointing the pointer of the target sub-variable to the fourth memory data.
[0012] 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.
[0013] Preferably, in response to the memory data modification request issued for the target sub-variable, it is determined whether the modification value indicated by the memory data modification request is consistent with the initial value; if yes, the count value in the fourth memory data is set to 0.
[0014] Preferably, in response to the memory data modification request issued for the target sub-variable, for each sub-variable in the array variable in which the target sub-variable is located, it is further determined whether the count value of the sub-variable is 0; if yes, the fourth memory data corresponding to the sub-variable is deleted, and the pointer of the sub-variable is pointed to the second memory data.
[0015] In a second aspect, the present application provides a computer readable storage medium, and the computer readable storage medium stores a computer program. When the computer program is run by a processor, the steps of the running method of the PLC programming software are executed.
[0016] The present application provides a running method of a PLC programming software and a storage medium. The method comprises, in response to an array variable creation request, determining whether the 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 yes, creating sub-variables corresponding to the number of sub-variables, 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. Through the memory multiplexing technology, the array variable sub-member level memory sharing is realized, and a dynamic loading strategy based on a threshold value is designed. Only the array variable sub-members actually used are allocated with memory. Compared with the prior art, the memory occupation in the online state of the software can be significantly reduced, and the system response speed can be improved. BRIEF DESCRIPTION OF DRAWINGS
[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the embodiments of the present application will be briefly introduced as follows. It should be understood that the following drawings only show some of the embodiments of the present application, and therefore should not be regarded as a limitation on the scope, and for those of ordinary skill in the art, other related drawings can also be obtained without creative labor on the basis of these drawings.
[0018] Figure 1 A flow chart of a running method of a PLC programming software provided by the embodiments of the present application is shown in FIG. 1.
[0019] Figure 2 A first memory data structure schematic diagram provided by the embodiments of the present application is shown in FIG. 2.
[0020] Figure 3 A second memory data structure schematic diagram provided by the embodiments of the present application is shown in FIG. 3.
[0021] Figure 4 A third memory data structure schematic diagram provided by the embodiments of the present application is shown in FIG. 4.
[0022] Figure 5 A flow chart of a count value change provided by the embodiments of the present application is shown in FIG. 5.
[0023] Figure 6 A structure schematic diagram of an electronic device provided by the embodiments of the present application is shown in FIG. 6. DETAILED DESCRIPTION
[0024] For tabular display of array variables, the existing PLC programming software lacks array variable expansion function in the editing state, and completely discards the memory data of the sub-members of the array variables, which reduces the static memory occupation, but at the cost of completely losing the visualization ability of the sub-members of the array variables, and the user cannot realize fine management of the array sub-variables. When the existing PLC programming software changes the array variables from the expanded state to the unexpanded state in the online state, the memory of the software will not be released, and the memory optimization effect of the array variables is not enough. For large arrays with the number of array members being more than ten thousand, especially when all the array variable sub-members need to be displayed, the software memory occupation will sharply rise, and then interface lag or even system crash will be caused.
[0025] Based on this, the present application provides a running method of a PLC programming software and a storage medium, to reduce the memory occupation of the PLC programming software when editing array variables.
[0026] The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application.
[0027] Embodiment one
[0028] Figure 1A flow chart of a running method of a PLC programming software is provided for the embodiments of the present application. As shown in Figure 1 The present application provides a running method of a PLC programming software, wherein the method can include:
[0029] S10, in response to an array variable creation request, 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.
[0030] S12, if yes, creating sub-variables corresponding to the requested number, and the pointer of each sub-variable points to the first memory data.
[0031] S13, if no, creating sub-variables corresponding to the preset number, and the pointer of each sub-variable points to the second memory data.
[0032] The PLC programming software herein can be used to implement the editing function of array variables and provide an array variable editing interface. The user can issue an array variable creation instruction through the control 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.
[0033] When the number of created sub-variables is less than or equal to the preset number, all the sub-variables can share a piece of memory data. The first memory data created herein 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. Here, the initial memory data of all the sub-variables is equal by default.
[0034] 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 piece of memory data, and the memory data of the sub-variables exceeding the preset number is not created.
[0035] The created array variable can be displayed in a tabular form through the array variable area. The array variable display area herein can be displayed in the array variable editing interface or in an additionally provided interface.
[0036] The array variable display area herein includes an array variable display sub-area corresponding to the created array variable. The 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.
[0037] When the user needs to expand the array variable, the array variable display sub-area can increase in size and display the specific sub-variables and the memory data corresponding to each sub-variable in a tabular form.
[0038] Here, the interface data of the array variable display area can be generated by reading the corresponding memory data. When the sub-variables of the array variable change from the unexpanded state to the expanded state, the interface data corresponding to the table of the sub-variables is generated, and when the sub-variables of the array variable change from the expanded state to the unexpanded state, the interface data corresponding to the table can be deleted, thereby reducing the memory occupation.
[0039] The running method of the PLC programming software provided in the embodiments of the present application can display the array variable in the form of a table. The existing programming software lacks the array variable expansion function, and the user cannot finely manage the sub-members of the array variable. In addition, the memory optimization of the array variable in the PLC programming software in the prior art is not sufficient. In particular, for a large array with a number of array members exceeding ten thousand, when all the sub-members of the array variable are displayed, the software memory occupation will sharply increase, thereby causing the interface to be stuck and even causing the system to crash. The present application realizes the sub-member level memory sharing of the array variable by using the memory reuse technology, and combines the array variable interface optimization mechanism and the threshold-based dynamic loading strategy to synchronously solve the problems of memory redundancy and interface sticking while ensuring the real-time performance.
[0040] Embodiment Two
[0041] In an embodiment of the present application, when the sub-variables of the array variable change from the unexpanded state to the expanded state to display the corresponding table, the management function of the sub-variables can also be provided, and the user can modify any sub-variable according to the requirements.
[0042] At this time, the PLC programming software can respond to the memory data modification request issued for the target sub-variable, determine whether the memory data of each sub-variable in the array variable where the target sub-variable is located and the adjacent sub-variable is consistent, and if not, point the pointer of the sub-variable to the third memory data.
[0043] The step of determining whether the memory data of each sub-variable in the array variable where the target sub-variable is located and the adjacent sub-variable is consistent specifically includes: determining whether the variable type name, the initial value, the comment value and the online value between the current sub-variable and the previous sub-variable are consistent; if yes, determining whether the pointers between the current sub-variable and the previous sub-variable point to the same memory data; and if not, determining that the memory data is inconsistent.
[0044] The memory data modification request herein is used to modify a single target sub-variable and at least includes a modification parameter value and a comment value. The memory data modification request can include the name or label of the target sub-variable to be modified, the name or label of the item (the parameter value or the comment value) to be modified, and the modified parameter value or comment value.
[0045] Here, each time the modification of the sub-variables is performed, all the sub-variables in the current array variable need to be traversed, and when the target sub-variable is found, it is discovered that the target sub-variable and the sub-member adjacent to the target sub-variable and having the memory data sharing exist data inconsistency (the initial value, the comment data and the like are not the same), and then the memory data splitting needs to be performed, that is, the third memory data is generated for the target sub-variable.
[0046] Here, the third memory data can be determined in the following manner: according to the initial value of the memory data and the modification content indicated by the memory data modification request, the third memory data is determined, wherein the modification content includes at least one of the modification value corresponding to the variable type name, the parameter value, the comment value and the online value. The third memory data is generated according to the modification content indicated by the memory data modification request to modify the first memory data or the second memory data.
[0047] Further, in the traversal, for the sub-variables with the memory data consistent, if the pointers between the current sub-variable and the previous sub-variable do not point to the same memory data, the corresponding pointer is modified to point to the same memory data, that is, the memory data is merged to reduce the memory occupation.
[0048] Embodiment three
[0049] 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 the expanded state, the search function of the sub-variables can also be provided. The search box can be included on the array variable editing interface. The user can input 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 the memory data; if not, the fourth memory data is created, and the pointer of the target sub-variable is pointed 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 the memory data, the fourth memory data needs to be newly created to display the target sub-variable in the array variable display area.
[0050] Further, the fourth memory data further includes the count value, and the step of creating the fourth memory data further includes setting the count value in the fourth memory data to 1.
[0051] In response to the memory data modification request issued for the target sub-variable, it is determined whether the modification value indicated by the memory data modification request is consistent with the initial value, and if so, the count value in the fourth memory data is set to 0.
[0052] In response to the memory data modification request issued for the target sub-variable, for each sub-variable in the array variable in which the target sub-variable is located, it is further determined whether the count value of the sub-variable is 0, and if so, the fourth memory data corresponding to the sub-variable is deleted, and the pointer of the sub-variable points to the second memory data.
[0053] When the user modifies the target sub-variable, the count value corresponding to the target sub-variable is 1, and when the target sub-variable is modified back to the initial value, the count value is reduced by 1. And for the sub-variable with a count value of 0, the pointer points to the second memory data, and the corresponding fourth memory data is cleared.
[0054] By combining the dynamic loading strategy of the threshold value, under the premise of ensuring real-time, the running method proposed in the application realizes the fine management capability of the sub-members of the array variable, and can also solve the problems of memory redundancy and interface lag.
[0055] Embodiment Four
[0056] In one specific embodiment of the present application, a PLC programming software large array variable tabular display method based on memory reuse and dynamic loading is provided. Here, the preset number can be 1000, and the memory data reuse can be achieved by the following steps:
[0057] An array variable A containing 1002 INT types is created in the programming software, and the created memory structure is as shown in Figure 2 The pointers of the first 1000 sub-members A[0]-A
[999] point to the same memory data 1, and the sub-members exceeding 1000 do not generate corresponding memory data. After creation, the initial values of the 1002 sub-members are all 0 by default, and the initial values of the annotations are all empty by default.
[0058] 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 values of the sub-members 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 A[1] is traversed, it is found that the initial value of A[1] is inconsistent with A[0], at which time memory data splitting is required to generate a new memory data 2, and in the process of continuing to traverse, it is found that A[2] and A[1] have the same initial value, and memory data merging can be performed, so the programming software will point the pointers of A[1] and A[2] to the memory data 2. 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 shown in Figure 3 .
[0059] For the part of the sub-member number of the array variable A exceeding the threshold value, the memory data is generated in a dynamic on-demand loading manner. Taking the array variable A as an example, the user sets the initial value of the sub-member A
[1001] of the array A to 1 in the programming software, the programming software queries whether the corresponding memory data exists through the name of the sub-member A
[1001] , the corresponding memory data of A
[1001] does not exist, the programming software creates 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 the array A is as shown in Figure 4 .
[0060] Next, the reference count management, the user operates the related attribute value of A
[1001] , the corresponding reference count value change process is as shown in Figure 5 . First, the comment value of A
[1001] is changed from empty to a non-default value "aa", at this time, the reference count value RefNum of the memory data 4 is increased by 1 to 2, then the user sets the parameter value of A
[1001] to the default value 0, at this time, the reference count value RefNum of the memory data 4 is reduced by 1 to 1, finally, the user changes the comment value of A
[1001] to the default value empty, at this time, the reference count value RefNum of the memory data 4 is reduced by 1 to 0, at this time, the programming software will clear the memory data corresponding to A
[1001] , and the memory structure of the array A will be as shown in Figure 3 .
[0061] For the array interface optimization aspect, when the array variable A is created, at this time, it is in the unexpanded state by default, the programming software only generates the interface data corresponding to the array variable A, and the interface data of the sub-member is not generated. When the array variable A changes from the unexpanded state to the expanded state, the programming software will generate the interface data of the sub-member corresponding to the array variable A. When the array variable A changes from the expanded state to the unexpanded state, the programming software will clear the interface data of the sub-member corresponding to the array variable A, and only the interface data corresponding to the array variable A is retained.
[0062] For the tabular display of the array variable, the existing programming software lacks the expansion function of the array variable in the editing state, and the user cannot finely manage the sub-member of the array variable, and in the online state, the memory optimization of the array variable is not enough, especially for a large array with a number of sub-members reaching ten thousand levels, when all the sub-members of the array variable are displayed, the software memory occupation will sharply rise, and then the interface lag or even system crash is caused. In view of these problems, the memory reuse technology is used to realize the sub-member level memory sharing of the array variable, the array variable interface optimization mechanism is combined, and the dynamic loading strategy based on the threshold value is innovatively designed, the memory redundancy and the interface lag problem are solved synchronously under the premise of ensuring the real-time performance, and the fine management ability of the sub-member of the array variable is retained.
[0063] Embodiment five
[0064] Please refer to Figure 6 , Figure 6 is a structural schematic 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.
[0065] The memory 620 stores machine readable instructions executable by the processor 610, when the electronic device 600 is running, the processor 610 and the memory 620 communicate through the bus 630, the machine readable instructions are executed by the processor 610, can execute the steps of the running method of the PLC programming software in the method embodiment as described above Figure 1 , the specific implementation can be referred to the method embodiment, and will not be repeated here.
[0066] The embodiment of the present application further provides a computer readable storage medium, the computer readable storage medium stores a computer program, the computer program is run by the processor, can execute the steps of the running method of the PLC programming software in the method embodiment as described above Figure 1 , the specific implementation can be referred to the method embodiment, and will not be repeated here.
[0067] Those skilled in the art can clearly understand that, for the convenience and brevity of the above description, the specific working process of the system, device and unit described above can refer to the corresponding process in the foregoing method embodiment, and will not be repeated here.
[0068] In the embodiments provided in 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 schematic. For example, the division of the units is only a logical function division, and actual implementation can have another division manner. For example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some communication interface, device or unit, which can be electrical, mechanical or other forms.
[0069] In addition, the units described as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, that is, they can be located in one place, or can be distributed on a plurality of network units. According to actual needs, some or all of the units can be selected to achieve the purpose of the embodiment of the present application.
[0070] Further, each functional module in the various embodiments of the present application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0071] It should be noted that if the functions are realized in the form of software functional modules and sold or used as independent products, they can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application or the part of the present application that essentially contributes to the prior art or the part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a plurality of instructions for causing 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 method described in the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various media that can store program codes.
[0072] In this document, relational terms such as first and second and the like can be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions.
[0073] The above only describes the embodiments of the present application and is 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 method of running a PLC programming software, characterized in that, The PLC programming software is used to provide an array variable editing interface, and the method comprises the following steps: In response to an array variable creation request issued by a user through the array variable editing interface, determining whether the number of sub-variables of an array variable indicated by the array variable creation request is less than or equal to a preset number, the array variable creation request being used to indicate the type of the array variable to be created and the number of sub-variables of the array variable; If yes, creating sub-variables corresponding to the number of sub-variables, and the pointer of each sub-variable pointing to first memory data; If no, creating sub-variables corresponding to the preset number, and the pointer of each sub-variable pointing to second memory data; The first / second memory data at least comprises a variable type name, a parameter value, a comment value and an online value, and is used to display the corresponding array variable in a display sub-region of the array variable in the array variable editing interface.
2. The method of claim 1, wherein, Further comprising: In response to a memory data modification request issued for a target sub-variable, for each sub-variable in the array variable in which the target sub-variable is located, determining whether the memory data of the sub-variable and an adjacent sub-variable is consistent, and if not, pointing the pointer of the sub-variable to third memory data.
3. The method of claim 2, wherein, The memory data at least comprises a variable type name, a parameter value, a comment value and an online value, and the step of determining whether the memory data of each sub-variable in the array variable in which the target sub-variable is located and an adjacent sub-variable is consistent, specifically comprises the following steps: Determining whether the variable type name, the initial value, the comment value and the online value between the current sub-variable and a previous sub-variable are consistent; If yes, determining whether the pointers between the current sub-variable and the previous sub-variable point to the same memory data; If no, determining that the memory data is inconsistent.
4. The method of claim 3, wherein, If the pointers between the current sub-variable and the previous sub-variable do not point to the same memory data, modifying the corresponding pointers to point to the same memory data.
5. The method of claim 2, wherein, The third memory data is determined in the following manner: According to the initial value of the memory data and the modification content indicated by the memory data modification request, determining the third memory data, Wherein, the modification content comprises at least one of the modification value corresponding to the variable type name, the parameter value, the comment value and the online value.
6. The method of claim 5, wherein, Further comprising: 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 no, creating fourth memory data, and pointing the pointer of the target sub-variable to the fourth memory data.
7. The method of claim 6, wherein, The fourth memory data further comprises a count value, and the step of creating the fourth memory data further comprises setting the count value in the fourth memory data to 1.
8. The method of 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, and if yes, setting the count value in the fourth memory data to 0.
9. The method of 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 in which the target sub-variable is located, further comprising determining whether the count value of the sub-variable is 0, and if yes, deleting the fourth memory data corresponding to the sub-variable, and pointing the pointer of the sub-variable to the second memory data.
10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program performs the steps of the running method of the PLC programming software according to any one of claims 1 to 9 when run by the processor.
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