Client analog data transmission method and transmission device
By reading configuration files to create thread pools and generating mock clients, the problems of low test efficiency and poor repeatability in the existing technology are solved, and automated data transmission is realized, which reduces test costs and improves efficiency and consistency.
Patent Information
- Application Number
- CN202411135283.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-19
- Publication Date
- 2025-01-03
AI Technical Summary
When testing network applications, the prior art requires a large number of physical equipment, resulting in high testing costs, low efficiency, error-prone and difficult to scale, and difficult to reproduce the test environment, resulting in poor repeatability of the test results.
Create a thread pool by reading configuration files, automatically generate and run a simulation client, and generate simulated data, avoiding manual configuration and management of a large number of physical devices, and using thread pool technology to improve resource management efficiency and realize automated data transmission.
It reduces testing costs, improves testing efficiency and environmental consistency, ensures repeatability of test results, saves hardware equipment procurement and maintenance costs, and simplifies development and maintenance complexity.
Smart Images

Figure CN119254649A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of lithium batteries, and in particular relates to a method and a device for transmitting client analog data. Background Art
[0002] With the development of the Internet of Things, more and more devices need to transmit and communicate data over the network. As a high-performance, asynchronous, event-driven network application framework, Netty is widely used in various network applications, including data transmission of IoT devices. However, actual testing and verification of the performance and stability of these applications requires a large number of client physical devices to simulate data transmission, which usually requires a lot of manpower and material resources in existing technologies.
[0003] For example, existing testing methods usually require a large number of physical devices, resulting in high procurement and maintenance costs; and existing testing methods require manual configuration and management of a large number of devices for data transmission, resulting in low testing efficiency; in addition, existing testing methods require a large number of physical devices, which usually require complex configuration and management, are prone to errors, and are not easy to expand; furthermore, due to the use of a large number of physical devices, the test environment is difficult to reproduce, resulting in poor repeatability of test results. Summary of the invention
[0004] The present invention provides a method and device for transmitting client simulation data, which are used to solve a series of problems in the prior art caused by the need for transmission data of a large number of physical devices when testing network applications.
[0005] In order to solve the above technical problems, in a first aspect, the present invention provides a method for transmitting client simulation data, comprising:
[0006] Read the configuration file required for client simulation data;
[0007] Based on the configuration information in the configuration file, create a thread pool;
[0008] Based on the configuration information, create a simulated client through the thread pool and run the simulated client;
[0009] Based on the device type of the simulated client, generating simulation data corresponding to the device type;
[0010] Based on the request type of the request of the simulated client, create a request object corresponding to the request type, wherein the request object includes the request type, transaction identity information and simulated client identity information;
[0011] The request object and the simulation data are sent to a server.
[0012] Optionally, creating a thread pool based on the configuration information in the configuration file includes:
[0013] Obtain the number of simulated clients in the configuration information;
[0014] Determine the number of threads in the thread pool based on the number of the simulated clients, wherein the number of threads is proportional to the number of the simulated clients;
[0015] Based on the number of threads, the thread pool is created.
[0016] Optionally, determining the number of threads in the thread pool based on the number of simulated clients includes:
[0017] The number of threads in the thread pool is determined based on the number of simulated clients, network latency, and request processing time of the simulated clients.
[0018] Optionally, the number of threads in the thread pool is determined by the following formula:
[0019] N y =N x ×(1+d / t);
[0020] Among them, N y is the number of threads, N x is the number of simulated clients, d is the network delay, and t is the request processing time.
[0021] Optionally, sending the request object and the simulation data to a server includes:
[0022] Based on the device type of the simulated client, determining the number of simulation parameters corresponding to the device type;
[0023] Determine the capacity of a byte buffer and establish the byte buffer based on the number of simulation parameters and the number of simulated clients;
[0024] Filling the simulation data into the byte buffer;
[0025] The byte buffer and the request object are sent to a server.
[0026] Optionally, after determining the capacity of the byte buffer based on the number of simulation parameters and the number of simulation clients and establishing the byte buffer, and before filling the simulation data into the byte buffer, the method further includes:
[0027] Obtaining the timestamp when the simulation data is generated;
[0028] Fill the byte buffer with the timestamp.
[0029] Optionally, the generating simulation data corresponding to the device type based on the device type of the simulated client includes:
[0030] Based on the device type of the simulated client, generate initial data of each parameter corresponding to the device type;
[0031] Based on the parameter type of the parameter, determining a data update strategy corresponding to the parameter type;
[0032] Based on the data updating strategy, the initial data of the parameters are updated to generate simulation data.
[0033] Optionally, the determining, based on the parameter type of the parameter, a data update strategy corresponding to the parameter type includes:
[0034] When the parameter is an operating state parameter, determining that the data update strategy corresponding to the parameter is periodic update;
[0035] When the parameter is a control state parameter, determining that the data update strategy corresponding to the parameter is to update the control state parameter when a trigger condition is satisfied, wherein the control state parameter is used to control changes in the system operation mode;
[0036] When the parameter is an associated parameter of a dependent parameter, the data update strategy corresponding to the parameter is determined to be based on the update of the dependent parameter, and the associated parameter is updated synchronously, wherein the dependent parameter is the operating state parameter or the control state parameter.
[0037] Optionally, sending the request object and the simulation data to a server includes:
[0038] Encode the request object into a string and then encapsulate it to obtain a real-time data object;
[0039] Encrypting the real-time data object by using an encryption algorithm;
[0040] Calculating the length of the encrypted real-time data object;
[0041] Fill the encrypted real-time data object and the length into a byte buffer;
[0042] The byte buffer and the simulation data are sent to a server.
[0043] In a second aspect, the present invention provides a transmission device for client simulation data, comprising:
[0044] The reading module is used to read the configuration files required by the client to simulate data;
[0045] A first creation module, used to create a thread pool based on the configuration information in the configuration file;
[0046] A second creation module, used to create a simulated client and run the simulated client through the thread pool based on the configuration information;
[0047] A generating module, configured to generate simulation data corresponding to the device type based on the device type of the simulated client;
[0048] A third creation module, configured to create a request object corresponding to the request type based on the request type of the request of the simulated client, wherein the request object includes the request type, transaction identity information and simulated client identity information;
[0049] A sending module is used to send the request object and the simulation data to a server.
[0050] Compared with the prior art, the present invention provides a method for transmitting client simulation data, which has the following advantages:
[0051] Beneficial effects:
[0052] In the present invention, the client is simulated and run by the thread in the thread pool. Here, the thread pool can be used to automatically create multiple simulated clients, and simulated data can be generated by the simulated client. Obviously, the present invention avoids the use of a large number of physical devices to generate transmission data. In addition, the present invention can automatically generate transmission data based on the configuration file, avoiding the need to manually configure a large number of devices for data transmission in the prior art. In summary, the present invention solves a series of problems caused by the need for transmission data of a large number of physical devices when testing network applications in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only part of the embodiments of the present invention, rather than all of the embodiments. For ordinary technicians in this field, without paying creative work, other drawings obtained based on these drawings all fall within the scope of protection of the present invention.
[0054] Figure 1 is a flow chart of a method for transmitting client simulation data provided by an embodiment of the present invention;
[0055] Figure 2 It is a schematic diagram of the transmission process of client simulation data provided by an embodiment of the present invention;
[0056] Figure 3 It is a structural diagram of a transmission device for client simulation data provided by an embodiment of the present invention;
[0057] Figure 4 It is a structural schematic diagram of a transmission device for client simulation data provided by an embodiment of the present invention;
[0058] Figure 5 It is a structural schematic diagram of a computer-readable storage medium provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0059] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0060] In order to make the description of the disclosed content more detailed and complete, the following is an illustrative description of the implementation mode and specific examples of the present invention; however, this is not the only form of implementing or applying the specific embodiments of the present invention. The implementation mode covers the features of multiple specific embodiments and the method steps and their sequence for constructing and operating these specific embodiments. However, other specific embodiments can also be used to achieve the same or equal functions and step sequences. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0061] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein.
[0062] In addition, in the description of the embodiments of the present invention, "multiple" means two or more than two, and other quantifiers are similar and should be understood. The preferred embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention. In addition, the embodiments of the present invention and the features therein may be combined with each other without conflict.
[0063] like Figure 1 The flowchart shown is a method for transmitting client simulation data provided by an embodiment of the present invention, which includes the following steps.
[0064] Step S110, reading the configuration file required by the client to simulate data.
[0065] It should be noted that the configuration file in this step stores simulation information required for client simulation data, such as the number of clients to be simulated, the address of the server, and the port information to be called.
[0066] It should be noted that the configuration file in this step may be pre-stored in a related storage space, or a user interface may be set in the user terminal, and the user inputs various configuration information in the user interface to form the configuration file.
[0067] Step S120: Create a thread pool based on the configuration information in the configuration file.
[0068] It should be noted that the thread pool is a mechanism for managing threads, especially in application scenarios that require a large number of threads to perform short-term tasks. It can effectively reuse threads, reduce the overhead of thread creation and destruction, and improve system efficiency. The thread pool mainly includes the following core components and concepts: 1. Thread factory: responsible for the strategy of creating new threads. 2. Work queue: used to store pending tasks, usually a blocking queue. When there are no tasks, the thread that obtains the task will be blocked. 3. Manager: responsible for assigning tasks to threads, recycling idle threads, and creating and destroying threads when needed. 4. Task interface: the interface that needs to be implemented for tasks processed by the thread pool.
[0069] It should be noted that the configuration information includes all information used to create a thread pool. For example, the configuration information may include core parameters of the specified thread pool, such as the number of core threads, the maximum number of threads, and the thread idle survival time.
[0070] Step S130: Based on the configuration information, a simulated client is created through the thread pool and the simulated client is run.
[0071] It should be noted that, in this step, the configuration information includes all information for creating and running the simulated client, for example, the configuration information may include the number and type of the simulated clients.
[0072] Step S140: Based on the device type of the simulated client, generate simulation data corresponding to the device type.
[0073] It should be noted that the correspondence between the device type of the simulated client and the corresponding simulated data can be set according to the specific needs of the application, and is not specifically limited here.
[0074] For example, the device types of the simulated client may include a battery management system (BMS) simulated client, a power conversion system (PCS) simulated client, an energy meter simulated client, a photovoltaic inverter simulated client, and a diesel generator simulated client, etc. The simulated data corresponding to the BMS simulated client may include device identity information and operating status data, etc., the simulated data corresponding to the PCS simulated client may include device identity information, grid-connected status data, and total power factor, etc., the simulated data corresponding to the energy meter simulated client may include device identity information, dispatching mode data, and system frequency, etc., the simulated data corresponding to the photovoltaic inverter simulated client may include device identity information, power, and power factor, etc., and the simulated data corresponding to the diesel generator simulated client may include device identity information, communication status data, and fuel consumption data, etc.
[0075] It should be noted that the method of generating simulation data may be any feasible method, for example, simulation data may be generated by a random number generator.
[0076] Step S150: based on the request type of the request of the simulated client, create a request object corresponding to the request type.
[0077] The request object includes request type, transaction identity information and simulated client identity information.
[0078] It should be noted that the request types of the simulated client request may include a login request, a data push request and a simulated data request.
[0079] It should be noted that the transaction identity information in this step is the identity information of any request sent by the simulated client, and the transaction identity information can be defined according to specific needs of the application, for example, it can be letters or numbers.
[0080] It should be noted that the simulated client identity information is the identity information of the simulated client that sends the request, and the identity information can be defined according to specific needs during application, for example, it can be letters or numbers.
[0081] Step S160: sending the request object and the simulation data to a server.
[0082] It should be noted that in this step, the method of sending the request object and the simulation data to the server can be any feasible method, such as sending them to the server through a network.
[0083] In an embodiment of the present invention, a client is simulated and run by a thread in a thread pool. Here, a plurality of simulated clients can be automatically created by using the thread pool, and simulated data can be generated by the simulated client. Obviously, the present invention avoids the use of a large number of physical devices to generate transmission data. In addition, the embodiment of the present invention can automatically generate transmission data based on a configuration file, avoiding the need to manually configure a large number of devices for data transmission in the prior art. In summary, the present invention solves a series of problems in the prior art caused by the need for transmission data of a large number of physical devices when testing network applications.
[0084] It is understandable that replacing hardware devices with software simulation not only saves procurement costs, but also avoids aging and damage of hardware devices, thus improving cost-effectiveness. The thread pool technology enables the system to efficiently manage resources, reduces system overhead by reusing threads, and improves overall efficiency. Automated data generation and transmission reduces human intervention, improves the convenience and efficiency of testing, and users only need simple configuration to complete complex testing tasks. Various test parameters are uniformly managed through configuration files, ensuring the consistency of the environment for each test, so that the test results are highly repeatable, which is convenient for subsequent analysis and comparison.
[0085] Optionally, in each implementation of the present invention, the network framework used to implement each step may be a Netty framework. The asynchronous and event-driven model provided by the Netty framework enables the system to maintain good performance and response speed in a high-concurrency environment, thereby simplifying the complexity of development and maintenance.
[0086] In an optional implementation, various abnormal situations in the simulated data transmission process can be captured and processed to ensure that the simulated data can be transmitted normally under abnormal conditions, avoiding system crashes or data loss due to abnormal conditions. In this implementation, the abnormal conditions can be set according to the specific needs of the application, such as network connection abnormalities, data format errors, etc.
[0087] In an optional implementation, creating a thread pool based on the configuration information in the configuration file includes:
[0088] Obtain the number of simulated clients in the configuration information;
[0089] Determine the number of threads in the thread pool based on the number of the simulated clients, wherein the number of threads is proportional to the number of the simulated clients;
[0090] Based on the number of threads, the thread pool is created.
[0091] It should be noted that the number of simulated clients configured in the configuration information can be set according to specific needs of the application and is not limited in detail here.
[0092] It should be noted that the proportional relationship between the number of threads and the number of simulated clients in this implementation can be determined according to the specific needs of the application. For example, the number of threads and the number of simulated clients can be equal, or the number of threads can be twice the number of simulated clients.
[0093] It should be noted that the method of creating a thread pool can be any feasible method, as long as the number of threads in the thread pool is ensured to be the set number of threads.
[0094] It can be understood that in this implementation, by setting the number of threads in the thread pool to be proportional to the number of simulated clients, it can be ensured that the threads in the thread pool can meet the demand for the number of simulated clients.
[0095] As a specific example, Figure 2 The figure shows a schematic diagram of the transmission process of client simulation data, which shows the connection relationship between the thread pool and the simulated client it creates and runs, wherein the thread pool manages multiple simulated clients (Netty clients 1-n) and the simulated clients interact with the server (Netty server).
[0096] In an optional implementation, determining the number of threads in the thread pool based on the number of simulated clients includes:
[0097] The number of threads in the thread pool is determined based on the number of simulated clients, network latency, and request processing time of the simulated clients.
[0098] It is understandable that threads are used to create and run simulated clients, so the number of threads should be determined based on the number of simulated clients so that the simulated clients can be effectively managed through the threads in the thread pool. In addition, network delays and simulated client request processing time will affect the task volume of threads in the thread pool, so the impact of network delays and simulated clients needs to be considered when determining the number of threads in the thread pool so that the threads in the thread pool can efficiently create and run simulated clients.
[0099] In an optional implementation, the number of threads in the thread pool is determined by the following formula:
[0100] N y =N x ×(1+d / t);
[0101] Among them, Ny is the number of threads, N x is the number of simulated clients, d is the network delay, and t is the request processing time.
[0102] It should be noted that in this implementation, when setting the number of threads, one simulated client can be allocated to each simulated client. In addition, when considering the simulated client occupying threads, this implementation also takes into account the network delay and the simulated client's request processing time. When the network delay is greater, the simulated client's request cannot be processed in time. At this time, more threads are needed to help process the simulated client's request to reduce the consequences of network delay. When the request processing time is shorter, the simulated client naturally sends out requests faster. At this time, more threads are naturally needed to manage the simulated client's requests.
[0103] Therefore, it can be understood that by utilizing the solution in this implementation, the number of threads in the thread pool can meet the requirements of efficient operation of the simulated client.
[0104] It should be noted that the method for obtaining network delay in this implementation can be any feasible method. For example, data can be sent from the sending port through the network and the sending time can be recorded, and data can be received from the receiving port and the receiving time can be recorded. The network delay can be obtained by calculating the receiving time and the sending time.
[0105] It should be noted that the method for determining the request processing time in this implementation can be any feasible method, for example, the processing time of multiple requests by the simulated client can be obtained, and then the average processing time of these requests can be used as the request processing time.
[0106] Optionally, the number of threads in the thread pool may be less than the number of cores of a central processor used to support the work of the thread pool.
[0107] It should be noted that the memory of the current server needs to be detected during the process of establishing the thread pool. When determining the number of threads in the thread pool, the memory occupied by the threads in the thread pool needs to not exceed the remaining memory of the current server.
[0108] Optionally, a load test can be performed. After the number of simulated clients is fixed, the number of threads in the thread pool is adjusted, and performance indicators such as the system's response time, throughput, and resource utilization are observed during the test. The number of threads with better performance indicators is determined as the number of threads corresponding to the number of clients.
[0109] In an optional implementation, sending the request object and the simulation data to the server includes:
[0110] Based on the device type of the simulated client, determining the number of simulation parameters corresponding to the device type;
[0111] Determine the capacity of a byte buffer and establish the byte buffer based on the number of simulation parameters and the number of simulated clients;
[0112] Filling the simulation data into the byte buffer;
[0113] The byte buffer and the request object are sent to a server.
[0114] It should be noted that the correspondence between the device model of the simulation client and the number of simulation parameters can be set according to the specific needs of the application, and is not limited in detail here. For example, the simulation parameters corresponding to the BMS simulation client may include device identity information, operation status information, communication status information, fault status information, charge and discharge status information, circuit breaker status information, relay status information, charge prohibition flag information, discharge prohibition status information, total voltage, total current, total power, total system on chip (System on Chip, SOC), total battery health status (State of Health, SOH), total standard operating procedure (Standard Operating Procedure, SOP), total sequence of events (Sequence of Events, SOE), single cell maximum value and index, single cell temperature maximum value and index and battery cluster information, and the corresponding number of simulation parameters is 21. The simulation parameters corresponding to the PCS simulation client may include device identity information, grid-connected status information, control mode information, scheduling mode information, three-phase voltage (corresponding to three voltages), three-phase current (corresponding to three currents), total active power, total reactive power, total apparent power, system frequency, daily charging power, discharging power, cumulative charging power, module temperature and ambient temperature. The corresponding number of simulation parameters is 19.
[0115] It should be noted that, in this implementation, the capacity of the byte buffer is directly proportional to the number of all simulation parameters corresponding to each simulation client.
[0116] It should be noted that the way to build a byte buffer has several advantages over other ways (such as directly using byte arrays or strings): First, the byte buffer is an efficient memory management abstraction provided by Netty. It can allocate and release memory when needed, thus avoiding frequent memory allocation and garbage collection pressure. This method is particularly advantageous when processing large amounts of data, and can effectively reduce memory fragmentation and improve memory usage efficiency. Secondly, the byte buffer supports the use of direct memory and heap memory. For scenarios that require zero-copy operations, you can use the byte buffer of direct memory, which avoids data copying during data transmission and improves the efficiency and speed of data transmission. Furthermore, the byte buffer provides a rich application programming interface and supports a variety of data operations, such as data reading, writing, slicing, etc., which enables more flexible data operations during data processing to cope with different needs and scenarios. In addition, the byte buffer provides support for byte orders of different platforms, which can easily convert byte orders to ensure data consistency and correctness in cross-platform data transmission. Finally, the byte buffer can more conveniently encrypt and decrypt data. In summary, by building a byte buffer, we can make full use of the efficient and scalable data processing capabilities provided by Netty, optimize memory management and data transmission efficiency, while ensuring data security and cross-platform compatibility, thereby improving the performance and stability of the overall system.
[0117] In an optional implementation, after determining the capacity of the byte buffer based on the number of simulation parameters and the number of simulation clients and establishing the byte buffer, and before filling the simulation data into the byte buffer, the method further includes:
[0118] Obtaining the timestamp when the simulation data is generated;
[0119] Fill the byte buffer with the timestamp.
[0120] As a specific example, the timestamp in this implementation may be a Unix timestamp.
[0121] It can be understood that filling the timestamp into the byte buffer can ensure the timeliness of the transmitted simulation data.
[0122] In an optional implementation, the generating, based on the device type of the simulated client, simulation data corresponding to the device type includes:
[0123] Based on the device type of the simulated client, generate initial data of each parameter corresponding to the device type;
[0124] Based on the parameter type of the parameter, determining a data update strategy corresponding to the parameter type;
[0125] Based on the data updating strategy, the initial data of the parameters are updated to generate simulation data.
[0126] It should be noted that, in this implementation, the correspondence between the device type of the simulated client and the initial data of each parameter can be set according to the specific method during application, which is not limited in detail here.
[0127] It should be noted that when generating the initial data of each parameter based on the device type of the simulated client, the generation method of the initial data corresponding to each parameter can be determined according to the specific needs of the application. For example, for ordinary parameters, the initial data can be generated by random numbers or standard values can be set. For associated parameters that change with changes in other parameters, the initial data of the associated parameters can be obtained based on the generated initial data of other parameters.
[0128] It should be noted that if the parameters corresponding to the device type have different characteristics under different conditions, it is necessary to simulate and generate simulation data of the parameters under various conditions.
[0129] As a specific example, common parameters of the BMS simulation client include device identity information, operating status information, communication status information, fault status information, charge and discharge status, circuit breaker status, relay status, charge prohibition flag, discharge prohibition flag, total voltage, total current, total power, total SOC, total SOH, total SOP and total SOE; parameters that have different characteristics under different conditions include battery maximum value and index and battery cluster information, where the battery maximum value and index value can be simulated under different battery conditions, and simulation data of each battery cluster can be generated under the conditions of different numbers and configurations of battery clusters.
[0130] As a specific example, the common parameters of the PCS simulation client may include grid-connected status, control mode, dispatching mode, three-phase voltage and current, total active power, total reactive power, total apparent power, total power factor, system frequency, module temperature and ambient temperature; associated parameters include the charging power, discharging power, cumulative charging power and discharging power of the day, and the power (common parameters) can be accumulated to obtain cumulative data.
[0131] As a specific example, common parameters of a photovoltaic inverter simulation client may include operating status, communication status, fault status, voltage, current information, frequency and temperature information; parameters that may have different characteristics under different conditions include irradiance, which can generate daily cumulative and total cumulative radiation by simulating different lighting conditions and power generation conditions; associated parameters include carbon dioxide emission reduction, which can be calculated through power generation.
[0132] As a specific example, common parameters of a diesel generator simulation client may include operating status, communication status, fault status, and system frequency; parameters with different characteristics under different conditions include power generation information, which simulates the power generation of a diesel generator under different loads and operating times, and can generate current and cumulative power generation; associated parameters include power, power factor, and fuel consumption information, where power and power factor can be derived from voltage and current, and fuel consumption information can be calculated based on power generation and operating time.
[0133] It should be noted that, in this implementation, the data update strategy corresponding to the parameter type can be set according to the specific needs of the application, and is not limited in detail here.
[0134] It can be understood that, in this implementation, by continuously updating the initial data of the parameters through the data update strategy, new simulation data of the parameters can be continuously obtained, so that the obtained simulation data has stronger real-time performance.
[0135] In an optional implementation, the determining, based on the parameter type of the parameter, a data update strategy corresponding to the parameter type includes:
[0136] When the parameter is an operating state parameter, determining that the data update strategy corresponding to the parameter is periodic update;
[0137] When the parameter is a control state parameter, determining that the data update strategy corresponding to the parameter is to update the control state parameter when a trigger condition is satisfied, wherein the control state parameter is used to control changes in the system operation mode;
[0138] When the parameter is an associated parameter of a dependent parameter, the data update strategy corresponding to the parameter is determined to be based on the update of the dependent parameter, and the associated parameter is updated synchronously, wherein the dependent parameter is the operating state parameter or the control state parameter.
[0139] It should be noted that in this implementation, the operating state parameters are parameters used to characterize the operating state of the simulation client, and can be set according to the specific needs of the application. For example, if the device type is a BMS simulation client, the corresponding operating state parameters can be total voltage, total current, total SOC, total SOH, single cell data and battery cluster data, etc.; if the device type is a PCS simulation client, the corresponding operating state parameters can be voltage, current, power factor, system frequency and temperature parameters, etc.; if the device type is an electric energy meter simulation client, the corresponding operating state parameters can be voltage, current, power factor, system frequency and temperature, etc.; if the device type is a photovoltaic inverter simulation client, the corresponding operating state parameters can be voltage, current, power, frequency and temperature, etc.; if the device type is a diesel generator simulation client, the corresponding operating state parameters can be voltage, current, power and frequency, etc.
[0140] It should be noted that in the present implementation, the control state parameters are parameters used to characterize the control state of the simulated client. By setting the control state parameters, the simulated client can be placed in different control scenarios. In this way, when the control state parameters are updated, when the simulated client meets the trigger conditions, that is, when the control scenario changes, the control state parameters are updated again. This allows the updated multiple sets of control state parameters to reflect different control scenarios, thereby ensuring the diversity and sufficiency of the simulation parameters.
[0141] It is understandable that there are associated parameters in the simulated client parameters that vary depending on changes in other parameters. When the dependent parameters are updated, the associated parameters need to be based on the corresponding relationship between the dependent parameters to ensure the reliability of the generated associated parameters.
[0142] As a specific example, when the device type is a BMS simulation client, operating status parameters such as total voltage, total current, total SOC, total SOH, single cell data, and battery cluster data can be periodically updated, and control status parameters such as operating status change parameters, charge and discharge status change parameters, and control status change parameters can be updated according to trigger conditions.
[0143] As a specific example, when the device type is a PCS analog client, operating status parameters such as voltage, current, power factor, and system frequency can be periodically updated, and control status parameters such as operating status change parameters, grid-connected status change parameters, and control mode change parameters can be updated according to trigger conditions. Since the accumulated electric energy is the accumulated amount of charging power and discharging power, the accumulated electric energy is an associated parameter of charging power and discharging power, and the charging power and discharging power are dependent parameters. Therefore, associated parameters such as the accumulated electric energy depend on the update of the dependent parameters.
[0144] As a specific example, when the device type is an electric energy meter simulation client, operating status parameters such as voltage, current, power factor, system frequency, module temperature and ambient temperature can be periodically updated, and control status parameters such as operating status change parameters, communication status change parameters and fault status change parameters can be updated according to trigger conditions, and associated parameters such as accumulated electric energy can be updated depending on the corresponding dependent parameters.
[0145] As a specific example, in a photovoltaic inverter simulation client whose device type is voltage, current, power, frequency, and temperature, etc., operating state parameters such as voltage, current, power, frequency, and temperature can be changed periodically, and control state parameters such as operating state change parameters, communication state change parameters, and fault state change parameters can be updated according to trigger conditions. Since the inverter's carbon dioxide emission reduction is calculated through power generation, and power generation is calculated through current and irradiance, power generation as an associated parameter depends on changes in the two dependent parameters of current and irradiance, and carbon dioxide as an associated parameter depends on changes in the dependent parameter of power generation, so associated parameters such as carbon dioxide emission reduction and power generation depend on corresponding dependent parameter updates.
[0146] As a specific example, when the device type is a diesel generator simulation client, the operating status parameters such as voltage, current, power and frequency can be changed periodically, and the control status parameters such as the diesel generator's operating status change parameters, communication status change parameters and fault status change parameters can be updated according to the trigger conditions. Since the power generation is calculated based on the current and power generation efficiency, the related parameters such as the power generation depend on the corresponding dependent parameters to be updated.
[0147] In an optional implementation, sending the request object and the simulation data to the server includes:
[0148] Encode the request object into a string and then encapsulate it to obtain a real-time data object;
[0149] Encrypting the real-time data object by using an encryption algorithm;
[0150] Calculating the length of the encrypted real-time data object;
[0151] Fill the encrypted real-time data object and the length into a byte buffer;
[0152] The byte buffer and the simulation data are sent to a server.
[0153] Specifically, the method of encoding the request object can be any achievable method, for example, the request object can be first converted into a Base64-encoded string, and then the encoded string can be encapsulated as a real-time data object, and the real-time data object can be further converted into a JSON string. It is understandable that converting the request object into a Base64-encoded string and a JSON string facilitates the transmission and parsing of the request object.
[0154] Specifically, the encryption algorithm used to encrypt the real-time data object in this implementation can be any achievable method, for example, it can be an Advanced Encryption Standard (AES) encryption algorithm. It is understandable that encrypting the real-time data object can ensure the security of the real-time data object.
[0155] Optionally, after calculating the length of the encrypted real-time data object, the data length may be converted into a big-endian format, and the real-time data object and the length may be filled into a byte buffer. The big-endian format may improve the efficiency and compatibility of data exchange.
[0156] Based on the above-mentioned method for transmitting client simulation data, an embodiment of the present invention provides a device for transmitting client simulation data, such as Figure 3 As shown, the present invention provides a transmission device for client simulation data, comprising:
[0157] A reading module 310 is used to read a configuration file required by the client to simulate data;
[0158] A first creation module 320, used to create a thread pool based on the configuration information in the configuration file;
[0159] A second creation module 330, configured to create a simulated client and run the simulated client through the thread pool based on the configuration information;
[0160] A generating module 340, configured to generate simulation data corresponding to the device type based on the device type of the simulated client;
[0161] A third creation module 350, configured to create a request object corresponding to the request type based on the request type of the request of the simulated client, wherein the request object includes the request type, transaction identity information and simulated client identity information;
[0162] The sending module 360 is used to send the request object and the simulation data to the server.
[0163] For other details about how the modules in the above-mentioned client simulation data transmission device implement the above-mentioned technical solution, please refer to the description of the client simulation data transmission method provided in the above-mentioned invention embodiment, which will not be repeated here.
[0164] Based on the above client simulation data transmission method, such as Figure 4 As shown, an embodiment of the present invention further provides a schematic diagram of the structure of a transmission device for client simulation data, the transmission device includes a processor 41 and a memory 42 coupled to the processor 41. The memory 42 stores a computer program, and when the computer program is executed by the processor 41, the processor 41 executes the steps of the transmission method for client simulation data in the above embodiment.
[0165] For other details about how the processor 41 in the above-mentioned client simulation data transmission device implements the above-mentioned technical solution, please refer to the description of the client simulation data transmission method provided in the above-mentioned invention embodiment, which will not be repeated here.
[0166] Among them, the processor 41 can also be called a CPU (Central Processing Unit), and the processor 41 may be an integrated circuit chip with signal processing capabilities; the processor 41 can also be a general-purpose processor, DSP (Digital Signal Process), ASIC (Application Specific Integrated Circuit), FPGA (Field Programmable Gate Array) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, among which the general-purpose processor can be a microprocessor or the processor 41 can also be any conventional processor, etc.
[0167] like Figure 5 As shown, the embodiment of the present invention also provides a schematic diagram of the structure of a computer-readable storage medium, on which a readable computer program 51 is stored; wherein the computer program 51 can be stored in the above storage medium in the form of a software product, including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, magnetic disk or optical disk, ROM (Read-Only Memory), RAM (Random Access Memory) and other media that can store program codes, or terminal devices such as computers, servers, mobile phones, and tablets.
[0168] In the several embodiments provided by the present invention, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation, such as multiple modules or components can be combined or integrated into another system, 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 an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.
[0169] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0170] In addition, each functional module in each embodiment of the present invention may be integrated into a processing module, or each module may exist physically separately, or two or more modules may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may be stored in a computer-readable storage medium.
[0171] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0172] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium), or a semiconductor medium (e.g., an SSD (solid state disk, solid state hard disk)).
[0173] The technical solution provided by the present invention is introduced in detail above. The present invention applies specific examples to illustrate the principle and implementation mode of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation mode and application scope. In summary, the content of this specification should not be understood as limiting the present invention.
[0174] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, optical storage, etc.) containing computer-usable program code.
[0175] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0176] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0177] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0178] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A method for transmitting client simulation data, characterized in that: include: Read the configuration file required for client simulation data; Based on the configuration information in the configuration file, create a thread pool; Based on the configuration information, create a simulated client through the thread pool and run the simulated client; Based on the device type of the simulated client, generating simulation data corresponding to the device type; Based on the request type of the request of the simulated client, create a request object corresponding to the request type, wherein the request object includes the request type, transaction identity information and simulated client identity information; The request object and the simulation data are sent to a server.
2. The method for transmitting client simulation data according to claim 1, characterized in that: The step of creating a thread pool based on the configuration information in the configuration file includes: Obtain the number of simulated clients in the configuration information; Determine the number of threads in the thread pool based on the number of the simulated clients, wherein the number of threads is proportional to the number of the simulated clients; Based on the number of threads, the thread pool is created.
3. The method for transmitting client simulation data according to claim 2, characterized in that: The determining the number of threads in the thread pool based on the number of simulated clients includes: The number of threads in the thread pool is determined based on the number of simulated clients, network latency, and request processing time of the simulated clients.
4. The method for transmitting client simulation data according to claim 3, characterized in that: The number of threads in the thread pool is determined by the following formula: N y =N x ×(1+d / t); Among them, N y is the number of threads, N x is the number of simulated clients, d is the network delay, and t is the request processing time.
5. The method for transmitting client simulation data according to claim 1, characterized in that: The sending the request object and the simulation data to the server includes: Based on the device type of the simulated client, determining the number of simulation parameters corresponding to the device type; Determine the capacity of a byte buffer and establish the byte buffer based on the number of simulation parameters and the number of simulated clients; Filling the simulation data into the byte buffer; The byte buffer and the request object are sent to a server.
6. The method for transmitting client simulation data according to claim 5, characterized in that: After determining the capacity of the byte buffer based on the number of simulation parameters and the number of simulation clients and establishing the byte buffer, and before filling the simulation data into the byte buffer, the method further includes: Obtaining the timestamp when the simulation data is generated; Fill the byte buffer with the timestamp.
7. The method for transmitting client simulation data according to claim 1, characterized in that: The step of generating simulation data corresponding to the device type based on the device type of the simulated client includes: Based on the device type of the simulated client, generate initial data of each parameter corresponding to the device type; Based on the parameter type of the parameter, determining a data update strategy corresponding to the parameter type; Based on the data updating strategy, the initial data of the parameters are updated to generate simulation data.
8. The method for transmitting client simulation data according to claim 7, characterized in that: The determining, based on the parameter type of the parameter, a data update strategy corresponding to the parameter type includes: When the parameter is an operating state parameter, determining that the data update strategy corresponding to the parameter is periodic update; When the parameter is a control state parameter, determining that the data update strategy corresponding to the parameter is to update the control state parameter when a trigger condition is satisfied, wherein the control state parameter is used to control changes in the system operation mode; When the parameter is an associated parameter of a dependent parameter, the data update strategy corresponding to the parameter is determined to be based on the update of the dependent parameter, and the associated parameter is updated synchronously, wherein the dependent parameter is the operating state parameter or the control state parameter.
9. The method for transmitting client simulation data according to claim 1, characterized in that: The sending the request object and the simulation data to the server includes: Encode the request object into a string and then encapsulate it to obtain a real-time data object; Encrypting the real-time data object by using an encryption algorithm; Calculating the length of the encrypted real-time data object; Fill the encrypted real-time data object and the length into a byte buffer; The byte buffer and the simulation data are sent to a server.
10. A transmission device for client simulation data, characterized in that: include: The reading module is used to read the configuration files required by the client to simulate data; A first creation module, used to create a thread pool based on the configuration information in the configuration file; A second creation module, used to create a simulated client and run the simulated client through the thread pool based on the configuration information; A generating module, configured to generate simulation data corresponding to the device type based on the device type of the simulated client; A third creation module, configured to create a request object corresponding to the request type based on the request type of the request of the simulated client, wherein the request object includes the request type, transaction identity information and simulated client identity information; A sending module is used to send the request object and the simulation data to the server.
