A networking method, device, equipment and storage medium

Automatically determine the master-slave relationship through the election and response data frames between terminal devices, solving the problem of cumbersome and time-consuming networking in the prior art, realizing automatic networking, and improving efficiency and stability.

CN118042555BActive Publication Date: 2025-01-07RENAC POWER TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202410188815.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-02-20
Publication Date
2025-01-07
Estimated Expiration
2044-02-20

AI Technical Summary

Technical Problem

In the prior art, the networking process of terminal equipment is cumbersome and time-consuming, and requires manual on-site configuration, resulting in inefficiency.

Method used

By broadcasting campaign data frames and answer data frames, the terminal device automatically determines the host and slave, realizing automatic networking and reducing manual intervention.

Benefits of technology

It improves networking efficiency, simplifies the configuration process, reduces labor and time costs, and ensures the stable operation of the energy storage system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118042555B_ABST
    Figure CN118042555B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of communication technology, and discloses a networking method, device, equipment and storage medium, the method comprising: broadcasting a first campaign data frame; when receiving the first campaign data frame or a second campaign data frame broadcasted by other terminal devices, feeding back a first response data frame; wherein the first response data frame includes the device information of the terminal device; based on the reception time of the first campaign data frame and each second campaign data frame, determining the host and slave from the terminal device and other terminal devices; when the terminal device acts as the host, receiving the second response data frame fed back by other terminal devices, establishing a connection with other terminal devices based on the second response data frame to complete the networking operation; wherein the second response data frame includes the device information of other terminal devices. The present invention can solve the problem that the manual networking process of terminal devices is cumbersome and time-consuming.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communication technology, and in particular to a networking method, an apparatus, a terminal device and a computer-readable storage medium. Background Art

[0002] In industrial and commercial energy storage systems, the energy management system is responsible for the control strategy of the energy storage system on the one hand, and for monitoring the fault anomalies in the operation of the energy storage system on the other hand, so as to protect the equipment in time when the equipment fails and ensure the safety of the equipment. In order to facilitate management, it is often necessary to network multiple terminal devices in the energy management system to achieve parallel communication of multiple terminal devices.

[0003] In the related art, a networking method of pre-defining a host is mainly adopted, and corresponding master-slave configurations are manually performed on each terminal device to network multiple terminal devices.

[0004] However, this networking mode of pre-defining the host requires manual reconfiguration on site whenever any terminal device in the parallel communication fails to charge or discharge, is shut down, or fails. The configuration process is cumbersome and time-consuming. Summary of the invention

[0005] In view of this, the present invention provides a networking method, apparatus, device and storage medium to solve the problem that the manual networking process of terminal devices is cumbersome and time-consuming.

[0006] To achieve the above object, an embodiment of the present invention provides a networking method applicable to a terminal device to be networked, the method comprising:

[0007] Broadcast the first campaign data frame;

[0008] When receiving the first campaign data frame or the second campaign data frame broadcasted by other terminal devices, feeding back a first response data frame; wherein the first response data frame includes device information of the terminal device;

[0009] Determine a master and a slave from the terminal device and the other terminal devices based on the reception time of the first campaign data frame and each of the second campaign data frames;

[0010] When this terminal device acts as the host, it receives the second response data frame fed back by the other terminal devices, and establishes a connection with the other terminal devices based on the second response data frame to complete the networking operation; wherein the second response data frame includes the device information of the other terminal devices.

[0011] As an improvement of the above solution, the broadcasting of the first campaign data frame includes:

[0012] Obtaining a target time window; wherein the target time window is determined by the device power-on duration of the terminal device and the other terminal devices;

[0013] Determining a delay duration based on the target time window;

[0014] After waiting for the delay time, the first campaign data frame is broadcast; wherein the broadcast time of the first campaign data frame is different from the broadcast time of the second campaign data frame.

[0015] As an improvement of the above solution, the determining of the master and the slave from the terminal device and the other terminal devices based on the reception time of the first campaign data frame and each of the second campaign data frames includes:

[0016] If the first campaign data frame is the first received campaign data frame, determining the terminal device as a host, and determining the other terminal devices as slaves;

