Double-script dynamic binding and parameterization configuration method and device for intelligent electric meter production test and medium
By combining C# and IronPython scripts, dynamic binding and parameterized configuration for smart meter production testing are achieved, solving the problem of frequent code updates in traditional methods and improving testing efficiency and flexibility.
Patent Information
- Application Number
- CN202511279996.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-09
- Publication Date
- 2026-01-06
AI Technical Summary
In the production testing of smart meters, traditional methods require frequent writing of test code, which lacks flexibility, while the method combining C# and Python suffers from large script size and poor debuggability.
The main framework and common methods of the testing tool are written in C#, combined with IronPython dual scripts. By configuring the execution environment, pre- and post-operation scripts, and data parsing, dynamic binding and parameterized configuration are achieved, avoiding frequent updates to the C# source code.
It reduced time costs, improved testing efficiency, allowed for flexible handling of various testing needs, and reduced the frequency of code updates.
Smart Images

Figure CN121277818A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of smart meter testing technology, and in particular relates to a dual-script dynamic binding and parameterized configuration method for smart meter production testing. Background Technology
[0002] When developing production testing software for discrete manufacturing, such as for smart meter testing, it is usually necessary to conduct multiple tests on the product according to specific project requirements to ensure that the product is configured correctly and meets quality standards.
[0003] The traditional approach involves directly writing the test process into the source code, but this method has significant drawbacks: each new project requires rewriting the test code to adapt to different testing needs and customized product parameters, which is not only time-consuming and labor-intensive but also lacks flexibility. Another approach combines C# source code and Python scripts. Specifically, the required parameters and runtime environment are first loaded through fixed C# source code, and then the Python script is executed to complete the test process. While this method improves the flexibility of process adjustments, it also has several problems. First, Python scripts abandon the powerful function capabilities of C#, resulting in excessively large scripts and high costs for writing and maintaining them; second, IronPython has extremely poor debuggability, making it difficult to quickly locate and resolve problems once they occur. Summary of the Invention
[0004] The purpose of this application is to overcome the problems of the prior art by disclosing a method, device and medium for dynamic binding and parameterized configuration of dual scripts in smart meter production testing. This application solves the problem of dynamic binding and parameterized configuration of dual scripts in smart meter production testing that exists in the background art.
[0005] On the one hand, the objective of this application is achieved through the following technical solution: A method for dynamic binding and parameterized configuration of dual scripts in smart meter production testing, comprising: According to the preset test guide document, add the test items to the process in the test order and configure the process parameters in the process management interface; And during production testing, the following steps are completed: configuring the execution environment, executing the pre-operation Python script, executing the communication operation, executing the post-operation Python script, and parsing the data. The pre-operation Python script and the post-operation Python script are selected for execution based on test requirements.
[0006] According to a preferred embodiment, configuring the execution environment includes: loading the configuration according to the test items and initializing the test objects, and performing a pre-test foolproof check; The communication operation includes: configuring communication with the same table or external tooling equipment according to the test object, then preprocessing the data returned by the communication and returning the result; The data analysis includes: performing final error prevention measures based on the test results, displaying the results on the interface, refreshing the data, and uploading the results to the MES system.
[0007] According to a preferred embodiment, when performing the production testing process, if a pre-operation Python script is included, The pre-operation Python script includes: using IronPython's CreateEngine() to create a Python engine, using SetVariable() to pass the test object variables to Python, then executing the pre-operation Python script and returning data; the Python script modifies the test object configuration parameters according to project needs.
[0008] According to a preferred embodiment, when performing the production testing process, if a post-operation Python script is included, The post-operation Python script includes: using IronPython to create a Python engine, and executing the Python script as needed to perform final processing and judgment on the test data.
[0009] According to a preferred embodiment, each test item includes the following: test item name, communication protocol, operation type, test item parameters, pre-operation script, and post-operation script.
[0010] According to a preferred embodiment, the test item name is used to uniquely identify the test item in the corresponding project; the communication protocol is used to determine the protocol type and communication method for communicating with the meter / tooling equipment; and the operation type is used to determine what processing operation to perform on the read data, including reading or writing.
[0011] According to a preferred embodiment, the test item parameters include: meter setting / checking parameters, setting / reading processing scheme, tooling equipment control parameters, and MES system interaction content.
[0012] According to a preferred embodiment, the pre-operation script is a Python script for communication with the electricity meter. The script can be edited as needed to configure and modify the setting / checking parameters according to the conditions. The script can call various methods in the C# source code. The script following the operation is a Python script generated after the electricity meter communicates with the user. The script can be edited as needed to process the data returned after communication, and various methods in the C# source code can be called within the script.
[0013] On the other hand, this application also discloses: An electronic device includes: at least one processor; and a memory communicatively connected to said at least one processor; The memory stores instructions that can be executed by the at least one processor, and the at least one processor executes the instructions stored in the memory to perform the aforementioned method.
[0014] On the other hand, this application also discloses: A computer-readable storage medium for storing instructions that, when executed, cause the aforementioned method to be implemented.
[0015] The aforementioned main solution and its various further alternative solutions can be freely combined to form multiple solutions, all of which are solutions that can be adopted and are claimed in this application. Those skilled in the art, after understanding the solution of this application, will realize that there are many combinations based on the prior art and common general knowledge, all of which are technical solutions to be protected in this application, and will not be exhaustively listed here.
[0016] The beneficial effects of this application are: This application uses C# to write the testing tool. The testing tool is only responsible for the main framework and public methods. It uses two IronPython scripts, one before and one after the encapsulated test items, to flexibly handle various requirements, avoiding frequent code updates and releases of the testing tool. Most changes in requirements only require modification of the IronPython scripts and test flow for the test items, without needing to modify the C# source code and release a new testing tool, thus reducing time costs and improving testing efficiency. Attached Figure Description
[0017] Figure 1 This is a schematic diagram illustrating the principle of the dual-script dynamic binding and parameterized configuration method for smart meter production testing in this application. Figure 1 1-a is a schematic diagram of the production and testing process structure of this application; Figure 1 Figure 1-b is a schematic diagram of the test item content structure of this application. Figure 1 1-c is a schematic diagram of the test item execution steps in the test process of this application; Figure 2 This is a schematic diagram of the equipment structure in this application. Detailed Implementation
[0018] The following specific examples illustrate the implementation of this application. Those skilled in the art can easily understand other advantages and effects of this application from the content disclosed in this specification. This application can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of this application. It should be noted that, unless otherwise specified, the following embodiments and features in the embodiments can be combined with each other.
[0019] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0020] Example 1 refer to Figure 1 As shown, this embodiment discloses a method for dynamic binding and parameterized configuration of dual scripts in smart meter production testing. The method includes: According to the preset test guide document, add the test items to the process in the test order and configure the process parameters in the process management interface; And during production testing, the following steps are completed: configuring the execution environment, executing the pre-operation Python script, executing the communication operation, executing the post-operation Python script, and parsing the data. The pre-operation Python script and the post-operation Python script are selected for execution based on test requirements.
[0021] Preferably, different types of test items are added through the test item management interface according to project needs. Each test item includes the following: test item name, communication protocol, operation type, test item parameters, pre-operation script, and post-operation script.
[0022] The test item name is used to uniquely identify the test item in this project.
[0023] Communication protocols are used to determine the type of protocol and communication method for communicating with devices such as meters and tooling equipment.
[0024] The operation type determines how the read-back data is processed.
[0025] Test parameters have different definitions and functions in different communication protocols and operation types, including meter setting / checking parameters, setting / reading processing schemes, tooling equipment control parameters, MES system interaction schemes, etc. They can be flexibly configured according to specific needs. After the C# source code checks the corresponding parameters, it will execute the corresponding function.
[0026] This is a pre-operation script, a Python script for communication with the electricity meter. It allows for simple script editing to configure and modify parameters such as settings and checks according to conditions. The script can call various methods from the C# source code. If the existing C# source code can handle the parameter configuration, this script is unnecessary.
[0027] The post-operation script is a Python script that processes the data returned after the meter communication. The script can call various methods in the C# source code. If the preprocessing of the data in the previous communication operation is sufficient and no additional special processing is required, the Python script does not need to be executed.
[0028] Preferably, each test item can be performed according to the following steps.
[0029] Configure the execution environment: Load the configuration according to the test items and initialize the test objects, and perform general error-proof checks before testing.
[0030] Pre-operation Python script: Use IronPython's CreateEngine() to create a Python engine, and use SetVariable() to pass variables such as the test object to the Python script. Then, execute the pre-operation Python script and return the data. The Python script can modify the test object configuration parameters according to project needs. If the parameters loaded in the previously configured execution environment do not require additional special processing, this Python script does not need to be executed.
[0031] Perform communication operations: The test tool communicates with the table or external tooling equipment according to the test object configuration, then preprocesses the data returned by the communication and returns the results.
[0032] Post-operation Python script: Use IronPython to create a Python engine again, and execute the Python script as needed to perform final processing and evaluation of the test data. If the data preprocessing in the previous communication operation is sufficient and no additional special processing is required, this Python script does not need to be executed.
[0033] Data parsing: Based on the test results, perform final general error prevention processing, display the results on the interface and refresh the data, and upload the results to the MES system, etc.
[0034] This application uses C# to write the testing tool. The testing tool is only responsible for the main framework and public methods. It uses two IronPython scripts, one before and one after the encapsulated test items, to flexibly handle various requirements, avoiding frequent code updates and releases of the testing tool. Most changes in requirements only require modification of the IronPython scripts and test flow for the test items, without needing to modify the C# source code and release a new testing tool, thus reducing time costs and improving testing efficiency.
[0035] Example 2 like Figure 2As shown in Embodiment 1, this embodiment also discloses an electronic device, including: at least one processor; and a memory communicatively connected to the at least one processor; the specific connection medium between the processor and the memory is not limited in this embodiment.
[0036] Figure 2 This example illustrates the connection between the processor and memory via a bus. The bus... Figure 2 The connections between other components are shown in thick lines for illustrative purposes only and should not be construed as limiting. Buses can be categorized into address buses, data buses, control buses, etc., but for ease of representation, [the specific bus type is not shown here]. Figure 2 A single thick line is used to represent a processor, but this does not mean there is only one bus or one type of bus. Alternatively, a processor can also be called a controller; there is no restriction on the name.
[0037] In this embodiment, the memory stores instructions executable by the at least one processor. By executing the instructions stored in the memory, the at least one processor performs the method described in Embodiment 1. The processor can implement... Figure 2 The functions of each module in the device shown.
[0038] The processor is the control center of the device. It can connect to various parts of the control device through various interfaces and lines. By running or executing instructions stored in memory and calling data stored in memory, it can monitor the device's various functions and process data, thereby enabling overall monitoring of the device.
[0039] In an alternative design, the processor may include one or more processing units. The processor may integrate an application processor and a modem processor, wherein the application processor primarily handles the operating system, user interface, and applications, while the modem processor primarily handles wireless communication. It is understood that the modem processor may also not be integrated into the processor. In some embodiments, the processor and memory may be implemented on the same chip; in some embodiments, they may also be implemented separately on separate chips.
[0040] The processor can be a general-purpose processor, such as a CPU, digital signal processor, application-specific integrated circuit, field-programmable gate array or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component, capable of implementing or executing the methods, steps, and logic block diagrams disclosed in the embodiments of this invention. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the dual-script dynamic binding and parameterized configuration method for smart meter production testing disclosed in the embodiments of this invention can be directly manifested as execution by a hardware processor, or execution by a combination of hardware and software modules within the processor.
[0041] Memory, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. Memory can include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card-type memory, random access memory (RAM), static random access memory (SRAM), programmable read-only memory (PROM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), magnetic memory, magnetic disk, optical disk, etc. Memory is any other medium capable of carrying or storing desired program code in the form of instructions or data structures, and accessible by a computer, but is not limited thereto. In embodiments of the present invention, memory can also be a circuit or any other device capable of implementing storage functions, used to store program instructions and / or data.
[0042] By designing and programming the processor, the code corresponding to the dual-script dynamic binding and parameterized configuration method for smart meter production testing described in the foregoing embodiments can be embedded into the chip, enabling the chip to execute the steps of the method described in the foregoing embodiments during runtime. How to design and program the processor is a technique well-known to those skilled in the art and will not be elaborated upon here.
[0043] Example 3 Based on Embodiment 1, this embodiment also discloses: a computer-readable storage medium for storing instructions that, when executed, cause the method described in Embodiment 1 to be implemented.
[0044] In some alternative embodiments, the present invention also provides a method for dynamic binding and parameterized configuration of dual scripts for smart meter production testing, which can also be implemented as a program product including program code. When the program product is run on a device, the program code is used to cause the control device to perform the steps in the method for dynamic binding and parameterized configuration of dual scripts for smart meter production testing according to various exemplary embodiments of the present invention as described above.
[0045] It should be noted that although several units or sub-units of the apparatus have been mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, according to embodiments of the invention, the features and functions of two or more units described above can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided and embodied by multiple units. Furthermore, although the operation of the method of the invention is described in a specific order in the drawings, this does not require or imply that these operations must be performed in that specific order, or that all the operations shown must be performed to achieve the desired result. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps.
[0046] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0047] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a server, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0048] Program code for performing the operations of this invention can be written using any combination of one or more programming languages, including object-oriented programming languages such as Java and C++, as well as conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on the user's computing device, partially on the user's device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0049] In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0050] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0051] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0052] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A method for dual-script dynamic binding and parameterized configuration of smart meter production testing, characterized in that, The double-script dynamic binding and parameterized configuration method for the intelligent electric meter production test comprises: According to the preset test guide document, the test items are added to the process in the test order and the process parameters are configured in the process management interface; And when the production test is executed, the following are completed: configuring the execution environment, operating the Python script before operation, executing the communication operation, operating the Python script after operation, and analyzing data, wherein the Python script before operation and the Python script after operation are selected for execution based on the test requirements.
2. The dual script dynamic binding and parameterized configuration method for smart meter production testing of claim 1, wherein, Configuring the execution environment includes: loading configuration and initializing test objects according to test items, and performing pre-test foolproofing checks; Executing the communication operation includes: configuring the same meter or peripheral tooling device communication according to the test object, then preprocessing the data returned by the communication and returning the result; Analyzing data includes: performing final foolproofing processing according to test results, displaying results and refreshing data on the interface, and uploading results to the MES system.
3. The dual script dynamic binding and parameterized configuration method for smart meter production testing of claim 1, wherein, When executing the production test process, if the Python script before operation is included, The Python script before operation includes: using CreateEngine() of IronPython to create a Python engine, and using SetVariable() to pass the test object variable to Python, then executing the Python pre-script and returning the data; the Python script changes the test object configuration parameters according to the project requirements.
4. The dual script dynamic binding and parameterized configuration method for smart meter production testing of claim 1, wherein, When executing the production test process, if the Python script after operation is included, The Python script after operation includes: using IronPython to create a Python engine, and executing the Python post-script to perform final processing and judgment on the test data according to the requirements.
5. The dual script dynamic binding and parameterized configuration method for smart meter production testing of claim 1, wherein, Each test item includes the following contents: test item name, communication protocol, operation type, test item parameter, operation pre-script, and operation post-script.
6. The dual script dynamic binding and parameterized configuration method for smart meter production testing of claim 5, wherein, The test item name is used to identify a unique test item in the corresponding project; the communication protocol is used to determine the protocol type and communication method for communication with the meter / tooling device; the operation type is used to determine what kind of processing operation is performed on the read data, including reading or writing.
7. The dual script dynamic binding and parameterized configuration method for smart meter production testing of claim 5, wherein, The test item parameter includes: meter setting / checking parameter, setting / reading processing scheme, tooling device control parameter, and MES system interaction content.
8. The dual script dynamic binding and parameterized configuration method for smart meter production testing of claim 5, wherein, The operation pre-script is a Python script before meter communication, which is edited according to the requirements to configure and modify the setting / checking parameters according to the conditions, and various methods in the C# source code can be called in the script; The operation post-script is a Python script after meter communication, which is edited according to the requirements to process the data returned after communication, and various methods in the C# source code can be called in the script.
9. An electronic device, comprising: It comprises: At least one processor; And a memory in communication connection with the at least one processor; Wherein the memory stores instructions executable by the at least one processor, and the at least one processor executes the method according to any one of claims 1 to 8 by executing the instructions stored in the memory.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium is configured to store instructions which, when executed, cause the method of any one of claims 1 to 8 to be implemented.