Main and standby machine switching method and device, computer equipment and storage medium
Patent Information
- Application Number
- CN202280094223.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-31
- Publication Date
- 2024-11-08
AI Technical Summary
The existing communication management master and backup machine switching mechanism has the problem of low system reliability and stability. Especially in the field of power system energy storage, the situation where the master machine and the backup machine are master or backup at the same time can easily lead to system instability.
By determining the idle time period for the current host to send business packets, switch between the active and standby machines to ensure that the active and standby machines are not active or standby at the same time when transmitting business packets. The fault level information in the interactive packets is used to determine the switching conditions. , and perform switching after receiving switching feedback to achieve seamless switching.
It improves the reliability and stability of the active and standby machine switching process, ensures the continuity and accuracy of communication, and avoids system instability caused by dual active or dual standby situations.
Smart Images

Figure CN118923091A_ABST
Abstract
Description
Master / standby machine switching method, device, computer equipment, and storage medium Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a method, apparatus, computer equipment, storage medium, and computer program product for switching between a primary and a secondary machine. Background Art
[0002] As the communication hub of monitoring systems, communication management machines are widely used in various fields. For example, in the field of power system energy storage, battery management systems in this field often use a communication management master-standby machine connection to prevent equipment failures and environmental impacts.
[0003] The current master-slave switching mechanism for communication management is that the master transmits the information received on the current uplink or downlink communication media link to the backup machine. There are situations where one machine can be the master or the backup machine at the same time, resulting in low system reliability and stability.
[0004] Summary of the Invention
[0005] Based on this, it is necessary to provide a master-slave machine switching method, device, computer equipment, computer-readable storage medium and computer program product to address the above technical problems, which can improve the reliability and stability of the system.
[0006] In a first aspect, the present application provides a method for switching between a primary and a secondary machine. The method comprises:
[0007] When the master-slave machine switching condition is met, determining an idle time period for the current master machine to send service messages; the service messages include at least one of uplink messages, downlink messages, and uplink and downlink messages;
[0008] The master-slave machine switching is started and completed during the idle time period for sending service messages.
[0009] In the above embodiment, when it is determined that the current host is in an idle time period for sending business messages, if the master-standby machine switching conditions are also met, the master-standby machine switching is started and completed in the idle time period for sending business messages, and the master-standby machine switching process is shielded from the device receiving the business message, thereby avoiding the information that the master and standby machines are both master or both standby machines to be transmitted to the device receiving the business message; and avoiding the master-standby machine switching when sending business messages, thereby improving the reliability and stability of the master-standby machine corresponding system.
[0010] In one embodiment, starting and completing the master-slave machine switching during the idle time period of sending the service message includes:
[0011] The current host generates a switching instruction, and the current host switches to the standby host;
[0012] The current master sends a switching instruction to the current standby, where the switching instruction instructs the current standby to switch to the master.
[0013] In the above embodiment, when the conditions for master-slave switching are met and the system is idle during service message transmission, the active master generates a switchover instruction and switches to the standby mode. This instruction is then sent to the active standby mode, causing the active standby mode to become the active master. The active master does not need to wait for feedback indicating that the active standby mode has switched to the active master mode before switching to the standby mode. This allows for seamless handover between the active and standby modes, avoids the situation where both the active and standby modes are active at the same time, and ensures reliable and continuous communication.
[0014] In one embodiment, starting and completing the master-slave machine switchover during the idle time period for sending service messages includes:
[0015] During the idle time period for sending service messages, the current host generates a switching instruction; the current host sends the switching instruction to the current standby machine, and upon receiving feedback that the current standby machine responds to the switching instruction and switches to the host, the current host switches to the standby machine.
[0016] In the above implementation, when the master and the standby machines are switched, after the master sends a switching instruction, the master switches to the standby machine only when it receives feedback that the standby machine has successfully switched, thereby ensuring that the master and standby machines are switched.
[0017] In one embodiment, after the current host and the current standby are powered on, a sending cycle and a sending time point of a service message sent by the current host are obtained, and a sending cycle and a sending time point of a service message sent by the current standby are obtained;
[0018] If the sending time points of the service messages sent by the current master and the current standby are different, the sending cycles and sending time points of the service messages sent by the current standby master and the current standby are synchronized.
[0019] In the above embodiment, after powering on the primary and backup machines, if their message transmission times are inconsistent, the backup machine needs to learn the message transmission strategy of the primary machine. This ensures that the message transmission times of the switched master are consistent before and after the idle period begins and ends, thus ensuring accuracy and system stability.
[0020] In one embodiment, when the master-slave machine switching condition is met, determining an idle time period for the master machine to send service messages includes:
[0021] After the current host completes sending the last service message, it obtains the interactive message with the current standby host;
[0022] If it is detected according to the interaction message that the master-slave machine switching condition is met, an idle time period for the master machine to send service messages is determined.
[0023] In the above embodiment, after the last business message is sent and before the next business message is sent, in the idle time period when the host sends the business message, if it is detected based on the interactive message between the current host and the current backup machine that the current host and the current backup machine meet the master-slave machine switching conditions, the master-slave machine switching is completed before the next message is sent, and the normal message sending of the business message is not affected.
[0024] In one embodiment, the interaction message includes a start byte, a check byte, and an information byte; the information byte stores a status instruction for characterizing the fault level and a control instruction for whether to switch between primary and standby modes; and the check byte stores verification information for verifying the integrity of the interaction message.
[0025] In the above embodiment, the master and standby machines communicate according to the set message format, making full use of each byte to transmit the fault level status of the master and standby machines, whether the master and standby machine switching is required, and verification information of the message integrity, thereby improving the message transmission rate and the utilization rate of each byte in the message.
[0026] In one embodiment, detecting that a master / slave machine switching condition is met according to the interaction message includes:
[0027] Parsing the interaction message to obtain the information byte;
[0028] Reading the first fault level of the master machine and the second fault level of the backup machine from the target bit of the information byte;
[0029] If the first fault level is higher than the second fault level, it is determined that the master-slave machine switching condition is met.
[0030] In the above embodiment, by parsing the interactive message between the master and standby machines, information is read from the target bit of the information byte to obtain the second fault level of the standby machine. According to the first fault level of the master machine and the second fault level of the standby machine, it is determined whether the conditions for switching between the master and standby machines are met. If the first fault level is higher than the second fault level, it is determined that the conditions for switching between the master and standby machines are met, thereby ensuring the accuracy of the switching between the master and standby machines.
[0031] In one embodiment, before determining that a master-slave machine switching condition is satisfied if the first fault level is higher than the second fault level, the method further includes:
[0032] It is determined whether the first fault level is a set fault level for active / standby switching; if the first fault level is the set fault level, it is determined whether the first fault level is higher than the second fault level.
[0033] In the above embodiment, when the master and standby machines meet the switching conditions, it is further determined whether the fault level of the master is the set fault level for master-standby switching. If the master reaches the set fault level for master-standby switching, the number of switching times is reduced and stability is improved.
[0034] In one embodiment, before obtaining the information bytes, the method further includes:
[0035] Obtaining a check byte of the interaction message;
[0036] Reading the check information in the check byte;
[0037] The interaction message is verified according to the verification information, and if the verification result shows that the interaction message is a complete interaction message, the information byte is obtained.
[0038] In the above embodiment, when determining whether the primary and backup machines meet the switching conditions based on the information in the interactive message, the integrity of the message is preliminarily verified based on the verification information in the interactive message to ensure the integrity of the interactive message and further ensure the accuracy of the message switching.
[0039] In one embodiment, determining an idle time period for a host to send a service message includes:
[0040] Determine the sending cycle of the current host to send business messages;
[0041] The idle time period of the sending cycle is determined as the idle time period for the host to send service messages.
[0042] In the above embodiment, the idle time period of the sending cycle is determined from the sending cycle of the current host sending business messages, and the idle time period of the sending cycle is determined as the idle time period for the host to send business messages, thereby avoiding the master-slave machine switching in the non-idle time period of the sending cycle of the current host sending business messages, and the situation where both are the master or the backup machine at the same time, thereby improving the stability of the system.
[0043] In one embodiment, determining the idle time period of the sending cycle includes:
[0044] Determining a service message sending time point of the host in the sending cycle;
[0045] The idle time period of the sending cycle is determined according to the service message sending time point.
[0046] In the above embodiment, the accuracy of the idle time period is ensured by determining the idle time period of the sending cycle according to the time point of sending the service message.
[0047] In one embodiment, determining an idle time period for a host to send a service message includes:
[0048] Determine a first sending period of an uplink message of the host and a second sending period of a downlink message of the host;
[0049] If the first sending cycle and the second sending cycle are different, the idle time period of the first sending cycle is determined as the idle time period for the host to send service messages.
[0050] In the above embodiment, if the uplink message sending cycle and the downlink message sending cycle of the current host are inconsistent, the idle time period of the first sending cycle is determined as the idle time period for the host to send business messages. That is to say, if the current host communicates with multiple devices at the same time and the communication cycles are inconsistent, the idle time period of the first sending cycle is determined as the idle time period for the host to send business messages, which is used as the time period for switching between the master and the standby machines to avoid the impact on the system caused by the inconsistency between the uplink message sending cycle and the downlink message sending cycle.
[0051] In one embodiment, after the idle time period for sending service messages starts and the step of switching between the primary and standby machines is completed, the method further includes:
[0052] A freeze period for switching between the primary and standby machines is determined, and the current states of the primary and standby machines are maintained during the freeze period for switching between the primary and standby machines.
[0053] In the above embodiment, after the master and standby machines complete the switch, the status of the switched master and standby machines is maintained for a period of time to avoid frequent switching of the master and standby machines, which may cause system instability.
[0054] In one embodiment, the communication rate between the current master and the current backup supports at least one of 5 Mbps and 10 Mbps.
[0055] In the above embodiment, the communication rate between the current master and the current standby supports at least one of 5 Mbps and 10 Mbps, which can flexibly configure the communication between the master and standby machines and improve the versatility of the master-standby machine switching method.
[0056] In a second aspect, the present application further provides a master-slave machine switching device. The device comprises:
[0057] A switching judgment module is used to determine the idle time period for the current host to send service messages when the master-slave machine switching condition is met; the service message includes at least one of an uplink message, a downlink message, and an uplink and downlink message;
[0058] The master-slave switching module is used to start and complete the master-slave machine switching during the idle time period of sending service messages.
[0059] In the above embodiment, when it is determined that the current host is in an idle time period for sending business messages, if the master-standby machine switching conditions are also met, the master-standby machine switching is started and completed in the idle time period for sending business messages, and the master-standby machine switching process is shielded from the device receiving the business message, thereby avoiding the information that the master and standby machines are both master or both standby machines to be transmitted to the device receiving the business message; and avoiding the master-standby machine switching when sending business messages, thereby improving the reliability and stability of the master-standby machine corresponding system.
[0060] In a third aspect, the present application further provides a computer device. The computer device includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are performed:
[0061] When the master-slave machine switching condition is met, determining an idle time period for the current master machine to send service messages; the service messages include at least one of uplink messages, downlink messages, and uplink and downlink messages;
[0062] The master-slave machine switching is started and completed during the idle time period for sending service messages.
[0063] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the following steps:
[0064] When the master-slave switch condition is met, determine the idle time period for the current master to send service messages;
[0065] The master-slave machine switching is started and completed during the idle time period for sending service messages.
[0066] In a fifth aspect, the present application further provides a computer program product. The computer program product includes a computer program that, when executed by a processor, implements the following steps:
[0067] When the master-slave machine switching condition is met, determining an idle time period for the current master machine to send service messages; the service messages include at least one of uplink messages, downlink messages, and uplink and downlink messages;
[0068] The master-slave machine switching is started and completed during the idle time period for sending service messages.
[0069] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0071] FIG1 is an application architecture diagram of a method for switching between a primary and a secondary machine according to an embodiment;
[0072] FIG2 is a schematic flow chart of a method for switching between a primary and a secondary machine according to an embodiment;
[0073] FIG3 is a flow chart of a method for determining an idle time period for sending service messages according to an embodiment;
[0074] FIG4 is a flow chart showing the steps of switching between a primary and a secondary machine in one embodiment;
[0075] FIG5 is a schematic flow chart of a method for switching between a primary and a secondary machine in another embodiment;
[0076] FIG6 is a schematic diagram showing the interconnection between the main and standby units of a battery management system in an energy storage power station according to an embodiment;
[0077] FIG7 is a schematic diagram of seamless switching between the primary and standby machines in one embodiment;
[0078] FIG8 is a schematic flow chart of a method for switching between a primary and a secondary machine in another embodiment;
[0079] FIG9 is a schematic flow chart of a method for switching between a primary and a secondary machine in another embodiment;
[0080] FIG10 is a structural block diagram of a master-slave machine switching device according to an embodiment;
[0081] FIG11 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0082] The following embodiments of the technical solution of the present application will be described in detail with reference to the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present application and are therefore only examples and are not intended to limit the scope of protection of the present application.
[0083] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application belongs; the terms used herein are only for the purpose of describing specific embodiments and are not intended to limit this application; the terms "including" and "having" and any variations thereof in the specification and claims of this application and the above-mentioned figure descriptions are intended to cover non-exclusive inclusions.
[0084] In the description of the embodiments of this application, the technical terms "first" and "second" are used only to distinguish different objects and should not be understood to indicate or imply relative importance or implicitly specify the quantity, specific order, or primary and secondary relationship of the indicated technical features. In the description of the embodiments of this application, the meaning of "plurality" is more than two, unless otherwise clearly and specifically defined.
[0085] References herein to "embodiments" mean that a particular feature, structure, or characteristic described in connection with the embodiments may be included in at least one embodiment of the present application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute an independent or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0086] In the description of the embodiments of this application, the term "and / or" is simply a description of the association relationship between associated objects, indicating that three relationships can exist. For example, A and / or B can represent the following three situations: A exists alone, A and B exist simultaneously, and B exists alone. In addition, the character " / " in this document generally indicates that the associated objects are in an "or" relationship.
[0087] In the description of the embodiments of the present application, the term "multiple" refers to more than two (including two). Similarly, "multiple groups" refers to more than two groups (including two groups), and "multiple pieces" refers to more than two pieces (including two pieces).
[0088] In the description of the embodiments of the present application, the technical terms "center", "longitudinal", "lateral", "length", "width", "thickness", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", "clockwise", "counterclockwise", "axial", "radial", "circumferential", etc., indicating the orientation or position relationship, are based on the orientation or position relationship shown in the accompanying drawings, and are only for the convenience of describing the embodiments of the present application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the embodiments of the present application.
[0089] In the description of the embodiments of the present application, unless otherwise expressly specified or limited, technical terms such as "installed," "connected," "connected," and "fixed" should be understood in a broad sense. For example, they can refer to fixed connections, detachable connections, or integration; mechanical connections or electrical connections; direct connections or indirect connections through an intermediate medium; internal connections between two components or interactions between two components. Those skilled in the art can understand the specific meanings of the above terms in the embodiments of the present application based on specific circumstances.
[0090] At present, in order to ensure the normal and stable operation of systems in various fields, redundant systems have been proposed. When a system fails, the normal operation of the system is ensured by switching between the main and backup machines. For example, in the traditional automotive field, the reliability requirements of the battery management system (BMS) are not as high as those of the power system equipment. For the battery management system in the field of power system energy storage, the working environment is harsh and it is susceptible to strong electromagnetic interference, which may cause functional failure. If a power outage is caused by equipment failure, the impact will be relatively large, so it is necessary to consider redundant design of the BMS. The currently adopted redundant design method is to design a dual-set of main and backup for key equipment in the BMS system, such as the battery management unit (BMU). Based on the dual-set design method of the master and backup, there is a problem that the master and backup machines cannot complete the switching in a timely, safe and reliable manner.
[0091] To switch between master and backup communication management machines, the master simply transmits information received on the current uplink or downlink communication media link to the backup machine, achieving seamless master / backup switching. However, this master / backup switching method can easily cause both machines to be simultaneously master or backup. This information can be transmitted to connected devices at higher and lower levels, causing anomalies.
[0092] Based on the above considerations, when it is detected that the conditions for master-slave switching are met between the current master and the current backup, it is determined whether the current master is in an idle time period for sending business messages, and the master-slave switching is started and completed in the idle time period for sending business messages. When the master-slave switching conditions are met and the master-slave switching is completed in the idle time period, it does not affect the current sending of business messages and the next sending of business messages, that is, it does not affect the communication between the host and the upstream and / or downstream devices. The master-slave switching process is shielded, so for the upstream and / or downstream devices, the master and the backup will not be the master at the same time, or the backup and the master will not be the backup at the same time, thereby improving the stability and reliability of the system where the master and backup machines are located.
[0093] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0094] The master-slave machine switching method provided in the embodiments of the present application is illustrated using the application architecture shown in FIG1 as an example. As shown in FIG1 , the application architecture includes an upper-layer device 102, a lower-layer device 104, a first device 106, and a second device 108. The first device 106 and the second device 108 can communicate with each other, for example, via optical fiber communication. The first device 106 and the second device 108 are configured as dual redundant systems. When the first device 106 is the master, the second device 108 is the backup. When the second device 108 is the master, the first device 106 is the backup. For example, using the first device 106 as the master, the first device 106 sends uplink messages to the upper-layer device 102 and can also send downlink messages to the lower-layer device 104. It is understood that the application architecture can be adjusted based on business needs. For example, if the master and backup machines only need to communicate with the upper-layer devices, the first device 106 and the second device 108 only need to send uplink messages to the upper-layer device 102. For example, the primary and backup machines only need to communicate with the lower-layer devices. In this case, the first device 106 and the second device 108 only need to send downlink messages to the lower-layer device 104. This application architecture is used as an example of a battery management system for energy storage power stations. The battery management system includes a primary machine 106 and a backup machine 108. When the primary and backup machine switching conditions are met, an idle time period for the current primary machine to send service messages is determined; the primary and backup machine switching begins and is completed during the idle time period for sending service messages. The primary and backup machines can be predefined key devices in the battery management system, for example, a battery management unit.
[0095] During a master-slave switchover, a communication path typically exists between the master and the standby, transmitting switchover commands or heartbeat signals. When the master issues a switchover command directly to the standby, and the slave executes the switchover after receiving the switchover command, a dual-standby situation can easily occur. When a slave fails to detect the master's heartbeat signal, it automatically becomes the master, which can easily lead to a dual-master situation. The simultaneous presence of dual masters or dual standbys in a system can lead to system instability. Therefore, a master-slave switchover method is proposed to address the issue of dual masters or dual standbys in a system during master-slave switchover.
[0096] In one embodiment, as shown in FIG2 , a method for switching between a primary and a secondary machine is provided. The method is described by taking the primary or secondary machine in FIG1 as an example, and includes the following steps:
[0097] Step 202: When the master / slave machine switching condition is met, determine the idle time period for the current master machine to send service messages. Service messages include at least one of uplink messages, downlink messages, and uplink / downlink messages.
[0098] Among them, the master and standby machines can be the master and standby machines of systems in different application fields. For example, the master and standby machines can be the master and standby machines of communication management machines, and the master and standby machines can be the master and standby machines used in battery management systems in the energy storage field. In the battery management system in the energy storage field, the master and standby machines can be key devices predetermined in the battery management system, for example, they can be battery management units. In this application, the master and standby machines of the battery management system in the energy storage field are taken as an example for explanation. In the battery management system in the energy storage field, in order to ensure the normal operation of the battery management system, a master and standby machine switching is provided. The number of standby machines in the battery management system can be one or more. The number of standby machines can be determined according to the needs of the battery management system and is not limited here. In this application, the number of host machines and the number of standby machines are both one for explanation.
[0099] The conditions for switching between the primary and backup units are pre-set. In energy storage battery management systems, this can be when the primary unit's fault level is higher than the backup unit's, or when the primary unit's fault level reaches a pre-set level. Furthermore, the pre-set level can be understood as the level at which the primary unit's fault level affects the battery management system, preventing it from sending control commands normally and impacting system performance and stability.
[0100] The host has upper-layer devices with communication behaviors and / or lower-layer devices with communication behaviors. Taking the battery management system as an example, the lower-layer devices of the host can be devices such as charging piles, and the upper-layer devices of the host can be monitoring devices, etc. Business messages refer to messages sent by the master and standby machines for business communications with upper-layer devices and / or lower-layer devices. If the master and standby machines are only connected to upper-layer devices, the business messages include uplink messages. Upper-layer messages refer to business messages sent by the host to upper-layer devices. If the master and standby machines are only connected to lower-layer devices, the business messages include downlink messages, and downlink messages refer to business messages sent by the host to lower-layer devices. If the master and standby machines are connected to upper-layer devices and lower-layer devices, the business messages include uplink messages and downlink messages. Among them, the sending cycles of the host for sending uplink messages and sending downlink messages can be the same or different. It is understandable that when the host sends uplink messages and downlink messages, it can be sent according to a fixed sending cycle, for example, once every 0.1s, sending an uplink message or downlink message in the first 0.1s, and sending the second uplink message or downlink message in the second 0.2s.
[0101] An idle time period is when a host does not send messages. This can include uplink messages, or both uplink and downlink messages. An idle time period can also be considered a service window for active / standby switchover. The time when a host sends service messages can be considered a service window for sending uplink and downlink messages.
[0102] Specifically, when the current master and the current backup machine meet the master-backup switching condition, the idle time period for the current master to send service messages is determined according to the sending cycle and the sending time point of the service messages sent by the current master.
[0103] Step 204: Start and complete the master / slave machine switchover during the idle time period for sending service messages.
[0104] Among them, the execution time point of the master-standby switch is any time point in the idle time period for sending business messages that can ensure that the master-standby machine is completed within the idle time period for sending business messages. The time point of the master-standby switch can also be determined according to the time when the standby machine receives the switching instruction. It can be understood that the master-standby switch starts and is completed in the idle time period for sending business messages. At this time, the switched host is about to start sending uplink messages or sending downlink messages. In the idle time period for sending business messages, the master-standby switch has been completed between the master and standby machines. This switching process shields the upstream device (which can also be understood as the upper-layer device) and the downstream device (which can also be understood as the lower-layer device) of the host. This transient process of the master-standby switch has no impact on the upstream and downstream devices.
[0105] Specifically, the master-slave machine switching starts in the idle time period for sending business messages, the current master machine switches to the backup machine, and the switched backup machine is obtained, and the current backup machine switches to the master machine, and the switched master machine is obtained. Furthermore, when the master-slave machine switching condition is met, the idle time period for the current master machine to send business messages is determined. The master machine generates a switching instruction, and sends an interactive message carrying the switching instruction to the current backup machine. Based on the sending time point of the interactive message and the transmission duration of the interactive message, the time point when the current backup machine receives the interactive message is determined, and the execution time point of the master-slave machine switching is determined based on the time point when the current backup machine receives the interactive message. The execution time point of the master-slave machine switching is a time point in the idle time period of the business message.
[0106] In the above-mentioned master-slave switching method, when the master-slave switching conditions are met and the current master is in an idle time period for sending business messages, the current master generates a switching instruction and switches to the backup machine, and sends the switching instruction to the current backup machine, so that the current backup machine switches to the master. The master does not need to receive feedback that the current backup machine has switched to the master before switching to the backup machine, thereby achieving seamless switching between the master and backup machines and avoiding the situation where the current master and backup machines are both the master and the backup machine. The master-slave switching is completed during the idle time period for sending business messages, and the transient process of master-slave switching is shielded from the upper and lower-layer devices, ensuring the reliability and continuity of communication.
[0107] To avoid dual-active or dual-standby situations during active / standby switchover, only one active server and one standby server can exist during normal service message transmission periods. In other words, active / standby switchover is completed during idle periods when service messages are not being sent. To accurately determine idle periods for sending service messages, the master's context message transmission cycle must be determined. Based on this cycle, the idle periods for sending service messages are further determined.
[0108] In one embodiment, as shown in FIG3 , a method for determining an idle time period for sending service messages is provided, comprising the following steps:
[0109] Step 302: Obtain the first sending period of the uplink message and the second sending period of the downlink message sent by the current host.
[0110] The service message may include an uplink message and a downlink message. The format of the service message sent by the host is pre-set and is not limited here. The first sending period of the uplink message and the second sending period of the downlink message sent by the host may be fixed.
[0111] Step 304 , determining whether the first sending period is equal to the second sending period, if so, executing step 306 , otherwise executing step 310 .
[0112] Step 306: Use any one of the first sending cycle and the second sending cycle as the sending cycle for the current host to send service messages.
[0113] Step 308: Determine the idle time period of the sending cycle as the idle time period for the host to send service messages.
[0114] The idle time period of the service message sending cycle may be fixed or determined according to the service message sending time point.
[0115] If the idle time period of the sending cycle can be fixed, the idle time period of the sending cycle is determined by determining the sending cycle of the current host sending service messages, and the idle time period of the sending cycle is determined as the idle time period of the host sending service messages. That is, the idle time period of the sending cycle is determined from the sending cycle of the current host sending service messages, and the idle time period of the sending cycle is determined as the idle time period of the host sending service messages. This avoids the situation where the master and backup machines are switched during the non-idle time period of the sending cycle of the current host sending service messages, thereby improving the stability of the system.
[0116] If the idle time period of the service message sending cycle is not fixed, the idle time period for the host to send the service message is determined by determining the time point in the sending cycle when the host sends the service message; and determining the idle time period of the sending cycle based on the time point in which the service message is sent. By determining the idle time period of the sending cycle based on the time point in which the service message is sent, the idle time period of the sending cycle is accurately determined.
[0117] Step 310: Determine the idle time period of the first sending cycle as the idle time period for the host to send service messages.
[0118] It is understandable that if a host communicates with multiple devices simultaneously and the communication cycles are inconsistent, such as between the host and an upper-layer device and between the host and a lower-layer device, but the communication cycle between the host and the upper-layer device is inconsistent with the communication cycle between the lower-layer devices, determining the host's idle time period based on the communication cycle between the host and the lower-layer devices will have a significant impact on the system. Therefore, to minimize the impact on the system, it is necessary to determine the host's idle time period, i.e., the first transmission cycle for sending uplink messages, based on the communication cycle between the host and the upper-layer device.
[0119] Specifically, if the first sending cycle and the second sending cycle are different, the idle time period of the first sending cycle is determined as the idle time period for the host to send service messages.
[0120] Furthermore, if the idle time period of the sending cycle can be fixed, the idle time period of the sending cycle can be determined by determining the sending cycle of the current host sending uplink messages, and the idle time period of the sending cycle can be determined as the idle time period for the host to send service messages. That is, the idle time period of the sending cycle is determined from the sending cycle of the current host sending uplink messages, and the idle time period of the sending cycle is determined as the idle time period for the host to send service messages. This avoids the situation where the master and backup machines are switched during the non-idle time period of the sending cycle of the current host sending service messages, thereby improving the stability of the system.
[0121] If the idle time period of the uplink message transmission cycle is not fixed, the idle time period for the host to send the uplink message is determined by determining the time point at which the host sends the uplink message during the transmission cycle; and determining the idle time period of the transmission cycle based on the time point at which the uplink message is sent. By determining the idle time period of the transmission cycle based on the time point at which the service message is sent, the idle time period of the transmission cycle is accurately determined.
[0122] In the above method for determining the idle time period for sending business messages, by obtaining the sending period of uplink messages and the sending period of downlink messages, it is judged whether the sending period of uplink messages and the sending period of downlink messages are consistent, and the idle time period for the host to send business messages is determined.
[0123] When the idle time period for sending business messages begins and the master-slave machine switch is completed, it is necessary to consider whether the sending cycle and sending time point of the current master and the current backup machine are consistent. In the case that the sending cycle and sending time point of the previous master and the current backup machine are consistent, after the current backup machine switches to the master, the sending time point of the next business message is consistent with the sending time point of the business message of the master before the switch. At this time, the current master switches to the backup machine after generating the switching instruction, and does not need to wait for the feedback that the current backup machine has switched to the master before switching to the backup machine. In one embodiment, the master-slave machine switch is started and completed during the idle time period for sending business messages, wherein the master-slave machine switch steps are shown in FIG4 and include the following steps:
[0124] Step 402: When the master-slave machine switching condition is met, determine the idle time period for the current master machine to send service messages.
[0125] The master-slave switching condition is that the master's fault level is higher than the standby's fault level. Alternatively, the master's fault level can be higher than the standby's fault level when the master's fault level reaches a preset fault level. For any master-slave switching condition, the master-slave fault level is determined based on the interaction messages between the master and standby machines. It is understood that the master exchanges messages with the standby machine while sending service messages, and determines the current standby machine's fault information and the master-slave status of the master machine based on the interaction messages with the standby machine.
[0126] Furthermore, in one embodiment, by obtaining the interaction message between the current host and the current standby machine and parsing the interaction message, the second fault level of the current standby machine is obtained. The current host judges based on its own first fault level and the received second fault level of the current standby machine whether the first fault level is higher than the second fault level. If the first fault level is higher than the second fault level, the master-standby machine switching condition is met.
[0127] Among them, the interactive message between the master and the backup machine includes a start byte, a check byte, and an information byte; the information byte stores status instructions for characterizing the fault level and control instructions for whether to switch between the master and the backup machine; the check byte stores verification information for verifying the integrity of the interactive message. The message format of the interactive message is determined according to the requirements of the master-slave machine switching to avoid the use of complex encoding methods.
[0128] It's understandable that the length of the messages exchanged between the master and standby machines affects the timeliness of the current standby machine switching to the master position. By determining the length of the messages exchanged between the master and standby machines based on actual needs, we avoid wasting extra bytes and taking up transmission time during message transmission. Therefore, the master and standby machines communicate according to the set message format, fully utilizing each byte to convey the fault level status of the master and standby machines, the need for a master-standby switch, and verification of message integrity. This improves message transmission rates, shortens transmission time, and fully utilizes every bit in the message.
[0129] For example, an interactive message consists of three bytes: a start byte, a check byte, and an information byte. Each byte contains eight bits, each representing specific information. Table 1 shows an example of an interactive message for the active / standby switchover protocol: the eight bits of the first start byte store the start character, which can be represented by 0x5A. The eight bits of the second information byte store specific information. Bits 1 through 0 are used as backup bits, and bits 3 through 2 represent the local active / standby status bits, with 1 representing the active device, 2 representing the standby device, and the others representing invalid. Bits 5 through 4 represent the local fault level, with 0 representing normal, 1 representing minor, 2 representing severe, and 3 representing emergency. Bits 7 through 6 represent the active / standby switchover request, with 1 representing an invalid request, 2 representing a valid request, and the others representing invalid data. The third check byte, consisting of eight bits, is a CRC checksum.
[0130] Table 1: Example of active / standby switchover protocol
[0131]
[0132]
[0133] Optionally, in one embodiment, when obtaining the interaction message between the current host and the current backup machine, the check byte of the interaction message is obtained; the check information in the check byte is read; the interaction message is checked according to the check information, and if the check result is that the interaction message is a complete interaction message, the information byte is obtained to determine whether the current host and the current backup machine meet the master-backup switching conditions.
[0134] During the master-slave machine switching, if the interactive message contains errors or is damaged, the master-slave machine switching will be misjudged, resulting in master-slave machine switching errors, etc. Therefore, when judging whether the master and standby machines meet the switching conditions based on the information in the interactive message, the integrity of the message is verified in advance based on the verification information in the interactive message to ensure the integrity of the interactive message and further ensure the accuracy of the message switching.
[0135] Furthermore, the communication rate between the master and standby machines is typically fixed and cannot be flexibly configured. This results in the communication rate between the master and standby machines not matching the actual application scenario, leading to issues such as delays and inaccuracies. In one embodiment, the communication rate between the current master and the current standby machine supports at least one of 5 Mbps and 10 Mbps. This allows for flexible configuration of communication between the master and standby machines, improving the versatility of the master-standby machine switching method.
[0136] Step 404: The current host generates a switch instruction, and the current host switches to the standby host.
[0137] Among them, when the host detects that the master-slave switching conditions are met, that is, when it detects that the fault level of the host is higher than the fault level of the standby machine, and when it is currently in the idle time period of the business message, it generates a switching instruction, and the current host switches from the master state to the standby state, obtaining the switched standby machine.
[0138] Step 406: The current master sends a switch instruction to the current standby, instructing the current standby to switch to the master.
[0139] Specifically, if the current master receives a signal from the current backup server to switch to master before switching, seamless handover between the master and backup servers cannot be ensured. Therefore, the current master generates a handover instruction, switching the current master to the backup server. When the current backup server receives the handover instruction, it responds to the handover instruction and switches from backup server status to master server status, becoming the master server after the handover, thus achieving seamless handover between the master and backup servers.
[0140] When the sending cycles and sending time points of the business messages of the master and backup machines are inconsistent, in order to ensure the successful switching between the master and backup machines, and to avoid the current master being switched to the backup machine during the idle time interval, and the current backup machine not being switched to the master, it is necessary to ensure that the current master is switched to the backup machine and the current backup machine is switched to the master.
[0141] In one embodiment, during an idle time period for sending service messages, the current host generates a switching instruction; the current host sends a switching instruction to the current standby machine, and when the current host receives feedback that the current standby machine has switched to the master in response to the switching instruction, the current host switches to the standby machine. In other words, the current host generates a switching instruction, and only when the current host receives feedback that the current standby machine has switched to the master will the current host switch to the standby machine. Through the communication handshake between the master and standby machines, the master-standby switching between the master and standby machines is realized, avoiding the situation where the switch is unsuccessful and there are two masters or two standbys. In the above-mentioned master-standby switching step, when the master-standby switching conditions are met and it is in an idle time period for sending service messages, the current host generates a switching instruction and switches to the standby machine, and sends the switching instruction to the current standby machine, so that the current standby machine switches to the master. The host does not need to receive feedback that the current standby machine has switched to the master before switching to the standby machine, thereby realizing seamless switching between the master and standby machines, avoiding the situation where the current master and standby machines are both the master and the standby machine, and ensuring the reliability and continuity of communication.
[0142] In another embodiment, as shown in FIG5 , a method for switching between a primary and a secondary machine is provided. The method is described by taking the method applied to the primary or secondary machine in FIG1 as an example, and includes the following steps:
[0143] Step 502: After the current host completes sending the last service message, it obtains the interaction message with the current standby machine.
[0144] Among them, the current master and the current standby have upper-layer devices and lower-layer devices with which they communicate. As shown in FIG6 , this is a schematic diagram of the master-standby interconnection of a battery management system suitable for the energy storage power station field in one embodiment. The master and standby use optical fiber for communication. The master and standby have upper-layer devices with which they communicate. The master and standby use optical fiber for communication and transmit interactive messages. The interactive messages include a start byte, a status instruction representing the fault level, a control instruction on whether to switch between the master and standby modes, and verification information for verifying the integrity of the interactive messages.
[0145] Step 504: If it is detected according to the interaction message that the master-slave machine switching condition is met, an idle time period for the master machine to send service messages is determined.
[0146] Specifically, when the current host obtains the interactive message with the current standby machine, it parses the interactive message to obtain the start byte, check byte, and information byte in the interactive message, and verifies the integrity of the interactive message based on the verification information in the check byte. When the verification is complete, the fault level information of the current standby machine is read from the target bit of the information byte. The current host compares the first fault level of the current standby machine with the second fault level of the current standby machine. When the first fault level is higher than the second fault level, the master-standby machine switching condition is met, and the idle time period for the host to send business messages is determined. Among them, the message parsing method can be implemented in an existing way and is not limited here. The verification of the CRC check bit can be implemented in an existing way and is not limited here.
[0147] Furthermore, in one embodiment, before determining that the master-slave switch condition is met if the first fault level is higher than the second fault level, a determination is made as to whether the first fault level is the set fault level for master-slave switch. If the first fault level is the set fault level, a determination is made as to whether the first fault level is higher than the second fault level. If the first fault level is higher than the second fault level, the master-slave switch condition is determined to be met. If the master-slave switch condition is met, a further determination is made as to whether the master's fault level is the set fault level for master-slave switch. If the master reaches the set fault level for master-slave switch, the number of switchovers is reduced, thereby improving stability.
[0148] Step 506: During the idle time period for sending service messages, the current host generates a switching instruction, and the current host switches to the standby host.
[0149] Step 508: The current master sends a switching instruction to the current standby. The switching instruction instructs the current standby to switch to the master, and the next service message is sent by the switched master.
[0150] In this case, the current master switches to the backup machine after generating a switch command. Upon receiving the switch command, the current backup machine switches to the master, achieving seamless handover between the master and backup machines. FIG7 is a schematic diagram illustrating seamless handover between the master and backup machines in one embodiment. FIG7 illustrates the master sending an uplink message. When the master sends its first uplink message, it determines the time required to send the uplink message within the sending cycle, which can be understood as the uplink message service window. After sending the uplink message, it enters an idle time period during the master transmission, which can be understood as the master-backup switch service window. It determines an idle time period for sending uplink messages. If it is detected that the current master and the current backup machine meet the master-backup switch requirements, the master-backup switch is completed before the second uplink message is sent. When sending the second uplink message, it determines the time required to send the uplink message within the sending cycle. After sending the uplink message, it enters an idle time period during the master transmission, determines an idle time period for sending uplink messages. If it is detected that the current master and the current backup machine meet the master-backup switch requirements, the master-backup switch is completed before the third uplink message is sent.
[0151] Specifically, during the idle time period for sending service messages, the current host generates a switching instruction, the current host switches to the backup machine, the current backup machine receives the switching instruction, responds to the switching instruction and switches to the host, and the switched host is obtained, and the next service message is sent by the switched host.
[0152] In this embodiment, during the time period between the last service message sent and the next service message sent, if the current master and the current backup machine detect that they meet the master-backup switching conditions based on their interactive messages, during the idle time period when the current master is sending service messages, the current master generates a switching instruction and switches to the backup machine, and sends the switching instruction to the current backup machine, causing the current backup machine to switch to the master. The master does not need to receive feedback that the current backup machine has switched to the master before switching to the backup machine, thus achieving seamless switching between the master and backup machines, avoiding the situation where the current master and backup machines are both master, and ensuring the normal transmission of messages without affecting the transmission of service messages, thereby ensuring the reliability and continuity of communication.
[0153] In another embodiment, as shown in FIG8 , a method for switching between a primary and a secondary machine is provided. The method is described by taking the primary and secondary machines in FIG1 as an example, and includes the following steps:
[0154] Step 802: After the current host completes sending the last service message, it obtains the interaction message with the current standby host.
[0155] Specifically, the sending cycle of the current host for sending business messages is determined, the business message sending time point of the current host in the sending cycle is determined, and after the current host completes the last business message sending, the interaction message with the current standby machine is obtained.
[0156] Step 804: parse the interaction message to obtain information bytes.
[0157] Step 806: Read the first fault level of the master machine and the second fault level of the backup machine from the target bit of the information byte.
[0158] Step 808: If the first fault level is higher than the second fault level, it is determined that the master-slave machine switching condition is met.
[0159] Step 810: Determine the idle time period for the current host to send service messages.
[0160] Specifically, according to the service message sending time point of the current host in the sending cycle, the idle time period of the sending cycle of the current host sending the service message is determined. It can be understood that the message interaction and the master-slave switching between the master and the slave are completed in sequence during the idle time period of the sending cycle of the service message.
[0161] Step 812: During the idle time period for sending service messages, the current host generates a switching instruction, and the current host switches to the standby host.
[0162] Step 814: The current master sends a switch instruction to the current standby, where the switch instruction instructs the current standby to switch to the master.
[0163] Step 816: Determine a freeze period for the master / slave machine switchover, and maintain the current states of the master / slave machines during the freeze period for the master / slave machine switchover.
[0164] The freeze period can be understood as a freezing window for the master / slave switchover. The freeze period is a set duration, which can be, but is not limited to, 10 seconds, or 8 seconds. During the freeze period, the current states of the master and the standby are maintained, ensuring that the master and the standby do not switch over after the switchover.
[0165] It's understandable that after the master / slave switch is complete, service messages need to be sent. If the new master / slave server meets the switchover conditions, the current service message transmission will be interrupted, causing system instability and data loss. Therefore, to avoid frequent master / slave switchovers and ensure system stability, after the master / slave switch is complete, the new master / slave servers maintain their current states for a set period of time, without switching again.
[0166] Specifically, after the master and standby machines complete the switch, the master machine after the switch needs to maintain its status as the master machine, and the standby machine after the switch needs to maintain its status as the standby machine. During this set time, the master and standby machine switch operation will not be performed.
[0167] In this embodiment, after the last service message was sent, during the idle time period when the host sends service messages, if it is detected that the current host and the current backup machine meet the master-backup switching conditions based on the interactive messages between the current host and the current backup machine, the current host generates a switching instruction and switches to the backup machine, and sends the switching instruction to the current backup machine so that the current backup machine switches to the host, and the master-backup switching is completed before the next message is sent. The host does not need to receive feedback that the current backup machine has switched to the host before switching the backup machine, thereby achieving seamless switching between the master and backup machines, avoiding the situation where the current master and backup machines are both the master and the backup machine, and ensuring the reliability and continuity of communication. After the master-backup machine completes the switch, it is ensured that the status of the switched master-backup machine is maintained for a period of time to avoid frequent switching between the master and backup machines, which may lead to system instability.
[0168] If the active and standby servers have the same sending period but different sending times, after a switchover, the current server may be at the sending time of the active server after the switchover, but not at the sending time of the active server before the switchover. Sending messages at this time can affect system stability. Therefore, to ensure consistency between the sending period and sending time of the active server before and after the switchover and maintain system stability, the sending period and sending time of the active and standby servers must be synchronized.
[0169] In another embodiment, as shown in FIG9 , a method for switching between a primary and a secondary machine is provided. The method is described by taking the primary and secondary machines in FIG1 as an example, and includes the following steps:
[0170] Step 902: After the current master and the current standby are powered on, the sending period and time of the service message sent by the current master are obtained, and the sending period and time of the service message sent by the current standby are obtained.
[0171] Step 904: If the time points at which the current master and the current backup send the service message are different, the sending cycles and time points of the service message sent by the current backup master and the current backup are synchronized.
[0172] Among them, under normal circumstances, the sending cycle of the business message sent by the current host and the current standby is the same. If the sending time points in the sending cycle of the business message sent by the current host and the current standby are different, the sending cycle and sending time points of the business message sent by the current standby host and the current standby are synchronized. That is, the sending cycle and sending time point in the current standby are set to the sending cycle and sending time point of the current host. For example, the sending cycle of the current host and the current standby is 100us, the sending time point of the current host is 85us, the next sending time point is 100us, and the transmission time length of the interactive message between the current host and the current standby is 5us. Before the current standby is switched, the sending cycle is 100us and the sending time point is 20us. After the current standby is switched to the host, it synchronizes its own sending time point to 10us and then sends the business message.
[0173] Step 906: When the master-slave machine switching condition is met, determine the idle time period for the current master machine to send service messages.
[0174] Among them, determining the idle time period for the current host to send service messages can be achieved by the above method, which will not be described in detail here.
[0175] Step 908: During the idle time period for sending service messages, the current host generates a switching instruction.
[0176] Step 910: The current master sends a switching instruction to the current standby. Upon receiving feedback that the current standby responds to the switching instruction and switches to the master, the current master switches to the standby.
[0177] In the above embodiment, after the master and standby machines are powered on, if the message sending time points of the master and standby machines are inconsistent, by synchronizing the sending cycles and sending time points of the current master and the current standby machine, it is ensured that the current host is in an idle time period for sending business messages. If the master and standby machine switching conditions are also met, the master and standby machine switching is started and completed in the idle time period for sending business messages, ensuring that the time for the host to send messages is consistent before and after the switching, and the master and standby machine switching process is shielded from the device receiving the business message, avoiding the information that the master and standby machines are both master or both standby machines are transmitted to the device receiving the business message, thereby improving the reliability and stability of the master and standby machine corresponding system.
[0178] It should be understood that, although the various steps in the flowcharts involved in the various embodiments described above are displayed in sequence according to the instructions of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowcharts involved in the various embodiments described above can include multiple steps or multiple stages, and these steps or stages are not necessarily executed and completed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of steps or stages in other steps.
[0179] Based on the same inventive concept, embodiments of the present application also provide a master-standby machine switching device for implementing the master-standby machine switching method described above. The implementation solution provided by this device is similar to the implementation solution described in the above-mentioned method. Therefore, the specific limitations of one or more embodiments of the master-standby machine switching device provided below can be found in the above-mentioned limitations of the master-standby machine switching method and will not be repeated here.
[0180] In one embodiment, as shown in FIG10 , a master / standby machine switching apparatus is provided, comprising: a switching determination module 1002 and a master / standby machine switching module 1004 , wherein:
[0181] The switching judgment module 1002 is used to determine the idle time period for the current master to send service messages when the master-slave switch condition is met. The service message includes at least one of an uplink message, a downlink message, and an uplink-downlink message;
[0182] The master-slave switching module 1004 is configured to start and complete the master-slave switching during an idle time period for sending service messages.
[0183] In the above-mentioned master-standby machine switching device, when it is determined that the current host is in an idle time period for sending business messages, if the master-standby machine switching conditions are also met, the master-standby machine switching is started and completed in the idle time period for sending business messages, and the master-standby machine switching process is shielded from the device receiving the business message, thereby avoiding the information that the master and standby machines are both master or both standby machines are both standby to be transmitted to the device receiving the business message; and avoiding the master-standby machine switching when sending business messages, thereby improving the reliability and stability of the master-standby machine corresponding system.
[0184] In another embodiment, a master-slave machine switching apparatus is provided. In addition to the switching determination module 1002 and the master-slave switching module 1004, the apparatus further includes: a message interaction module, a message parsing module, a time synchronization module, a verification module, a freezing module, and an idle time period determination module, wherein:
[0185] The master-slave switching module 1004 is further configured to generate a switching instruction during an idle period of sending service messages, and switch the current master to the backup machine; the current master sends a switching instruction to the current backup machine, and the switching instruction instructs the current backup machine to switch to the master machine.
[0186] The master-slave switching module 1004 is further configured to generate a switch instruction for the current master during an idle period of sending service messages; the current master sends the switch instruction to the current standby, and upon receiving feedback that the current standby responds to the switch instruction and switches to the master, the current master switches to the standby.
[0187] The time synchronization module is used to obtain the sending cycle and sending time point of the current host sending business messages and the sending cycle and sending time point of the current standby sending business messages after the current host and the current standby are powered on;
[0188] If the sending time points of the service messages sent by the current master and the current standby are different, the sending cycle and sending time points of the service messages sent by the current standby master and the current standby are synchronized.
[0189] The message interaction module is used to obtain the interaction message with the current standby machine after the current host completes sending the last business message.
[0190] The switching judgment module 1002 is further configured to determine an idle time period for the master to send service messages if it is detected from the interaction messages that the master-slave machine switching condition is met.
[0191] In one embodiment, the interactive message includes a start byte, a check byte, and an information byte; the information byte stores a status instruction for characterizing the fault level and a control instruction for whether to switch between active and standby modes; and the check byte stores check information for checking the integrity of the interactive message.
[0192] The message parsing module is used to parse the interactive message and obtain the information byte; read the first fault level of the master machine and the second fault level of the backup machine from the target bit of the information byte;
[0193] The switching judgment module 1002 is further configured to determine that a master-slave machine switching condition is met if the first fault level is higher than the second fault level.
[0194] The switching determination module 1002 is further configured to determine whether the first fault level is a set fault level for active / standby switching, and if the first fault level is the set fault level, determine whether the first fault level is higher than the second fault level.
[0195] The verification module is used to obtain the verification byte of the interactive message; read the verification information in the verification byte; verify the interactive message according to the verification information, and if the verification result shows that the interactive message is a complete interactive message, obtain the information byte.
[0196] The idle time period determination module is used to determine the current sending period of the host for sending service messages; and determine the idle time period of the sending period as the idle time period for the host to send service messages.
[0197] The idle time period determination module is further used to determine the service message sending time point of the host in the sending cycle; and determine the idle time period of the sending cycle according to the service message sending time point.
[0198] The idle time period determination module is also used to determine the first sending cycle of the host's uplink message and the second sending cycle of the host's downlink message; if the first sending cycle and the second sending cycle are different, the idle time period of the first sending cycle is determined as the idle time period for the host to send service messages.
[0199] The freezing module is used to determine a freezing time period for the master-slave machine switching and maintain the current state of each of the master and standby machines during the freezing time period of the master-slave machine switching.
[0200] In one embodiment, the communication rate between the current master machine and the current backup machine supports at least one of 5 Mbps and 10 Mbps.
[0201] Each module in the active / standby machine switching device described above can be implemented in whole or in part through software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in hardware form, or can be stored in a computer device memory in software form, so that the processor can call and execute the corresponding operations of each module.
[0202] In one embodiment, a computer device is provided, which may be a server or a terminal device, and its internal structure diagram may be shown in FIG11 . The computer device includes a processor, a memory, and a network interface connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data such as interaction messages between the master and standby machines and the sending cycle of the master. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a master-standby machine switching method is implemented.
[0203] Those skilled in the art will understand that the structure shown in FIG11 is merely a block diagram of a portion of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0204] In one embodiment, a computer device is further provided, including a memory and a processor. The memory stores a computer program, and the processor implements the steps in the above method embodiments when executing the computer program.
[0205] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0206] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0207] It should be noted that the data involved in this application (including but not limited to data used for analysis, stored data, displayed data, etc.) are all information and data authorized by the user or fully authorized by all parties.
[0208] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, database or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory may include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in the various embodiments provided herein may include at least one of a relational database and a non-relational database. Non-relational databases may include, but are not limited to, distributed databases based on blockchains. The processor involved in the various embodiments provided herein may be, but are not limited to, a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, and the like.
[0209] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0210] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present application. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present application, and these modifications and improvements fall within the scope of protection of the present application. Therefore, the scope of protection of the present application shall be determined by the appended claims.
Claims
1. A method for switching between a primary and a standby machine, characterized in that: The method comprises: When the master-slave machine switching condition is met, determining an idle time period for the current master machine to send service messages; the service messages include at least one of uplink messages, downlink messages, and uplink and downlink messages; The master-slave machine switching is started and completed during the idle time period for sending service messages.
2. The method according to claim 1, characterized in that The starting and completing of the master-slave machine switching during the idle time period of sending the service message includes: during the idle time period of sending the service message, the current master machine generates a switching instruction, and the current master machine switches to the backup machine; The current master sends the switching instruction to the current standby machine, where the switching instruction instructs the current standby machine to switch to the master machine.
3. The method according to claim 1, characterized in that The master-slave machine switching is started and completed during the idle time period for sending the service message, including: During the idle time period for sending service messages, the current host generates a switching instruction; the current host sends the switching instruction to the current standby machine, and upon receiving feedback that the current standby machine responds to the switching instruction and switches to the host, the current host switches to the standby machine.
4. The method according to claim 1, wherein The method further comprises: After the current master and the current standby are powered on, the sending period and time of the service message sent by the current master are obtained, as well as the sending period and time of the service message sent by the current standby; If the sending time points of the service messages sent by the current master and the current standby are different, the sending cycles and sending time points of the service messages sent by the current standby master and the current standby are synchronized.
5. The method according to any one of claims 1 to 4, characterized in that When the master / slave switchover conditions are met, the idle time period for the master to send service packets is determined, including: After the current host completes sending the last service message, it obtains the interactive message with the current standby host; If it is detected according to the interaction message that the master-slave machine switching condition is met, an idle time period for the master machine to send service messages is determined.
6. The method according to claim 5, characterized in that The interactive message includes a start byte, a check byte, and an information byte; the information byte stores a status instruction for characterizing a fault level and a control instruction for whether to switch between active and standby modes; the check byte stores check information for checking the integrity of the interactive message.
7. The method according to claim 6, characterized in that Detecting, according to the interaction message, that a master / slave machine switching condition is met includes: Parsing the interaction message to obtain the information byte; Reading the first fault level of the master machine and the second fault level of the backup machine from the target bit of the information byte; If the first fault level is higher than the second fault level, it is determined that the master-slave machine switching condition is met.
8. The method according to claim 7, characterized in that Before determining that a master-slave machine switching condition is satisfied if the first fault level is higher than the second fault level, the method further includes: It is determined whether the first fault level is a set fault level for active / standby switching; if the first fault level is the set fault level, it is determined whether the first fault level is higher than the second fault level.
9. The method according to claim 7, characterized in that Before obtaining the information byte, the method further includes: Obtaining a check byte of the interaction message; Reading the check information in the check byte; The interaction message is verified according to the verification information, and if the verification result shows that the interaction message is a complete interaction message, the information byte is obtained.
10. The method according to claim 1, characterized in that Determine the idle time period for the host to send service packets, including: Determine the sending cycle of the current host to send business messages; The idle time period of the sending cycle is determined as the idle time period for the host to send service messages.
11. The method according to claim 10, characterized in that Determining an idle time period of the sending cycle includes: Determining a sending time point of the service message of the host in the sending cycle; The idle time period of the sending cycle is determined according to the sending time point of the service message.
12. The method according to claim 1, characterized in that Determine the idle time period for the host to send service packets, including: Determine a first sending period of an uplink message of the host and a second sending period of a downlink message of the host; If the first sending cycle and the second sending cycle are different, the idle time period of the first sending cycle is determined as the idle time period for the host to send service messages.
13. The method according to claim 1, wherein After the idle time period for sending service messages starts and the step of switching between the primary and standby machines is completed, the method further includes: A freeze period for switching between the primary and standby machines is determined, and the current states of the primary and standby machines are maintained during the freeze period for switching between the primary and standby machines.
14. The method according to claim 2, characterized in that The communication rate between the current master and the current standby supports at least one of 5 Mbps and 10 Mbps.
15. A master-slave machine switching device, characterized in that: The device comprises: A switching judgment module is used to determine the idle time period for the current host to send service messages when the master-slave machine switching condition is met; the service message includes at least one of an uplink message, a downlink message, and an uplink and downlink message; The master-slave switching module is used to start and complete the master-slave machine switching during the idle time period of sending service messages.
16. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 14 are implemented.
17. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 14 are implemented.
18. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 14 are implemented.