[0017] If any of the second campaign data frames is the first received campaign data frame, the other terminal device corresponding to the second campaign data frame is determined to be a host, and the current terminal device and the remaining other terminal devices are determined to be slaves.

[0018] As an improvement of the above solution, the method further includes:

[0019] When this terminal device acts as the host, based on the reception time of the first campaign data frame and the second campaign data frame, this terminal device and the other terminal devices are sorted in chronological order to generate a master-slave device sequence table, and the master-slave device sequence table is sent to each of the slaves; wherein the master-slave device data table is used to determine the campaign order of the host and the slave, as well as each of the slaves.

[0020] As an improvement of the above solution, the method further includes:

[0021] When the terminal device as the host detects that any of the slaves is offline, the master-slave device sequence table is updated, and the updated master-slave device sequence table is sent to other slaves.

[0022] As an improvement of the above solution, the method further includes:

[0023] Before the terminal device takes the initiative to go offline as the host, it sends an exit instruction to each of the slaves, so that each of the slaves responds to the exit instruction and selects a new host based on the master-slave device sequence table.

[0024] As an improvement to the above solution, when the terminal device as the slave detects that the master fails and is offline, it competes with other slaves for the master again.

[0025] To achieve the above object, an embodiment of the present invention further provides a networking device, which is applicable to a terminal device to be networked, and the device includes:

[0026] A host election module, used for broadcasting a first election data frame;

[0027] A data response module is used to feed back a first response data frame when receiving the first campaign data frame or a second campaign data frame broadcasted by other terminal devices; wherein the first response data frame includes device information of the terminal device;

[0028] A master-slave determination module, configured to determine a master and a slave from the terminal device and the other terminal devices based on the reception time of the first campaign data frame and each of the second campaign data frames;

[0029] The host networking module is used to receive the second response data frame fed back by the other terminal devices when the terminal device acts as the host, and establish a connection with the other terminal devices based on the second response data frame to complete the networking operation; wherein the second response data frame includes the device information of the other terminal devices.

[0030] To achieve the above objectives, an embodiment of the present invention further provides a terminal device, comprising: a memory and a processor, the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the networking method of any of the above embodiments by executing the computer instructions.

[0031] To achieve the above objectives, an embodiment of the present invention further provides a computer-readable storage medium, on which computer instructions are stored, and the computer instructions are used to enable a computer to execute the networking method of any of the above implementations.

[0032] Compared with the prior art, one embodiment of the above invention has the following beneficial effects:

[0033] In the present invention, the terminal device to be networked first broadcasts a first election data frame. Then, upon receiving the first election data frame or the second election data frame broadcasted by other terminal devices, a first response data frame is fed back, and the first response data frame includes the device information of the terminal device. Then, based on the reception time of the first election data frame and each second election data frame, the host and the slave are determined from the terminal device and other terminal devices. Therefore, the terminal device to be networked can automatically elect the host and the slave. When the terminal device is the host, the second response data frame fed back by other terminal devices is received, and a connection is established with other terminal devices based on the second response data frame to complete the networking operation, and the second response data frame includes the device information of other terminal devices. Therefore, the problem that the manual networking process of terminal devices is cumbersome and time-consuming can be solved to improve the networking efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0035] Figure 1 is a flow chart of a networking method according to an embodiment of the present invention;

[0036] Figure 2 is a flow chart of a networking method according to an embodiment of the present invention;

[0037] Figure 3 is a flow chart of another networking method according to an embodiment of the present invention;

[0038] Figure 4 is a structural block diagram of a networking device according to an embodiment of the present invention;

[0039] Figure 5 is a structural block diagram of a terminal device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0040] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0041] The industrial and commercial energy storage system consists of a battery system, a battery management system BMS, an energy storage inverter system PCS, an energy management system EMS, a transformer, an air conditioner, a fire protection system, a monitoring system, and an alarm system. Unlike the independent construction of the energy storage inverter system PCS and batteries in large energy storage power stations, the industrial and commercial energy storage system is mainly built in an integrated manner and managed in the form of energy storage cabinets. In most cases, multiple energy storage cabinets are often required for parallel operation, so an overall and systematic energy management system is required for management.

