CN115276868A - Method, device and system for synchronizing main and standby equipment - Google Patents

Method, device and system for synchronizing main and standby equipment Download PDF

Info

Publication number
CN115276868A
CN115276868A CN202210793347.0A CN202210793347A CN115276868A CN 115276868 A CN115276868 A CN 115276868A CN 202210793347 A CN202210793347 A CN 202210793347A CN 115276868 A CN115276868 A CN 115276868A
Authority
CN
China
Prior art keywords
slave
master
slave device
task
time
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202210793347.0A
Other languages
Chinese (zh)
Other versions
CN115276868B (en
Inventor
张世强
张锋瑞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Traffic Control Technology TCT Co Ltd
Original Assignee
Traffic Control Technology TCT Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Traffic Control Technology TCT Co Ltd filed Critical Traffic Control Technology TCT Co Ltd
Priority to CN202210793347.0A priority Critical patent/CN115276868B/en
Publication of CN115276868A publication Critical patent/CN115276868A/en
Application granted granted Critical
Publication of CN115276868B publication Critical patent/CN115276868B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04JMULTIPLEX COMMUNICATION
    • H04J3/00Time-division multiplex systems
    • H04J3/02Details
    • H04J3/06Synchronising arrangements
    • H04J3/0635Clock or time synchronisation in a network
    • H04J3/0638Clock or time synchronisation among nodes; Internode synchronisation
    • H04J3/0658Clock or time synchronisation among packet nodes
    • H04J3/0661Clock or time synchronisation among packet nodes using timestamps
    • H04J3/0667Bidirectional timestamps, e.g. NTP or PTP for compensation of clock drift and for compensation of propagation delays
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W4/00Services specially adapted for wireless communication networks; Facilities therefor
    • H04W4/30Services specially adapted for particular environments, situations or purposes
    • H04W4/40Services specially adapted for particular environments, situations or purposes for vehicles, e.g. vehicle-to-pedestrians [V2P]
    • H04W4/42Services specially adapted for particular environments, situations or purposes for vehicles, e.g. vehicle-to-pedestrians [V2P] for mass transport vehicles, e.g. buses, trains or aircraft

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Aviation & Aerospace Engineering (AREA)
  • Synchronisation In Digital Transmission Systems (AREA)
  • Electric Clocks (AREA)

Abstract

The invention provides a method, a device and a system for synchronizing a main device and a standby device, wherein the method comprises the following steps: determining the clock deviation of the time between the master equipment and the slave equipment according to the communication information between the master equipment and the slave equipment; determining the starting time of the current period of each platform task on the slave device according to the starting time of the current period of each platform task on the master device and the clock deviation; and sending the starting time of the current task cycle of each platform task on the slave device to the slave device, so that the slave device determines the starting time of the next cycle of each platform task on the slave device according to the current running time, the cycle duration and the starting time of the current task cycle of each platform task on the slave device. The invention is suitable for the time synchronization problem of a plurality of platform tasks with different periods on the master equipment and the slave equipment, and after one equipment is down, the other equipment can take over the work seamlessly, thereby ensuring the availability of the redundant equipment.

Description

Method, device and system for synchronizing main and standby equipment
Technical Field
The present invention relates to the field of clock synchronization technologies, and in particular, to a method, an apparatus, and a system for synchronizing a master device and a slave device.
Background
The high-speed railway vehicle-mounted equipment is key equipment for ensuring the running safety of a train, receives control information such as line conditions, running permission and the like from ground equipment, generates a target distance continuous speed mode curve according to the traction braking characteristic of the train, ensures that the train does not exceed an allowable speed curve, ensures the safe running of the train at the maximum running speed as much as possible, and reduces the running time of the train.
If the vehicle-mounted equipment does not adopt the hot standby technology, once the vehicle-mounted equipment fails, the train is braked and stopped according to the fault guiding safety principle. After the train is stopped, if the vehicle-mounted equipment is restarted, the fault can be recovered, and the train can continue to run under the supervision of the vehicle-mounted equipment; if the vehicle-mounted equipment is restarted, the fault still cannot be recovered, and the operation efficiency is seriously influenced. Therefore, the vehicle-mounted equipment is designed into a double-system hot standby mode, one system fails, and the other system can continue to control the vehicle.
If the vehicle-mounted devices with mutually hot backup redundancy run application execution processes with a plurality of different running cycles, how to solve the problem of time synchronization between the main system and the standby system and further promote the application of independently running tasks with a plurality of different cycles in the dual systems is an important issue to be solved in the industry at present.
Disclosure of Invention
Aiming at the problems in the prior art, the invention provides a method, a device and a system for synchronizing a main device and a standby device.
The invention provides a method for synchronizing a main device and a standby device, which is applied to the main device and comprises the following steps:
determining the clock deviation of the time between the master equipment and the slave equipment according to the communication information between the master equipment and the slave equipment;
determining the starting time of the current period of each platform task on the slave equipment according to the starting time of the current period of each platform task on the master equipment and the clock deviation;
and sending the starting time of the current task cycle of each platform task on the slave device to the slave device, so that the slave device determines the starting time of the next cycle of each platform task on the slave device according to the current running time, the cycle duration and the starting time of the current task cycle of each platform task on the slave device.
According to the method for synchronizing the main device and the standby device provided by the present invention, the step of determining the clock deviation between the main device and the slave device according to the communication information between the main device and the slave device comprises:
sending a signal to the slave device, and determining a first moment of sending the signal;
receiving feedback information sent by the slave equipment, wherein the feedback information comprises a second moment when the slave equipment receives the signal and a third moment when the slave equipment sends the feedback information, and determining a fourth moment when the feedback information is received;
determining a first time length between the first time and a third time, and a second time length between the second time and a fourth time;
and determining the clock deviation between the master equipment and the slave equipment according to the first time length and the second time length.
According to the master device and slave device synchronization method provided by the invention, the step of determining the clock deviation between the master device and the slave device at this time according to the communication information between the master device and the slave device comprises the following steps:
determining the clock deviation of each interactive communication between the master equipment and the slave equipment according to the communication information of each interactive communication between the master equipment and the slave equipment;
and after the maximum value and the minimum value in the current clock deviation corresponding to all times of interactive communication are removed, obtaining the average value of the rest current clock deviations by adopting a least square method, and taking the average value as the current clock deviation between the master equipment and the slave equipment.
According to the method for synchronizing the main device and the standby device provided by the invention, the step of determining the starting time of the current period of each platform task on the slave device according to the starting time of the current period of each platform task on the main device and the clock deviation comprises the following steps:
reading the starting time of the current period of each platform task in the shared memory on the main equipment; sending the starting time of the current period of each platform task to the shared memory by each platform task;
and subtracting the clock deviation of this time from the start time of the current period of each platform task in the shared memory to obtain the start time of the current period of each platform task on the slave device.
The invention also provides a master-slave device synchronization method, which is applied to slave devices and comprises the following steps:
receiving the starting time of the current task cycle of each platform task on the slave equipment, which is sent by the master equipment;
the starting time of the current task cycle of each platform task on the slave device is determined by the master device according to the starting time of the current cycle of each platform task on the master device and the clock deviation between the master device and the slave device;
the clock deviation of this time is determined by the master device according to the communication information between the master device and the slave device;
and determining the starting time of the next period of each platform task on the slave equipment according to the current running time, the period duration and the starting time of the current task period of each platform task on the slave equipment.
According to the method for synchronizing the main device and the standby device provided by the invention, the step of determining the starting time of the next period of each platform task on the slave device according to the current operating time, the period duration and the starting time of the current task period of each platform task on the slave device comprises the following steps:
sharing the starting time of the current task cycle of each platform task on the slave equipment to each platform task on the slave equipment through a shared memory on the slave equipment;
and determining the starting time of the next period of each platform task by each platform task on the slave device according to the current running time, the period duration and the starting time of the current task period of each platform task.
According to the master/slave device synchronization method provided by the present invention,
the invention also provides a device for synchronizing the main device and the standby device, which comprises:
the first calculation module is used for determining the clock deviation between the master equipment and the slave equipment according to the communication information between the master equipment and the slave equipment;
the second calculation module is used for determining the starting time of the current period of each platform task on the slave device according to the starting time of the current period of each platform task on the master device and the clock deviation;
and the sending module is used for sending the starting 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 starting time of the next cycle of each platform task on the slave device according to the current running time, the cycle duration and the starting time of the current task cycle of each platform task on the slave device.
The invention also provides a device for synchronizing the main device and the standby device, which comprises:
the receiving module is used for receiving the starting time of the current task period of each platform task on the slave equipment, which is sent by the master equipment;
the starting time of the current task cycle of each platform task on the slave device is determined by the master device according to the starting time of the current cycle of each platform task on the master device and the clock deviation between the master device and the slave device;
the clock deviation is determined by the master device according to communication information between the master device and the slave device;
and the third calculation module is used for determining the starting time of the next period of each platform task on the slave equipment according to the current running time, the period duration and the starting time of the current task period of each platform task on the slave equipment.
The invention also provides a main and standby equipment synchronization system which comprises the two main and standby equipment synchronization devices.
According to the method, the device and the system for synchronizing the main equipment and the standby equipment, the clock deviation between the main equipment and the standby equipment is calculated through the communication information between the main equipment and the standby equipment, the period starting time of the platform task on the slave equipment is obtained by taking the period starting time of the platform task on the main equipment as a reference and combining the clock deviation, and the starting time of the next period is determined by the platform task on the slave equipment according to the period starting time.
Drawings
In order to more clearly illustrate the technical solutions of the present invention or the prior art, the drawings needed for the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and those skilled in the art can also obtain other drawings according to the drawings without creative efforts.
Fig. 1 is one of the flow diagrams of the main/standby device synchronization methods provided in the present invention;
fig. 2 is a schematic diagram of an interactive communication process between a master device and a slave device designed by a PTP1588 clock synchronization protocol in the master device and slave device synchronization method provided by the present invention;
fig. 3 is a schematic diagram of signaling interaction of periodic calibration synchronization of a master device and a slave device in the method for synchronizing the master device and the slave device according to the present invention;
fig. 4 is a second flowchart of the primary/standby device synchronization method according to the present invention;
fig. 5 is a schematic signaling interaction diagram illustrating cycle start time correction of a slave device in the master/slave device synchronization method according to the present invention;
fig. 6 is a schematic structural diagram of a primary/standby device synchronization apparatus provided in the present invention;
fig. 7 is a second schematic structural diagram of the primary/standby device synchronization apparatus provided in the present invention;
fig. 8 is a schematic structural diagram of an electronic device provided in the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is obvious that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The following describes a master/slave device synchronization method according to the present invention with reference to fig. 1, which is applied to a master device and includes:
step 101, determining the clock deviation between a master device and a slave device according to communication information between the master device and the slave device;
when the master device and the slave device are started, determining one device as the master device, and taking the starting time of the running period of a plurality of platform tasks on the master device as a reference; the other device acts as a slave. The main execution body of the present embodiment is a master device.
Optionally, the master device and the slave device are a hardware-integrated security computer platform, and a real-Time communication mode is adopted between the master device and the slave device, and an ethernet TSN (Time Sensitive Network) communication technology is used.
A master-slave synchronization process is independently designed on software, and the communication process between the master device and the slave device is completed through a PTP1588 clock synchronization protocol. And calculating the clock deviation t _ offset of the time between the master device and the slave device according to the information of the mutual communication between the master device and the slave device. The present embodiment is not limited to the specific content of the communication information.
102, determining the starting time of the current period of each platform task on the slave device according to the starting time of the current period of each platform task on the master device and the clock deviation;
the master and slave devices are redundant computer platforms, and the master and slave devices have a plurality of same platform periodic tasks. Each platform periodic task is 1 independent process or 1 independent thread.
In order to realize the synchronization between the multi-platform task running on the slave device and the platform task running period on the master device, the master-slave synchronization process on the master device takes the current period starting time of the platform task on the master device as a reference, and the starting time of the current period of each platform task on the slave device is calculated according to the current clock offset t _ offset.
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 determines the start time of the next cycle of each platform task on the slave device according to the current running time, the cycle duration and the start time of the current task cycle of each platform task on the slave device.
And the master-slave synchronization process on the master device sends the start time of the current period of each platform task on the slave device to the slave device, and the slave device calculates the start time of the next period of each platform task on the slave device according to the start time.
In this embodiment, the clock skew between the main devices and the standby devices is calculated through the communication information between the main devices and the standby devices, the cycle start time of the platform task on the slave device is obtained by taking the cycle start time of the platform task on the main device as a reference in combination with the clock skew, and the platform task on the slave device determines the start time of the next cycle according to the cycle start time of the platform task itself.
On the basis of the foregoing embodiment, in this embodiment, the step of determining the current clock offset between the master device and the slave device according to communication information between the master device and the slave device includes:
sending a signal to the slave device, and determining a first moment of sending the signal;
receiving feedback information sent by the slave equipment, wherein the feedback information comprises a second moment when the slave equipment receives the signal and a third moment when the slave equipment sends the feedback information, and determining a fourth moment when the feedback information is received;
as shown in fig. 2, the interactive communication process between the master device and the slave device designed by PTP1588 clock synchronization protocol includes the following steps:
1. the master device sends a signal to the slave device at a first time t1 and sends t1 to the slave device.
2. The slave device receives the signal transmitted by the master device at the second instant t2 due to the time delay.
3. The slave device sends feedback information to the master device at a third time t3, wherein the feedback information comprises t2 and t3.
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.
Determining a first time length between the first time and a third time, and a second time length between the second time and a fourth time;
and determining the clock deviation between the master equipment and the slave equipment according to the first time length and the second time length.
According to the communication process between the master device and the slave device, the master device and the slave device can obtain t1, t2, t3 and t4. Since the real-time communication method is adopted, the communication between the master and the slave is deterministic delay communication, that is, the delay time is a fixed value.
When the delay time is set to t _ delay and the current clock offset is set to t _ offset, the following formula can be obtained:
t1+t_delay=t2+t_offset;
t3+t_delay=t4-t_offset
by calculation, we can get:
t_offset=((t1-t3)-(t2-t4))/2。
according to the embodiment, the clock deviation is obtained through calculation at multiple moments of interactive communication between the master device and the slave device, the method is simple, and calculation is accurate, so that the efficiency and accuracy of synchronization of the master device and the slave device are further improved.
On the basis of the foregoing embodiment, in this embodiment, the step of determining the current clock offset between the master device and the slave device according to communication information between the master device and the slave device includes:
determining the clock deviation of each interactive communication between the master equipment and the slave equipment according to the communication information of each interactive communication between the master equipment and the slave equipment;
and after the maximum value and the minimum value in the current clock deviation corresponding to all times of interactive communication are removed, obtaining the average value of the rest current clock deviations by adopting a least square method, and taking the average value as the current clock deviation between the master equipment and the slave equipment.
In order to reduce data errors caused by one-time interactive communication process, realization of multiple interactive communication sampling is considered, and communication information of multiple interactive communication, namely t1, t2, t3 and t4, is obtained.
According to the communication information of each interactive communication, a plurality of clock deviations t _ offsets are obtained, and all t _ offsets _ sam are sequenced from large to small. The previous largest value or values, and the following largest value or values are removed, and the remaining t _ offset is the desired value.
The average value t _ offset _ avg of the remaining t _ offsets is obtained by the least square method. And taking t _ offset _ avg as the clock deviation between the master device and the slave device.
According to the embodiment, the average clock deviation is determined through the communication information of multiple interactive communications obtained by multiple interactive communication sampling, and the accuracy of clock deviation calculation is improved, so that the accuracy of synchronization of the main equipment and the standby equipment is further improved.
On the basis of the foregoing embodiments, in this embodiment, 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 clock offset of this time includes:
reading the starting time of the current period of each platform task in the shared memory on the main equipment; sending the starting time of the current period of each platform task to the shared memory by each platform task;
and subtracting the clock deviation of this time from the start time of the current period of each platform task in the shared memory to obtain the start time of the current period of each platform task on the slave device.
As shown in fig. 3, each platform task on the master device shares the start time tn _ master _ cycle of its current task cycle with the master-slave synchronization process through the shared memory.
After the master-slave synchronization process on the master device reads the start time of the current cycle of each platform task, the start time of the current cycle of each platform task on the slave device is calculated according to t _ offset _ avg, namely:
tn_slave_cyclesbase=tn_master_cyclebase-t_offset_avg。
the master-slave synchronization process on the master device sends tn _ slave _ cycle base to the slave device. And after receiving the data, the master-slave synchronous process on the slave equipment shares the processes or threads of each platform task to the slave equipment through the shared memory.
The process or thread of each platform task of the slave device calculates the starting time of each next period according to the starting time of the current period of each platform task on the slave device, namely: t _ start = t _ curr + t _ cycle- (t _ curr + t _ cycle-tn _ slave _ cycle)% t _ cycle.
Wherein n is the serial number of the platform tasks, i.e. n =1,2,3 … total number of the platform tasks.
The embodiment obtains the period starting time of the platform task on the slave device by taking the period starting time of the platform task on the master device as a reference and combining the clock deviation, and the platform task on the slave device determines the starting time of the next period of the slave device according to the period starting time of the slave device, so that the method is suitable for the time synchronization problem of a plurality of platform tasks with different periods on the master device and the slave device.
The following describes a master/slave device synchronization method according to the present invention with reference to fig. 4, which is applied to a slave device, and includes:
step 401, receiving the start time of the current task cycle of each platform task on the slave device sent by the master device;
when the master device and the slave device are started, determining one device as the master device, and taking the starting time of the running period of a plurality of platform tasks on the master device as a reference; the other device acts as a slave. The execution subject of this embodiment is a slave device.
The starting time of the current task cycle of each platform task on the slave device is determined by the master device according to the starting time of the current cycle of each platform task on the master device and the clock deviation between the master device and the slave device;
the clock deviation of this time is determined by the master device according to the communication information between the master device and the slave device;
and the master equipment calculates the clock deviation t _ offset of the time between the master equipment and the slave equipment according to the information of the interactive communication between the master equipment and the slave equipment. The present embodiment is not limited to the specific content of the communication information.
The master and slave devices are redundant computer platforms, and the master and slave devices have a plurality of same platform periodic tasks. Each platform periodic task is 1 independent process or 1 independent thread.
In order to realize the synchronization between the multi-platform task running on the slave device and the platform task running period on the master device, the master-slave synchronization process on the master device takes the current period starting time of the platform task on the master device as a reference, and the starting time of the current period of each platform task on the slave device is calculated according to the current clock offset t _ offset.
And the slave equipment receives the start time of the current cycle of each platform task on the slave equipment, which is sent by the master-slave synchronization process on the master equipment, and calculates the start time of the next cycle of each platform task on the slave equipment according to the start time.
Step 402, determining the starting time of the next period of each platform task on the slave device according to the current running time, the period duration and the starting time of the current task period of each platform task on the slave device.
In this embodiment, the clock skew between the main devices and the standby devices is calculated through the communication information between the main devices and the standby devices, the cycle start time of the platform task on the slave device is obtained by taking the cycle start time of the platform task on the main device as a reference in combination with the clock skew, and the platform task on the slave device determines the start time of the next cycle according to the cycle start time of the platform task itself.
On the basis of the foregoing embodiment, in this embodiment, the step of determining the start time of the next period of each platform task on the slave device according to the current operating time, the period duration, and the start time of the current task period of each platform task on the slave device includes:
sharing the starting time of the current task cycle of each platform task on the slave equipment to each platform task on the slave equipment through a shared memory on the slave equipment;
and determining the starting time of the next period of each platform task by each platform task on the slave device according to the current running time, the period duration and the starting time of the current task period of each platform task.
And the master-slave synchronization process on the master device sends the start time tn _ slave _ cycle of the current task cycle of the nth platform task on the slave device to the slave device. And after receiving the data, the master-slave synchronous process on the slave equipment shares the processes or threads of each platform task to the slave equipment through the shared memory.
The process or thread of each platform task of the slave device calculates the starting time of each next period according to the starting time of the current period of each platform task on the slave device, namely: t _ start = t _ curr + t _ cycle- (t _ curr + t _ cycle-tn _ slave _ cycle)% t _ cycle.
Wherein n is the serial number of the platform tasks, i.e. n =1,2,3 … total number of the platform tasks.
The embodiment obtains the period starting time of the platform task on the slave device by taking the period starting time of the platform task on the master device as a reference and combining clock deviation, and the platform task on the slave device determines the starting time of the next period of the slave device according to the period starting time of the slave device, so that the method is suitable for the time synchronization problem of a plurality of platform tasks with different periods on the master device and the slave device.
On the basis of the above embodiments, the present embodiment further includes:
receiving the clock deviation sent by the master equipment;
determining the difference between the clock deviation and the corresponding clock deviation after the cycle start time of each platform task on the slave equipment is corrected for the last time;
and under the condition that the difference value is larger than a preset threshold value, informing each platform task on the slave device to adjust the starting time of the current task period of each platform task.
In the periodic operation process of the platform task, due to the deviation of the clock oscillation frequency of the master device and the slave device, the clock offset of the two devices can be continuously changed in an accumulated mode along with the change of time, and therefore the synchronous error accumulation of the master device and the slave device is increased.
In order to eliminate the cumulative effect of the errors, it is necessary to periodically monitor whether the clock offset t _ offset of the two devices changes, and when the change is greater than a preset threshold allowed by synchronization, for example, 2ms, the period start time of the slave device needs to be corrected to ensure that the task periods of the master device and the slave device are consistent.
As shown in fig. 5, platform tasks on the master and slave devices periodically perform PTP1588 protocol interaction, 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 differs from t _ offset _ avg _ last, which is obtained by first calculation after last correction, by more than a preset threshold. And if the time is larger than the preset threshold value, informing each platform task of adjusting the cycle start time through the shared memory.
And counting the times of positive offset and the times of negative offset according to the positive and negative directions of the clock offset calculated every time after the last correction. And (4) adjusting the period starting time of the platform task on the equipment to be faster or slower by a preset value, such as 2ms, according to the times of the positive offset and the times of the negative offset.
In this embodiment, when the clock skew of the master device and the slave device is accumulated to a large value, the cycle start time of the platform task on the slave device is corrected, so that the clock skew between the master device and the slave device is reduced.
The following describes the master/slave device synchronization apparatus provided in the present invention, and the master/slave device synchronization apparatus described below and the master/slave device synchronization method described above may be referred to in correspondence to each other.
As shown in fig. 6, the apparatus includes a first calculating module 601, a second calculating module 602, and a sending module 603, wherein:
the first calculation module 601 is configured to determine a current clock offset between a master device and a slave device according to communication information between the master device and the slave device;
the second calculation module 602 is configured to determine, according to the start time of the current cycle of each platform task on the master device and the clock deviation of this time, the start time of the current cycle of each platform task on the slave device;
the sending module 603 is configured 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 determines the start time of the next cycle of each platform task on the slave device according to the current running time, the cycle duration, and the start time of the current task cycle of each platform task on the slave device.
In this embodiment, the clock skew between the main devices and the standby devices is calculated through the communication information between the main devices and the standby devices, the cycle start time of the platform task on the slave device is obtained by taking the cycle start time of the platform task on the main device as a reference in combination with the clock skew, and the platform task on the slave device determines the start time of the next cycle according to the cycle start time of the platform task itself.
The following describes the master/slave device synchronization apparatus provided in the present invention, and the master/slave device synchronization apparatus described below and the master/slave device synchronization method described above may be referred to in correspondence with each other.
As shown in fig. 7, the apparatus comprises a receiving module 701 and a third calculating module 702, wherein:
the receiving module 701 is configured to receive start time of a current task cycle of each platform task on the slave device, where the start time is sent by the master device;
the starting time of the current task cycle of each platform task on the slave device is determined by the master device according to the starting time of the current cycle of each platform task on the master device and the clock deviation between the master device and the slave device;
the clock deviation of this time is determined by the master device according to the communication information between the master device and the slave device;
the third calculating module 702 is configured to determine the start time of the next period of each platform task on the slave device according to the current running time, the period duration, and the start time of the current task period of each platform task on the slave device.
In this embodiment, a clock skew between the master device and the slave device is calculated through communication information between the master device and the slave device, the cycle start time of a platform task on the slave device is obtained by taking the cycle start time of the platform task on the master device as a reference and combining the clock skew, and the platform task on the slave device determines the start time of the next cycle according to the cycle start time of the platform task.
The following describes the master/slave device synchronization system provided by the present invention, and the master/slave device synchronization system described below and the master/slave device synchronization apparatus described above may be referred to with respect to each other.
The master-slave device synchronization system includes the master-slave device synchronization apparatus in the above two embodiments.
In this embodiment, the clock skew between the main devices and the standby devices is calculated through the communication information between the main devices and the standby devices, the cycle start time of the platform task on the slave device is obtained by taking the cycle start time of the platform task on the main device as a reference in combination with the clock skew, and the platform task on the slave device determines the start time of the next cycle according to the cycle start time of the platform task itself.
Fig. 8 illustrates a physical structure diagram of an electronic device, and as shown in fig. 8, the electronic device may include: a processor (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 via the communication bus 840. Processor 810 may call logic instructions in memory 830 to perform a master-slave synchronization method comprising: determining the clock deviation of the time between the master equipment and the slave equipment according to the communication information between the master equipment and the slave equipment; determining the starting time of the current period of each platform task on the slave device according to the starting time of the current period of each platform task on the master device and the clock deviation; and sending the starting time of the current task cycle of each platform task on the slave device to the slave device, so that the slave device determines the starting time of the next cycle of each platform task on the slave device according to the current running time, the cycle duration and the starting time of the current task cycle of each platform task on the slave device.
In addition, the logic instructions in the memory 830 can be implemented in the form of software functional units and stored in a computer readable storage medium when the software functional units are sold or used as independent products. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
In another aspect, the present invention further provides a computer program product, where the computer program product includes a computer program, the computer program may be stored on a non-transitory computer readable storage medium, and when the computer program is executed by a processor, a computer is capable of executing the method for synchronizing a master device and a slave device provided by the above methods, where the method includes: determining the clock deviation of the time between the master equipment and the slave equipment according to the communication information between the master equipment and the slave equipment; determining the starting time of the current period of each platform task on the slave device according to the starting time of the current period of each platform task on the master device and the clock deviation; and sending the starting time of the current task cycle of each platform task on the slave device to the slave device, so that the slave device determines the starting time of the next cycle of each platform task on the slave device according to the current running time, the cycle duration and the starting time of the current task cycle of each platform task on the slave device.
In another aspect, the present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored, the computer program being implemented, when executed by a processor, to perform the method for synchronizing a master device and a slave device provided by the above methods, the method including: determining the clock deviation of the time between the master equipment and the slave equipment according to the communication information between the master equipment and the slave equipment; determining the starting time of the current period of each platform task on the slave device according to the starting time of the current period of each platform task on the master device and the clock deviation; and sending the starting time of the current task cycle of each platform task on the slave device to the slave device, so that the slave device determines the starting time of the next cycle of each platform task on the slave device according to the current running time, the cycle duration and the starting time of the current task cycle of each platform task on the slave device.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. Based on the understanding, the above technical solutions substantially or otherwise contributing to the prior art may be embodied in the form of a software product, which may be stored in a computer-readable storage medium, such as ROM/RAM, magnetic disk, optical disk, etc., and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method according to the various embodiments or some parts of the embodiments.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (10)

1. A master device and standby device synchronization method is applied to a master device, and comprises the following steps:
determining the clock deviation of the time between the master equipment and the slave equipment according to the communication information between the master equipment and the slave equipment;
determining the starting time of the current period of each platform task on the slave device according to the starting time of the current period of each platform task on the master device and the clock deviation;
and 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 determines the start time of the next cycle of each platform task on the slave device according to the current running time, the cycle duration and the start time of the current task cycle of each platform task on the slave device.
2. The method according to claim 1, wherein the step of determining the current clock skew 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 moment of sending the signal;
receiving feedback information sent by the slave device, wherein the feedback information comprises 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;
determining a first time length between the first time and a third time, and a second time length between the second time and a fourth time;
and determining the clock deviation between the master equipment and the slave equipment according to the first time length and the second time length.
3. The method according to claim 1, wherein the step of determining the current clock skew between the master device and the slave device according to the communication information between the master device and the slave device comprises:
determining the clock deviation of each interactive communication between the master equipment and the slave equipment according to the communication information of each interactive communication between the master equipment and the slave equipment;
and after the maximum value and the minimum value in the current clock deviation corresponding to all times of interactive communication are removed, obtaining the average value of the rest current clock deviations by adopting a least square method, and taking the average value as the current clock deviation between the master equipment and the slave equipment.
4. The method according to any one of claims 1 to 3, wherein 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 clock offset of this time includes:
reading the starting time of the current period of each platform task in the shared memory on the main equipment; sending the starting time of the current period of each platform task to the shared memory by each platform task;
and subtracting the clock deviation of this time from the start time of the current period of each platform task in the shared memory to obtain the start time of the current period of each platform task on the slave device.
5. A master device and standby device synchronization method is applied to a slave device, and comprises the following steps:
receiving the starting time of the current task cycle of each platform task on the slave equipment, which is sent by the master equipment;
the starting time of the current task cycle of each platform task on the slave device is determined by the master device according to the starting time of the current cycle of each platform task on the master device and the clock deviation between the master device and the slave device;
the clock deviation of this time is determined by the master device according to the communication information between the master device and the slave device;
and determining the starting time of the next period of each platform task on the slave equipment according to the current running time, the period duration and the starting time of the current task period of each platform task on the slave equipment.
6. The method according to claim 5, wherein the step of determining the start time of the next period of each platform task on the slave device according to the current operating time, the period duration, and the start time of the current task period of each platform task on the slave device comprises:
sharing the starting time of the current task cycle of each platform task on the slave equipment to each platform task on the slave equipment through a shared memory on the slave equipment;
and determining the starting time of the next period of each platform task by each platform task on the slave device according to the current running time, the period duration and the starting time of the current task period of each platform task.
7. The method according to claim 5 or 6, further comprising:
receiving the clock deviation sent by the master equipment;
determining the difference between the clock deviation and the corresponding clock deviation after the cycle start time of each platform task on the slave equipment is corrected for the last time;
and under the condition that the difference value is larger than a preset threshold value, informing each platform task on the slave device to adjust the starting time of the current task period of each platform task.
8. A master-slave device synchronization apparatus, comprising:
the first calculation module is used for determining the clock deviation between the master equipment and the slave equipment according to the communication information between the master equipment and the slave equipment;
the second calculation module is used for determining the starting time of the current period of each platform task on the slave device according to the starting time of the current period of each platform task on the master device and the clock deviation;
and the sending module is used for sending the starting 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 starting time of the next cycle of each platform task on the slave device according to the current running time, the cycle duration and the starting time of the current task cycle of each platform task on the slave device.
9. A master-slave device synchronization apparatus, comprising:
the receiving module is used for receiving the starting time of the current task cycle of each platform task on the slave equipment, which is sent by the master equipment;
the starting time of the current task cycle of each platform task on the slave device is determined by the master device according to the starting time of the current cycle of each platform task on the master device and the clock deviation between the master device and the slave device;
the clock deviation is determined by the master device according to communication information between the master device and the slave device;
and the third calculation module is used for determining the starting time of the next period of each platform task on the slave device according to the current running time, the period duration and the starting time of the current task period of each platform task on the slave device.
10. A master-slave device synchronization system, comprising the master-slave device synchronization apparatus according to claim 8 and the master-slave device synchronization apparatus according to claim 9.
CN202210793347.0A 2022-07-05 2022-07-05 Master and slave equipment synchronization method, device and system Active CN115276868B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210793347.0A CN115276868B (en) 2022-07-05 2022-07-05 Master and slave equipment synchronization method, device and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210793347.0A CN115276868B (en) 2022-07-05 2022-07-05 Master and slave equipment synchronization method, device and system

Publications (2)

Publication Number Publication Date
CN115276868A true CN115276868A (en) 2022-11-01
CN115276868B CN115276868B (en) 2024-09-10

Family

ID=83763548

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210793347.0A Active CN115276868B (en) 2022-07-05 2022-07-05 Master and slave equipment synchronization method, device and system

Country Status (1)

Country Link
CN (1) CN115276868B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030014679A1 (en) * 2001-06-15 2003-01-16 Nec Corporation Network synchronization technique
CN104079364A (en) * 2014-06-19 2014-10-01 北京航空航天大学 Distributed real-time test system clock synchronization method
CN106131947A (en) * 2016-09-14 2016-11-16 潘进 A kind of method that between Wireless Communication Equipment, clock synchronizes
CN110865877A (en) * 2019-10-14 2020-03-06 平安银行股份有限公司 Task request response method and device
WO2020135857A1 (en) * 2018-12-29 2020-07-02 中兴通讯股份有限公司 Time synchronization method, system and device, and storage medium
CN114584246A (en) * 2022-03-01 2022-06-03 四川九洲电器集团有限责任公司 Wireless ad hoc network time synchronization method, system and medium based on FPGA

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030014679A1 (en) * 2001-06-15 2003-01-16 Nec Corporation Network synchronization technique
CN104079364A (en) * 2014-06-19 2014-10-01 北京航空航天大学 Distributed real-time test system clock synchronization method
CN106131947A (en) * 2016-09-14 2016-11-16 潘进 A kind of method that between Wireless Communication Equipment, clock synchronizes
WO2020135857A1 (en) * 2018-12-29 2020-07-02 中兴通讯股份有限公司 Time synchronization method, system and device, and storage medium
CN110865877A (en) * 2019-10-14 2020-03-06 平安银行股份有限公司 Task request response method and device
CN114584246A (en) * 2022-03-01 2022-06-03 四川九洲电器集团有限责任公司 Wireless ad hoc network time synchronization method, system and medium based on FPGA

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
YOUNG SEO LEE等: ""FlexRay and Ethernet AVB Synchronization for High QoS Automotive Gateway"", 《IEEE》, 7 December 2016 (2016-12-07) *

Also Published As

Publication number Publication date
CN115276868B (en) 2024-09-10

Similar Documents

Publication Publication Date Title
US7920587B2 (en) Method for establishing a global time base in a time-controlled communications system and communications system
EP3026515B1 (en) Programmable controller system
CN109921942B (en) Cloud platform switching control method, device and system and electronic equipment
CN104516306B (en) The automated system of redundancy
US10042812B2 (en) Method and system of synchronizing processors to the same computational point
CN109946956A (en) Device main and standby system synchronization and hot standby method
CN108279597A (en) A kind of computer interlocking platform courses method based on finite state machine
KR101560497B1 (en) Method for controlling reset of lockstep replicated processor cores and lockstep system using the same
CN106100901B (en) Flow velocity control method and device
CN105227289A (en) A kind of clock synchronizing method of quick precise and safety and system
KR20190074026A (en) Synchronization method and system among multiple MCUs in EtherCAT-based slave system
CN114640416B (en) High-reliability local area network training time synchronous control method and system
CN111726388A (en) Cross-cluster high-availability implementation method, device, system and equipment
CN105426171A (en) Synchronization and switching method and system for multiple two-out-of-two systems
CA3148590A1 (en) Apparatus and method for controlling a railway system
WO2019242321A1 (en) Time synchronization method, device, network device and computer readable storage medium
CN115276868A (en) Method, device and system for synchronizing main and standby equipment
CN109639381B (en) Host software timing method for safety computer platform of urban rail transit signal system
CN202142052U (en) Safe redundant computer system of train-control vehicle-mounted equipment
US9794335B2 (en) Computer system synchronization
CN114104037B (en) Vehicle-mounted signal equipment redundancy equipment, method, device and medium
CN115037596A (en) Abnormal state warning method and device, electronic equipment and storage medium
CN115276710B (en) Transponder transmission system, transponder positioning compensation method, device and medium
CN111065007A (en) Optical fiber network time-frequency synchronization method, device, medium and equipment
CN114650113A (en) Method and device for selecting clock source

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant