Equipment data acquisition method and device, electronic equipment and readable storage medium
By using the main thread to start the child thread in device testing and creating independent processes to perform data acquisition tasks, the problem of low device data acquisition efficiency caused by multi-process interference is solved, and more efficient device data acquisition is achieved.
Patent Information
- Application Number
- CN202411915774.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-24
- Publication Date
- 2025-04-25
AI Technical Summary
During the equipment testing process, when multiple equipment data are collected at the same time, multiple processes will be created and started, resulting in mutual interference between processes. Some equipment data needs to be collected repeatedly, which is relatively inefficient.
The child thread is started through the main thread and sets a thread callback for the child thread. The child thread creates an independent process to perform data acquisition tasks, obtains device data from the device to be tested, and passes the collected device data to the main thread through the thread callback.
It reduces mutual interference between various processes, ensures that all equipment data can be successfully collected, and improves the efficiency of equipment data acquisition.
Smart Images

Figure CN119883782A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of testing technology, and more specifically, to a device data acquisition method, apparatus, electronic device and readable storage medium in the field of testing technology. Background Art
[0002] During the device testing process, it is often necessary to obtain multiple pieces of device data from the device under test, so as to analyze the device under test based on the obtained multiple pieces of device data and determine possible problems of the device under test and their causes.
[0003] In the process of collecting device data, the common practice is to collect each device data separately. When collecting each device data, a corresponding process is created to collect device data from the device under test. The problem with this method is that when multiple device data are collected at the same time, multiple processes will be created and started at the same time, and multiple processes may interfere with each other, resulting in the need to collect some device data repeatedly, which leads to low efficiency in the process of collecting device data. Summary of the invention
[0004] The present application provides a device data collection method, apparatus, electronic device and readable storage medium, which can improve the efficiency of the device data collection process.
[0005] In a first aspect, a device data collection method is provided, the method comprising:
[0006] When receiving a data collection instruction input for the device under test, the main thread starts a child thread and sets a thread callback for the child thread; wherein the child thread corresponds to the target data collection task indicated by the data collection instruction;
[0007] The child thread creates an independent process to execute the target data collection task, so as to obtain the device data required to be collected by the data collection task from the device under test;
[0008] After acquiring the device data collected by the independent process, the child thread transfers the device data to the main thread through the thread callback.
[0009] In an embodiment of the present application, when acquiring device data from the device under test, upon receiving a data acquisition instruction input for the device under test, the main thread starts a child thread and sets a thread callback for each child thread. The child thread creates an independent process to execute the target data acquisition task, acquires device data from the device under test, and returns the collected device data to the main thread through a thread callback. When multiple data acquisition tasks are performed simultaneously, the main thread creates multiple child threads, each of which creates an independent process to execute a data acquisition task and returns the collected device data to the main thread. The main thread can control multiple processes through multiple threads respectively, and interact with the child thread through the thread callback set for the child thread, so that the main thread can manage each process separately, and does not need to judge whether the corresponding device data is collected through the signal returned after the process completes data collection, thereby reducing the mutual interference between the processes, ensuring that the data of each device can be collected smoothly, and thus improving the collection efficiency of the device data.
[0010] Optionally, the child thread creates an independent process to execute the target data acquisition task, including: the child thread creates the independent process and specifies a data acquisition script to be run by the independent process; wherein the data acquisition script is used to obtain the device data from the device under test; the child thread passes the target task parameters of the target data acquisition task to the data acquisition script; wherein the target task parameters are passed to the child thread by the main thread; the child thread starts the independent process to run the data acquisition script, so that the data acquisition script obtains the device data from the device under test based on the task parameters.
[0011] In an embodiment of the present application, when the child thread creates an independent process to execute a target data acquisition task, it specifies a data acquisition script that the independent process runs, sets corresponding target task parameters for the data acquisition script, and then starts the data acquisition script, so that the data acquisition script can successfully obtain device data from the device under test based on the target task parameters.
[0012] Optionally, before starting the sub-thread, the method further includes: the main thread receiving task parameters of at least one data collection task input by the tester through a pre-displayed data collection interface; and obtaining the target task parameters corresponding to the target data collection task from the task parameters of the at least one data collection task.
[0013] In the embodiment of the present application, the task parameters input by the tester are received through the data collection interface, so that the tester can quickly set the task parameters used when obtaining device data according to needs, thereby improving the efficiency of the device parameter collection process.
[0014] Optionally, the method also includes: the child thread obtains process status information of the independent process and transmits the process status information to the main thread; the main thread generates task status information of the target data acquisition task based on the process status information; the main thread sends the task status information to the electronic device used by the tester, and / or displays the task status information in a display window.
[0015] In an embodiment of the present application, task status information of the data acquisition task is generated based on the process status of the independent process. In the process of outputting the task status information, the task status information is sent to the electronic device used by the tester and / or displayed in the display window, which can facilitate the tester to promptly know the task status of the data acquisition task.
[0016] Optionally, the method further includes: the child thread obtaining process status information of the independent process and transmitting the process status information to the main thread; when the main thread determines that the target data acquisition task is executed incorrectly based on the process status information, restarting the child thread.
[0017] In an embodiment of the present application, the main thread restarts the child thread when it determines that the target data acquisition task has an execution error based on the process status information of the independent process, which can facilitate timely re-acquisition of device data when device data acquisition fails, thereby improving data acquisition efficiency.
[0018] Optionally, when the main thread determines that the target data acquisition task is executed incorrectly based on the process status information, the main thread restarts the child thread, including: when the main thread determines that the independent process is blocked based on the process status information, the main thread obtains the blocking duration of the independent process; when the blocking duration is greater than a preset duration, the main thread restarts the child thread; or, when the main thread determines that the independent process is blocked based on the process status information, the main thread outputs a notification message; if a restart instruction input by the tester after obtaining the notification message is received, the main thread restarts the child thread.
[0019] In an embodiment of the present application, when the main thread determines that an independent process is blocked based on process status information, the main thread restarts the child thread if the blocking time is greater than a preset time, or outputs notification information when the independent process is determined to be blocked based on process status information. If the child thread is restarted by receiving a restart instruction entered by the tester after obtaining the notification information, the independent process can be restarted in time to reacquire device data when device data acquisition fails, thereby improving data collection efficiency.
[0020] Optionally, when the main thread receives a data collection instruction input for the device under test, it starts a sub-thread, including: the main thread displays a data collection interface; wherein the data collection interface includes multiple instruction input controls; the multiple instruction input controls correspond one-to-one to multiple data collection tasks; when the main thread receives the data collection instruction input by the tester through the target instruction input control, it starts the sub-thread; wherein the target instruction input control is the instruction input control corresponding to the target data collection task.
[0021] In an embodiment of the present application, the main thread displays a data collection interface, and receives data collection instructions through a command input control in the data collection interface, which can facilitate testers to quickly start data collection tasks, thereby improving data collection efficiency.
[0022] In a second aspect, a device for collecting device data is provided, the device comprising:
[0023] A starting module, configured to start a sub-thread and set a thread callback for the sub-thread when receiving a data collection instruction input for the device under test; wherein the sub-thread corresponds to a target data collection task indicated by the data collection instruction;
[0024] An execution module, used for creating an independent process to execute the target data collection task, so as to obtain the device data required to be collected by the data collection task from the device under test;
[0025] The return module is used to transfer the device data to the main thread through the thread callback after acquiring the device data collected by the independent process.
[0026] In a third aspect, an electronic device is provided, comprising a memory for storing executable program code; and a processor for calling and running the executable program code from the memory, so that the electronic device executes a method in any possible implementation of the first aspect.
[0027] In a fourth aspect, an electronic device program product is provided, the electronic device program product comprising: an executable program code, when the executable program code is run on an electronic device, the electronic device executes the method in any possible implementation manner of the above-mentioned first aspect.
[0028] In a fifth aspect, a readable storage medium is provided, which stores an executable program code. When the executable program code runs on an electronic device, the electronic device executes the method in any possible implementation of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1This is a schematic diagram of an application scenario of a device data collection method provided in an embodiment of the present application;
[0030] Figure 2 It is a schematic diagram of a data collection interface provided in an embodiment of the present application;
[0031] Figure 3 It is a flowchart of the steps of a device data collection method provided by an embodiment of the present application;
[0032] Figure 4 It is a signaling interaction diagram of a device data collection process provided by an embodiment of the present application;
[0033] Figure 5 It is a structural schematic diagram of a device data acquisition device provided in an embodiment of the present application;
[0034] Figure 6 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0035] The technical solution in the present application will be described clearly and in detail below in conjunction with the accompanying drawings. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B: "and / or" in the text is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.
[0036] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as suggesting or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features.
[0037] During the device testing process, it is often necessary to obtain multiple pieces of device data from the device under test, so as to analyze the device under test based on the obtained multiple pieces of device data and determine possible problems of the device under test and their causes.
[0038] In the process of collecting device data, the common practice is to collect each device data separately. When collecting each device data, a corresponding process is created to collect device data from the device under test. The problem with this method is that when multiple device data are collected at the same time, multiple processes will be created and started at the same time, and multiple processes may interfere with each other, resulting in the need to collect some device data repeatedly, which leads to low efficiency in the process of collecting device data.
[0039] For example, when collecting two pieces of device data at the same time, two processes will be created and started to collect the two pieces of device data respectively. When one of the processes completes the collection of the device data first and returns a completion signal, it will be mistaken for the completion signal returned by the other process, causing the other process to be stopped. The other process has not completed the collection of the device data. At this time, the process needs to be restarted to collect data again, which will increase the collection time of the device data and reduce efficiency.
[0040] In order to solve the above technical problems, an embodiment of the present application provides a device data acquisition method, in which the main thread, upon receiving a data acquisition instruction input for the device under test, starts a child thread and sets a thread callback for the child thread. The child thread creates an independent process to execute the data acquisition task indicated by the data acquisition instruction (hereinafter referred to as the target data acquisition task) to obtain the device data to be collected by the target data acquisition task from the device under test, and returns the collected device data to the main thread through the thread callback.
[0041] Among them, each data collection task is used to collect one or one device data. When multiple data collection tasks are carried out simultaneously, the main thread will create multiple child threads and set thread callbacks for each child thread. Each child thread creates an independent process to perform a data collection task and returns the collected device data to the main thread through thread callbacks. The main thread can control multiple processes through multiple threads respectively, and interact with the child threads through thread callbacks set for the child threads, so that the main thread can manage each process separately, and there is no need to judge whether the corresponding device data has been collected through the signal returned after the process completes data collection. In this way, the mutual interference between the processes can be reduced, and the data of each device can be collected smoothly, thereby improving the efficiency of the device data collection process.
[0042] See also Figure 1 , Figure 1 This is a schematic diagram of an application scenario of a device data collection method provided in an embodiment of the present application. The scenario includes a computer 11 and a vehicle 12, wherein the vehicle 12 is a device to be tested, and the computer 11 is used to execute the device data collection method. The computer 11 can be connected to a head unit terminal (HUT) in the vehicle 12 by wired connection or wireless connection to obtain device data from the head unit terminal.
[0043] See also Figure 2 , Figure 2 is a schematic diagram of a data collection interface provided in an embodiment of the present application. Figure 1During the test, the computer 11 starts the main thread to display the data acquisition interface 20. The tester can control the electronic device 11 to connect to the host terminal in the vehicle 12 through the relevant controls in the data acquisition interface 20, obtain the root authority of the host terminal, and then obtain the device data from the host terminal.
[0044] like Figure 2 As shown, a device selection control 201 is displayed in the data collection interface 20. The tester can input the terminal identification of the host terminal for which the device data needs to be obtained to the electronic device through the device selection control 201. The electronic device can select the host terminal corresponding to the terminal identification from one or more detected terminal devices according to the terminal identification, and establish a communication channel with the host terminal. Afterwards, the tester can click the instruction input control 202, and the electronic device obtains the root authority of the host terminal in response to the tester's click operation.
[0045] like Figure 2 As shown, the data collection interface 20 is provided with a command input control 203 and a parameter input control 207. After obtaining the root authority of the host terminal, when it is necessary to obtain one or more device logs of the host terminal, the tester can first input the log identifier of each device log to the electronic device through the parameter input control 207. Then, the tester can click the command input control 203 to input the data collection command to the electronic device, and the data collection command instructs the electronic device to obtain the device log corresponding to the log identifier from the host terminal. Correspondingly, the electronic device executes the corresponding data collection task in response to the tester's click operation, and obtains the corresponding device log from the host terminal according to the log identifier.
[0046] The data acquisition interface 20 is provided with a command input control 205 and a parameter input control 208. After obtaining the root authority of the host terminal, when it is necessary to obtain the screen recording file of the host terminal, the tester first inputs the recording time of the screen recording file to the electronic device through the parameter input control 208. Then, the tester can click the command input control 205 to input the data acquisition command to the electronic device, and the data acquisition command instructs the electronic device to obtain the screen recording file corresponding to the recording time from the host terminal. Correspondingly, the electronic device executes the corresponding data acquisition task in response to the tester's click operation, and obtains the screen recording file of the corresponding time from the host terminal according to the recording time.
[0047] The data collection interface 20 is provided with a command input control 206. After obtaining the root authority of the host terminal, when it is necessary to obtain a screenshot of the host terminal, the tester can click the command input control 206 to input a data collection command to the electronic device, and the data collection command instructs the electronic device to obtain a screenshot of the host terminal. Correspondingly, the electronic device executes the corresponding data collection task in response to the tester's click operation and obtains a screenshot from the host terminal.
[0048] like Figure 2 As shown, the data acquisition interface 20 is also provided with a command input control 204. When the tester needs to export the device log to other locations, the tester can click the command input control 204, and the electronic device can respond to the click operation to export the acquired device log to other locations. The data acquisition interface 20 is also provided with a command input control 209. Before establishing a communication connection with the device under test, the tester can click the command input control 209, and the electronic device can respond to the click operation to detect all devices under test that can currently establish a communication connection. The data acquisition interface 20 is also provided with a command input control 210. When it is necessary to view the acquired device log, the tester can click the command input control 210, and the electronic device can respond to the click operation to open the folder storing the device log. The data acquisition interface 20 is also provided with a command input control 211. When it is necessary to view the acquired screen recording file, the tester can click the command input control 211, and the electronic device can respond to the click operation to open the folder storing the screen recording file. The data collection interface 20 is also provided with a command input control 212. When the acquired screenshot needs to be viewed, the tester can click the command input control 212, and the electronic device can open the folder storing the screenshot in response to the click operation.
[0049] like Figure 2 As shown, the data collection interface 20 is also provided with a display window 212. During the data collection task, the electronic device can display various information in the data collection process through the display window 212. It should be understood that the parameter input control and the instruction input control can be composed of one or more controls such as buttons, input boxes, and drop-down menus. Figure 2 In addition to the controls shown, other types of controls may be displayed in the data collection interface 20 . The present embodiment does not limit the specific composition of the data collection interface 20 .
[0050] It should be noted that Figure 1 and Figure 2 For illustrative purposes only, the device data collection method can be executed by a computer, or by other electronic devices such as a tablet, a laptop, etc. The device to be tested may include but is not limited to a vehicle, and the data collection process may be performed by Figure 2The data collection interface shown may also be implemented in other ways, which are not limited in this embodiment.
[0051] See also Figure 3 , Figure 3 This is a flow chart of the steps of a device data collection method provided by an embodiment of the present application. Figure 3 As shown, the method comprises the following steps:
[0052] Step 301: When receiving a data collection instruction input for a device under test, the main thread starts a child thread and sets a thread callback for the child thread.
[0053] Among them, the main thread is a thread started by the electronic device when executing the device data collection method, and the sub-thread is created and started by the main thread after the electronic device receives the data collection instruction. The sub-thread corresponds to the target data collection task indicated by the data collection instruction.
[0054] like Figure 2 As shown, when the tester controls the electronic device 20 to display the data acquisition interface 20, the main thread is created and started by the electronic device. At this time, the main thread monitors the data acquisition interface 20 to obtain the data acquisition instruction input by the tester through the instruction input control. In combination with the above example, when it is necessary to obtain one or more device logs of the host terminal, the tester can first input the log identifier of each device log to the electronic device through the parameter input control 207, and the main thread can capture the log identifier input by the tester through the parameter input control 207. Afterwards, the tester can click the instruction input control 203 to input the data acquisition instruction to the electronic device. The main thread can capture the data acquisition instruction (i.e., click operation), and in response to the data acquisition instruction, create and start a corresponding sub-thread, and the target data acquisition task corresponding to the sub-thread is used to collect the device log corresponding to the log identifier.
[0055] In the process of obtaining device logs, if it is necessary to obtain a screenshot of the host terminal at the same time, the tester can first input the recording time through the parameter input control 208, and then click the instruction input control 206 to input the data collection instruction to the electronic device. The main thread can capture the data collection instruction, and in response to the data collection instruction, create and start a corresponding sub-thread, and the target data collection task corresponding to the sub-thread is used to obtain a screenshot of the host terminal.
[0056] Similarly, if it is necessary to simultaneously obtain the screen recording file of the host terminal, the tester can first input the recording time of the screen recording file to the electronic device through the parameter input control 208, and the main thread can capture the recording time input by the tester through the parameter input control 208. Then, the tester can click the instruction input control 205 to input the data collection instruction to the electronic device. The main thread can capture the data collection instruction, and in response to the data collection instruction, create and start a corresponding sub-thread, and the target data collection task corresponding to the sub-thread is used to obtain the screen recording file of the host terminal.
[0057] It can be understood that when multiple data collection tasks need to be executed simultaneously, the main thread can simultaneously create and start a sub-thread corresponding to each data collection task.
[0058] Step 302: The child thread creates an independent process to execute the target data collection task to obtain the device data required to be collected by the data collection task from the device under test.
[0059] Step 303: After obtaining the device data collected by the independent process, the child thread transfers the device data to the main thread through thread callback.
[0060] In this embodiment, after being created and started by the main thread, the child thread creates and starts an independent process to perform the target data collection task, and obtains the device data required to be collected by the target data collection task from the device under test through the independent process. After capturing the device data collected by the independent process, the child thread returns the device data to the main thread through the thread callback. After receiving the device data passed by the child thread through the thread callback, the main thread determines that the data collection task corresponding to the child thread has been completed, and can close the child thread, and the child thread releases the independent process.
[0061] In combination with the above example, after the child thread corresponding to the data acquisition task of obtaining the device log is created and started, the child thread creates an independent process, and then runs the data acquisition script corresponding to the acquisition of the device log in the independent process, obtains the device log from the host terminal, and runs the data acquisition script corresponding to the data acquisition task to execute the data acquisition task. As in the above example, after the data acquisition script is run, for each log identifier, the data acquisition script sends a data request to the host terminal, and the data request includes the log identifier of the device log. After receiving the data request, the host terminal determines the storage path of the device log according to the log identifier in the data request, and then obtains the device log from the storage path and sends the device log to the electronic device. After the device log is sent to the electronic device, it is passed to the independent process and can be captured by the child thread. The child thread can execute a thread callback and pass the device log to the main thread through the thread callback.
[0062] Similarly, after the child thread corresponding to the data acquisition task of obtaining the screenshot is created and started, the child thread creates an independent process, and then runs the data acquisition script corresponding to obtaining the screenshot in the independent process to obtain the screenshot from the host terminal. Exemplarily, after the data acquisition script is run, the data acquisition script sends a data request to the host terminal. After receiving the data request, the host terminal performs a screenshot operation on the screen to obtain a screenshot, and sends the screenshot to the electronic device. After the screenshot is sent to the electronic device, it is passed to the independent process and can be captured by the child thread. The child thread can execute a thread callback and pass the screenshot to the main thread through the thread callback.
[0063] Similarly, after the child thread corresponding to the data acquisition task for obtaining the screen recording file is created and started, the child thread creates an independent process, and then runs the data acquisition script corresponding to obtaining the screen recording file in the independent process to obtain the screen recording file from the host terminal. Exemplarily, after the data acquisition script is run, the data acquisition script sends a data request to the host terminal, and the data request includes the recording duration. After receiving the data request, the host terminal records the screen according to the recording duration in the data request to obtain a screen recording file corresponding to the recording duration, and sends the screen recording file to the electronic device. The screen recording file is sent to the electronic device and then passed to the independent process, which can be captured by the child thread. The child thread can execute a thread callback and pass the screen recording file to the main thread through the thread callback.
[0064] Among them, when the device under test sends device data to the electronic device, the device data can be obtained according to the pre-set rules. For example, for a screen recording file, if a screen recording file needs to be obtained, after receiving the data request, the device under test can record a screen recording file and send a screen recording file to the electronic device. If it is necessary to obtain N (N is an integer greater than 1) screen recording files, after receiving the data request, the device under test can record a screen recording file every preset time, and after continuously recording N screen recording files, send N screen recording files to the electronic device.
[0065] It should be noted that device data may include but is not limited to the device logs, screen recording files, and screenshots mentioned in the above examples.
[0066] In an embodiment of the present application, when acquiring device data from the device under test, upon receiving a data acquisition instruction input for the device under test, the main thread starts a child thread and sets a thread callback for each child thread. The child thread creates an independent process to execute the target data acquisition task, acquires device data from the device under test, and returns the collected device data to the main thread through a thread callback. When multiple data acquisition tasks are performed simultaneously, the main thread creates multiple child threads, each of which creates an independent process to execute a data acquisition task and returns the collected device data to the main thread. The main thread can control multiple processes through multiple threads respectively, and interact with the child thread through the thread callback set for the child thread, so that the main thread can manage each process separately, and does not need to judge whether the corresponding device data is collected through the signal returned after the process completes data collection, thereby reducing the mutual interference between the processes, ensuring that the data of each device can be collected smoothly, and thus improving the collection efficiency of the device data.
[0067] Optionally, the child thread creates an independent process to execute the target data collection task, including:
[0068] The child thread creates an independent process and specifies a data collection script to be run by the independent process; wherein the data collection script is used to obtain device data from the device under test;
[0069] The child thread passes the target task parameters of the target data collection task to the data collection script; wherein the target task parameters are passed from the main thread to the child thread;
[0070] The child thread starts an independent process to run a data acquisition script, so that the data acquisition script obtains device data from the device under test based on the task parameters.
[0071] Exemplarily, when creating a child thread, the main thread can pass the script identifier of the data acquisition script to the child thread to specify the data acquisition script to be run to the child thread. Optionally, when the data acquisition script is an application, the script identifier can be the package name of the application. At the same time, if the target task parameters are needed to obtain device data, the main thread can pass the target task parameters to the data acquisition script. After the child thread is started, it can create an independent process and specify the data acquisition script that the independent process needs to run, so that the data acquisition script obtains device data from the device under test based on the target task parameters.
[0072] As in the above example, the target task parameter for obtaining the screen recording file is the recording duration. When the main thread creates the corresponding child thread, it can pass the package name of the data acquisition script to the child thread and pass the recording duration to the child thread. When the child thread creates an independent process, it sets the independent process to run the data acquisition script used to obtain the screen recording file, and passes the recording duration to the data acquisition script. The recording duration is the input parameter of the data acquisition script. After that, the child thread starts the independent process, and the independent process runs the data acquisition script. The data acquisition script obtains the screen recording file from the device under test based on the recording duration.
[0073] Similarly, the target task parameter when obtaining device logs is the log identifier. When the main thread creates a child thread, it can pass the package name of the data collection script to the child thread and pass the log identifier to the child thread. When the child thread creates an independent process, it sets the independent process to run the data collection script used to obtain device logs, and passes the log identifier to the data collection script. The log identifier is the input parameter of the data collection script. After that, the child thread starts the independent process, and the independent process runs the data collection script. The data collection script obtains the corresponding device log from the device under test based on the log identifier.
[0074] It should be understood that when the acquisition of device data does not require the use of target task parameters, when creating an independent process, the child thread does not need to pass the target task parameters to the data acquisition script.
[0075] In an embodiment of the present application, when the child thread creates an independent process to execute a target data acquisition task, it specifies a data acquisition script that the independent process runs, sets corresponding target task parameters for the data acquisition script, and then starts the data acquisition script, so that the data acquisition script can successfully obtain device data from the device under test based on the target task parameters.
[0076] Optionally, before starting the child thread, the method may further include:
[0077] The main thread receives the task parameters of at least one data collection task input by the tester through the pre-displayed data collection interface;
[0078] From the task parameters of at least one data collection task, a target task parameter corresponding to the target data collection task is obtained.
[0079] like Figure 2As shown, after the main thread starts the data collection interface 20, for the two data collection tasks of obtaining device logs and screenshots, the tester can input the log identifier through the parameter input control 207 and the recording duration through the parameter input control 208. The log identifier and the recording duration are task parameters. When the user clicks the instruction input control 208 (i.e., the data collection instruction), the main thread can determine that the target data collection task is the data collection task of obtaining the screen recording file. At this time, the main thread can determine the recording duration input by the parameter input control 208 as the target task parameter.
[0080] Similarly, when receiving a user click operation (ie, data collection instruction) on the instruction input control 203, the main thread can determine the target data collection task as a data collection task for obtaining device logs. At this time, the main thread can determine the log identifier input by the parameter input control 207 as the target task parameter.
[0081] Optionally, the task parameters of the data acquisition task can also be preset. For example, for a screen recording file, a recording duration can be preset, and the recording duration is stored in the electronic device. When receiving a user's click operation on the instruction input control 205 (i.e., a data acquisition instruction), the main thread can determine that the target data acquisition task is a data acquisition task for acquiring a screen recording file, and the main thread can use the pre-stored recording duration as the target task parameter. It should be understood that the method for obtaining the target task parameter may include but is not limited to the above examples.
[0082] In the embodiment of the present application, the task parameters input by the tester are received through the data collection interface, so that the tester can quickly set the task parameters used when obtaining device data according to needs, thereby improving the efficiency of the device parameter collection process.
[0083] Optionally, the method may further include:
[0084] The child thread obtains the process status information of the independent process and passes the process status information to the main thread;
[0085] The main thread generates task status information of the target data collection task based on the process status information.
[0086] The main thread sends the task status information to the electronic device used by the tester, and / or displays the task status information in a display window
[0087] Exemplarily, for each sub-thread corresponding to a data acquisition task, after creating and starting an independent process, the sub-thread can obtain the process status information of the independent process, and pass the process status information of the independent process to the main thread through a thread callback. As in the above example, for the data acquisition task of acquiring a screen recording file, after the sub-thread creates and starts an independent process, when the independent process enters a blocked state during operation, the sub-thread can pass the process status information of the independent process entering a blocked state to the main thread. When the main thread receives the process status information, it determines that the task state of the target data acquisition task is a stopped state, and generates task status information indicating that the target data acquisition task is in a stopped state.
[0088] Similarly, for the data collection task of obtaining screen recording files, after the child thread creates and starts an independent process, the independent process enters the termination state during operation after the data collection script is completed. The child thread can pass the process status information of the independent process entering the termination state to the main thread. When the main thread receives the process status information, it determines that the target data collection task is completed and generates task status information indicating that the target data collection task is completed.
[0089] Exemplarily, after generating the above task status information, the main thread of the electronic device used by the tester, such as a mobile phone, can send the task status information to the tester's mobile phone to inform the tester of the task status of the target data collection task through the task status information.
[0090] like Figure 2 As shown, a display window 212 is provided in the data collection interface 20. After generating the task status information of the target collection task, the main thread can display the task status information in the display window 212. In this way, the tester can determine the task status of the data collection task in time through the task status information displayed in the task display window 212.
[0091] In an embodiment of the present application, task status information of the data acquisition task is generated based on the process status of the independent process. In the process of outputting the task status information, the task status information is sent to the electronic device used by the tester and / or displayed in the display window, which can facilitate the tester to promptly know the task status of the data acquisition task.
[0092] Optionally, the method may further include:
[0093] The child thread obtains the process status information of the independent process and passes the process status information to the main thread;
[0094] When the main thread determines that the target data collection task has an execution error based on the process status information, it restarts the child thread.
[0095] In one embodiment, after receiving the process status information transmitted by the child thread, the main thread can determine the state of the independent process based on the process status information. When the state of the independent process is determined to be a blocked state, a suspended state, or a dormant state based on the process status information, it is determined that the independent process has not successfully executed the target data acquisition task, and the target data acquisition task execution error occurs. At this time, the main thread can recreate a child thread and start the child thread, so that the child thread recreates the independent process to execute the target data acquisition task to reacquire device data.
[0096] When the main thread restarts the child thread, it can pass the target task parameters to the restarted child thread and specify the data collection script that the independent process needs to run, so that the independent process can run the data collection script again to obtain device data.
[0097] In an embodiment of the present application, the main thread restarts the child thread when it determines that the target data acquisition task has an execution error based on the process status information of the independent process, which can facilitate timely re-acquisition of device data when device data acquisition fails, thereby improving data acquisition efficiency.
[0098] Optionally, when the main thread determines based on the process status information that an execution error has occurred in the target data collection task, restarting the sub-thread includes:
[0099] When the main thread determines that the independent process is blocked based on the process status information, it obtains the blocking time of the independent process; when the blocking time is greater than the preset time, the child thread is restarted;
[0100] Alternatively, when the main thread determines that the independent process is blocked based on the process status information, it outputs notification information; if a restart instruction input by the tester after obtaining the notification information is received, the sub-thread is restarted.
[0101] In one embodiment, when the child thread determines that the independent process has entered a blocked state, it can obtain the blocking time of the independent process entering the blocked state, transmit process status information indicating that the independent process has entered a blocked state to the main thread, and transmit the blocking time to the main thread. Correspondingly, when the main thread receives the process status information and the blocking time, if it is determined that the independent process is blocked according to the process status information, and it is determined that the blocking time is greater than the preset time, it is determined that the blocking time of the independent process exceeds the limit, and the child thread can be restarted, and the device data can be re-obtained by restarting the independent process through the child thread.
[0102] In another embodiment, the main thread may output notification information when determining that the independent process is blocked based on the process status information. For example, the main thread may send a notification message to the mobile phone used by the tester to notify the tester that the independent process has entered a blocked state. After the tester determines that the independent process has entered a blocked state through the mobile phone, the tester may send a restart instruction to the electronic device through the mobile phone. After the restart instruction is sent to the electronic device, it is captured by the main thread. After capturing the restart instruction, the main thread restarts the child thread to restart the independent process.
[0103] For another example, the main thread can output a notification message through a display window to notify the tester that the independent process has entered a blocked state. The tester can input a restart instruction to the electronic device through the control in the data acquisition interface. After the restart instruction is input to the electronic device, it is captured by the main thread. After capturing the restart instruction, the main thread restarts the child thread to restart the independent process.
[0104] In an embodiment of the present application, when the main thread determines that an independent process is blocked based on process status information, the main thread restarts the child thread if the blocking time is greater than a preset time, or outputs notification information when the independent process is determined to be blocked based on process status information. If the child thread is restarted by receiving a restart instruction entered by the tester after obtaining the notification information, the independent process can be restarted in time to reacquire device data when device data acquisition fails, thereby improving data collection efficiency.
[0105] Optionally, when receiving a data collection instruction input for the device under test, the main thread starts the sub-thread, including:
[0106] The main thread displays a data collection interface; wherein the data collection interface includes a plurality of command input controls; the plurality of command input controls correspond one to one with the plurality of data collection tasks;
[0107] When the main thread receives the data collection instruction input by the tester through the target instruction input control, it starts the sub-thread; wherein the target instruction input control is the instruction input control corresponding to the target data collection task.
[0108] like Figure 2As shown, after the main thread is started by the electronic device, the main thread can display the data acquisition interface 20, which includes a command input control 203, a command input control 205 and a command input control 206, each of which corresponds to a data acquisition task. When a click operation by the tester through one of the target command input controls (such as the command input control 203) is received, the data acquisition command input by the user through the command input control 203 is received. At this time, the main thread can start the sub-thread corresponding to the data acquisition task (i.e., the target data acquisition task) corresponding to the acquisition of the device log, and the sub-thread creates and starts an independent process to obtain the device log from the device under test. The understanding of the command input control can refer to the above example, and this embodiment will not be repeated here.
[0109] In an embodiment of the present application, the main thread displays a data collection interface, and receives data collection instructions through a command input control in the data collection interface, which can facilitate testers to quickly start data collection tasks, thereby improving data collection efficiency.
[0110] See also Figure 4 , Figure 4 1 is a signaling interaction diagram of a device data collection process provided by an embodiment of the present application. Figure 4 As shown, the method includes:
[0111] Step 401: The main thread creates a child thread.
[0112] Step 402: The main thread sets a thread callback for the child thread.
[0113] Step 403: The main thread passes task parameters to the child thread.
[0114] Step 404: The main thread specifies a data collection script to the child thread.
[0115] In this embodiment, for each data collection task, after receiving the input data collection instruction, the main thread creates a corresponding child thread for the data collection task. At the same time, the main thread sets a thread callback for the child thread, passes task parameters to the child thread, and specifies a data collection script to the child thread. Figure 2 As shown, when the device data that the data acquisition task needs to obtain is the device log, the main thread sets a thread callback for the child thread after creating the child thread, obtains the log identifier (task parameter) input in the data acquisition interface 20, and passes the log identifier to the child thread, and at the same time specifies to the child thread the data acquisition script that needs to be run when obtaining the device log.
[0116] Step 405: The child thread creates an independent process.
[0117] Step 406: The child thread passes the task parameters to the data collection script.
[0118] Step 407: The child thread specifies the data collection script to the independent process.
[0119] In this embodiment, after being created and started, the child thread creates and starts an independent process. At the same time, the child thread specifies the data collection script that the independent process needs to run, and passes the task parameters to the data collection script.
[0120] Step 408: The independent process runs the data collection script.
[0121] In this embodiment, after the independent process is created and started, the data collection script can be run to obtain the device data required for the data collection task.
[0122] Step 409: The child thread captures the device data collected by the independent process.
[0123] Step 410: The child thread transfers device data to the main thread.
[0124] Step 411: The main thread releases the child thread.
[0125] In this embodiment, after the independent process runs the data acquisition script to obtain device data, the device data can be captured by the child thread, and the child thread can call the thread callback to return the device data to the main thread. Correspondingly, the main thread can receive the device data returned by the child thread.
[0126] After the independent process runs the data collection script to obtain device data, the independent process enters the end state. At this time, the child thread can pass the process status information of the independent process (which can be the exit code of the independent process) to the main thread. When the main thread receives the process status information, it determines that the independent process has completed the data collection task, and can release the child thread, and the independent process is also released.
[0127] Similarly, the child thread can pass the process status information when the independent process enters the blocking state to the main thread. After receiving the process status information, the main thread determines that the independent process enters the blocking state and can restart the child thread.
[0128] See also Figure 5 , Figure 5 Schematic diagram of the structure of a device data acquisition device provided in an embodiment of the present application. Figure 5 As shown, the device 500 includes:
[0129] The starting module 501 is used to start a sub-thread and set a thread callback for the sub-thread when receiving a data collection instruction input for the device under test; wherein the sub-thread corresponds to the target data collection task indicated by the data collection instruction;
[0130] An execution module 502 is used to create an independent process to execute the target data collection task, so as to obtain the device data required to be collected by the data collection task from the device under test;
[0131] The return module 503 is used to transfer the device data to the main thread through the thread callback after acquiring the device data collected by the independent process.
[0132] Optionally, the execution module 502 is used by the child thread to create the independent process and specify a data acquisition script for the independent process to run; wherein the data acquisition script is used to obtain the device data from the device under test; the child thread passes the target task parameters of the target data acquisition task to the data acquisition script; wherein the target task parameters are passed by the main thread to the child thread; the child thread starts the independent process to run the data acquisition script, so that the data acquisition script obtains the device data from the device under test based on the task parameters.
[0133] Optionally, the startup module 501 is also used for, before the startup sub-thread, the main thread receiving the task parameters of at least one data collection task input by the tester through a pre-displayed data collection interface; and obtaining the target task parameters corresponding to the target data collection task from the task parameters of the at least one data collection task.
[0134] Optionally, the device 500 also includes an output module, which is used for the sub-thread to obtain process status information of the independent process and pass the process status information to the main thread; the main thread generates task status information of the target data acquisition task based on the process status information; the main thread sends the task status information to the electronic device used by the tester, and / or displays the task status information in a display window.
[0135] Optionally, the device 500 also includes a restart module, which is used for the child thread to obtain process status information of the independent process and pass the process status information to the main thread; when the main thread determines that the target data acquisition task has an execution error based on the process status information, the main thread restarts the child thread.
[0136] Optionally, the restart module is specifically used to obtain the blocking duration of the independent process when it is determined that the independent process is blocked based on the process status information; restart the sub-thread when the blocking duration is greater than a preset duration; or, when the main thread determines that the independent process is blocked based on the process status information, output a notification message; if a restart instruction entered by the tester after obtaining the notification message is received, restart the sub-thread.
[0137] Optionally, the startup module 501 is specifically used for the main thread to display a data acquisition interface; wherein the data acquisition interface includes multiple instruction input controls; the multiple instruction input controls correspond one-to-one to multiple data acquisition tasks; when the main thread receives the data acquisition instruction input by the tester through the target instruction input control, it starts the sub-thread; wherein the target instruction input control is the instruction input control corresponding to the target data acquisition task.
[0138] See also Figure 6 , Figure 6 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application.
[0139] For example, Figure 6 As shown, the electronic device 600 includes: a memory 601 and a processor 602, wherein the memory 601 stores an executable program code 6011, and the processor 602 is used to call and execute the executable program code 6011 to perform a device data collection method.
[0140] In addition, an embodiment of the present application also protects a device data collection apparatus, which may include a memory and a processor, wherein the memory stores executable program code, and the processor is used to call and execute the executable program code to execute a device data collection method provided by an embodiment of the present application.
[0141] In this embodiment, the functional modules of the device can be divided according to the above method example. For example, each functional module can be corresponded, or two or more functions can be integrated into one processing module. The above integrated module can be implemented in the form of hardware. It should be noted that the division of modules in this embodiment is schematic and is only a logical function division. There may be other division methods in actual implementation.
[0142] It should be noted that all relevant contents of each step involved in the above method embodiment can be referred to the functional description of the corresponding functional module, which will not be repeated here.
[0143] It should be understood that the apparatus provided in this embodiment is used to execute the above-mentioned device data collection method, and thus can achieve the same effect as the above-mentioned implementation method.
[0144] In the case of an integrated unit, the device may include a processing module and a storage module. When the device is applied to an electronic device, the processing module may be used to control and manage the actions of the electronic device. The storage module may be used to support the electronic device to execute mutual program codes, etc.
[0145] The processing module may be a processor or a controller, which may implement or execute various exemplary logic blocks, modules and circuits disclosed in the present application. The processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of digital signal processing (DSP) and a microprocessor, etc. The storage module may be a memory.
[0146] In addition, the device provided in the embodiments of the present application may specifically be a chip, a component or a module, and the chip may include a connected processor and a memory; wherein the memory is used to store instructions, and when the processor calls and executes the instructions, the chip can execute a device data acquisition method provided in the above embodiments.
[0147] This embodiment also provides a readable storage medium, in which executable program code is stored. When the executable program code is run on an electronic device, the electronic device executes the above-mentioned related method steps to implement a device data collection method provided by the above embodiment.
[0148] This embodiment further provides an electronic device program product. When the electronic device program product runs on an electronic device, the electronic device executes the above-mentioned related steps to implement a device data collection method provided by the above embodiment.
[0149] Among them, the device, readable storage medium, electronic device program product or chip provided in this embodiment are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods provided above and will not be repeated here.
[0150] Through the description of the above implementation methods, technical personnel in the relevant field can understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0151] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0152] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A device data collection method, characterized in that: The method comprises: When receiving a data collection instruction input for the device under test, the main thread starts a child thread and sets a thread callback for the child thread; wherein the child thread corresponds to the target data collection task indicated by the data collection instruction; The child thread creates an independent process to execute the target data collection task, so as to obtain the device data required to be collected by the data collection task from the device under test; After acquiring the device data collected by the independent process, the child thread transfers the device data to the main thread through the thread callback.
2. The method according to claim 1, characterized in that The child thread creates an independent process to execute the target data collection task, including: The child thread creates the independent process and specifies a data acquisition script to be run by the independent process; wherein the data acquisition script is used to obtain the device data from the device under test; The child thread transfers the target task parameters of the target data collection task to the data collection script; wherein the target task parameters are transferred from the main thread to the child thread; The child thread starts the independent process to run the data acquisition script, so that the data acquisition script obtains the device data from the device under test based on the task parameters.
3. The method according to claim 2, characterized in that Before starting the sub-thread, the method further includes: The main thread receives task parameters of at least one data collection task input by the tester through a pre-displayed data collection interface; The target task parameter corresponding to the target data collection task is acquired from the task parameters of the at least one data collection task.
4. The method according to any one of claims 1 to 3, characterized in that The method further comprises: The child thread obtains the process status information of the independent process and transmits the process status information to the main thread; The main thread generates task status information of the target data acquisition task based on the process status information; The main thread sends the task status information to the electronic device used by the tester, and / or displays the task status information in a display window.
5. The method according to any one of claims 1 to 3, characterized in that The method further comprises: The child thread obtains the process status information of the independent process and transmits the process status information to the main thread; When the main thread determines that the target data acquisition task is executed incorrectly based on the process status information, the main thread restarts the sub-thread.
6. The method according to claim 5, characterized in that When the main thread determines based on the process status information that the target data acquisition task has an execution error, restarting the sub-thread includes: The main thread obtains the blocking duration of the independent process when it is determined based on the process status information that the independent process is blocked; and restarts the child thread when the blocking duration is greater than a preset duration; Alternatively, when the main thread determines that the independent process is blocked based on the process status information, the main thread outputs notification information; if a restart instruction input by the tester after obtaining the notification information is received, the sub-thread is restarted.
7. The method according to claim 5, characterized in that When the main thread receives a data collection instruction input for the device under test, the sub-thread is started, including: The main thread displays a data collection interface; wherein the data collection interface includes a plurality of command input controls; the plurality of command input controls correspond one to one with a plurality of data collection tasks; The main thread starts the sub-thread when receiving the data collection instruction input by the tester through the target instruction input control; wherein the target instruction input control is the instruction input control corresponding to the target data collection task.
8. A device data collection device, characterized in that: The device comprises: A starting module, configured to start a sub-thread and set a thread callback for the sub-thread when receiving a data collection instruction input for the device under test; wherein the sub-thread corresponds to a target data collection task indicated by the data collection instruction; An execution module, used for creating an independent process to execute the target data collection task, so as to obtain the device data required to be collected by the data collection task from the device under test; The return module is used to transfer the device data to the main thread through the thread callback after acquiring the device data collected by the independent process.
9. An electronic device, characterized in that: The electronic device comprises: A memory for storing executable program codes; A processor, configured to call and run the executable program code from the memory, so that the electronic device executes the method according to any one of claims 1 to 7.
10. A readable storage medium, characterized in that: The readable storage medium stores an executable program code, and when the executable program code runs on an electronic device, the electronic device executes the method according to any one of claims 1 to 7.