[0042] In the related art, the following two networking methods are mainly used: the first is to use a two-layer energy management system architecture in the energy management system for a large number of industrial and commercial energy storage in parallel. The second is to use the master-slave mode, pre-define the host, and perform corresponding master-slave configuration on all terminal devices. However, in the first networking method, since the two-layer energy management system architecture requires increased hardware investment, when there is a problem with the hardware, the entire energy management system will stop running. Therefore, the first networking method has high requirements for hardware reliability and stability. In the second networking method, since the terminal equipment of industrial and commercial parallel machines sometimes does not charge or discharge, shuts down, or shuts down due to a fault, it is necessary to manually reconfigure the site, and the configuration process is cumbersome and time-consuming. In addition, when the energy management system is parallel, a host is required to count the power data of all energy storage cabinets, and allocate the charge and discharge of each device according to the operating status. All devices are networked through the Transmission Control Protocol (TCP). The host actively connects all slaves, establishes a handshake, and sends data. If the host is shut down, the energy management system will have no host to manage and distribute energy, and the entire system will be shut down, which is not conducive to the stable operation of the energy storage system.

[0043] In view of this, according to an embodiment of the present invention, a networking method embodiment is provided, which can be used for the terminal devices to be networked in the above energy management system. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that here.

[0044] Figure 1 is a flow chart of a networking method according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps:

[0045] Step S11, broadcasting the first campaign data frame.

[0046] Specifically, the first campaign data frame is broadcast based on an algorithm for randomly and periodically sending a contention data packet, and the first campaign data frame is broadcast periodically through a user datagram protocol (UDP, User Datagram Protocol).

[0047] Exemplarily, taking the example of multiple terminal devices receiving information through a receiving port and sending information through a sending port, each terminal device sends a campaign data frame to the local area network through the sending port, and the local area network transmits the received campaign data frame to each terminal device through the receiving port.

[0048] Specifically, the first election data frame includes an election identifier, a device code of the terminal device, and a communication address of the terminal device, wherein the election identifier is used to determine that the current data frame is an election data frame for the election host, and the communication address is an IP address.

[0049] Step S12, when receiving the first campaign data frame or the second campaign data frame broadcasted by other terminal devices, feeding back a first response data frame; wherein the first response data frame includes device information of the terminal device.

[0050] Specifically, the second campaign data frame includes a campaign identifier, a device code of other terminal devices, and a communication address of other terminal devices, wherein the number of other terminal devices is greater than or equal to one.

[0051] Furthermore, the first response data frame also includes a response identifier; wherein the response identifier is used to determine that the current data frame is a campaign data frame for the campaign host. The device information of the terminal device includes the device code of the terminal device and the communication address of the terminal device. In addition, the device information also includes the device level of the terminal device and other information used for networking control.

[0052] Optionally, when receiving the first campaign data frame or the second campaign data frame broadcast by other terminal devices, the method also includes stopping broadcasting the first campaign data frame to avoid additional occupation of the information transmission channel, thereby improving the networking efficiency of the terminal device and other terminal devices.

[0053] Step S13, based on the reception time of the first campaign data frame and each second campaign data frame, determining the master and slave from the terminal device and other terminal devices.

[0054] In the embodiment of the present application, the terminal device corresponding to the first campaign data frame received by the terminal device is used as the host, and the remaining terminal devices are used as slaves. It is not limited that the terminal device corresponding to the second campaign data frame received by the terminal device can be used as the host, and the remaining terminal devices can be used as slaves, which can be determined according to the actual situation.

[0055] Step S14, when the terminal device acts as a host, it receives the second response data frame fed back by other terminal devices, and establishes a connection with other terminal devices based on the second response data frame to complete the networking operation; wherein the second response data frame includes device information of other terminal devices.

[0056] Furthermore, the second response data frame includes a response identifier. The device information of other terminal devices includes the device code of other terminal devices and the communication address of other terminal devices. In addition, the device information of other terminal devices also includes the device level of other terminal devices and other information used for networking control.

[0057] The networking method provided in this embodiment is that each terminal device automatically broadcasts a campaign data frame, and each terminal device feeds back a response data frame when receiving any campaign data frame to inform the sender of the device information of the terminal device. Based on the reception time of the received campaign data frame, the host and the slave are determined from each terminal device. Therefore, the terminal device can automatically elect the host and the slave without the need to manually go to the site to configure the master and the slave, saving networking time and improving networking efficiency. After the host and the slave are elected, the device terminal as the host establishes a connection with each slave according to the response data frame of the received slave to complete the networking operation. Therefore, the automatic networking of the terminal device can be realized without increasing additional hardware investment, and the networking process is simple and easy to maintain.

