Function test method, system and equipment of intelligent electric meter and medium
By using a tiered testing model and automated tools to automatically generate test cases, the problems of low testing efficiency and insufficient coverage of smart meter data freeze function were solved, achieving efficient and accurate test results and function optimization.
Patent Information
- Application Number
- CN202511714012.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-20
- Publication Date
- 2026-02-17
AI Technical Summary
In existing technologies, the data freeze function of smart meters has low testing efficiency and insufficient coverage. The test cases are not matched with the meters and cannot fully cover boundary and abnormal scenarios, resulting in inaccurate test results.
A layered testing model is adopted to generate test cases for smart meters, including a basic function layer, a boundary exception layer, an interaction layer, and a performance stress layer. External events are simulated through automation tools to automatically generate and execute test cases and generate test results for the data freeze function.
The testing efficiency and coverage of the smart meter data freeze function have been improved, ensuring that test cases cover all functional points, boundary conditions and abnormal scenarios, and achieving accurate test results and functional optimization.
Smart Images

Figure CN121541130A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of automation testing, and in particular to a function testing method, system, device and medium for a smart meter. BACKGROUND
[0002] The smart meter is a basic device of the advanced measurement system of the smart grid, and the data freezing function (such as daily freezing, whole-hour freezing, instantaneous freezing, etc.) of the smart meter is a core function supporting electricity settlement, line loss analysis and load monitoring. Therefore, the accuracy and reliability of the data freezing function are crucial.
[0003] In related technologies, in order to test the data freezing function, the test cases are usually manually generated and tested by the staff according to the test requirements and the configuration of the smart meter. However, the above-mentioned method has low test efficiency and coverage, and there may be a situation that the test cases do not match the smart meter.
[0004] Therefore, how to accurately test the data freezing function of the smart meter and improve the test efficiency and coverage is a technical problem to be solved by the person skilled in the art at present. SUMMARY
[0005] The purpose of the present application is to provide a function testing method, system, device and medium for a smart meter, which can accurately test the data freezing function of the smart meter and improve the test efficiency and coverage.
[0006] To solve the above technical problems, the present application provides a function testing method for a smart meter, comprising:
[0007] determining test requirement information of the smart meter; wherein the test requirement information comprises function points, boundary conditions and abnormal scenes related to the data freezing function;
[0008] establishing a hierarchical test model based on the test requirement information; wherein the hierarchical test model is a model for dividing test levels of the smart meter;
[0009] generating test cases corresponding to each test level according to the hierarchical test model;
[0010] controlling the smart meter to execute the test cases corresponding to each test level in turn, and obtaining actual freezing data generated when the smart meter executes the test cases;
[0011] generating a data freezing function test result of the smart meter based on the actual freezing data.
[0012] Optionally, controlling the smart meter to execute the test cases corresponding to each test level in turn comprises:
[0013] determining a test order of all the test levels;
[0014] selecting a current test level according to the test order;
[0015] concurrently executing all test cases corresponding to the current test level;
[0016] determining whether all the test levels are selected; if not, entering the step of selecting a current test level according to the test order.
[0017] Optionally, generating test cases corresponding to each test level according to the hierarchical test model comprises:
[0018] generating test cases corresponding to a basic function layer, a boundary exception layer, an interaction layer and a performance stress layer respectively according to the hierarchical test model;
[0019] wherein the test cases corresponding to the basic function layer are test cases for verifying the data freeze function under normal state; the test cases corresponding to the boundary exception layer are test cases for verifying the data freeze function under boundary state; the test cases corresponding to the interaction layer are test cases for verifying the influence of interaction events on the data freeze function; and the test cases corresponding to the performance stress layer are test cases for verifying the influence of performance stress on the data freeze function.
[0020] Optionally, in the process of controlling the smart meter to execute test cases corresponding to each test level in turn, the method further comprises:
[0021] determining whether the currently executed test case depends on external events;
[0022] if yes, injecting corresponding external events into the smart meter by using an automation tool.
[0023] Optionally, generating a data freeze function test result of the smart meter based on the actual freeze data comprises:
[0024] comparing the actual freeze data with expected data based on data values, time labels and data formats, and generating the data freeze function test result of the smart meter according to the comparison result;
[0025] correspondingly, the method further comprises:
[0026] determining whether the data freeze function of the smart meter is abnormal according to the data freeze function test result;
[0027] if yes, generating a function optimization scheme according to the data freeze function test result.
[0028] Optionally, the method further comprises:
[0029] reading reference data from the smart meter if the master-backup data storage switching test instruction is received;
[0030] sending a test start instruction to the smart meter through a serial port to make the smart meter enter a test mode and return first response information;
[0031] sending a damage simulation instruction to the smart meter after the first response information is received to make the smart meter mark a master storage block as unusable and return second response information;
[0032] triggering a data storage operation of the smart meter after the second response information is received;
[0033] sending a query instruction to the smart meter to make the smart meter return a storage block currently performing data storage;
[0034] reading data from a backup storage block if the storage block currently performing data storage in the smart meter is the backup storage block;
[0035] determining whether the data in the backup storage block and the storage logic of the reference data are correct; if yes, determining that the master-backup data storage switching function of the smart meter is normal; if no, determining that the master-backup data storage switching function of the smart meter is abnormal.
[0036] determining that the master-backup data storage switching function of the smart meter is abnormal if the storage block currently performing data storage in the smart meter is the master storage block.
[0037] Optionally, determining whether the data in the backup storage block and the storage logic of the reference data are correct comprises:
[0038] determining whether the data in the backup storage block is new data that is incremented on the basis of the reference data;
[0039] if yes, determining that the data in the backup storage block and the storage logic of the reference data are correct;
[0040] if no, determining that the data in the backup storage block and the storage logic of the reference data are incorrect.
[0041] The application further provides a function test system of a smart meter, which comprises:
[0042] a demand determination module configured to determine test demand information of the smart meter; wherein the test demand information comprises function points, boundary conditions and abnormal scenarios related to a data freezing function;
[0043] a hierarchical module, configured to establish a hierarchical test model based on the test requirement information, wherein the hierarchical test model is a model for dividing test levels of the smart meter;
[0044] a use case generation module, configured to generate test cases corresponding to each of the test levels according to the hierarchical test model;
[0045] a test module, configured to control the smart meter to execute the test cases corresponding to each of the test levels in sequence, and acquire actual frozen data generated by the smart meter when executing the test cases;
[0046] a result generation module, configured to generate a data freezing function test result of the smart meter based on the actual frozen data.
[0047] The application further provides a storage medium having a computer program stored thereon, the computer program being configured to implement the steps of the function test method of the smart meter when executed.
[0048] The application further provides an electronic device comprising a memory and a processor, the memory having a computer program stored therein, the processor being configured to implement the steps of the function test method of the smart meter when invoking the computer program in the memory.
[0049] The application discloses a function test method of a smart meter. The method establishes a hierarchical test model according to test requirement information of the smart meter. The hierarchical test model can divide test items into different levels. According to the hierarchical test model, test cases corresponding to each of the test levels can be generated. The above process generates test cases by using the hierarchical test model, so as to ensure that the test cases cover various function points, boundary conditions and abnormal scenarios. After the test cases are generated, the smart meter can be controlled to execute the test cases corresponding to each of the test levels in sequence. According to actual frozen data generated by the smart meter when executing the test cases, a data freezing function test result can be generated. The above process automatically generates and executes the test cases corresponding to the test levels for the smart meter, without human intervention in the generation and execution of the test cases. Therefore, the application can accurately test the data freezing function of the smart meter, and improve test efficiency and coverage. The application further provides a function test system of a smart meter, a storage medium and an electronic device, which have the above beneficial effects, and details are not described herein. BRIEF DESCRIPTION OF DRAWINGS
[0050] In order to more clearly illustrate the embodiments of the application, the drawings needed in the embodiments will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the application, and other drawings can be obtained by those skilled in the art without creative effort.
[0051] Figure 1 A flow chart of a function test method of a smart meter provided by an embodiment of the present application.
[0052] Figure 2 A structural schematic diagram of a function test system of a smart meter provided by an embodiment of the present application. DETAILED DESCRIPTION
[0053] To make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described below in detail with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only some but not all of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present application.
[0054] Please see the following Figure 1 , Figure 1 A flow chart of a function test method of a smart meter provided by an embodiment of the present application.
[0055] The specific steps can include:
[0056] S101: determining test requirement information of a smart meter.
[0057] In the embodiment, the test requirement information can be determined based on a design scheme of the smart meter, and the test requirement information includes function points, boundary conditions and abnormal scenarios related to a data freeze function.
[0058] The function points are various specific functions that the data freeze function should achieve in a normal operation state, for example, freeze triggering of different periods, accurate recording of data, etc.; the boundary conditions are extreme or critical situations of the data freeze function, such as storage fullness, period switching, etc.; and the abnormal scenarios are abnormal scenarios in achieving the data freeze function, such as power failure, communication failure, etc.
[0059] By determining the test requirement information, subsequent tests can be comprehensive and targeted, and the data freeze function of the smart meter can be accurately and comprehensively tested.
[0060] S102: establishing a hierarchical test model based on the test requirement information.
[0061] In the embodiment, the hierarchical test model can be established according to the test requirement information, and the hierarchical test model is a model for dividing test levels of the smart meter.
[0062] The test levels can include a basic function layer, a boundary abnormality layer, an interaction layer and a performance pressure layer.
[0063] The basic function layer is a level for testing normal triggering of the data freezing function and data accuracy; the boundary exception layer is a level for testing behavior under extreme conditions such as critical time and full load storage; the interaction layer is a level for testing the coordination of the data freezing function and events such as time correction, meter reading and power failure; and the performance pressure layer is a level for simulating testing scenarios such as high concurrency and continuous freezing.
[0064] S103: generating a test case corresponding to each test level according to the hierarchical test model;
[0065] According to the hierarchical test model, a test case corresponding to each test level is generated in this step to ensure comprehensive coverage of the data freezing function of the smart meter.
[0066] Each test level has a plurality of corresponding test cases. Specifically, the process of generating a test case corresponding to each test level according to the hierarchical test model includes generating test cases corresponding to the basic function layer, the boundary exception layer, the interaction layer and the performance pressure layer respectively according to the hierarchical test model.
[0067] The test case corresponding to the basic function layer is a test case for verifying the data freezing function under normal conditions.
[0068] The test case corresponding to the boundary exception layer is a test case for verifying the data freezing function under boundary conditions.
[0069] The test case corresponding to the interaction layer is a test case for verifying the influence of interaction events on the data freezing function.
[0070] The test case corresponding to the performance pressure layer is a test case for verifying the influence of performance pressure on the data freezing function.
[0071] S104: controlling the smart meter to sequentially execute the test case corresponding to each test level, and obtaining actual freezing data generated when the smart meter executes the test case.
[0072] In this step, the smart meter can be controlled to sequentially execute the test cases of each test level, and actual freezing data can be obtained during testing. The actual freezing data can include data when a test case is executed, or data when multiple test cases are executed.
[0073] Specifically, the step can control the smart meter to execute the test case corresponding to each test level in turn by: determining a test order of all the test levels; selecting a current test level according to the test order; executing all the test cases corresponding to the current test level in parallel; determining whether all the test levels are selected; if not, proceeding to the step of selecting the current test level according to the test order; and if yes, ending the test process.
[0074] As a feasible implementation, when proceeding to the step of selecting the current test level according to the test order, the original executed test case can be kept to continue execution, or the original executed test case can be controlled to stop execution.
[0075] S105: generating a data freeze function test result of the smart meter based on the actual freeze data.
[0076] After obtaining the actual freeze data, the step can compare the actual freeze data with the expected data item by item, and generate the data freeze function test result of the smart meter according to the comparison result. The data freeze function test result includes a test pass rate, a failed case detail, a defect positioning, a coverage range, and the like.
[0077] The embodiment establishes a hierarchical test model according to the test requirement information of the smart meter. The hierarchical test model can divide the test items into different levels, and the test case corresponding to each test level can be generated according to the hierarchical test model. The above process generates the test case by using the hierarchical test model, and ensures that the test case covers each function point, boundary condition and abnormal scene. After generating the test case, the embodiment can control the smart meter to execute the test case corresponding to each test level in turn, and generate the data freeze function test result based on the actual freeze data generated when the smart meter executes the test case. The above process automatically generates and executes the corresponding test case for the smart meter according to the test level, without human intervention in the generation and execution of the test case. Therefore, the embodiment can accurately test the data freeze function of the smart meter, and improves the test efficiency and coverage.
[0078] As for the Figure 1 Further to the corresponding embodiment, in the process of controlling the smart meter to execute the test case corresponding to each test level in turn, it can also be determined whether the currently executed test case depends on an external event; if yes, an automatic tool is used to inject a corresponding external event into the smart meter; and if not, the test case corresponding to each test level is continuously executed. The above operation can automatically identify the dependence of the test case on the event, and accurately inject external events such as time setting and power failure, so as to ensure the completeness of the test scene and improve the test efficiency and accuracy.
[0079] As for theFigure 1 For further introduction of the corresponding embodiment, the data freeze function test result of the smart meter is generated based on the actual freeze data, which includes: comparing the actual freeze data with the expected data based on data value, time label and data format, and generating the data freeze function test result of the smart meter according to the comparison result.
[0080] After obtaining the data freeze function test result, the embodiment can determine whether the data freeze function of the smart meter is abnormal according to the data freeze function test result; if it is abnormal, a function optimization scheme is generated according to the data freeze function test result.
[0081] As for Figure 1 The corresponding embodiment can also implement white box testing in the following way:
[0082] If the master-slave data storage switching test instruction is received, the reference data is read from the smart meter; the test start instruction is sent to the smart meter through the serial port to make the smart meter enter the test mode and return the first response information; after receiving the first response information, the damage simulation instruction is sent to the smart meter to make the smart meter mark the main storage block as unusable and return the second response information; after receiving the second response information, the data storage operation of the smart meter is triggered; the query instruction is sent to the smart meter to make the smart meter return the storage block currently performing data storage; if the storage block currently performing data storage in the smart meter is the standby storage block, the data in the standby storage block is read; it is determined whether the data in the standby storage block and the storage logic of the reference data are correct; if yes, it is determined that the master-slave data storage switching function of the smart meter is normal; if no, it is determined that the master-slave data storage switching function of the smart meter is abnormal; if the storage block currently performing data storage in the smart meter is the main storage block, it is determined that the master-slave data storage switching function of the smart meter is abnormal.
[0083] Further, whether the data in the standby storage block and the reference data are correct can be determined in the following way in the above process: it is determined whether the data in the standby storage block is new data that is incremented on the basis of the reference data; if yes, it is determined that the data in the standby storage block and the storage logic of the reference data are correct; if no, it is determined that the data in the standby storage block and the storage logic of the reference data are incorrect.
[0084] When a smart meter freezes data, the new data should increment based on the previous data. In this embodiment, the presence of a storage logic error is determined by whether there is an incrementing relationship between the data in the backup storage block and the baseline data. This process ensures the continuity and accuracy of data during primary / backup storage switching, preventing data loss or errors, thereby guaranteeing the reliability of the smart meter and the accuracy of billing.
[0085] The process described in the above embodiments is illustrated below through examples in practical applications.
[0086] Current black-box testing methods have the following shortcomings:
[0087] 1. Traditional manual testing is inefficient: it relies heavily on the experience of testers, and the execution, recording, and comparison of test cases are time-consuming and labor-intensive.
[0088] 2. Insufficient test case coverage: Existing test cases are often fragmented and general, and cannot cover all boundary and abnormal scenarios in a specific meter design scheme (e.g., power outage at a specific time, communication interruption and concurrent freezing commands, etc.).
[0089] 3. Low coupling between test cases and design: There is no "tailor-made" testing for the specific design of the internal storage architecture, event triggering mechanism, communication module, etc. of the electricity meter, which makes it impossible to discover some deep-seated logical defects.
[0090] 4. Lack of systematic approach: The testing process, test case management, and result analysis do not form an automated closed loop, resulting in poor repeatability and traceability.
[0091] Furthermore, current automated testing is limited to functional verification through business interfaces (such as DL645 or DL698.45 protocols), which cannot simulate internal abnormal states or directly query internal states. This results in insufficient test coverage of deep functions such as data backup and fault recovery, and a heavy reliance on white-box testing and manual intervention.
[0092] To address the technical problems existing in the aforementioned related technologies, this embodiment provides a smart meter freeze function verification scheme based on test modes. This scheme pre-configures test modes in the meter firmware and interacts with an external test system through a dedicated test instruction set, thereby simulating abnormal internal states of the meter and querying its deeper states, ultimately achieving comprehensive and automated reliability verification.
[0093] The black-box automation process based on the layered testing model provided in this solution includes the following steps:
[0094] Step A1: Test requirements analysis and modeling.
[0095] Based on the design scheme of the electricity meter (especially the freezing logic, storage mapping relationship, clock synchronization mechanism, and event triggering logic), extract all functional points, boundary conditions, and abnormal scenarios related to data freezing.
[0096] A tiered testing model is established based on the extracted functional points, boundary conditions, and abnormal scenarios related to data freezing.
[0097] The layered testing model includes: basic function layer (normal freeze timing, data correctness), boundary anomaly layer (critical moment, full load storage), communication and event interaction layer (interaction with meter reading, time synchronization, power failure events), and performance stress layer (continuous multiple freezes, high communication concurrency).
[0098] Step A2: In the test case generation phase, design specific test cases for each layer based on the layered test model.
[0099] The test cases corresponding to the basic functional layer serve the following purposes: For various types of freezes, different freeze periods can be set. Test cases are designed to traverse the freeze periods, verifying the timing of freezes, the correctness of data, and the recursion of freeze records. Considering the special characteristics of IoT meters, freeze test cases are designed to verify the consistency of freezes between the metering module and the management module. The impact of basic influencing factors such as time modification, zeroing, and modification of frozen associated objects on the freeze function is verified to ensure the completeness of the freeze function. If there is a backup design for freeze records, the storage mechanism of the current and backup copies of the freeze records, as well as the mechanism for enabling backups, are verified.
[0100] The test cases for the boundary anomaly layer (critical moment, extreme case, full load storage) serve the following purposes: For different types of freezing, there are different freezing depths, and the design uses a circular queue to store frozen data; test cases are designed to verify the coverage strategy after the queue is full; freezing data is triggered under critical conditions; for different types of freezing, there are different freezing periods, and different freezing period boundary values are input to trigger freezing.
[0101] The test cases for the communication and event interaction layer (interaction with meter reading, time synchronization, and power outage events) serve the following purposes: For the design of freezing records triggered by the clock, design freezing commands before and after clock synchronization to verify logical conflicts; for the frozen records supporting multiple reading methods, design a method for traversing and reading; for the relationship between power outage and freezing, design freezing to be triggered at the moment of power outage to verify the freezing logic.
[0102] The test cases for the performance stress layer (continuous multiple freezes, high communication concurrency) serve the following purposes: Set all freeze triggers to the same time point to perform multiple types of freezes simultaneously; under stable power conditions, conduct concurrent testing of reading freeze records using the meter's multi-channel ports; conduct concurrent testing of reading freeze records before and after power outages and power-on; trigger freezes under various boundary conditions, such as at midnight when the meter is already at full load, to verify the reliability of the freeze function; generate freeze data when multiple channels communicate simultaneously.
[0103] This embodiment can parameterize and script the above test cases to form a test case library that can be automatically called by the test system.
[0104] Step A3: Automated test cases.
[0105] Specifically, this step involves configuring the test environment (such as connecting the electricity meter, control console, clock server, etc.) and scheduling concurrent execution of the test case scripts generated in step A2. During execution, automation tools simulate various external events: such as precisely controlling the on / off state of the control console to simulate a power outage, modifying the electricity meter time and freezing related parameters through software commands, etc.
[0106] Step A4: Automatic collection and judgment of test results.
[0107] This step automatically collects actual frozen data from the electricity meter (via a communication interface such as RS-485, infrared, Bluetooth, etc.); it then automatically compares the collected actual data with the expected results (pre-calculated correct values based on test case inputs and the meter's design logic). The comparison process can compare data values, as well as the time stamp and data format. Based on the comparison results, a structured test report is automatically generated, marking pass / fail test cases and recording the actual and expected values at the time of failure.
[0108] The test cases using a circular queue structure for storing frozen data from electricity meters illustrate the aforementioned black-box automation process based on a hierarchical testing model. The purpose of this test is to verify whether new frozen data can correctly overwrite the oldest data once the queue is full.
[0109] The test steps include: automatically modifying the meter time and triggering a number of times far exceeding the queue capacity (e.g., 120 freezes if the queue depth is 100); the automated tool accurately records the expected data for the 101st to 120th freezes; reading all frozen data in the meter queue through the communication interface; and the result comparison module verifying whether the data stored in the queue is the frozen data for the 21st to 120th freezes, rather than the data for the 1st to 100th freezes.
[0110] The expected result of this test is that the 20 oldest data entries in the meter are overwritten, and the latest 100 data entries are stored.
[0111] An example illustrating the stress test process involving multiple types of freeze triggering at the same time point under extreme operating conditions:
[0112] Automated tools automatically apply voltage and current via a programmable power supply.
[0113] Parameter settings for automated scripts.
[0114] For example, the parameters include: daily freeze (departs at 0:00 every day), hourly freeze (triggered on the hour), monthly freeze (triggered at 0:00 on the 1st of each month), hourly freeze (triggered every hour), minute freeze (triggered every 15 minutes), switch freeze (switches the time to execution), and settlement day freeze (execution from the settlement day).
[0115] Switchover freeze can be set to switchover time as 2025-10-01 00:00; settlement date freeze can be set to settlement date as 00:00 on the 1st.
[0116] The automated script synchronizes with a clock server, precisely controls the meter time, and waits for a specific moment. For example, it sets the meter time to 2025-09-30 23:59:50 and automatically delays by 10 seconds.
[0117] The process for verifying the accuracy of battery freeze can be as follows: an automated script automatically reads the frozen battery level and the current battery level via a Bluetooth interface.
[0118] The automatic comparison logic does not simply determine whether the two are equal. Instead, it determines whether the frozen power is between the current power read in the previous 5 seconds and the current power read in the next 5 seconds, based on the power pulse constant and the freezing mechanism, thereby verifying that it is indeed the instantaneous value at 00:00:00.
[0119] The simultaneous multi-type freeze verification logic is as follows: An automated script automatically reads and collects the freeze time and frozen battery level from each freeze data point via Bluetooth to form a comparison information table and checks data consistency. The columns of the comparison information table include: daily freeze, monthly freeze, hourly freeze, minute freeze, time zone table switch freeze, time period table switch freeze, and settlement day freeze. The rows of the comparison information table include: battery level before freeze, battery level after freeze, freeze time, battery level of the frozen data, expected freeze time, and expected battery level of the frozen data.
[0120] The report generated based on the above information includes: test items, problem descriptions, expected values, measured values, test results, and problem levels.
[0121] This solution also offers customized testing solutions for white-box testing (taking primary / standby data storage switching reliability testing as an example).
[0122] Daily frozen data is stored in two physical blocks of Flash memory: Block 0 (primary storage block) and Block 1 (standby storage block). The question is whether, in the event of a failure in primary storage block Block 0, the meter can automatically and correctly switch minute-by-minute frozen data to standby storage block Block 1, ensuring data continuity and accuracy without any disruption to the service.
[0123] The purpose of this test is to verify whether the meter can correctly switch to the backup storage area when a simulated fault occurs in the primary storage area, and whether the current function is unaffected.
[0124] The prerequisite for testing in this embodiment is that the meter under test must be running firmware that supports the "test interface".
[0125] The test mode instructions in this embodiment are designed as follows:
[0126] AT+TESTMODE=ON / / The first command (i.e., the test start command) is used to control the smart meter to enter test mode; if the reply is OK, it means the command was executed successfully; if the reply is FAIL, it means the command was executed unsuccessfully.
[0127] AT+FLASHSIM=MAIN,BAD / / The second command (i.e., the damage simulation command) is used to control the smart meter to simulate damage to the main storage area; if the reply is OK, it means the command was executed successfully; if the reply is FAIL, it means the command was executed unsuccessfully.
[0128] AT+GETACTIVEBLOCK / / The third command (i.e., the query command) is used to control the smart meter to query the currently active storage block; if the reply is ACTIVE_BLOCK= MAIN, it means that the currently used storage area is the primary storage area; if the reply is ACTIVE_BLOCK= SECONDARY, it means that the currently used storage area is the secondary storage area.
[0129] AT+TESTMODE=OFF / / Fourth command, used to control the smart meter to exit test mode; if OK is returned, the command was executed successfully; if FAIL is returned, the command failed.
[0130] The process of automating the reliability testing of primary / standby data storage switching is as follows:
[0131] Step B1: The test system reads the current data through the regular business interface and records it as baseline data. This process confirms the initial state.
[0132] Step B2: The test system sends AT+TESTMODE=ON via serial port, and the meter replies OK (i.e., the first response message).
[0133] The above operations can be used to achieve fault injection.
[0134] The test system sends AT+FLASHSIM=MAIN,BAD, and the meter internally marks the main storage block as unavailable and replies with OK (second response message).
[0135] Step B3: Test the system to wait for or actively trigger a new data operation.
[0136] The above steps can be used to trigger business operations.
[0137] Step B4: The test system sends AT+GETACTIVEBLOCK to query via the test interface.
[0138] The meter responds with ACTIVE_BLOCK=SECONDARY, confirming that it has switched to the standby storage area. ACTIVE_BLOCK=SECONDARY indicates that the currently used storage area is the standby storage area. This operation allows for behavioral observation.
[0139] Step B5: The test system reads data again through the regular business interface.
[0140] The above operations can be used to verify data consistency.
[0141] Step B6: The system automatically compares the logical correctness of the data read in step B5 with the baseline data (e.g., the new data should be incremented based on the old data).
[0142] The above operations can be used to compare the results.
[0143] Step B7: The test system sends AT+TESTMODE=OFF through the dedicated test interface to exit test mode and end the test. AT+TESTMODE=OFF represents the command used to control the smart meter to exit test mode. The above operations can achieve state restoration and cleanup.
[0144] If the data before the test is as follows: the current cumulative electricity consumption of the meter is 500.25 kWh; the main storage block (Block 0) is available; the most recent frozen data in the meter is: serial number 5, time 2025-07-19 11:00, electricity consumption is 490.00 kWh.
[0145] The steps for using an automated test script are as follows:
[0146] Step C1: Initial state confirmation.
[0147] The action performed was as follows: the test system sent a command to read the frozen minute data via the host computer.
[0148] The meter returned DATA (2025-07-19 11:00, 490.00kWh).
[0149] The test system records this data as baseline data. The currently active block should be PRIMARY (i.e., Block 0), but this is usually not readable through the business interface and needs to be confirmed through subsequent test commands.
[0150] Step C2: Inject fault.
[0151] The action performed is as follows: the test system sends the test command AT+TESTMODE=ON via the serial port.
[0152] The meter responded "OK," indicating that it has entered test mode and the firmware has begun accepting simulated fault commands.
[0153] The action performed is: the test system sends AT+FLASHSIM=MAIN,BAD.
[0154] The meter returned OK, which means that the firmware internally marked the main storage block (Block 0) as "damaged".
[0155] Step C3: Trigger business operations.
[0156] The action performed is as follows: the test system waits until the next minute freeze point (e.g., 11:15), or triggers a power data update through other business instructions, thereby naturally generating a minute freeze data write operation.
[0157] Step C4: Observe the behavior.
[0158] The action performed is as follows: The test system sends AT+GETACTIVEBLOCK through the test interface.
[0159] If the meter responds with ACTIVE_BLOCK=SECONDARY, it means that the system has successfully switched to the standby storage block.
[0160] Step C5: Verify data consistency.
[0161] The action performed was as follows: the test system sent the command to read the frozen minute data again through the host computer.
[0162] If the meter replies with DATA(2025-07-19 11:00, 490.00kWh) and DATA(2025-07-19 11:15,500.25kWh), it means that the newly generated minute-freeze data was successfully read.
[0163] Step C6: Result comparison.
[0164] Expected behavior 1: The data read should contain one more new record than the baseline data.
[0165] Expected behavior 2: The energy value (500.25kWh) of the new record (2025-07-19 11:15) should be equal to the current energy value at the time the business operation is triggered.
[0166] Actual result: The new data DATA (2025-07-19 11:15 500.25kWh) was successfully read and the value is correct, so the comparison is successful.
[0167] Step C7: Clean up and restore.
[0168] The testing system sends AT+TESTMODE=OFF through the test interface. If the meter replies "OK", it means the test mode has been exited.
[0169] If the test result is satisfactory, it indicates that the primary / backup storage switching mechanism of the meter firmware is working properly. In a scenario simulating a primary storage block failure, the system can automatically and seamlessly switch to the backup block, ensuring the continuity and consistency of business data, which meets design expectations.
[0170] Please see Figure 2 , Figure 2 This is a schematic diagram of the structure of a functional testing system for a smart meter provided in an embodiment of this application. The functional testing system includes:
[0171] The requirement determination module is used to determine the test requirement information of the smart meter; wherein, the test requirement information includes the functional points, boundary conditions and abnormal scenarios related to the data freeze function;
[0172] A hierarchical module is used to establish a hierarchical test model based on the test requirement information; wherein, the hierarchical test model is a model used to divide the test levels of the smart meter;
[0173] The test case generation module is used to generate test cases corresponding to each test level according to the layered test model.
[0174] The testing module is used to control the smart meter to execute the test cases corresponding to each test level in sequence, and to obtain the actual frozen data generated when the smart meter executes the test cases;
[0175] The result generation module is used to generate the data freezing function test results of the smart meter based on the actual frozen data.
[0176] This embodiment establishes a hierarchical testing model based on the testing requirements of smart meters. The hierarchical testing model divides test items into different levels, and test cases corresponding to each test level can be generated based on the model. This process utilizes the hierarchical testing model to generate test cases, ensuring that the test cases cover all functional points, boundary conditions, and abnormal scenarios. After generating the test cases, this embodiment can control the smart meter to sequentially execute the test cases corresponding to each test level, and generate data freezing function test results based on the actual frozen data generated when the smart meter executes the test cases. The above process automatically generates and executes corresponding test cases for the smart meter according to the test levels, without requiring manual intervention in test case generation and execution. Therefore, this embodiment can accurately test the data freezing function of smart meters, improving testing efficiency and coverage.
[0177] Furthermore, the process by which the test module controls the smart meter to sequentially execute the test cases corresponding to each test level includes: determining the test order of all test levels; selecting the current test level according to the test order; concurrently executing all test cases corresponding to the current test level; determining whether all test levels have been selected; if not, proceeding to the step of selecting the current test level according to the test order.
[0178] Furthermore, the process by which the test case generation module generates test cases corresponding to each test level according to the layered testing model includes: generating test cases corresponding to the basic functionality layer, boundary exception layer, interaction layer, and performance stress layer respectively according to the layered testing model; wherein, the test cases corresponding to the basic functionality layer are test cases used to verify the data freezing function under normal conditions; the test cases corresponding to the boundary exception layer are test cases used to verify the data freezing function under boundary conditions; the test cases corresponding to the interaction layer are test cases used to verify the impact of interaction events on the data freezing function; and the test cases corresponding to the performance stress layer are test cases used to verify the impact of performance stress on the data freezing function.
[0179] Furthermore, it also includes:
[0180] The judgment module is used to determine whether the currently executed test case depends on an external event during the process of controlling the smart meter to execute the test cases corresponding to each test level in sequence; if so, it uses an automated tool to inject the corresponding external event into the smart meter.
[0181] Furthermore, the process by which the result generation module generates the data freezing function test result of the smart meter based on the actual frozen data includes: comparing the actual frozen data with the expected data based on the data value, time tag and data format, and generating the data freezing function test result of the smart meter based on the comparison result;
[0182] Furthermore, it also includes:
[0183] The optimization module is used to determine whether the data freezing function of the smart meter is abnormal based on the test results of the data freezing function; if so, it generates a function optimization plan based on the test results of the data freezing function.
[0184] Furthermore, it also includes:
[0185] The white-box testing module is used to read baseline data from the smart meter if a primary / backup data storage switchover test command is received; it is also used to send a test start command to the smart meter via a serial port to cause the smart meter to enter test mode and return a first response message; it is also used to send a damage simulation command to the smart meter after receiving the first response message to cause the smart meter to mark the primary storage block as unavailable and return a second response message; it is also used to trigger the data storage operation of the smart meter after receiving the second response message; and it is also used to send a query command to the smart meter to cause the smart meter to return... The system is configured to: retrieve the storage block currently storing data; read data from the backup storage block if the storage block currently storing data in the smart meter is a backup storage block; determine whether the storage logic of the data in the backup storage block is correct with the reference data; if yes, determine that the primary / backup data storage switching function of the smart meter is normal; if no, determine that the primary / backup data storage switching function of the smart meter is abnormal; and determine that the primary / backup data storage switching function of the smart meter is abnormal if the storage block currently storing data in the smart meter is the primary storage block.
[0186] Furthermore, the process by which the white-box testing module determines whether the storage logic of the data in the backup storage block is correct compared to the baseline data includes: determining whether the data in the backup storage block is new data added on top of the baseline data; if yes, then the storage logic of the data in the backup storage block is correct compared to the baseline data; if no, then the storage logic of the data in the backup storage block is incorrect compared to the baseline data.
[0187] Since the embodiments of the system part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the system part, and they will not be repeated here.
[0188] This application also provides a storage medium on which a computer program is stored, which, when executed, can perform the steps provided in the above embodiments. The storage medium may include various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0189] This application also provides an electronic device that may include a memory and a processor. The memory stores a computer program, and when the processor calls the computer program in the memory, it can implement the steps provided in the above embodiments. Of course, the electronic device may also include various network interfaces, power supplies, and other components.
[0190] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the systems disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple; relevant parts can be referred to the method section. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from the principles of this application, and these improvements and modifications also fall within the protection scope of this application.
[0191] It should also be noted that, in this specification, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
Claims
1. A method for testing the function of a smart meter, characterized in that, include: Determine the testing requirements for smart meters; wherein, the testing requirements include functional points, boundary conditions, and abnormal scenarios related to the data freeze function; A hierarchical test model is established based on the aforementioned test requirements information; wherein, the hierarchical test model is a model used to divide the test levels of the smart meter; Generate test cases corresponding to each test level based on the hierarchical test model; The system controls the smart meter to sequentially execute the test cases corresponding to each test level, and obtains the actual frozen data generated when the smart meter executes the test cases; The test results of the data freezing function of the smart meter are generated based on the actual frozen data.
2. The functional testing method for a smart meter according to claim 1, characterized in that, Controlling the smart meter to sequentially execute the test cases corresponding to each of the test levels includes: Determine the test order for all the aforementioned test levels; Select the current test level according to the test order described above; Execute all test cases corresponding to the current test level concurrently; Determine whether all test levels have been selected; if not, proceed to the step of selecting the current test level according to the test order.
3. The functional testing method for a smart meter according to claim 1, characterized in that, Based on the hierarchical testing model, test cases are generated for each test level, including: Based on the layered testing model, test cases are generated for the basic functional layer, boundary exception layer, interaction layer, and performance stress layer, respectively. Specifically, the test cases corresponding to the basic functional layer are test cases used to verify the data freezing function under normal conditions; the test cases corresponding to the boundary exception layer are test cases used to verify the data freezing function under boundary conditions; the test cases corresponding to the interaction layer are test cases used to verify the impact of interaction events on the data freezing function; and the test cases corresponding to the performance stress layer are test cases used to verify the impact of performance stress on the data freezing function.
4. The functional testing method for a smart meter according to claim 1, characterized in that, The process of controlling the smart meter to sequentially execute the test cases corresponding to each test level also includes: Determine whether the currently executing test case depends on external events; If so, then use automated tools to inject the corresponding external event into the smart meter.
5. The functional testing method for a smart meter according to claim 1, characterized in that, The test results of the smart meter's data freezing function are generated based on the actual frozen data, including: The actual frozen data is compared with the expected data based on the data value, time tag and data format, and the data freezing function test result of the smart meter is generated according to the comparison result. Correspondingly, it also includes: Determine whether the data freeze function of the smart meter is abnormal based on the test results of the data freeze function. If so, a functional optimization plan will be generated based on the data freeze function test results.
6. The functional testing method for a smart meter according to claim 1, characterized in that, Also includes: If a primary / backup data storage switching test command is received, reference data is read from the smart meter; A test start command is sent to the smart meter via serial port, so that the smart meter enters test mode and returns the first response information; After receiving the first response information, a damage simulation command is sent to the smart meter so that the smart meter marks the main storage block as unavailable and returns the second response information; Upon receiving the second response information, the data storage operation of the smart meter is triggered; Send a query command to the smart meter so that the smart meter returns the storage block where data is currently being stored; If the storage block currently used for data storage in the smart meter is a spare storage block, then data is read from the spare storage block; Determine whether the storage logic of the data in the backup storage block is correct compared with that of the reference data; If so, the main / backup data storage switching function of the smart meter is determined to be normal; If not, it is determined that the main and backup data storage switching function of the smart meter is abnormal; If the storage block currently storing data in the smart meter is the main storage block, then the main / backup data storage switching function of the smart meter is determined to be abnormal.
7. The functional testing method for a smart meter according to claim 6, characterized in that, Determining whether the storage logic of the data in the spare storage block is correct compared to the reference data includes: Determine whether the data in the backup storage block is new data incremented based on the baseline data; If so, then the storage logic of the data in the backup storage block is determined to be correct with that of the reference data; If not, then it is determined that the data in the backup storage block has a storage logic error with the reference data.
8. A functional testing system for a smart meter, characterized in that, include: The requirement determination module is used to determine the test requirement information of the smart meter; wherein, the test requirement information includes the functional points, boundary conditions and abnormal scenarios related to the data freeze function; A hierarchical module is used to establish a hierarchical test model based on the test requirement information; wherein, the hierarchical test model is a model used to divide the test levels of the smart meter; The test case generation module is used to generate test cases corresponding to each test level according to the layered test model. The testing module is used to control the smart meter to execute the test cases corresponding to each test level in sequence, and to obtain the actual frozen data generated when the smart meter executes the test cases; The result generation module is used to generate the data freezing function test results of the smart meter based on the actual frozen data.
9. An electronic device, characterized in that, The device includes a memory and a processor, wherein the memory stores a computer program, and the processor invokes the computer program in the memory to implement the steps of the functional testing method for the smart meter as described in any one of claims 1 to 7.
10. A storage medium, characterized in that, The storage medium stores computer-executable instructions, which, when loaded and executed by a processor, implement the steps of the functional testing method for a smart meter as described in any one of claims 1 to 7.