Master-slave equipment synchronization method, device and system
By calculating the clock deviation between the master device and the slave device in the high-speed railway on-board equipment, the time synchronization of multiple different period platform tasks on the master and slave devices is realized, ensuring that another device can seamlessly take over the work after the device goes down, solving the problem Redundant equipment availability issues were addressed.
Patent Information
- Application Number
- CN202210793347.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-05
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2042-07-05
AI Technical Summary
In high-speed railway on-board equipment, during the execution of multiple applications with different operating cycles, how to solve the problem of time synchronization between the active and backup systems to ensure that after one device goes down, the other device can seamlessly take over the work and ensure the availability of redundant devices.
The clock deviation is calculated through the communication information between the master device and the slave device. The cycle start time of the platform task on the master device is used as the benchmark. The cycle start time of the platform task on the slave device is determined based on the clock deviation, and the slave device starts based on its own cycle. The time determines the start time of the next cycle and achieves time synchronization.
It effectively solves the time synchronization problem between the active and backup devices, ensures that the other device can seamlessly take over the work after the device goes down, and improves the availability and synchronization accuracy of the redundant device.
Smart Images

Figure CN115276868B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of clock synchronization, and in particular to a method, device and system for synchronizing a master and a backup device. Background Art
[0002] High-speed railway on-board equipment is key equipment to ensure the safety of train operation. It receives control information such as line conditions and driving permits from ground equipment, and generates a target distance continuous speed mode curve based on the train's traction and braking characteristics to ensure that the train does not exceed the allowable speed curve and runs at the maximum operating speed as much as possible to ensure safe operation of the train and reduce the train running time.
[0003] If the onboard equipment does not use hot standby technology, once the onboard equipment fails, the train will brake and stop according to the fault-oriented safety principle. After stopping, if the onboard equipment is restarted, the fault can be restored and the train can continue to run under the supervision of the onboard equipment; if the onboard equipment is restarted, the fault still cannot be restored, which will seriously affect the operation efficiency. Therefore, the onboard equipment is designed to have dual-system hot standby. If one system fails, the other system can continue to control the train.
[0004] If multiple applications with different operating cycles are executed in mutually hot standby redundant on-board devices, how to solve the time synchronization problem of the primary and standby systems, and then promote the independent operation of multiple applications with different cycle tasks in the dual machines, is an important issue that needs to be solved urgently in the industry. Summary of the invention
[0005] In view of the problems existing in the prior art, the present invention provides a method, device and system for synchronizing a master and a backup device.
[0006] The present invention provides a master-slave device synchronization method, which is applied to a master device and includes:
[0007] Determine the current clock deviation between the master device and the slave device according to the communication information between the master device and the slave device;
[0008] Determine the start time of the current cycle of each platform task on the slave device according to the start time of the current cycle of each platform task on the master device and the current clock deviation;
[0009] The start time of the current task cycle of each platform task on the slave device is sent to the slave device, so that the slave device can determine the start time of the next cycle of each platform task on the slave device based on the current running time, cycle length and start time of the current task cycle of each platform task on the slave device.
[0010] According to a master-slave device synchronization method provided by the present invention, the step of determining the current clock deviation between the master device and the slave device according to the communication information between the master device and the slave device comprises:
[0011] Sending a signal to the slave device and determining a first time to send the signal;
[0012] receiving feedback information sent by the slave device, the feedback information including a second time when the slave device receives the signal and a third time when the slave device sends the feedback information, and determining a fourth time when the feedback information is received;
[0013] Determine a first duration between the first moment and a third moment, and a second duration between the second moment and a fourth moment;
[0014] A current clock deviation between the master device and the slave device is determined according to the first time length and the second time length.
[0015] According to a master-slave device synchronization method provided by the present invention, the step of determining the current clock deviation between the master device and the slave device according to the communication information between the master device and the slave device comprises:
[0016] Determine the clock deviation of each interactive communication between the master device and the slave device according to the communication information of each interactive communication between the master device and the slave device;
[0017] After removing the maximum and minimum values of the current clock deviations corresponding to all interactive communications, the least square method is used to obtain the average value of the remaining current clock deviations, and the average value is used as the current clock deviation between the master device and the slave device.
[0018] According to a master-slave device synchronization method provided by the present invention, the step of determining the start time of the current cycle of each platform task on the slave device according to the start time of the current cycle of each platform task on the master device and the current clock deviation comprises:
[0019] Reading the start time of the current cycle of each platform task in the shared memory on the master device; wherein the start time of the current cycle of each platform task is sent to the shared memory by each platform task;
[0020] The start time of the current cycle of each platform task in the shared memory is subtracted from the current clock deviation to obtain the start time of the current cycle of each platform task on the slave device.
[0021] The present invention also provides a master-slave device synchronization method, which is applied to a slave device and includes:
[0022] Receive the start time of the current task cycle of each platform task on the slave device sent by the master device;
[0023] The start time of the current task cycle of each platform task on the slave device is determined by the master device according to the start time of the current cycle of each platform task on the master device and the current clock deviation between the master device and the slave device;
[0024] The current clock deviation is determined by the master device according to communication information between the master device and the slave device;
[0025] The start time of the next cycle of each platform task on the slave device is determined according to the current running time, cycle duration and start time of the current task cycle of each platform task on the slave device.
[0026] According to a master-slave device synchronization method provided by the present invention, the step of determining the start time of the next cycle of each platform task on the slave device according to the current running time, cycle length and start time of the current task cycle of each platform task on the slave device includes:
[0027] Sharing the start time of the current task cycle of each platform task on the slave device to each platform task on the slave device through the shared memory on the slave device;
[0028] The starting time of the next cycle of each platform task is determined by each platform task on the slave device according to the current running time of each platform task, the cycle duration and the starting time of the current task cycle.
[0029] According to a method for synchronizing a master device and a standby device provided by the present invention,
[0030] The present invention also provides a master-slave device synchronization device, comprising:
[0031] A first calculation module, used to determine a current clock deviation between the master device and the slave device according to communication information between the master device and the slave device;
[0032] A second calculation module, used to determine the start time of the current cycle of each platform task on the slave device according to the start time of the current cycle of each platform task on the master device and the current clock deviation;
[0033] A sending module is used to send the start time of the current task cycle of each platform task on the slave device to the slave device, so that the slave device can determine the start time of the next cycle of each platform task on the slave device according to the current running time, cycle length and start time of the current task cycle of each platform task on the slave device.
[0034] The present invention also provides a master-slave device synchronization device, comprising:
[0035] A receiving module, used for receiving the start time of the current task cycle of each platform task on the slave device sent by the master device;
[0036] The start time of the current task cycle of each platform task on the slave device is determined by the master device according to the start time of the current cycle of each platform task on the master device and the current clock deviation between the master device and the slave device;
[0037] The current clock deviation is determined by the master device according to communication information between the master device and the slave device;
[0038] The third calculation module is used to determine the start time of the next cycle of each platform task on the slave device according to the current running time, cycle length and start time of the current task cycle of each platform task on the slave device.
[0039] The present invention also provides a master-standby equipment synchronization system, comprising the above two master-standby equipment synchronization devices.
[0040] The master-slave device synchronization method, device and system provided by the present invention calculate the clock deviation between the master and slave devices through the communication information between the master and slave devices, take the cycle start time of the platform task on the master device as the benchmark, and combine the clock deviation to obtain the cycle start time of the platform task on the slave device. The platform task on the slave device determines the start time of its next cycle according to its own cycle start time. It is suitable for the time synchronization problem of multiple platform tasks with different cycles on the master and slave devices. After one device fails, another device can seamlessly take over the work, thereby ensuring the availability of redundant devices. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions in the present invention or 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 some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0042] Figure 1 This is one of the flow charts of the master-slave device synchronization method provided by the present invention;
[0043] Figure 2 It is a schematic diagram of the interactive communication process between the master and slave devices designed by the PTP1588 clock synchronization protocol in the master-slave device synchronization method provided by the present invention;
[0044] Figure 3It is a schematic diagram of signaling interaction for periodic calibration synchronization of master and slave devices in the master-slave device synchronization method provided by the present invention;
[0045] Figure 4 This is the second flow chart of the master-slave device synchronization method provided by the present invention;
[0046] Figure 5 It is a schematic diagram of signaling interaction for cycle start time correction of a slave device in the master-slave device synchronization method provided by the present invention;
[0047] Figure 6 It is one of the structural schematic diagrams of the master-slave equipment synchronization device provided by the present invention;
[0048] Figure 7 This is the second structural schematic diagram of the master-slave equipment synchronization device provided by the present invention;
[0049] Figure 8 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0051] Combine the following Figure 1 A master-slave device synchronization method of the present invention is described, which is applied to a master device and includes:
[0052] Step 101, determining a current clock deviation between the master device and the slave device according to communication information between the master device and the slave device;
[0053] When the master and slave devices are started, one device is determined as the master device, and the start time of the operation cycle of multiple platform tasks on the master device is used as a reference; the other device is used as the slave device. The execution subject of this embodiment is the master device.
[0054] Optionally, the master and slave devices are hardware-integrated secure computer platforms, and real-time communication is adopted between the master and slave devices, using Ethernet TSN (Time Sensitive Network) communication technology.
[0055] A master-slave synchronization process is designed separately in software, and the communication process between the master and slave devices is completed through the PTP1588 clock synchronization protocol. According to the information of the interactive communication between the two, the clock deviation t_offset between the master and slave devices is calculated. This embodiment is not limited to the specific content of the communication information.
[0056] Step 102, determining the start time of the current cycle of each platform task on the slave device according to the start time of the current cycle of each platform task on the master device and the current clock deviation;
[0057] The master and slave devices are redundant computer platforms, and the master and slave devices have multiple identical platform periodic tasks. Each platform periodic task is an independent process or an independent thread.
[0058] In order to synchronize the operation cycle of the platform tasks on the master device with that of the multi-platform tasks on the slave device, the master-slave synchronization process on the master device uses the current cycle start time of the platform tasks on the master device as the benchmark and calculates the start time of the current cycle of each platform task on the slave device according to the current clock deviation t_offset.
[0059] Step 103, sending the start time of the current task cycle of each platform task on the slave device to the slave device, so that the slave device can determine the start time of the next cycle of each platform task on the slave device according to the current running time, cycle length and start time of the current task cycle of each platform task on the slave device.
[0060] The master-slave synchronization process on the master device sends the start time of the current cycle of each platform task on the slave device to the slave device, and the slave device calculates the start time of the next cycle of each platform task on the slave device based on this.
[0061] This embodiment calculates the clock deviation between the master and backup devices through the communication information between the master and backup devices, takes the cycle start time of the platform task on the master device as a benchmark, and combines the clock deviation to obtain the cycle start time of the platform task on the slave device. The platform task on the slave device determines the start time of its next cycle based on its own cycle start time. This embodiment is suitable for the time synchronization problem of multiple platform tasks with different cycles on the master and slave devices. After one device fails, another device can seamlessly take over the work, thereby ensuring the availability of redundant devices.
[0062] Based on the above embodiment, the step of determining the current clock deviation between the master device and the slave device according to the communication information between the master device and the slave device in this embodiment includes:
[0063] Sending a signal to the slave device and determining a first time to send the signal;
[0064] receiving feedback information sent by the slave device, the feedback information including a second time when the slave device receives the signal and a third time when the slave device sends the feedback information, and determining a fourth time when the feedback information is received;
[0065] like Figure 2 As shown in the figure, the interactive communication process between the master and slave devices designed by the PTP1588 clock synchronization protocol includes the following steps:
[0066] 1. The master device sends a signal to the slave device at the first time t1, and sends t1 to the slave device.
[0067] 2. Due to the time delay, the slave device receives the signal sent by the master device at the second time t2.
[0068] 3. The slave device sends feedback information to the master device at a third time t3, where the feedback information includes t2 and t3.
[0069] 4. Due to the time delay, the master device receives the feedback information sent by the slave device at the fourth time t4, and sends t4 to the slave device.
[0070] Determine a first duration between the first moment and a third moment, and a second duration between the second moment and a fourth moment;
[0071] A current clock deviation between the master device and the slave device is determined according to the first time length and the second time length.
[0072] According to the communication process between the master and slave devices, both the master and slave devices can obtain t1, t2, t3 and t4. Because real-time communication is adopted, the communication between the master and slave is deterministic delay communication, that is, the delay time is a fixed value.
[0073] The delay time is set to t_delay, and the current clock deviation is set to t_offset, then the following formula can be obtained:
[0074] t1+t_delay=t2+t_offset;
[0075] t3+t_delay=t4-t_offset
[0076] By calculation, we can get:
[0077] t_offset=((t1-t3)-(t2-t4)) / 2.
[0078] This embodiment calculates the clock deviation through multiple moments of interactive communication between the master and slave devices. The method is simple and the calculation is accurate, thereby further improving the efficiency and accuracy of synchronization between the master and slave devices.
[0079] Based on the above embodiment, the step of determining the current clock deviation between the master device and the slave device according to the communication information between the master device and the slave device in this embodiment includes:
[0080] Determine the clock deviation of each interactive communication between the master device and the slave device according to the communication information of each interactive communication between the master device and the slave device;
[0081] After removing the maximum and minimum values of the current clock deviations corresponding to all interactive communications, the least square method is used to obtain the average value of the remaining current clock deviations, and the average value is used as the current clock deviation between the master device and the slave device.
[0082] In order to reduce the data error caused by one interactive communication process, it is considered to implement multiple interactive communication samplings to obtain the communication information of multiple interactive communications, namely, t1, t2, t3 and t4.
[0083] According to the communication information of each interactive communication, multiple clock deviations t_offset are obtained, and all t_offset_sam are sorted in descending order. The largest one or more values in the front and the largest one or more values in the back are removed, and the remaining t_offset is the ideal value.
[0084] The least square method is used to obtain the average value t_offset_avg of the remaining t_offset, and t_offset_avg is used as the current clock deviation between the master device and the slave device.
[0085] This embodiment determines the average clock deviation by sampling multiple interactive communications to obtain communication information of multiple interactive communications, thereby improving the accuracy of clock deviation calculation and further improving the accuracy of synchronization between the primary and standby devices.
[0086] Based on the above embodiments, the step of determining the start time of the current cycle of each platform task on the slave device according to the start time of the current cycle of each platform task on the master device and the current clock deviation in this embodiment includes:
[0087] Reading the start time of the current cycle of each platform task in the shared memory on the master device; wherein the start time of the current cycle of each platform task is sent to the shared memory by each platform task;
[0088] The start time of the current cycle of each platform task in the shared memory is subtracted from the current clock deviation to obtain the start time of the current cycle of each platform task on the slave device.
[0089] like Figure 3As shown, each platform task on the master device shares the start time tn_master_cyclebase of its current task cycle with the master-slave synchronization process through shared memory.
[0090] After the master-slave synchronization process on the master device reads the start time of the current cycle of each platform task, it calculates the start time of the current cycle of each platform task on the slave device according to t_offset_avg, that is:
[0091] tn_slave_cyclesbase=tn_master_cyclebase-t_offset_avg.
[0092] The master-slave synchronization process on the master device sends tn_slave_cyclesbase to the slave device. After receiving it, the master-slave synchronization process on the slave device shares it with the processes or threads of each platform task on the slave device through shared memory.
[0093] The process or thread of each platform task of the slave device calculates the start time of each next cycle according to the start time of the current cycle of each platform task on the slave device, that is: t_start = t_curr + t_cycle - (t_curr + t_cycle - tn_slave_cyclesbase) % t_cycle.
[0094] Wherein, n is the serial number of the platform task, that is, n=1, 2, 3…the total number of platform tasks.
[0095] This embodiment uses the cycle start time of the platform task on the master device as a benchmark and combines it with the clock deviation to obtain the cycle start time of the platform task on the slave device. The platform task on the slave device determines the start time of its next cycle based on its own cycle start time. This embodiment is suitable for the time synchronization problem of multiple platform tasks with different cycles on the master and slave devices.
[0096] Combine the following Figure 4 A master-slave device synchronization method of the present invention is described, which is applied to a slave device and includes:
[0097] Step 401, receiving the start time of the current task cycle of each platform task on the slave device sent by the master device;
[0098] When the master and slave devices are started, one device is determined as the master device, and the start time of the operation cycle of multiple platform tasks on the master device is used as a reference; the other device is the slave device. The execution subject of this embodiment is the slave device.
[0099] The start time of the current task cycle of each platform task on the slave device is determined by the master device according to the start time of the current cycle of each platform task on the master device and the current clock deviation between the master device and the slave device;
[0100] The current clock deviation is determined by the master device according to communication information between the master device and the slave device;
[0101] The master device calculates the current clock deviation t_offset between the master and slave devices based on the information of the interactive communication between the two devices. This embodiment is not limited to the specific content of the communication information.
[0102] The master and slave devices are redundant computer platforms, and the master and slave devices have multiple identical platform periodic tasks. Each platform periodic task is an independent process or an independent thread.
[0103] In order to synchronize the operation cycle of the platform tasks on the master device with that of the multi-platform tasks on the slave device, the master-slave synchronization process on the master device uses the current cycle start time of the platform tasks on the master device as the benchmark and calculates the start time of the current cycle of each platform task on the slave device according to the current clock deviation t_offset.
[0104] The slave device receives the start time of the current cycle of each platform task on the slave device sent by the master-slave synchronization process on the master device, and calculates the start time of the next cycle of each platform task on the slave device accordingly.
[0105] Step 402, determining the start time of the next cycle of each platform task on the slave device according to the current running time, cycle duration and start time of the current task cycle of each platform task on the slave device.
[0106] This embodiment calculates the clock deviation between the master and backup devices through the communication information between the master and backup devices, takes the cycle start time of the platform task on the master device as the benchmark, and combines the clock deviation to obtain the cycle start time of the platform task on the slave device. The platform task on the slave device determines the start time of its next cycle based on its own cycle start time. This embodiment is suitable for the time synchronization problem of multiple platform tasks with different cycles on the master and slave devices. After one device fails, another device can seamlessly take over the work to ensure the availability of redundant devices.
[0107] On the basis of the above embodiment, the step of determining the start time of the next cycle of each platform task on the slave device according to the current running time, cycle duration and start time of the current task cycle of each platform task on the slave device in this embodiment includes:
[0108] Sharing the start time of the current task cycle of each platform task on the slave device to each platform task on the slave device through the shared memory on the slave device;
[0109] The starting time of the next cycle of each platform task is determined by each platform task on the slave device according to the current running time of each platform task, the cycle duration and the starting time of the current task cycle.
[0110] The master-slave synchronization process on the master device sends the start time tn_slave_cyclesbase of the current task cycle of the nth platform task on the slave device to the slave device. After receiving the master-slave synchronization process on the slave device, it is shared to the processes or threads of each platform task of the slave device through shared memory.
[0111] The process or thread of each platform task of the slave device calculates the start time of each next cycle according to the start time of the current cycle of each platform task on the slave device, that is: t_start = t_curr + t_cycle - (t_curr + t_cycle - tn_slave_cyclesbase) % t_cycle.
[0112] Wherein, n is the serial number of the platform task, that is, n=1, 2, 3…the total number of platform tasks.
[0113] This embodiment uses the cycle start time of the platform task on the master device as a benchmark and combines it with the clock deviation to obtain the cycle start time of the platform task on the slave device. The platform task on the slave device determines the start time of its next cycle based on its own cycle start time. This embodiment is suitable for the time synchronization problem of multiple platform tasks with different cycles on the master and slave devices.
[0114] Based on the above embodiments, this embodiment also includes:
[0115] Receiving the current clock deviation sent by the master device;
[0116] Determine the difference between the current clock deviation and the clock deviation corresponding to the most recently corrected cycle start time of each platform task on the slave device;
[0117] When the difference is greater than a preset threshold, each platform task on the slave device is notified to adjust the start time of the current task cycle of each platform task.
[0118] During the platform task cycle, due to the deviation of the clock oscillation frequency of the master and slave devices, the clock offset of the two devices will continue to accumulate and change over time, thereby causing the synchronization error of the master and slave devices to accumulate and increase.
[0119] To eliminate the cumulative effect of this error, it is necessary to periodically monitor whether the clock offset t_offset of the two devices has changed. When the change is greater than the preset threshold allowed by synchronization, such as 2ms, the cycle start time of the slave device needs to be corrected to ensure that the task cycle of the master and slave devices remains consistent.
[0120] like Figure 5 As shown in the figure, the platform tasks on the master and slave devices periodically interact with the PTP1588 protocol, calculate t_offset_avg in real time, and the slave device monitors in real time whether the clock offset of the current master and slave devices is greater than the preset threshold value compared with the t_offset_avg_last calculated for the first time after the last correction. If it is greater than the preset threshold value, each platform task is notified through shared memory to adjust the cycle start time.
[0121] According to the positive and negative directions of the clock deviation calculated each time after the last correction, the number of positive and negative offsets is counted. According to the number of positive and negative offsets, the period start time of the platform task on the device is accelerated or decelerated by a preset value, such as 2ms.
[0122] In this embodiment, when the clock offset between the master and slave devices accumulates to a large value, the period start time of the platform task on the slave device is corrected, thereby reducing the clock offset between the master and slave devices.
[0123] The master-standby device synchronization apparatus provided by the present invention is described below. The master-standby device synchronization apparatus described below and the master-standby device synchronization method described above can be referred to each other.
[0124] like Figure 6 As shown, the device includes a first calculation module 601, a second calculation module 602 and a sending module 603, wherein:
[0125] The first calculation module 601 is used to determine the current clock deviation between the master device and the slave device according to the communication information between the master device and the slave device;
[0126] The second calculation module 602 is used to determine the start time of the current cycle of each platform task on the slave device according to the start time of the current cycle of each platform task on the master device and the current clock deviation;
[0127] The sending module 603 is used to send the start time of the current task cycle of each platform task on the slave device to the slave device, so that the slave device can determine the start time of the next cycle of each platform task on the slave device based on the current running time, cycle length and start time of the current task cycle of each platform task on the slave device.
[0128] This embodiment calculates the clock deviation between the master and backup devices through the communication information between the master and backup devices, takes the cycle start time of the platform task on the master device as a benchmark, and combines the clock deviation to obtain the cycle start time of the platform task on the slave device. The platform task on the slave device determines the start time of its next cycle based on its own cycle start time. This embodiment is suitable for the time synchronization problem of multiple platform tasks with different cycles on the master and slave devices. After one device fails, another device can seamlessly take over the work, thereby ensuring the availability of redundant devices.
[0129] The master-standby device synchronization apparatus provided by the present invention is described below. The master-standby device synchronization apparatus described below and the master-standby device synchronization method described above can be referred to each other.
[0130] like Figure 7 As shown, the device includes a receiving module 701 and a third calculating module 702, wherein:
[0131] The receiving module 701 is used to receive the start time of the current task cycle of each platform task on the slave device sent by the master device;
[0132] The start time of the current task cycle of each platform task on the slave device is determined by the master device according to the start time of the current cycle of each platform task on the master device and the current clock deviation between the master device and the slave device;
[0133] The current clock deviation is determined by the master device according to communication information between the master device and the slave device;
[0134] The third calculation module 702 is used to determine the start time of the next cycle of each platform task on the slave device according to the current running time, cycle duration and start time of the current task cycle of each platform task on the slave device.
[0135] This embodiment calculates the clock deviation between the master and backup devices through the communication information between the master and backup devices, takes the cycle start time of the platform task on the master device as a benchmark, and combines the clock deviation to obtain the cycle start time of the platform task on the slave device. The platform task on the slave device determines the start time of its next cycle based on its own cycle start time. This embodiment is suitable for the time synchronization problem of multiple platform tasks with different cycles on the master and slave devices. After one device fails, another device can seamlessly take over the work, thereby ensuring the availability of redundant devices.
[0136] The master-standby device synchronization system provided by the present invention is described below. The master-standby device synchronization system described below and the master-standby device synchronization device described above can be referred to each other.
[0137] The master-slave device synchronization system includes the master-slave device synchronization apparatus in the above two embodiments.
[0138] This embodiment calculates the clock deviation between the master and backup devices through the communication information between the master and backup devices, takes the cycle start time of the platform task on the master device as a benchmark, and combines the clock deviation to obtain the cycle start time of the platform task on the slave device. The platform task on the slave device determines the start time of its next cycle based on its own cycle start time. This embodiment is suitable for the time synchronization problem of multiple platform tasks with different cycles on the master and slave devices. After one device fails, another device can seamlessly take over the work, thereby ensuring the availability of redundant devices.
[0139] Figure 8 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 8 As shown, the electronic device may include: a processor 810, a communication interface 820, a memory 830 and a communication bus 840, wherein the processor 810, the communication interface 820 and the memory 830 communicate with each other through the communication bus 840. The processor 810 may call the logic instructions in the memory 830 to execute the master-slave device synchronization method, which includes: determining the current clock deviation between the master device and the slave device according to the communication information between the master device and the slave device; determining the start time of the current cycle of each platform task on the slave device according to the start time of the current cycle of each platform task on the master device and the current clock deviation; sending the start time of the current task cycle of each platform task on the slave device to the slave device, so that the slave device can determine the start time of the next cycle of each platform task on the slave device according to the current running time, cycle length and start time of the current task cycle of each platform task on the slave device.
[0140] In addition, the logic instructions in the above-mentioned memory 830 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0141] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the master-slave device synchronization method provided by the above methods, which includes: determining the current clock deviation between the master device and the slave device based on the communication information between the master device and the slave device; determining the start time of the current cycle of each platform task on the slave device based on the start time of the current cycle of each platform task on the master device and the current clock deviation; sending the start time of the current task cycle of each platform task on the slave device to the slave device, so that the slave device can determine the start time of the next cycle of each platform task on the slave device based on the current running time, cycle duration and start time of the current task cycle of each platform task on the slave device.
[0142] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the master-slave device synchronization method provided by the above-mentioned methods, the method comprising: determining the current clock deviation between the master device and the slave device based on the communication information between the master device and the slave device; determining the start time of the current cycle of each platform task on the slave device based on the start time of the current cycle of each platform task on the master device and the current clock deviation; sending the start time of the current task cycle of each platform task on the slave device to the slave device, so that the slave device can determine the start time of the next cycle of each platform task on the slave device based on the current running time, cycle duration and start time of the current task cycle of each platform task on the slave device.
[0143] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0144] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0145] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for synchronizing a master device and a backup device, It is characterized in that Applicable to main equipment, including: Determine the current clock deviation between the master device and the slave device according to the communication information between the master device and the slave device; Determine the start time of the current cycle of each platform task on the slave device according to the start time of the current cycle of each platform task on the master device and the current clock deviation; Sending the start time of the current task cycle of each platform task on the slave device to the slave device, so that the slave device can determine the start time of the next cycle of each platform task on the slave device according to the current running time, cycle length and start time of the current task cycle of each platform task on the slave device; The start time of the next cycle of each platform task is calculated as follows: t_start=t_curr+t_cycle-(t_curr+t_cycle-tn_slave_cyclesbase)%t_cycle Among them, n is the serial number of the platform task, that is, n=1, 2, 3...the total number of platform tasks, t_start is the start time of the next cycle, tn_slave_cyclesbase is the start time of the current task cycle, t_cycle is the cycle duration, and t_curr is the current running time.
2. The method for synchronizing a master device and a backup device according to claim 1, It is characterized in that The step of determining the current clock deviation between the master device and the slave device according to the communication information between the master device and the slave device comprises: Sending a signal to the slave device and determining a first time to send the signal; receiving feedback information sent by the slave device, the feedback information including a second time when the slave device receives the signal and a third time when the slave device sends the feedback information, and determining a fourth time when the feedback information is received; Determine a first duration between the first moment and a third moment, and a second duration between the second moment and a fourth moment; A current clock deviation between the master device and the slave device is determined according to the first time length and the second time length.
3. The master-slave device synchronization method according to claim 1, It is characterized in that The step of determining the current clock deviation between the master device and the slave device according to the communication information between the master device and the slave device comprises: Determine the clock deviation of each interactive communication between the master device and the slave device according to the communication information of each interactive communication between the master device and the slave device; After removing the maximum and minimum values of the current clock deviations corresponding to all interactive communications, the least square method is used to obtain the average value of the remaining current clock deviations, and the average value is used as the current clock deviation between the master device and the slave device.
4. The method for synchronizing a master device with a backup device according to any one of claims 1 to 3, It is characterized in that The step of determining the start time of the current cycle of each platform task on the slave device according to the start time of the current cycle of each platform task on the master device and the current clock deviation comprises: Reading the start time of the current cycle of each platform task in the shared memory on the master device; wherein the start time of the current cycle of each platform task is sent to the shared memory by each platform task; The start time of the current cycle of each platform task in the shared memory is subtracted from the current clock deviation to obtain the start time of the current cycle of each platform task on the slave device.
5. A method for synchronizing a master device and a backup device, It is characterized in that Applicable to slave devices, including: Receive the start time of the current task cycle of each platform task on the slave device sent by the master device; The start time of the current task cycle of each platform task on the slave device is determined by the master device according to the start time of the current cycle of each platform task on the master device and the current clock deviation between the master device and the slave device; The current clock deviation is determined by the master device according to communication information between the master device and the slave device; Determine the start time of the next cycle of each platform task on the slave device according to the current running time, cycle duration and start time of the current task cycle of each platform task on the slave device; The start time of the next cycle of each platform task is calculated as follows: t_start=t_curr+t_cycle-(t_curr+t_cycle-tn_slave_cyclesbase)%t_cycle Among them, n is the serial number of the platform task, that is, n=1, 2, 3...the total number of platform tasks, t_start is the start time of the next cycle, tn_slave_cyclesbase is the start time of the current task cycle, t_cycle is the cycle duration, and t_curr is the current running time.
6. The method for synchronizing a master device and a backup device according to claim 5, It is characterized in that The step of determining the start time of the next cycle of each platform task on the slave device according to the current running time, cycle duration and start time of the current task cycle of each platform task on the slave device comprises: Sharing the start time of the current task cycle of each platform task on the slave device to each platform task on the slave device through the shared memory on the slave device; The starting time of the next cycle of each platform task is determined by each platform task on the slave device according to the current running time of each platform task, the cycle duration and the starting time of the current task cycle.
7. The method for synchronizing a master device with a backup device according to claim 5 or 6, It is characterized in that Also includes: Receiving the current clock deviation sent by the master device; Determine the difference between the current clock deviation and the clock deviation corresponding to the most recently corrected cycle start time of each platform task on the slave device; When the difference is greater than a preset threshold, each platform task on the slave device is notified to adjust the start time of the current task cycle of each platform task.
8. A master-slave device synchronization device, It is characterized in that include: A first calculation module, used to determine a current clock deviation between the master device and the slave device according to communication information between the master device and the slave device; A second calculation module, used to determine the start time of the current cycle of each platform task on the slave device according to the start time of the current cycle of each platform task on the master device and the current clock deviation; A sending module, used for sending the start time of the current task cycle of each platform task on the slave device to the slave device, so that the slave device can determine the start time of the next cycle of each platform task on the slave device according to the current running time, cycle length and start time of the current task cycle of each platform task on the slave device; The start time of the next cycle of each platform task is calculated as follows: t_start=t_curr+t_cycle-(t_curr+t_cycle-tn_slave_cyclesbase)%t_cycle Among them, n is the serial number of the platform task, that is, n=1, 2, 3...the total number of platform tasks, t_start is the start time of the next cycle, tn_slave_cyclesbase is the start time of the current task cycle, t_cycle is the cycle duration, and t_curr is the current running time.
9. A master-slave device synchronization device, It is characterized in that include: A receiving module, used for receiving the start time of the current task cycle of each platform task on the slave device sent by the master device; The start time of the current task cycle of each platform task on the slave device is determined by the master device according to the start time of the current cycle of each platform task on the master device and the current clock deviation between the master device and the slave device; The current clock deviation is determined by the master device according to communication information between the master device and the slave device; A third calculation module is used to determine the start time of the next cycle of each platform task on the slave device according to the current running time, cycle length and start time of the current task cycle of each platform task on the slave device; The start time of the next cycle of each platform task is calculated as follows: t_start=t_curr+t_cycle-(t_curr+t_cycle-tn_slave_cyclesbase)%t_cycle Among them, n is the serial number of the platform task, that is, n=1, 2, 3...the total number of platform tasks, t_start is the start time of the next cycle, tn_slave_cyclesbase is the start time of the current task cycle, t_cycle is the cycle duration, and t_curr is the current running time.
10. A master-slave device synchronization system, It is characterized in that It includes the master-slave equipment synchronization device described in claim 8 and the master-slave equipment synchronization device described in claim 9.