[0058] As one of the optional implementations, broadcasting the first campaign data frame in the above step S11 includes: obtaining a target time window; wherein the target time window is determined by the power-on time of the terminal device and other terminal devices; determining a delay time based on the target time window; after waiting for the delay time, broadcasting the first campaign data frame; wherein the broadcast time of the first campaign data frame is different from the broadcast time of the second campaign data frame.

[0059] Optionally, the above-mentioned target time window is determined according to the following steps: obtaining the power-on startup time and device self-test time of the terminal device and other terminal devices; determining the device power-on time of the terminal device and other terminal devices based on the power-on startup time and device self-test time; determining the power-on delay based on the time difference between the longest and shortest power-on times of all devices; and determining the target time window based on the power-on delay.

[0060] For example, when a terminal device is turned on, there is a process of booting up and self-testing. During this process, there is a 2-3s delay between the longest and shortest time of each terminal device. Therefore, in order to prevent each terminal device from sending data frames at the same time as much as possible, the Transmission Control Protocol (TCP) has a 7-8s time window at random time. Optionally, the target time window is 100ms, so the probability of each terminal device sending a campaign data frame at the same time is relatively small.

[0061] Furthermore, this embodiment can obtain the target time window when the terminal device is turned on to randomly obtain the delay time within the target time window, so that after the terminal device is turned on, it waits for the delay time and broadcasts the first campaign data frame.

[0062] The networking method provided in this embodiment determines the delay duration based on the target time window determined by the power-on duration of the terminal device and other terminal devices, and then broadcasts the first campaign data frame based on the delay duration. The broadcast time of the first campaign data frame is different from the broadcast time of the second campaign data frame of other terminal devices. Therefore, it can effectively avoid that each terminal device sends the campaign data frame at the same time, thereby reducing the probability of networking errors and ensuring the stability of terminal device networking.

[0063] As one of the optional implementation modes, in the above step S13, based on the reception time of the first campaign data frame and each second campaign data frame, the host and the slave are determined from the present terminal device and other terminal devices, including: if the first campaign data frame is the first received campaign data frame, then the present terminal device is determined to be the host, and the other terminal devices are determined to be slaves; if any second campaign data frame is the first received campaign data frame, then the other terminal devices corresponding to the second campaign data frame are determined to be the host, and the present terminal device and the remaining other terminal devices are determined to be slaves.

[0064] In the networking method provided in this embodiment, since the order in which each terminal device receives the election data frame is consistent with the order in which each terminal device sends the election data frame, the terminal device corresponding to the first election data frame is used as the host, and the remaining terminal devices are used as slaves. This can ensure the consistency of the host determined by each terminal device to a certain extent, so as to ensure the smooth operation of the networking process. At the same time, due to the unique sending time point of the first terminal device that sends the election data frame, the first terminal device that sends the election data frame can avoid competing with the remaining terminal devices in the same time window, reducing the possibility of collision, and can ensure to a certain extent that only one terminal device competes at the same time. Moreover, by using the first terminal device that sends the election data frame as the host, the master-slave election can also be completed earlier, so that the host can coordinate the remaining terminal devices to complete the networking earlier, thereby further ensuring the stable operation of the energy management system and the energy storage system.

[0065] In addition, the terminal device can also feed back the determined master and slave information to other terminal devices, and when receiving the master confirmation information sent by other terminal devices, the master remains unchanged.

[0066] As one of the optional implementation modes, the networking method provided by the present invention also includes: when the terminal device acts as a host, based on the reception time of the first campaign data frame and the second campaign data frame, the terminal device and other terminal devices are sorted in chronological order to generate a master-slave device sequence table, and the master-slave device sequence table is sent to each slave; wherein the master-slave device data table is used to determine the campaign order of the host and the slave, as well as each slave.

