Disclosure of Invention
It is an object of embodiments of the present invention to provide a method and apparatus for controlling opening and closing of a device, and a machine-readable storage medium, to solve the above technical problems, or at least partially solve the above technical problems.
In order to achieve the above object, an embodiment of the present invention provides a method for controlling opening and closing of a device, for a first switch panel including a first switch, the method including: associating the first switch with a second switch; when the state of the first switch changes, sending a state change notification indicating the changed state of the first switch to a second switch panel including the second switch, so that the state of the second switch is consistent with the state of the first switch; wherein at least one of the first switch and the second switch is connected to a control loop of a controlled device.
Optionally, the associating the first switch with the second switch includes: sending an association request, wherein the association request comprises an Identification (ID) of the first switch; receiving an association confirmation from the second switch panel, the association confirmation including an ID of the second switch; associating the first switch with a second switch according to an ID of the second switch included in the received association confirmation.
Optionally, the associating the first switch with the second switch includes: receiving an association request from the second switch panel, the association request including an ID of the second switch; associating the first switch with a second switch according to an ID of the second switch included in the received association request; sending an association confirmation to the second switch panel, the association confirmation including the ID of the first switch.
Optionally, the method further includes: receiving a state change notification from the second switch panel, the state change notification indicating a post-change state of the second switch; and changing the state of the first switch according to the changed state of the second switch indicated by the received state change notification, so that the state of the first switch is consistent with the state of the second switch.
Optionally, the method further includes: sending a disassociation notification to the second switch panel, the disassociation notification including the ID of the first switch; and/or receiving a disassociation notification from the second switch panel, the disassociation notification including an ID of the second switch, and disassociating the first switch from the second switch according to the ID of the second switch included in the disassociation notification.
According to another aspect of the present invention, there is provided an apparatus for controlling opening and closing of a device for a first switch panel including a first switch, the apparatus comprising: an association module to associate the first switch with a second switch; a change module, configured to send a state change notification indicating a changed state of the first switch to a second switch panel including the second switch when a state of the first switch changes, so that the state of the second switch is consistent with the state of the first switch; wherein at least one of the first switch and the second switch is connected to a control loop of a controlled device.
Optionally, the association module is configured to send an association request, where the association request includes an identification ID of the first switch; receiving an association confirmation from the second switch panel, the association confirmation including an ID of the second switch; associating the first switch with a second switch according to an ID of the second switch included in the received association confirmation.
Optionally, the association module is configured to receive an association request from the second switch panel, where the association request includes an ID of the second switch; associating the first switch with a second switch according to an ID of the second switch included in the received association request; sending an association confirmation to the second switch panel, the association confirmation including the ID of the first switch.
Optionally, the change module is further configured to receive a state change notification from the second switch panel, where the state change notification indicates a changed state of the second switch; and changing the state of the first switch according to the changed state of the second switch indicated by the received state change notification, so that the state of the first switch is consistent with the state of the second switch.
Optionally, the apparatus further comprises: a cancellation module to send a disassociation notification to the second switch panel, the disassociation notification including the ID of the first switch; and/or receiving a disassociation notification from the second switch panel, the disassociation notification including an ID of the second switch, and disassociating the first switch from the second switch according to the ID of the second switch included in the disassociation notification.
According to yet another aspect of the present invention, there is provided a machine-readable storage medium having stored thereon instructions for causing a machine to perform any one of the aforementioned methods for controlling opening and closing of a device.
Through the technical scheme, the first switch is associated with the second switch, when the state of the first switch changes, the state change notification indicating the changed state of the first switch is sent to the second switch panel comprising the second switch, so that the state of the second switch is consistent with the state of the first switch, and at least one of the first switch and the second switch is connected with the control loop of the controlled equipment; therefore, different switches can be associated, and flexible upgrading can be realized for a single control switch; and the double control function can be realized without actual wiring support, and the flexibility of the control relationship between the switch and the equipment is increased.
Additional features and advantages of embodiments of the invention will be set forth in the detailed description which follows.
Detailed Description
The following detailed description of embodiments of the invention refers to the accompanying drawings. It should be understood that the detailed description and specific examples, while indicating embodiments of the invention, are given by way of illustration and explanation only, not limitation.
FIG. 1 is a flow chart of a method for controlling opening and closing of a device according to an embodiment of the present invention; the method can be used in a switch panel. The switch panel may be an intelligent switch and may include a microcontroller, a relay, and a communication assembly. One, two and three switch panels can be formed according to the number of the relays. As shown in fig. 2, the microcontroller controls the normally open contact of the relay to be closed and opened through the IO port, so that the load circuit is closed and opened, and meanwhile, the microcontroller can detect the current state of the load circuit. The communication component may employ wireless communication technology (ZigBee protocol) or 433MHz) for communication. The control and the state of the switch can be transmitted to the intelligent gateway through the communication component, and the switch panel can be communicated with the cloud server and the terminal where the APP (application) is located through the communication component. The switch panels can also interact through the communication component. As shown in fig. 1, the method is for a first switch panel including a first switch, and may include the following steps.
In step S110, the first switch is associated with the second switch.
Wherein at least one of the first switch and the second switch is connected to a control loop of the controlled device.
The first switch and the second switch may be relays as shown in fig. 2. For example, in the scenario shown in FIG. 3, switch panel 1 includes switches 1-1 and 1-2, and switch panel 2 includes switches 2-1 and 2-2. The lamp L1 is dually controlled using the switch 1-1 of the switch panel 1 and the switch 2-1 of the switch panel 2. The control loop for lamp L1 is connected to switch 2-1 so that opening and closing of switch 2-1 controls the ignition and extinction of lamp L1. To enable switch 1-1 to control lamp L1, switch 1-1 and switch 2-1 need to be associated. For example, the switch 1-1 and the switch 2-1 are triggered for 5-10 seconds at the same time, the switch panel 1 and the switch panel 2 respectively know that the switch 1-1 and the switch 2-1 enter the association mode, at this time, the switch 1-1 and the switch 2-1 perform mutual bidirectional information exchange through the communication component, after the information exchange is completed, the switch panel 1 stores the ID (identification) of the associated switch 2-1 corresponding to the switch 1-1, and the switch panel 2 stores the ID of the associated switch 1-1 corresponding to the switch 2-1. In this way, the association between switch 1-1 and switch 2-1 is achieved.
In an embodiment, as shown in FIG. 4, associating the first switch with the second switch may include the following steps.
In step S402, an association request is transmitted.
Wherein the association request includes an ID of the first switch.
In step S404, an association confirmation from the second switch panel is received.
Wherein the association confirmation includes the ID of the second switch.
In step S406, the first switch is associated with the second switch in accordance with the ID of the second switch included in the received association confirmation.
In an embodiment, as shown in FIG. 5, associating the first switch with the second switch may include the following steps.
In step S502, an association request from a second switch panel is received.
Wherein the association request includes an ID of the second switch.
In step S504, the first switch is associated with the second switch according to the ID of the second switch included in the received association request.
In step S506, an association confirmation is sent to the second switch panel.
Wherein the association confirmation includes the ID of the first switch.
For example, the switch panel 1 broadcasts an association request for the switch 1-1 in the association mode, where the association request includes the ID of the switch 1-1. The switch panel 2 receives the association request for the switch 2-1 in the association mode, determines that the switch 2-1 is associated with the switch 1-1, stores the ID of the switch 1-1 corresponding to the switch 2-1, and replies an association confirmation including the ID of the switch 2-1. The switch panel 1 receives the association confirmation from the switch panel 2 for the switch 1-1, associates the switch 1-1 with the switch 2-1 according to the ID of the switch 2-1 in the association confirmation, and stores the ID of the lower switch 2-1 corresponding to the switch 1-1. The switch panel 2 broadcasts an association request for the switch 2-1 in the association mode, the association request including the ID of the switch 2-1. The switch panel 1 receives the association request for switch 1-1 in association mode, finds that switch 1-1 has been associated with switch 2-1, and discards the received association request and does not send any association confirmation. Thus, the association of switch 1-1 with switch 2-1 can be achieved. In the above example, the switch 1-1 first sends out an association request to realize the association between the switch 1-1 and the switch 2-1; the association of switch 1-1 with switch 2-1 may also be accomplished by switch 2-1 first issuing an association request. The order in which switch 1-1 and switch 2-1 send association requests may be random, e.g., determined by the randomness with which both access channels.
In step S120, when the state of the first switch changes, a state change notification indicating the changed state of the first switch is transmitted to a second switch panel including a second switch so that the state of the second switch coincides with the state of the first switch.
For example, when the trigger switch 1-1 is closed, the switch panel 1 sends a state change notification indicating that the switch 1-1 is closed to the communication component of the switch panel 2 through the communication component. The switch panel 2 closes the switch 2-1 according to the state change notification, and the lamp L1 is lighted. When the trigger switch 1-1 is turned off, the switch panel 1 sends a state change notification indicating that the switch 1-1 is turned off to the communication component of the switch panel 2 through the communication component, the switch panel 2 turns off the switch 2-1 according to the state change notification, and the lamp L1 is turned off.
When the switch panel 1-1 receives a control command from the outside, for example in the case of closing or opening the switch 1-1 remotely controlled by the APP, the switch panel 1 closes or opens the switch 1-1 according to the received control command and sends a state change notification to the switch panel 2, indicating that the switch 1-1 is closed or opened. After receiving the state change notification, the switch panel 2 changes the state of the switch 2-1 to on or off according to the instruction of the state change notification.
In an embodiment, as shown in fig. 6, the method may further include the following steps.
In step S602, a state change notification from the second switch panel is received.
Wherein the state change notification indicates a post-change state of the second switch.
In step S604, the state of the first switch is changed according to the post-change state of the second switch indicated by the received state change notification, so that the state of the first switch coincides with the state of the second switch.
For example, when the trigger switch 2-1 is closed, the lamp L1 lights up, while the switch panel 2 sends a state change notification indicating that the switch 2-1 is closed to the switch panel 1 through the communication component. The switch panel 1 receives the state change notice through the communication component, and closes the switch 1-1 according to the indication of the state change notice, so that the states of the switch 1-1 and the switch 2-1 are kept consistent and are closed. When the trigger switch 2-1 is turned off, the lamp L1 goes out, and the switch panel 2 sends a state change notification indicating that the switch 2-1 is turned off to the switch panel 1 through the communication component. The switch panel 1 receives the state change notice through the communication component, and switches 1-1 off according to the indication of the state change notice, so that the states of the switches 1-1 and 2-1 are consistent and are both off.
In an embodiment, the method further comprises: sending a disassociation notification to the second switch panel. Wherein the disassociation notification includes the ID of the first switch.
Alternatively, the method may further comprise: receiving a disassociation notification from the second switch panel, the disassociation notification including an ID of the second switch, and disassociating the first switch from the second switch according to the ID of the second switch included in the disassociation notification.
For example, the switch 1-1 is activated a plurality of times, e.g., 3 times, in succession, and the switch 1-1 begins to disassociate. The switch panel 1 broadcasts a disassociation notification including the ID of the switch 1-1 through the communication component. After the switch panel 2 receives the disassociation notification, the association between the switch 2-1 and the switch 1-1 is canceled according to the disassociation notification.
By adopting the method, the three-control function can be realized. As shown in fig. 7, a switch panel 3 is added to fig. 3, and the switch panel 3 includes a switch 3-1 and a switch 3-2. Switch 1-1, switch 2-1 and switch 3-2 of figure 7 may be associated. For example, the switch 1-1, the switch 2-1 and the switch 3-2 are triggered for 5-10 seconds at the same time, the switch panel 1, the switch panel 2 and the switch panel 3 respectively know that the switch 1-1, the switch 2-1 and the switch 3-2 enter the association mode, at this time, the switch 1-1, the switch 2-1 and the switch 3-2 perform bidirectional information exchange with each other through the communication assembly, after the information exchange is completed, the switch panel 1 stores the IDs (identifications) of the associated switch 2-1 and the switch 3-2 corresponding to the switch 1-1, the switch panel 2 stores the IDs of the associated switch 1-1 and the switch 3-2 corresponding to the switch 2-1, and the switch panel 3 stores the IDs of the associated switch 1-1 and the switch 2-1 corresponding to the switch 3-2. In this manner, the association between switch 1-1, switch 2-1 and switch 3-2 is achieved. When the state of any one of the switch 1-1, the switch 2-1 and the switch 3-2 is changed, the switch panel where the switch is located sends a state change notice to indicate the changed state, and other related switches correspondingly change the state, so that the state consistency among the related switches is maintained. When any one of the switch 1-1, the switch 2-1 and the switch 3-2 issues a disassociation notification, the other associated switches disassociate from the switch.
By the method, for the switch panel, the association among a plurality of switches can be realized through operation processing without replacing hardware, so that double control, three control or multiple control is carried out on the equipment; the method is flexible to operate, actual wiring is not needed, operation efficiency is improved, and wiring cost is saved.
Fig. 8 is a structural diagram of an apparatus for controlling opening and closing of devices according to an embodiment of the present invention; the device may be used in a first switch panel comprising a first switch, as shown in fig. 8, and may comprise the following modules.
An associating module 810 for associating the first switch with the second switch.
A change module 820, configured to send a state change notification indicating a changed state of the first switch to a second switch panel including a second switch when the state of the first switch changes, so that the state of the second switch is consistent with the state of the first switch.
Wherein at least one of the first switch and the second switch is connected to a control loop of the controlled device.
In one embodiment, the association module 810 is configured to send an association request, where the association request includes an identification ID of the first switch; receiving an association confirmation from the second switch panel, the association confirmation including an ID of the second switch; associating the first switch with the second switch according to the ID of the second switch included in the received association confirmation.
In one embodiment, the association module 810 is configured to receive an association request from a second switch panel, the association request including an ID of the second switch; associating the first switch with the second switch according to the ID of the second switch included in the received association request; an association confirmation is sent to the second switch panel, the association confirmation including the ID of the first switch.
In one embodiment, the change module 820 is further configured to receive a state change notification from the second switch panel, the state change notification indicating a changed state of the second switch; and changing the state of the first switch according to the changed state of the second switch indicated by the received state change notification, so that the state of the first switch is consistent with the state of the second switch.
In an embodiment, as shown in fig. 9, the apparatus may further include: a cancellation module 910 configured to send a cancellation association notification to the second switch panel, the cancellation association notification including the ID of the first switch; and/or receiving a disassociation notification from the second switch panel, the disassociation notification including an ID of the second switch, and disassociating the first switch from the second switch according to the ID of the second switch included in the disassociation notification.
The above device corresponds to the above method, and the detailed description of the specific embodiments can be found in the above method, which is not repeated herein.
The invention also discloses a machine-readable storage medium, wherein the machine-readable storage medium is stored with instructions for causing a machine to execute any one of the methods for controlling the opening and closing of the equipment.
Although the embodiments of the present invention have been described in detail with reference to the accompanying drawings, the embodiments of the present invention are not limited to the details of the above embodiments, and various simple modifications can be made to the technical solutions of the embodiments of the present invention within the technical idea of the embodiments of the present invention, and these simple modifications all belong to the protection scope of the embodiments of the present invention.
It should be noted that the various features described in the above embodiments may be combined in any suitable manner without departing from the scope of the invention. In order to avoid unnecessary repetition, the embodiments of the present invention do not describe every possible combination.
Those skilled in the art can understand that all or part of the steps in the method for implementing the above embodiments may be implemented by a program instructing related hardware, where the program is stored in a storage medium and includes several instructions to enable a (may be a single chip, a chip, etc.) or a processor (processor) to execute all or part of the steps of the method described in the embodiments of the present application. 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 addition, any combination of various different implementation manners of the embodiments of the present invention is also possible, and the embodiments of the present invention should be considered as disclosed in the embodiments of the present invention as long as the combination does not depart from the spirit of the embodiments of the present invention.