Disclosure of Invention
In view of the above, it is necessary to provide a method and an apparatus for testing an electrical measuring instrument, a computer device and a storage medium, which can improve the testing efficiency.
A method of testing an electrical measuring instrument, the method comprising:
acquiring a use case scheme of each function in a detection project, wherein the use case scheme comprises a plurality of scheme types; the scheme type is generated by adding control codes, and each control code corresponds to an operation program of the electric measuring instrument;
executing the operation program of the electric measuring instrument of the scheme type and saving the execution data;
and obtaining a function test result of the electric measuring instrument according to the execution data.
In one embodiment, the test item supports the functionality of replication as another test item; and/or the use case scenario supports replication as a scenario type for another use case scenario.
In one embodiment, the scheme types include a start loop scheme and an end loop scheme; wherein the start loop scheme is set before the scheme type or use case scheme of the start loop, the end loop scheme is set after the scheme type or use case scheme of the end loop, and the parameter of the start loop scheme includes the loop number.
In one embodiment, the functions, use case scenarios, and scenario types support add, delete, modify, and query operations.
In one embodiment, the scheme type includes one or more of a table body operation scheme, a serial port operation scheme, a meter reading and writing communication scheme, a delay scheme, a prompt scheme, a starting loop scheme, an ending loop scheme, a data comparison scheme and a variable value saving file scheme.
In one embodiment, before acquiring a use case scenario for each function in a detection item, where the use case scenario includes multiple scenario types, the method includes: when the use case scheme or the scheme type is added to the detection item in a copy mode, judging whether a variable in the use case scheme or the scheme type exists in the detection item; and if the variable in the use case scheme or the scheme type does not exist in the detection item, acquiring the variable definition of the variable in the use case scheme or the scheme type.
In one embodiment, the executing the operating program of the electrical measuring instrument of the scheme type and saving the execution data comprises: and acquiring the selected scheme type in the use case scheme, executing the operation program of the electric measuring instrument of the scheme type, and storing the execution data.
A test apparatus for an electrical measuring instrument, the apparatus comprising:
the system comprises a use case scheme acquisition module, a detection item detection module and a processing module, wherein the use case scheme acquisition module is used for acquiring a use case scheme of each function in the detection item, and the use case scheme comprises a plurality of scheme types; the scheme type is generated by adding control codes, and each control code corresponds to an operation program of the electric measuring instrument;
the execution module is used for executing the operation program of the electric measuring instrument of the scheme type and storing the execution data;
and the functional test result acquisition module is used for acquiring a functional test result of the electrical measuring instrument according to the execution data.
A computer device comprising a memory and a processor, the memory storing a computer program, the processor implementing the following steps when executing the computer program:
acquiring a use case scheme of each function in a detection project, wherein the use case scheme comprises a plurality of scheme types; the scheme type is generated by adding control codes, and each control code corresponds to an operation program of the electric measuring instrument;
executing the operation program of the electric measuring instrument of the scheme type and saving the execution data;
and obtaining a function test result of the electric measuring instrument according to the execution data.
A computer-readable storage medium, on which a computer program is stored which, when executed by a processor, carries out the steps of:
acquiring a use case scheme of each function in a detection project, wherein the use case scheme comprises a plurality of scheme types; the scheme type is generated by adding control codes, and each control code corresponds to an operation program of the electric measuring instrument;
executing the operation program of the electric measuring instrument of the scheme type and saving the execution data;
and obtaining a function test result of the electric measuring instrument according to the execution data.
According to the method, the device, the computer equipment and the storage medium for testing the electric measuring instrument, the scheme type is generated by writing the operation program of the electric measuring instrument in advance and adding the control code, then the case scheme is generated according to a plurality of scheme types, each function in the detection project is generated, then the function test is performed on the electric measuring instrument by executing the operation program of the electric measuring instrument of the scheme type, and through the editing tool generated by the scheme, the test function coverage rate is improved, the test level is inherited, and the test efficiency is improved.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
In one embodiment, as shown in FIG. 1, there is provided a method of testing an electrical measuring instrument, comprising the steps of:
s110, acquiring a use case scheme of each function in the detection project, wherein the use case scheme comprises a plurality of scheme types; the scheme type is generated by adding control codes, and each control code corresponds to an operation program of the electric measuring instrument.
The detection project is a project for testing and establishing the electric measuring instrument, and comprises the detection of a plurality of functions, each function has a corresponding use case scheme, one function can be detected through one or more use case schemes, for example, the function is to read the number of times of short power failure of the electric measuring instrument, the scheme detail of the use case scheme can be edited, a plurality of control code generation scheme types are added, the plurality of scheme types form the use case scheme, as shown in fig. 2, the scheme detail of the use case scheme of the function for reading the number of times of short power failure of the electric measuring instrument comprises a plurality of added control codes (C4, EN, W2 … … JSXH), and each control code corresponds to an operation program of the electric measuring instrument (for example, the baud rate is converted, the 485 communication handshake RQ, the setting of the capture item is 16 pieces … …, and the delay is 10s or the end of the cycle). And the scheme type is expressed by adopting a data format JSON.
Firstly, different detection items are defined according to test requirements, such as a single-phase intelligent meter and a three-phase intelligent meter, and the detection items are represented by a tree structure. And defining various detection functions in the detection items, and finally adding a use case scheme to the detection functions, wherein the specific functions are verified through the use case scheme.
Wherein the electrical measuring instrument can communicate through DLMS/COSEM protocol.
And S120, executing the operation program of the electric measuring instrument of the scheme type, and storing the execution data.
The scheme type comprises one or more of a table body operation scheme, a serial port operation scheme, a meter reading and writing communication scheme, a delay scheme, a prompt scheme, a cycle starting scheme, a cycle ending scheme, a data comparison scheme and a variable value storage file scheme. Each scheme type can be generated by adding one or more control codes, for example, the operation scheme of the platform body is generated by adding the control codes corresponding to power-on, power-off, standard meter information reading (voltage, current, total power, power factor, voltage and current included angle, and the like), electric energy reading error and reading date timing error. The performance data is data obtained for a test procedure of the electrical measuring instrument, for example, the performance data is the number of short power outages of the electrical measuring instrument, or the performance data is a reading of the electrical measuring instrument.
And S130, obtaining a function test result of the electric measuring instrument according to the execution data.
After the execution data is obtained, the performance of the electric measuring instrument is analyzed, and a function test result of the electric measuring instrument is obtained.
According to the test method of the electric measuring instrument, the scheme type is generated by writing the operation program of the electric measuring instrument in advance and adding the control code, then the case scheme is generated according to a plurality of scheme types, each function in the detection project is generated, then the function test is carried out on the electric measuring instrument by executing the operation program of the electric measuring instrument of the scheme type, and the editing tool generated by the scheme improves the coverage rate of the test function, enables the test level to be inherited and improves the test efficiency.
In one embodiment, step S110 is preceded by: and S100, adding a plurality of scheme types in the case scheme writing module to generate the case scheme.
In one embodiment, the test item supports the functionality of replication as another test item; and/or the use case scenario supports replication as a scenario type for another use case scenario.
The edited detection item can be copied and pasted to another detection item, and the edited detection item can be reused as a function of another detection item, so that the time for a tester to edit the detection item is reduced. Similarly, the edited use case scheme can be copied and pasted to another use case scheme, and as a scheme type of another use case scheme, the time for the tester to edit the use case scheme can also be reduced.
In one embodiment, the scheme types include a start loop scheme and an end loop scheme; wherein the start loop scheme is set before the scheme type or use case scheme of the start loop, the end loop scheme is set after the scheme type or use case scheme of the end loop, and the parameter of the start loop scheme includes the loop number.
Wherein the start loop scheme is used to define a position for starting a loop and the end loop scheme is used to define a position for ending a loop. By starting the loop plan and ending the loop plan, the use case plan composed of the plan type can be repeatedly tested, and the function composed of the use case plan can also be repeatedly tested.
In one embodiment, the functions, use case scenarios, and scenario types support add, delete, modify, and query operations. For example, as shown in fig. 2, the control code in the scheme type of the use-case scheme may be added, modified, deleted, and refreshed, and by selecting a scheme detail, the addition, modification, deletion, and refresh may be implemented by selecting the corresponding control.
In one embodiment, the function, use case scheme, and scheme type support import and export operations in an editing tool generated by the scheme. The information in the editing tool adopts a Json format, so that the editing tool is simple and easy to understand, complicated protocol understanding is removed, partial functions can be shared by a plurality of systems, and protocols are not distinguished. An editing interface of various scheme types is provided in the editing tool and is used for generating specific scheme types. And providing a variable definition function in the editing tool for storing and comparing data in the case scheme.
In one embodiment, the scheme type includes one or more of a table body operation scheme, a serial port operation scheme, a meter reading and writing communication scheme, a delay scheme, a prompt scheme, a starting loop scheme, an ending loop scheme, a data comparison scheme and a variable value saving file scheme.
The serial port operation scheme comprises switching of serial port operation parameter baud rate, a verification mode, data bits and the like, the meter communication read-write scheme comprises 485 communication handshake, infrared communication handshake, read parameters and write parameters, the scheme content is expressed by adopting a general data format JSON, and a use case writer can write the use case scheme only by adjusting JSON attribute content. The data alignment scheme supports single and multiple alignments; each scheme in the multiple alignments only supports the relation of AND OR OR; the comparison types include a comparison range, a comparison equality and a comparison-only, the comparison-only is to calculate the filled formula and store the result in one variable (for example, to store the value corresponding to the variable I in the formula plus 1 in the variable TMP), the comparison range judges whether the value in the formula is within a set range (for example, judges whether the value corresponding to the variable T1 in the formula is within the range of the maximum value and the minimum value, where the maximum value and the minimum value are to obtain specific values by replacing the variables with corresponding values and calculating the specific values through the formula), and the comparison-equal judges whether the values on both sides of the formula are equal (for example, the formula in the scheme is [ a1] = [ B1] +1, the comparison type is the comparison equal, that is the value corresponding to the left variable a1 of the comparison equal sign, and the value corresponding to the right variable B1 of the equal sign is added with 1 or not equal); the comparison mode comprises character string type comparison, shaping data comparison, floating point type comparison and time type comparison, wherein the floating point type comparison supports selection of 1-6 bit decimal numbers; the filled formula is processed before comparison, firstly, the variable name in the formula is replaced by a specific value, then, a formula calculation function of the system is called to carry out formula calculation, the formula calculation function supports the basic addition, subtraction, multiplication and division, and also supports the mathematical functions of square, root, sin, cos, tan and the like, required comparison data are filled in a database comparison interface, and the system can generate a data comparison scheme in a JSON format.
In one embodiment, before acquiring a use case scenario for each function in a detection item, where the use case scenario includes multiple scenario types, the method includes: when the use case scheme or the scheme type is added to the detection item in a copy mode, judging whether a variable in the use case scheme or the scheme type exists in the detection item; and if the variable in the use case scheme or the scheme type does not exist in the detection item, acquiring the variable definition of the variable in the use case scheme or the scheme type.
When the use case scheme or the scheme type is integrally copied and added to the detection project, variables in the use case scheme or the scheme type may not be defined, and the undefined variables need to be defined before the detection project is run. Variables used in the case scheme need to be defined firstly and then can be used, the variable types comprise character strings, DateTime, Date, Time, Yeast, Month, Day, Hour, Minute, Second and Array, the numerical groups in the embodiment are all two-dimensional numerical groups, the defined variable use range is the case scheme, and the variables can only start with letters and consist of letters, numbers and underlines.
In one embodiment, the executing the operating program of the electrical measuring instrument of the scheme type and saving the execution data comprises: and acquiring the selected scheme type in the use case scheme, executing the operation program of the electric measuring instrument of the scheme type, and storing the execution data. In the embodiment, only the selected scheme type can be executed, and partial function test of the electric measuring instrument is realized.
For example, the selection scheme supports shift or ctrl shortcut multiple selection modes. The embodiment supports debugging of a table body scheme and debugging of a meter scheme.
In one specific embodiment, as shown in fig. 3, a method of testing an electrical measuring instrument includes:
a1, configuring parameters; the parameter configuration comprises the configuration of the type of the table body, the communication port of the meter and the specification parameters of the product.
a2, judging parameters, specifically judging whether the table type, the table communication port, the meter communication port and the product specification parameters are qualified. The qualified product enters a3, and the unqualified product enters a 12.
a3, judging whether to start, and starting the execution of the detection item when the tester clicks the start button. Entry a4 is initiated, otherwise a12 is entered.
a4, cycling use cases, specifically, performing loop execution on use case schemes, and entering a 5.
a5, the scheme of the circulation use case is detailed, specifically, the scheme type is circulated, and the process enters a 6.
a6, whether the mark for starting the loop exists or not, specifically, the position of the loop starting scheme and the acquisition loop number are judged. If the flag to start the cycle is found, go to a7, otherwise go to a 8.
a7, judging the control code, specifically obtaining the corresponding value of the control code, and entering a 9.
a8, a loop processing module, which controls the loop execution mode to enter a 7.
a9, obtaining the corresponding scheme type according to the value corresponding to the control code, wherein the scheme type comprises one or more of a table body operation scheme, a serial port operation scheme, a meter reading and writing communication scheme, a time delay scheme, a prompt scheme, a cycle starting scheme, a cycle ending scheme, a data comparison scheme and a variable value stored in a file scheme, executing the operation program of the electric measuring instrument of the scheme type, and entering a 10.
a10, judging whether the circulation use case scheme detail is finished, specifically judging whether the number of times of circulation of the scheme type is reached, if yes, entering a11, otherwise, entering a 5.
a11, judging whether the loop case is finished, specifically judging whether the loop times of the case scheme are reached, if yes, entering a12, otherwise, entering a 4.
a12, end.
The parameter configuration comprises parameter configuration of a table body type, a table body communication port, a meter communication port and the like, and further comprises parameter configuration of product specification parameters such as current, voltage, frequency, phase line, pulse constant and the like. Before starting, the parameters are judged to be non-null validity.
The platform body processing module calls different functions by combining with the platform body type to process operations related to the platform body, wherein the operations comprise power-on, power-off, standard table value reading, standard table error reading and the like. Wherein the values of the standard table are read out and then the variable value saving function is called to save data. The operation of the table bodies of different manufacturers and different models can be expanded in the module.
The meter communication, variable value storage and data comparison module is used for processing a scheme needing to be communicated with a meter, calling a DLMS protocol processing unit to perform framing transmission, receiving and analyzing, and storing a read result into a variable specified by the scheme; the write operation carries out formula processing on the parameters to be written, and stores the processing result into the variables specified by the scheme. The data comparison processing data comparison scheme is characterized in that firstly, whether each comparison type in the scheme is equal in comparison, equal in comparison range or only calculated is distinguished, and different processing functions are respectively called. And the other modules are used for processing serial port parameters, delaying processing, prompting processing and the like.
It should be understood that although the steps in the flowcharts of fig. 1 and 3 are shown in sequence as indicated by the arrows, the steps are not necessarily performed in sequence as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 1 and 3 may include multiple steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of performing the steps or stages is not necessarily sequential, but may be performed alternately or alternately with other steps or at least some of the other steps or stages.
In one embodiment, as shown in fig. 4, there is provided a test apparatus of an electrical measuring instrument, including: a use case scheme obtaining module 210, an execution module 220, and a functional test result obtaining module 230, wherein:
a use case scheme obtaining module 210, configured to obtain a use case scheme for each function in the detection item, where the use case scheme includes multiple scheme types; the scheme type is generated by adding control codes, and each control code corresponds to an operation program of the electric measuring instrument.
And the execution module 220 is used for executing the operation program of the electric measuring instrument of the scheme type and storing the execution data.
A functional test result obtaining module 230, configured to obtain a functional test result of the electrical measuring instrument according to the execution data.
In one embodiment, the test item supports the functionality of replication as another test item; and/or the use case scenario supports replication as a scenario type for another use case scenario.
In one embodiment, the scheme types include a start loop scheme and an end loop scheme; wherein the start loop scheme is set before the scheme type or use case scheme of the start loop, the end loop scheme is set after the scheme type or use case scheme of the end loop, and the parameter of the start loop scheme includes the loop number.
In one embodiment, the functions, use case scenarios, and scenario types support add, delete, modify, and query operations.
In one embodiment, the scheme type includes one or more of a table body operation scheme, a serial port operation scheme, a meter reading and writing communication scheme, a delay scheme, a prompt scheme, a starting loop scheme, an ending loop scheme, a data comparison scheme and a variable value saving file scheme.
In one embodiment, the testing apparatus of the electrical measuring instrument further comprises: a variable judging module, configured to judge whether a variable in the use case scenario or the scenario type exists in the detection item when the use case scenario or the scenario type is added to the detection item in a copy manner; and the variable definition module is used for acquiring the variable definition of the variable in the use case scheme or the scheme type if the variable in the use case scheme or the scheme type does not exist in the detection item.
In one embodiment, the executing module 220 is further configured to obtain a scheme type selected in the use-case scheme, execute an operating program of the electrical measuring instrument of the scheme type, and store the execution data.
For the specific definition of the test device of the electrical measuring instrument, reference may be made to the above definition of the test method of the electrical measuring instrument, which is not repeated here. The various modules in the test apparatus of the electrical measuring instrument described above may be implemented in whole or in part by software, hardware, and combinations thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a server, the internal structure of which may be as shown in fig. 5. The computer device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the computer device is used for storing execution data. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a method of testing an electrical measuring instrument.
Those skilled in the art will appreciate that the architecture shown in fig. 5 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is further provided, which includes a memory and a processor, the memory stores a computer program, and the processor implements the steps of the above method embodiments when executing the computer program.
In an embodiment, a computer-readable storage medium is provided, on which a computer program is stored which, when being executed by a processor, carries out the steps of the above-mentioned method embodiments.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database or other medium used in the embodiments provided herein can include at least one of non-volatile and volatile memory. Non-volatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical storage, or the like. Volatile Memory can include Random Access Memory (RAM) or external cache Memory. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM), among others.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.