[0067] The networking method provided in this embodiment sorts the terminal device and other terminal devices in chronological order based on the reception time of the first contest data frame and the second contest data frame, generates a master-slave device sequence table, and sends the master-slave device sequence table to each slave. Therefore, the consistency of the master-slave device sequence table between each terminal device can be ensured to ensure the stable operation of each terminal device.

[0068] For example, Figure 2As shown, taking the networking of terminal device 1, terminal device 2, terminal device 3, terminal device 4 and terminal device 5 as an example, terminal device 1, terminal device 2, terminal device 3, terminal device 4 and terminal device 5 send election data frames to the local area network. Assuming that the time sequence of sending election data frames to the local area network is terminal device 1, terminal device 3, terminal device 5, terminal device 2 and terminal device 4, each terminal device informs the local area network of the order in which it receives the election data frames. Each terminal device unanimously agrees that terminal device 1 is the host, then terminal device 1 connects terminal device 2, terminal device 3, terminal device 4 and terminal device 5 through the transmission control protocol and starts data communication. Terminal device 1, as the host, sends its master-slave device sequence table to terminal device 2, terminal device 3, terminal device 4 and terminal device 5.

[0069] As one optional implementation, the networking method provided by the present invention further includes: when the terminal device as the host detects that any slave is offline, updating the master-slave device sequence table and sending the updated master-slave device sequence table to other slaves.

[0070] Specifically, the following steps are used to detect whether a slave is offline: when the terminal device as the host detects that it is disconnected from any slave, it sends a preset number of connection requests to the slave; if it is unable to re-establish a connection with the slave, it determines that the slave is offline; if it re-establishes a connection with the offline slave, it determines that the slave is online. Therefore, it is possible to avoid false detection of the slave being offline due to unstable communication. Optionally, the preset number of times is three times.

[0071] The networking method provided in this embodiment updates the master-slave device sequence table when the host detects that any slave is offline, and sends the updated master-slave device sequence table to other slaves. Therefore, the consistency of the master-slave sequence table between various terminal devices can be ensured to ensure stable operation between various online terminal devices.

[0072] As one of the optional implementation modes, the networking method provided by the present invention also includes: before the terminal device actively goes offline as a host, sending an exit instruction to each slave, so that each slave responds to the exit instruction and selects a new host based on the master-slave device sequence table.

[0073] In the networking method provided in this embodiment, the host sends an exit command to each slave before actively going offline, so that each slave re-selects a new host based on the master-slave device sequence table. When any terminal device is shut down, a new host can be quickly selected to perform energy management and distribution, thereby ensuring the safe operation of the energy storage system.

[0074] Specifically, before the host actively goes offline, the host can determine the election order of each slave according to the master-slave device sequence table, determine the next master according to the election order, and inform each slave of the determined next master through an exit instruction. In addition, the slave can also respond to the exit instruction, and after the host goes offline, each slave determines the election order of each slave according to the stored master-slave device sequence table to elect the next master.

[0075] For example, Figure 2 As shown, if the terminal device 1 is actively offline, in the subsequent process, the terminal device 3 is directly used as the host to connect to other slaves.

[0076] As an optional implementation manner, the networking method provided by the present invention further includes: when the terminal device as a slave detects that the host fails and is offline, it re-compete for the master with other slaves.

[0077] Specifically, the following steps are used to detect whether the host is offline due to a fault: when the host's exit command is not received, if the host's control command, query command is not received within a preset host detection period, or the communication with the host is disconnected, the host is determined to be offline due to a fault; if the host's control command, query command is received within a preset host detection period, or the communication with the host is connected, the host is determined to be online. When the host's exit command is received, the host is determined to be offline actively.

[0078] Specifically, re-election for the master with other slaves means returning to step S11 to redetermine the master and slaves.

[0079] The networking method provided in this embodiment is that when the terminal device as a slave detects that the host fails and goes offline, it re-compete for the host with other slaves. Therefore, when the host fails, a new host can still be automatically selected to perform energy management and allocation.

[0080] As one of the optional implementation modes, the networking method provided by the present invention also includes: the new host regards the offline host as a slave, and adjusts the election order of the offline host to the last terminal device in the election to update the master-slave sequence table; and sends the updated master-slave sequence table to each slave.

