Disclosure of Invention
The invention mainly aims to provide a data synchronization method, user equipment and a computer readable storage medium, and aims to solve the technical problem that the running states of air conditioners displayed on the user equipment and the air conditioner side are different when the network environment is poor in the prior art.
In order to achieve the above object, the present invention provides a data synchronization method, including the steps of:
the method comprises the steps that user equipment responds to an air conditioner adjusting instruction input by a user, determines a corresponding first air conditioner running state according to the air conditioner adjusting instruction, and sends the first air conditioner running state to a server, so that the server modifies a second air conditioner running state stored locally into the first air conditioner running state, and reply information is generated and fed back;
judging whether the reply information is successfully adjusted information, wherein the successfully adjusted information is used for representing that the server successfully modifies the running state of the air conditioner side;
and when the reply information is the successful adjustment information, displaying the running state of the first air conditioner in a current display interface so as to realize data synchronization.
Preferably, before the user equipment responds to an air conditioner adjustment instruction input by a user, determines a corresponding first air conditioner operation state according to the air conditioner adjustment instruction, and sends the first air conditioner operation state to a server, so that the server modifies a second air conditioner operation state stored locally into the first air conditioner operation state, and generates and feeds back a reply message, the data synchronization method further includes:
the method comprises the steps that user equipment responds to a login instruction input by a user, reads a user identifier from the login instruction, and inquires a corresponding air conditioner identifier according to the user identifier;
sending the air conditioner identification to a server so that the server queries a corresponding third air conditioner running state from a preset mapping relation according to the air conditioner identification, and feeding back the third air conditioner running state when the third air conditioner running state is queried, wherein the preset mapping relation comprises the corresponding relation between the air conditioner identification and the air conditioner running state;
and when the third air conditioner running state is received, displaying the third air conditioner running state in a current display interface.
Preferably, after the user equipment responds to a login instruction input by a user, reads a user identifier from the login instruction, and queries a corresponding air conditioner identifier according to the user identifier, the data synchronization method further includes:
sending a detection instruction to the air conditioner corresponding to the air conditioner identifier so that the air conditioner responds to the detection instruction to detect the network connection state of the network where the air conditioner is located, and feeding back the online state when the network connection state is the online state;
monitoring whether an online state fed back by the air conditioner is received within a first preset time;
and when the online state fed back by the air conditioner is received within the first preset time, the step of sending the air conditioner identification to a server is executed, so that the server inquires a corresponding third air conditioner running state from a preset mapping relation according to the air conditioner identification, and when the third air conditioner running state is inquired, the step of feeding back the third air conditioner running state is executed.
Preferably, the sending of the air conditioner identifier to the server is performed so that the server queries a corresponding third air conditioner operating state from a preset mapping relationship according to the air conditioner identifier, and when the third air conditioner operating state is queried, after the third air conditioner operating state is fed back, the data synchronization method further includes:
when the third air conditioner running state is not received, acquiring a default running state, and displaying the default running state in the current display interface;
sending a state updating instruction to the server according to a preset period so that the server responds to the state updating instruction, inquires a corresponding fourth air conditioner running state according to the air conditioner identification, and feeds back the fourth air conditioner running state when the fourth air conditioner running state is inquired;
and when the fourth air conditioner running state fed back by the server is not received within a second preset time, displaying a preset prompting interface, wherein the preset prompting interface is used for prompting a user that the current network is unstable.
Preferably, the sending of the state updating instruction to the server according to the preset period is performed, so that the server responds to the state updating instruction, queries a corresponding fourth air conditioner operating state according to the air conditioner identifier, and after the fourth air conditioner operating state is fed back when the fourth air conditioner operating state is queried, the data synchronization method further includes:
and when a fourth air conditioner running state fed back by the server is received within a second preset time, switching the equipment state displayed in the current display interface from the default running state to the fourth air conditioner running state.
Preferably, the sending of the state updating instruction to the server according to the preset period is performed, so that the server responds to the state updating instruction, queries a corresponding fourth air conditioner operating state according to the air conditioner identifier, and when the fourth air conditioner operating state is queried, before the fourth air conditioner operating state is fed back, the data synchronization method further includes:
calculating the current packet loss rate;
and when the current packet loss rate is lower than a preset threshold value, executing the step of sending a state updating instruction to the server according to a preset period so that the server responds to the state updating instruction, inquiring a corresponding fourth air conditioner running state according to the air conditioner identification, and feeding back the fourth air conditioner running state when the fourth air conditioner running state is inquired.
Preferably, when the reply message is the adjustment success message, the data synchronization method further includes, after the first air conditioner operation state is displayed in a current display interface to implement data synchronization, the step of:
responding to a synchronization instruction input by a user, acquiring a locally stored running state and taking the running state as a first synchronization state;
sending the synchronization instruction to the server, so that the server responds to the synchronization instruction, acquires a locally stored running state and feeds the running state back as a second synchronization state;
sending the synchronization instruction to the air conditioner so that the air conditioner responds to the synchronization instruction, acquires a locally stored running state and feeds the running state back as a third synchronization state;
comparing the first synchronization state, the second synchronization state and the third synchronization state;
and when the first synchronization state, the second synchronization state and the third synchronization state are the same, displaying prompt information of successful synchronization.
Preferably, after comparing the first synchronization status, the second synchronization status and the third synchronization status, the data synchronization method further includes:
when the first synchronization state, the second synchronization state and the third synchronization state are different, modifying the locally stored first synchronization state into the third synchronization state;
sending a state correction instruction to the server to enable the server to modify the locally stored second synchronization state into the third synchronization state in response to the state correction instruction.
In addition, to achieve the above object, the present invention further provides a user equipment, including: a memory, a processor and a data synchronization program stored on the memory and executable on the processor, the data synchronization program configured to implement the steps of the data synchronization method as described above.
Further, to achieve the above object, the present invention also provides a computer-readable storage medium having stored thereon a data synchronization program which, when executed by a processor, implements the steps of the data synchronization method as described above.
According to the method and the device, before the user equipment displays the first air conditioner running state, the running states of the server side and the air conditioner side are modified firstly until the running state is modified, and then the first air conditioner running state is displayed on the user equipment side, so that the running states of the smart phone side, the server side and the air conditioner side are kept synchronous, and the technical problem that the running states of the user equipment and the air conditioner side are different when the network environment is poor in the prior art is solved.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Referring to fig. 1, fig. 1 is a schematic structural diagram of a user equipment in a hardware operating environment according to an embodiment of the present invention.
As shown in fig. 1, the user equipment may include: a processor 1001, such as a CPU, a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Wherein a communication bus 1002 is used to enable connective communication between these components. The user interface 1003 may include a Display screen (Display), and the optional user interface 1003 may further include a standard wired interface and a wireless interface, and the wired interface for the user interface 1003 may be a USB interface in the present invention. The network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory (e.g., a magnetic disk memory). The memory 1005 may alternatively be a storage device separate from the processor 1001.
Those skilled in the art will appreciate that the architecture shown in fig. 1 does not constitute a limitation of the user equipment and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components.
As shown in fig. 1, a memory 1005, which is a kind of computer-readable storage medium, may include therein an operating system, a network communication module, a user interface module, and a data synchronization program.
In the user equipment shown in fig. 1, the network interface 1004 is mainly used for connecting to a backend server and performing data communication with the backend server; the user interface 1003 is mainly used for connecting peripheral equipment; the user equipment calls the data synchronization program stored in the memory 1005 through the processor 1001 and performs the following operations:
responding to an air conditioner adjusting instruction input by a user, determining a corresponding first air conditioner running state according to the air conditioner adjusting instruction, sending the first air conditioner running state to a server, so that the server modifies a second air conditioner running state stored locally into the first air conditioner running state, and generating and feeding back reply information;
judging whether the reply information is successfully adjusted information, wherein the successfully adjusted information is used for representing that the server successfully modifies the running state of the air conditioner side;
and when the reply information is the successful adjustment information, displaying the running state of the first air conditioner in a current display interface so as to realize data synchronization.
Further, the processor 1001 may call the data synchronization program stored in the memory 1005, and also perform the following operations:
responding to a login instruction input by a user, reading a user identifier from the login instruction, and inquiring a corresponding air conditioner identifier according to the user identifier;
sending the air conditioner identification to a server so that the server queries a corresponding third air conditioner running state from a preset mapping relation according to the air conditioner identification, and feeding back the third air conditioner running state when the third air conditioner running state is queried, wherein the preset mapping relation comprises the corresponding relation between the air conditioner identification and the air conditioner running state;
and when the third air conditioner running state is received, displaying the third air conditioner running state in a current display interface.
Further, the processor 1001 may call the data synchronization program stored in the memory 1005, and also perform the following operations:
sending a detection instruction to the air conditioner corresponding to the air conditioner identifier so that the air conditioner responds to the detection instruction to detect the network connection state of the network where the air conditioner is located, and feeding back the online state when the network connection state is the online state;
monitoring whether an online state fed back by the air conditioner is received within a first preset time;
and when the online state fed back by the air conditioner is received within the first preset time, the step of sending the air conditioner identification to a server is executed, so that the server inquires a corresponding third air conditioner running state from a preset mapping relation according to the air conditioner identification, and when the third air conditioner running state is inquired, the step of feeding back the third air conditioner running state is executed.
Further, the processor 1001 may call the data synchronization program stored in the memory 1005, and also perform the following operations:
when the third air conditioner running state is not received, acquiring a default running state, and displaying the default running state in the current display interface;
sending a state updating instruction to the server according to a preset period so that the server responds to the state updating instruction, inquires a corresponding fourth air conditioner running state according to the air conditioner identification, and feeds back the fourth air conditioner running state when the fourth air conditioner running state is inquired;
and when the fourth air conditioner running state fed back by the server is not received within a second preset time, displaying a preset prompting interface, wherein the preset prompting interface is used for prompting a user that the current network is unstable.
Further, the processor 1001 may call the data synchronization program stored in the memory 1005, and also perform the following operations:
and when a fourth air conditioner running state fed back by the server is received within a second preset time, switching the equipment state displayed in the current display interface from the default running state to the fourth air conditioner running state.
Further, the processor 1001 may call the data synchronization program stored in the memory 1005, and also perform the following operations:
calculating the current packet loss rate;
and when the current packet loss rate is lower than a preset threshold value, executing the step of sending a state updating instruction to the server according to a preset period so that the server responds to the state updating instruction, inquiring a corresponding fourth air conditioner running state according to the air conditioner identification, and feeding back the fourth air conditioner running state when the fourth air conditioner running state is inquired.
Further, the processor 1001 may call the data synchronization program stored in the memory 1005, and also perform the following operations:
responding to a synchronization instruction input by a user, acquiring a locally stored running state and taking the running state as a first synchronization state;
sending the synchronization instruction to the server, so that the server responds to the synchronization instruction, acquires a locally stored running state and feeds the running state back as a second synchronization state;
sending the synchronization instruction to the air conditioner so that the air conditioner responds to the synchronization instruction, acquires a locally stored running state and feeds the running state back as a third synchronization state;
comparing the first synchronization state, the second synchronization state and the third synchronization state;
and when the first synchronization state, the second synchronization state and the third synchronization state are the same, displaying prompt information of successful synchronization.
Further, the processor 1001 may call the data synchronization program stored in the memory 1005, and also perform the following operations:
when the first synchronization state, the second synchronization state and the third synchronization state are different, modifying the locally stored first synchronization state into the third synchronization state;
sending a state correction instruction to the server to enable the server to modify the locally stored second synchronization state into the third synchronization state in response to the state correction instruction.
In this embodiment, before the user equipment displays the first air conditioner running state, the running states of the server side and the air conditioner side are modified first until the running state is modified, and then the first air conditioner running state is displayed on the user equipment side, so that the running states of the smart phone side, the server side and the air conditioner side are kept synchronous, and the technical problem that the running states of the user equipment and the air conditioner side are different when the network environment is poor in the prior art is solved.
Based on the above hardware structure, an embodiment of the data synchronization method of the present invention is provided.
Referring to fig. 2, fig. 2 is a flowchart illustrating a data synchronization method according to a first embodiment of the present invention.
In a first embodiment, the data synchronization method comprises the steps of:
step S10: responding to an air conditioner adjusting instruction input by a user, determining a corresponding first air conditioner running state according to the air conditioner adjusting instruction, sending the first air conditioner running state to a server, so that the server modifies a second air conditioner running state stored locally into the first air conditioner running state, and generating and feeding back reply information;
it is understood that the execution subject is a user device, and the user device can be an electronic device which can be connected with the internet, such as a smart phone, a personal computer and the like. In order to control the air conditioner through the smart phone, the smart phone and the air conditioner can be connected to the internet, and the air conditioner has different running states and the running states can also change along with the operation of a user, so that the consistency of the records of the smart phone, the server and the air conditioner side on the air conditioner information needs to be ensured. The air conditioner running state comprises adjustable parameters such as air conditioner control temperature and humidity.
In a specific implementation, a user may open a preset webpage or an application program related to an air conditioner in the smart phone by operating the smart phone, and the user may input an operation on the air conditioner in the opened interface, for example, the temperature of the air conditioner control currently displayed in the interface is "room temperature 23 degrees celsius", the operation input by the user is to adjust the temperature to "room temperature 26 degrees celsius", and the adjustment operation of "room temperature 26 degrees celsius" may be sent to the server. After the server receives the adjustment operation of the room temperature of 26 ℃, because the air conditioner operation state pre-stored at the server side is the room temperature of 23 ℃, the second air conditioner operation state, namely the room temperature of 23 ℃, stored at the server side can be modified into the first air conditioner operation state, namely the room temperature of 26 ℃, and after the modification is successful, reply information can be generated and sent to the smart phone.
Step S20: judging whether the reply information is adjustment success information or not, wherein the adjustment success information is used for representing that the server successfully modifies the locally stored second air conditioner operation state;
it can be understood that if the smart phone can receive the reply message, it indicates that the smart phone can be normally networked. At this time, the running state recorded by the server side is 'room temperature 26 ℃, and after the running state of the server side is successfully modified, the server can send a temperature adjusting instruction to the air conditioner, so that the air conditioner can modify the running state of the locally stored air conditioner into the first air conditioner running state according to the temperature adjusting instruction, therefore, after data is synchronized in real time at the server side, the synchronized data, namely' room temperature 26 ℃, can be sent to the air conditioner, and the modification of the air conditioner temperature is realized.
It should be understood that, after the modification of the operation state of the air conditioner side is completed, the air conditioner generates adjustment success information and feeds back the adjustment success information to the server. And after receiving the adjustment success information sent by the air conditioner, the server sends the adjustment success information to the smart phone.
Step S30: and when the reply information is the successful adjustment information, displaying the running state of the first air conditioner in a current display interface so as to realize data synchronization.
It can be understood that when the smart phone receives the adjustment success information, the running state recorded by the server side is successfully modified to be the room temperature of 26 ℃, the control temperature is successfully modified to be the room temperature of 26 ℃, after the server and the air conditioner side are successfully modified, the room temperature of 26 ℃ can be displayed on the smart phone side, and at the moment, the running states of the smart phone side, the server side and the air conditioner side are all the room temperature of 26 ℃, so that the real-time synchronization of the running states of the air conditioner on the three equipment sides is realized. And even if the network is unstable, the temperature displayed by the user equipment side and the air conditioner side can not be different, because the air conditioner adjusting instruction can be sent out when the network where the mobile phone is located is stable, the parameters of the air conditioner can be successfully modified when the network where the air conditioner is located is stable, and the user can observe the operating state after the operation on the mobile phone side after the parameters of the air conditioner side are successfully modified, the operating states of the user equipment side and the air conditioner side can not be changed when the network is unstable.
In this embodiment, before the user equipment displays the first air conditioner running state, the running states of the server side and the air conditioner side are modified first until the running state is modified, and then the first air conditioner running state is displayed on the user equipment side, so that the running states of the smart phone side, the server side and the air conditioner side are kept synchronous, and the technical problem that the running states of the user equipment and the air conditioner side are different when the network environment is poor in the prior art is solved.
Referring to fig. 3, fig. 3 is a flowchart illustrating a data synchronization method according to a second embodiment of the present invention, and the data synchronization method according to the second embodiment of the present invention is proposed based on the first embodiment shown in fig. 2.
In the second embodiment, before the step S10, the data synchronization method further includes:
step S101: responding to a login instruction input by a user, reading a user identifier from the login instruction, and inquiring a corresponding air conditioner identifier according to the user identifier;
it can be understood that, when using the air conditioner application program in the smart phone, in order to facilitate the user to view the current operating state of the air conditioner through the air conditioner application program in real time, when the user logs in the air conditioner application program, for example, the user inputs an account name and a password to log in the air conditioner application program, so as to obtain the user identifier. The user identification can be an account name or a unique character code and is used for uniquely determining the user identity.
In a specific implementation, each account may be bound with one or more air conditioner identifiers, and each air conditioner identifier is used for uniquely corresponding to one air conditioner. And after determining the corresponding air conditioner identifier according to the user identifier, indicating that the user wants to check the real-time running state of the air conditioner corresponding to the air conditioner identifier.
Step S102: sending the air conditioner identification to a server so that the server queries a corresponding third air conditioner running state from a preset mapping relation according to the air conditioner identification, and feeding back the third air conditioner running state when the third air conditioner running state is queried, wherein the preset mapping relation comprises the corresponding relation between the air conditioner identification and the air conditioner running state;
it should be understood that after determining the air conditioner identifier, the air conditioner identifier may be sent to the server to query the real-time operation state of the air conditioner, and since the operation state of the air conditioner is automatically synchronized to the server whenever the operation state of the air conditioner changes, the real-time operation state of the air conditioner may be directly known by querying the operation state at the server side. For example, if the corresponding third air conditioner running state queried by the server from the preset mapping relationship according to the air conditioner identifier is "room temperature 17 degrees centigrade", it represents that the actually controlled temperature of the air conditioner at the time is "room temperature 17 degrees centigrade".
Step S103: and when the third air conditioner running state is received, displaying the third air conditioner running state in a current display interface.
It can be understood that when the air conditioner running state fed back by the server is "room temperature 17 degrees centigrade", the information of "room temperature 17 degrees centigrade" is displayed in the display interface at the side of the smart phone, so that the user can observe the real-time running state of the air conditioner in real time through the user equipment.
Further, after the step S101, the data synchronization method may further include: sending a detection instruction to the air conditioner corresponding to the air conditioner identifier so that the air conditioner responds to the detection instruction to detect the network connection state of the network where the air conditioner is located, and feeding back the online state when the network connection state is the online state; monitoring whether an online state fed back by the air conditioner is received within a first preset time; and when the online state fed back by the air conditioner is received within the first preset time, the step of sending the air conditioner identification to a server is executed, so that the server inquires a corresponding third air conditioner running state from a preset mapping relation according to the air conditioner identification, and when the third air conditioner running state is inquired, the step of feeding back the third air conditioner running state is executed.
It can be understood that, when a user logs in an account at the smartphone side to query the real-time operation state of the air conditioner, it may be determined whether the air conditioner can be normally connected to the network first. Although the running state of the air conditioner is automatically updated to the server in real time when the running state of the air conditioner changes, the problem does not occur when the user equipment directly inquires the air conditioner information recorded by the server side, but if the air conditioner cannot be normally connected to the network, the air conditioner information recorded by the server side may be wrong, and the air conditioner information displayed by the user equipment side is not the real-time running state of the air conditioner. Therefore, in order to avoid the situation of inconsistency of the air conditioner information, whether the air conditioner can be normally connected to the network or not can be detected, and if the air conditioner can be normally connected to the network, the air conditioner operation state recorded by the server side is consistent with the actual operation state of the air conditioner.
In a specific implementation, after a user successfully logs in an air conditioner application program of a smart phone, a detection instruction is sent to an air conditioner corresponding to an air conditioner identifier so as to judge whether the air conditioner can be normally connected to a network. Of course, the user equipment may also send the detection instruction to the server, so that the server forwards the detection instruction to the air conditioner.
It can be understood that, when the air conditioner receives the detection instruction, the network environment of the network where the air conditioner is located is detected, and if the network environment of the network where the air conditioner is located can enable the air conditioner to stably synchronize the air conditioner operation state with the server, an online state can be generated and fed back to the user equipment, so that the user equipment can execute subsequent slave operations; the network environment of the network where the air conditioner is located cannot enable the air conditioner to stably synchronize the air conditioner running state with the server, and if the problem of network disconnection or too low network speed occurs, the online state cannot be generated and fed back to the user equipment. If the user equipment does not receive the online state within the first preset time, the user can be prompted that the network environment of the network where the air conditioner is located is poor.
In the embodiment, the running state of the air conditioner is inquired in real time through the user equipment, so that a user can directly observe the real-time running state of the air conditioner at the user equipment side.
Referring to fig. 4, fig. 4 is a flowchart illustrating a data synchronization method according to a third embodiment of the present invention, and the data synchronization method according to the third embodiment of the present invention is proposed based on the second embodiment shown in fig. 3.
In the third embodiment, after the step S102, the data synchronization method further includes:
step S103': when the third air conditioner running state is not received, acquiring a default running state, and displaying the default running state in the current display interface;
it can be understood that, when the operation state of the air conditioner is queried in real time through the smart phone, the user can directly observe the real-time operation state of the air conditioner at the user equipment side, and if the smart phone does not receive the queried third air conditioner operation state fed back by the server, it indicates that the network of the smart phone is unstable, or the server side fails to synchronize operation state information from the air conditioner side in time, and can acquire the default operation state to display the default operation state at the smart phone side. For example, if the air conditioner running state fed back by the server is successfully received 3 minutes ago, and the air conditioner running state fed back by the server in real time is not successfully received at the moment, the running state can be continuously displayed to be the room temperature of 15 ℃.
Step S104: sending a state updating instruction to the server according to a preset period so that the server responds to the state updating instruction, inquires a corresponding fourth air conditioner running state according to the air conditioner identification, and feeds back the fourth air conditioner running state when the fourth air conditioner running state is inquired;
it should be understood that the actual operation state of the air conditioner before 3 minutes is "room temperature 15 degrees celsius", but the actual operation state of the current air conditioner is not necessarily "room temperature 15 degrees celsius", and may be changed due to a user's operation or other reasons. Therefore, a state updating instruction is sent to the server according to a preset period so as to continuously try to inquire the real-time air conditioner running state at the server side.
Step S105: and when the fourth air conditioner running state fed back by the server is not received within a second preset time, displaying a preset prompting interface, wherein the preset prompting interface is used for prompting a user that the current network is unstable.
In a specific implementation, when the air conditioner running state fed back by the server in real time is not received, a state updating instruction can be sent to the server every 2 seconds to obtain the real-time running state of the air conditioner. When the air conditioner running state fed back by the server is not received within 8 seconds, a preset prompting interface can be displayed on the smart phone to prompt that the network of the user is unstable. In addition, in order to avoid the failure of the instruction of the user for operating the air conditioner due to the instability of the network, the user can be prohibited from operating the air conditioner in advance until the running state of the air conditioner fed back by the server in real time is received, the normal operation state is recovered, and the user can normally operate the air conditioner.
Further, after the step S104, the data synchronization method may further include: and when a fourth air conditioner running state fed back by the server is received within a second preset time, switching the equipment state displayed in the current display interface from the default running state to the fourth air conditioner running state.
It can be understood that, when the smart phone does not receive the air conditioner running state fed back by the server in real time in the earlier stage, the "default running state", for example, "room temperature 15 degrees celsius", is displayed temporarily in the current display interface until the air conditioner running state fed back by the server in real time, for example, "room temperature 18 degrees celsius", is received, then the "room temperature 15 degrees celsius" may be switched to "room temperature 18 degrees celsius", so as to ensure that the smart phone side can update the latest running state information of the air conditioner in real time.
Further, before the step S104, the data synchronization method may further include: calculating the current packet loss rate; and when the current packet loss rate is lower than a preset threshold value, executing the step of sending a state updating instruction to the server according to a preset period so that the server responds to the state updating instruction, inquiring a corresponding fourth air conditioner running state according to the air conditioner identification, and feeding back the fourth air conditioner running state when the fourth air conditioner running state is inquired.
It can be understood that, considering that when the network environment is poor, the operation of the user for adjusting the air conditioner through the smart phone may not reach the air conditioning device in time to modify the parameters, and the operation states of the air conditioner recorded by the smart phone, the server and the air conditioner may not be consistent, a preset threshold is preset to limit the packet loss rate, and only when the current packet loss rate is lower than the preset threshold, a subsequent process of querying the operation state of the air conditioner to change the operation information displayed at the smart phone side is executed, so that the operation states of the air conditioner recorded by the smart phone, the server and the air conditioner are consistent. For example, the preset threshold is set to 10%, and when the packet loss rate of the current network is lower than 10%, the subsequent operation is performed.
In this embodiment, when the real-time operating state of the air conditioner fed back by the server is not received, a state updating instruction may be periodically sent to the server to continuously try to obtain the real-time operating state of the air conditioner.
Referring to fig. 5, fig. 5 is a flowchart illustrating a fourth embodiment of the data synchronization method according to the present invention, and the fourth embodiment of the data synchronization method according to the present invention is proposed based on the first embodiment shown in fig. 2.
In the fourth embodiment, after the step S30, the data synchronization method further includes:
step S40: responding to a synchronization instruction input by a user, acquiring a locally stored running state and taking the running state as a first synchronization state;
it is understood that, although the implementation manners of the first to third embodiments of the data synchronization method of the present invention can ensure that the air-conditioning operation states recorded by the smartphone, the server and the air-conditioner are consistent, considering that the air-conditioning operation states recorded by the three may not be consistent due to a network problem or an operation error of any one of the three devices, the above problem can be avoided by periodically querying the operation states recorded by the three.
In a specific implementation, a user may click on a "data synchronization" option on the smartphone side to generate a synchronization command, but of course, the smartphone may also generate the synchronization command periodically, for example, the synchronization command is generated every 10 minutes. And responding to the synchronous instruction to acquire the air conditioner running state recorded by the intelligent mobile phone side, namely a first synchronous state, such as' room temperature 15 ℃.
Step S50: sending the synchronization instruction to the server, so that the server responds to the synchronization instruction, acquires a locally stored running state and feeds the running state back as a second synchronization state;
it should be understood that, after querying the "room temperature 15 degrees celsius" recorded by the smartphone side, the synchronization instruction may be sent to the server to query the real-time state of the air conditioner operation recorded by the server side, that is, the second synchronization state, which may be "room temperature 15 degrees celsius".
Step S60: sending the synchronization instruction to the air conditioner so that the air conditioner responds to the synchronization instruction, acquires a locally stored running state and feeds the running state back as a third synchronization state;
it can be understood that after the "room temperature 15 degrees centigrade" recorded by the smartphone side and the "room temperature 15 degrees centigrade" recorded by the server side are queried, a synchronization instruction can be sent to the air conditioner again to query the device state actually operated by the air conditioner side, that is, the third synchronization state, which can be the "room temperature 15 degrees centigrade".
Step S70: comparing the first synchronization state, the second synchronization state and the third synchronization state;
it should be understood that after the operation states recorded by the smartphone, the server, and the air conditioner side are obtained respectively, the first synchronization state, the second synchronization state, and the third synchronization state may be compared.
Step S80: and when the first synchronization state, the second synchronization state and the third synchronization state are the same, displaying prompt information of successful synchronization.
It can be understood that the recorded states of the three are all ' room temperature 15 ℃, and then ' synchronization success ' can be prompted at the smart phone side.
Further, after the step S70, the data synchronization method may further include: when the first synchronization state, the second synchronization state and the third synchronization state are different, modifying the locally stored first synchronization state into the third synchronization state; sending a state correction instruction to the server to enable the server to modify the locally stored second synchronization state into the third synchronization state in response to the state correction instruction.
In a specific implementation, if the states recorded by the three devices are not the same, for example, the first synchronization state recorded by the smart phone side is "room temperature 15 degrees celsius", the second synchronization state recorded by the server side is "room temperature 16 degrees celsius", and the third synchronization state recorded by the air conditioner side is "room temperature 17 degrees celsius", where the state recorded by the air conditioner side is a state in which the air conditioner operates in real time, both the states recorded by the smart phone side and the server side can be modified into the state recorded by the air conditioner side. Therefore, the 'room temperature 15 ℃ recorded by the intelligent mobile phone side can be modified into' room temperature 17 ℃, and the 'room temperature 16 ℃ recorded by the server side can be modified into' room temperature 17 ℃, so that the recorded states of the server and the user equipment side are modified into a third synchronous state, and the running states of the air conditioners recorded by the server, the user equipment side and the user equipment side are kept consistent.
In the embodiment, the air conditioner running information recorded by the user equipment, the server and the air conditioner is obtained in real time, and the air conditioner running information of the user equipment, the server and the air conditioner is compared to check whether the air conditioner running states recorded by the user equipment, the server and the air conditioner are consistent or not in real time.
Furthermore, an embodiment of the present invention further provides a computer-readable storage medium, where a data synchronization program is stored on the computer-readable storage medium, and when executed by a processor, the data synchronization program implements the following operations:
responding to an air conditioner adjusting instruction input by a user, determining a corresponding first air conditioner running state according to the air conditioner adjusting instruction, sending the first air conditioner running state to a server, so that the server modifies a second air conditioner running state stored locally into the first air conditioner running state, and generating and feeding back reply information;
judging whether the reply information is successfully adjusted information, wherein the successfully adjusted information is used for representing that the server successfully modifies the running state of the air conditioner side;
and when the reply information is the successful adjustment information, displaying the running state of the first air conditioner in a current display interface so as to realize data synchronization.
Further, the data synchronization program when executed by the processor further performs the following operations:
responding to a login instruction input by a user, reading a user identifier from the login instruction, and inquiring a corresponding air conditioner identifier according to the user identifier;
sending the air conditioner identification to a server so that the server queries a corresponding third air conditioner running state from a preset mapping relation according to the air conditioner identification, and feeding back the third air conditioner running state when the third air conditioner running state is queried, wherein the preset mapping relation comprises the corresponding relation between the air conditioner identification and the air conditioner running state;
and when the third air conditioner running state is received, displaying the third air conditioner running state in a current display interface.
Further, the data synchronization program when executed by the processor further performs the following operations:
sending a detection instruction to the air conditioner corresponding to the air conditioner identifier so that the air conditioner responds to the detection instruction to detect the network connection state of the network where the air conditioner is located, and feeding back the online state when the network connection state is the online state;
monitoring whether an online state fed back by the air conditioner is received within a first preset time;
and when the online state fed back by the air conditioner is received within the first preset time, the step of sending the air conditioner identification to a server is executed, so that the server inquires a corresponding third air conditioner running state from a preset mapping relation according to the air conditioner identification, and when the third air conditioner running state is inquired, the step of feeding back the third air conditioner running state is executed.
Further, the data synchronization program when executed by the processor further performs the following operations:
when the third air conditioner running state is not received, acquiring a default running state, and displaying the default running state in the current display interface;
sending a state updating instruction to the server according to a preset period so that the server responds to the state updating instruction, inquires a corresponding fourth air conditioner running state according to the air conditioner identification, and feeds back the fourth air conditioner running state when the fourth air conditioner running state is inquired;
and when the fourth air conditioner running state fed back by the server is not received within a second preset time, displaying a preset prompting interface, wherein the preset prompting interface is used for prompting a user that the current network is unstable.
Further, the data synchronization program when executed by the processor further performs the following operations:
and when a fourth air conditioner running state fed back by the server is received within a second preset time, switching the equipment state displayed in the current display interface from the default running state to the fourth air conditioner running state.
Further, the data synchronization program when executed by the processor further performs the following operations:
calculating the current packet loss rate;
and when the current packet loss rate is lower than a preset threshold value, executing the step of sending a state updating instruction to the server according to a preset period so that the server responds to the state updating instruction, inquiring a corresponding fourth air conditioner running state according to the air conditioner identification, and feeding back the fourth air conditioner running state when the fourth air conditioner running state is inquired.
Further, the data synchronization program when executed by the processor further performs the following operations:
responding to a synchronization instruction input by a user, acquiring a locally stored running state and taking the running state as a first synchronization state;
sending the synchronization instruction to the server, so that the server responds to the synchronization instruction, acquires a locally stored running state and feeds the running state back as a second synchronization state;
sending the synchronization instruction to the air conditioner so that the air conditioner responds to the synchronization instruction, acquires a locally stored running state and feeds the running state back as a third synchronization state;
comparing the first synchronization state, the second synchronization state and the third synchronization state;
and when the first synchronization state, the second synchronization state and the third synchronization state are the same, displaying prompt information of successful synchronization.
Further, the data synchronization program when executed by the processor further performs the following operations:
when the first synchronization state, the second synchronization state and the third synchronization state are different, modifying the locally stored first synchronization state into the third synchronization state;
sending a state correction instruction to the server to enable the server to modify the locally stored second synchronization state into the third synchronization state in response to the state correction instruction.
In this embodiment, before the user equipment displays the first air conditioner running state, the running states of the server side and the air conditioner side are modified first until the running state is modified, and then the first air conditioner running state is displayed on the user equipment side, so that the running states of the smart phone side, the server side and the air conditioner side are kept synchronous, and the technical problem that the running states of the user equipment and the air conditioner side are different when the network environment is poor in the prior art is solved.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments. The use of the words first, second, third, etc. do not denote any order, but rather the words first, second, third, etc. are to be interpreted as names.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.