[0081] As one of the optional implementation modes, the networking method provided by the present invention also includes: when the terminal device as a host detects the third election data frame sent by the target terminal device, the target terminal device is added as the last election terminal device to the master-slave sequence table, and each slave is notified; as a host, a connection is established with the target terminal device to perform corresponding communication and control operations on the target terminal device.

[0082] It should be noted that the target terminal device can be a new terminal device or a terminal device that is back online after being offline. Specifically, as long as there is a broadcast on the local area network, the registration information is compared, and the terminal device that has not been registered is a new terminal device.

[0083] It should be noted that in order to ensure the stable operation of the energy management system, the master-slave sequence table needs to be updated every time the information of the terminal device changes, and the updated master-slave sequence table is sent to each slave.

[0084] Exemplarily, the terminal devices are sorted in the time sequence according to the reception time of the campaign data frame. In the master-slave sequence table, the first terminal device is the terminal device corresponding to the first received campaign data frame, the second terminal device is the terminal device corresponding to the second received campaign data frame, and so on. The last terminal device is the terminal device corresponding to the last received campaign data frame. Then, the campaign order can be reflected by the arrangement order of each terminal device in the master-slave sequence table. Based on this, after any host goes offline, the offline host is arranged at the end of the master-slave sequence table. And, when any new terminal device joins or an offline slave comes online, the new terminal device or the slave that comes back online is arranged at the end of the master-slave sequence table.

[0085] It is worth noting that, in order to verify the effectiveness of the networking method of the present invention, five industrial and commercial energy storage devices were networked in the laboratory using the networking method provided by the embodiment of the present invention. After testing, these five industrial and commercial energy storage devices can complete the automatic master-slave management of the master and slave machines within 5 seconds. This networking method does not require relevant personnel to do any master-slave machine configuration, which simplifies the requirements for on-site configuration to achieve unmanned management. When any host is turned off, the next host can be automatically elected within 10 seconds based on the offline judgment configured by the present invention. When any slave is turned off, the host will update the offline information of the slave and actively synchronize the information to the remaining slaves. When an abnormal situation occurs, it can also automatically re-network in a very short time to ensure the reliability and stability of the energy management system.

[0086] As an example, the networking method provided by the present invention is described below with a specific embodiment. Figure 3As shown, in a specific embodiment, the networking communication method of the terminal device includes the following steps: step S21, all terminal devices are turned on for the first time, and the election process begins, and then step S22 is executed; step S22, after all terminal devices are turned on, they wait randomly within a 10s period, and then step S23 is executed; step S23, all terminal devices send election data frames to compete for the host; wherein the election data frame includes an election identification, a device code, and a communication address, and then step S24 is executed; step S24, all terminal devices receive the election data frames in sequence, select the terminal device corresponding to the first received election data frame as the host, and the remaining terminal devices as slaves, and establish a master-slave device sequence table according to the time sequence of receiving the election data frames, and then step S25 is executed; step S25, when each terminal device receives the first election data frame, it stops sending the election data frame and feeds back a response data frame to the host; wherein the response data frame includes a response identification, the device code and the communication address of the terminal device, Then execute step S26; step S26, the terminal device as the host establishes a TCP connection with each slave according to the received response data frame, and then executes step S27; step S27, the host sends a master-slave device sequence table to each slave, and then executes step S28; step S28, the host starts to enter the control process, and then executes step S29; step S29, the host periodically detects the TCP communication status with the slave, and then executes step S30; step S30, the host determines whether there is any slave offline according to the TCP communication status with the slave, if so, execute step S31, if not, return to step S28; step S31, the host reconnects to the slave 3 times, and then executes step S32; step S32, whether the host and the slave are successfully connected, if so, return to step S28, if not, execute step S33; step S33, the host updates the status of the slave in the master-slave device sequence table, and sends the updated master-slave device sequence table to all slaves, and then returns to step S28, and the host continues to control the slave.

[0087] It is understandable that complex network configuration will make the operation and maintenance of the energy management system difficult. If the terminal equipment is manually configured on site for master-slave networking, a large amount of manpower and time costs will be increased. However, by adopting the networking method provided in the embodiment of the present invention, the terminal equipment can automatically form a network. Even if any terminal device is shut down or fails, the remaining terminal devices can have corresponding hosts to manage and distribute energy to maintain the normal operation of the energy storage system. Compared with the networking method of the two-layer energy management system architecture, the networking method provided in this embodiment does not require additional hardware investment. Compared with the networking method of manually configuring the master and slave machines, the networking method provided in this embodiment allows the terminal equipment to automatically compete for the master and slave machines, which is simple to operate and maintain, and can save manpower and time costs.

[0088] In this embodiment, a networking device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0089] This embodiment provides a networking device, which is applicable to terminal devices to be networked. Figure 4 As shown, the networking device includes:

[0090] The host election module 41 is used to broadcast a first election data frame;

[0091] The data response module 42 is used to feedback a first response data frame when receiving the first election data frame or the second election data frame broadcasted by other terminal devices; wherein the first response data frame includes device information of the terminal device;

[0092] A master-slave determination module 43, for determining a master and a slave from the terminal device and other terminal devices based on the reception time of the first campaign data frame and each second campaign data frame;

[0093] The host networking module 44 is used to receive the second response data frame fed back by other terminal devices when the terminal device acts as a host, and establish a connection with other terminal devices based on the second response data frame to complete the networking operation; wherein the second response data frame includes device information of other terminal devices.

[0094] In some optional implementations, the host election module 41 includes:

[0095] A time window acquisition unit, used to acquire a target time window; wherein the target time window is determined by the device power-on time of the terminal device and other terminal devices;

[0096] A delay duration determining unit, used to determine the delay duration based on the target time window;

[0097] The campaign data broadcast unit is used to broadcast the first campaign data frame after waiting for a delay time; wherein the broadcast time of the first campaign data frame is different from the broadcast time of the second campaign data frame.

[0098] In some optional implementations, the master-slave determination module 43 includes:

[0099] a first host selection unit, configured to determine that the terminal device is a host if the first campaign data frame is the first received campaign data frame, and to determine that the other terminal devices are slaves;

[0100] The second host selection unit is used to determine that if any second campaign data frame is the first received campaign data frame, the other terminal device corresponding to the second campaign data frame is the host, and determine the terminal device and the remaining other terminal devices as slaves.

[0101] In some optional implementations, the networking device further includes:

[0102] The sequence table generation module is used to sort the terminal device and other terminal devices in chronological order based on the reception time of the first election data frame and the second election data frame when the terminal device acts as a host, so as to generate a master-slave device sequence table, and send the master-slave device sequence table to each slave; wherein the master-slave device data table is used to determine the election order of the host and the slave, as well as each slave.

[0103] In some optional implementations, the networking device further includes:

[0104] The sequence table update module is used to update the master-slave device sequence table when the terminal device as the host detects that any slave device is offline, and send the updated master-slave device sequence table to other slave devices.

[0105] In some optional implementations, the networking device further includes:

[0106] The host exit module is used to send an exit instruction to each slave before the terminal device takes the initiative to go offline as a host, so that each slave responds to the exit instruction and selects a new host based on the master-slave device sequence table.

[0107] In some optional implementations, the networking device further includes:

[0108] The host failure module is used to re-elect the host with other slaves when the terminal device detects that the host fails and goes offline as a slave.

[0109] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.

[0110] The networking device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.

[0111] See also Figure 5 , is a structural block diagram of a terminal device provided by an embodiment of the present invention.

[0112] A terminal device provided in an embodiment of the present invention includes a processor 51, a memory 52, and a computer program stored in the memory 52 and configured to be executed by the processor 51. When the processor 51 executes the computer program, a networking method as in any of the above embodiments is implemented.

[0113] When the processor 51 executes the computer program, the steps in the above networking method embodiment are implemented, for example Figure 1 Alternatively, the processor 51 implements the functions of each module / unit in the above networking device embodiment when executing the computer program, for example Figure 4 The functions of each module of the networking device shown.

[0114] Exemplarily, the computer program may be divided into one or more modules, one or more modules are stored in the memory 52, and executed by the processor 51 to implement the present invention. One or more modules may be a series of computer program instruction segments capable of implementing specific functions, and the instruction segments are used to describe the execution process of the computer program in the terminal device.

[0115] The terminal device may be a computing device such as a desktop computer, a notebook, a PDA, or a cloud server. The terminal device may include, but is not limited to, a processor 51 and a memory 52. ​​Those skilled in the art will appreciate that Figure 5 It is only an example of a terminal device and does not constitute a limitation of the terminal device. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the terminal device may also include input and output devices, network access devices, buses, etc.

[0116] The processor 51 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. The processor 51 is the control center of the terminal device, and uses various interfaces and lines to connect various parts of the entire terminal device.

[0117] The memory 52 can be used to store computer programs and / or modules. The processor 51 implements various functions of the terminal device by running or executing the computer programs and / or modules stored in the memory 52 and calling the data stored in the memory 52. ​​The memory 52 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application required for a function, etc.; the data storage area can store data created according to the use of the terminal device, etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0118] Among them, if the module / unit integrated in the terminal device is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. Computer-readable media may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal and software distribution medium, etc.

[0119] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.

Claims

1. A networking method, characterized in that: Applicable to a terminal device to be networked, the method comprises: Broadcast the first campaign data frame; When receiving the first campaign data frame or the second campaign data frame broadcasted by other terminal devices, feeding back a first response data frame; wherein the first response data frame includes device information of the terminal device; Determine a master and a slave from the terminal device and the other terminal devices based on the reception time of the first campaign data frame and each of the second campaign data frames; When the terminal device acts as the host, receiving the second response data frame fed back by the other terminal device, and establishing a connection with the other terminal device based on the second response data frame to complete the networking operation; wherein the second response data frame includes device information of the other terminal device; The broadcast first campaign data frame includes: Obtaining a target time window; wherein the target time window is determined by the device power-on duration of the terminal device and the other terminal devices; Randomly obtain a delay duration within the target time window; After waiting for the delay time, the first campaign data frame is broadcast; wherein the broadcast time of the first campaign data frame is different from the broadcast time of the second campaign data frame.

2. The networking method according to claim 1, characterized in that: The determining of the master and the slave from the terminal device and the other terminal devices based on the reception time of the first campaign data frame and each of the second campaign data frames includes: If the first campaign data frame is the first received campaign data frame, determining the terminal device as a host, and determining the other terminal devices as slaves; If any of the second campaign data frames is the first received campaign data frame, the other terminal device corresponding to the second campaign data frame is determined to be a host, and the current terminal device and the remaining other terminal devices are determined to be slaves.

3. The networking method according to claim 1, characterized in that: The method further comprises: When this terminal device acts as the host, based on the reception time of the first campaign data frame and the second campaign data frame, this terminal device and the other terminal devices are sorted in chronological order to generate a master-slave device sequence table, and the master-slave device sequence table is sent to each of the slaves; wherein the master-slave device data table is used to determine the campaign order of the host and the slave, as well as each of the slaves.

4. The networking method according to claim 3, characterized in that: The method further comprises: When the terminal device as the host detects that any of the slaves is offline, the master-slave device sequence table is updated, and the updated master-slave device sequence table is sent to other slaves.

5. The networking method according to claim 3, characterized in that: The method further comprises: Before the terminal device takes the initiative to go offline as the host, it sends an exit instruction to each of the slaves, so that each of the slaves responds to the exit instruction and selects a new host based on the master-slave device sequence table.

6. The networking method according to claim 1, characterized in that: The method further comprises: When the terminal device as the slave detects that the master fails and goes offline, it competes with other slaves for the master again.

7. A networking device using the networking method according to any one of claims 1 to 6, characterized in that: Applicable to terminal equipment to be networked, the device comprises: A host election module, used for broadcasting a first election data frame; A data response module is used to feed back a first response data frame when receiving the first campaign data frame or a second campaign data frame broadcasted by other terminal devices; wherein the first response data frame includes device information of the terminal device; A master-slave determination module, configured to determine a master and a slave from the terminal device and the other terminal devices based on the reception time of the first campaign data frame and each of the second campaign data frames; The host networking module is used to receive the second response data frame fed back by the other terminal devices when the terminal device acts as the host, and establish a connection with the other terminal devices based on the second response data frame to complete the networking operation; wherein the second response data frame includes the device information of the other terminal devices.

8. A terminal device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the networking method according to any one of claims 1 to 6 by executing the computer instructions.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the networking method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Dynamic networking method and device and electronic equipment

    CN116017630A