Device online and offline sensing method and apparatus
By generating a compressed bitmap of device status and using XOR operations for comparative analysis, the problem of quickly sensing changes in the online and offline status of a large number of devices is solved, achieving efficient status sensing and response.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- OPPLE LIGHTING CO LTD
- Filing Date
- 2024-12-24
- Publication Date
- 2026-06-26
Smart Images

Figure CN122293548A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of information processing technology, and in particular to a method and apparatus for online and offline sensing of devices. Background Technology
[0002] With the continuous development of IoT devices, more and more smart devices are beginning to connect to the IoT. For example, many lighting devices can also be connected to the IoT to control them through the network.
[0003] In related technologies, smart devices maintain a connection with the system through a heartbeat mechanism so that the system can sense the online and offline status of the devices. However, how to quickly sense changes in the online and offline status of a large number of devices in a short period of time remains an urgent problem to be solved. Summary of the Invention
[0004] This invention provides a method and apparatus for sensing online and offline status of devices, which solves the problem in the prior art of how to quickly sense changes in the online and offline status of a large number of devices in a short period of time.
[0005] This invention provides a method for online and offline sensing of devices, comprising: Based on the online and offline status cache information of each access device at the first moment, a compressed bitmap of the status of the first access device is generated; Obtain the online / offline status cache information of each access device at the current moment, and generate a second access device status compressed bitmap; wherein, the first moment is one device status scan cycle earlier than the current moment; By performing an XOR operation, the compressed bitmaps of the first and second access device statuses are compared and analyzed to obtain the online and offline status of the access devices.
[0006] Optionally, before the step of generating a first access device status compressed bitmap based on the online / offline status cache information of each access device at the first moment, the method further includes: Obtain device status information reported by each access device, and hash and cache the device status information in the memory data storage system through range routing; The device status information of each memory data storage system is scanned to obtain online and offline status cache information from each device status information.
[0007] Optionally, the access device status compressed bitmap includes: a running container, a bitmap container, and an array container.
[0008] Optionally, generating a first access device status compressed bitmap based on the online / offline status cache information of each access device at the first moment includes: If the data distribution of the online and offline status cache information at the first moment is a dense data distribution, the online and offline status cache information is stored in the bitmap container; If the data distribution of the online and offline status cache information at the first moment is sparse, the online and offline status cache information is stored in the array container; If the online / offline status cache information is continuous data at the first moment, the online / offline status cache information is stored in the running container.
[0009] Optionally, the step of comparing and analyzing the first and second access device status compressed bitmaps through an XOR operation to obtain the online / offline status of the access device includes: The change is obtained by comparing the first and second access device state compressed bitmaps bit by bit using an XOR operation. Based on the change amount, determine whether each access device corresponding to the bit has experienced an online / offline change.
[0010] Optionally, after obtaining the change by comparing the first access device state compressed bitmap and the second access device state compressed bitmap bitmap bit-by-bit through an XOR operation, the method further includes: When the change is not zero, the current device is determined to be the target access device; The changes in the target access device and its device identity information are written into the status change device message queue, and the status change device message queue is pushed to the service end according to a preset period.
[0011] The present invention also provides an online and offline sensing device, comprising: The first generation module is used to generate a compressed bitmap of the status of the first access device based on the online and offline status cache information of each access device at the first moment. The second generation module is used to obtain the online and offline status cache information of each access device at the current moment and generate a second access device status compressed bitmap; wherein, the first moment is earlier than the current moment by one device status scan cycle; The sensing module is used to compare and analyze the compressed bitmap of the first access device status and the compressed bitmap of the second access device status through an XOR operation to obtain the online and offline status of the access device.
[0012] Optionally, the device is further used for: Obtain device status information reported by each access device, and hash and cache the device status information in the memory data storage system through range routing; The device status information of each memory data storage system is scanned to obtain online and offline status cache information from each device status information.
[0013] Optionally, the device is further used for: Based on the range mapping relationship, the target sharding unit corresponding to the device status information is determined in the memory data storage system. The online and offline status cache information is obtained by performing a task scanning operation through the target shard unit and stored in the corresponding target shard unit.
[0014] Optionally, the device is further used for: If the data distribution of the online and offline status cache information at the first moment is a dense data distribution, the online and offline status cache information is stored in the bitmap container; If the data distribution of the online and offline status cache information at the first moment is sparse, the online and offline status cache information is stored in the array container; If the online / offline status cache information is continuous data at the first moment, the online / offline status cache information is stored in the running container.
[0015] Optionally, the device is further used for: The change is obtained by comparing the first and second access device state compressed bitmaps bit by bit using an XOR operation. Based on the change amount, determine whether each access device corresponding to the bit has experienced an online / offline change.
[0016] Optionally, the device is further used for: When the change is not zero, the current device is determined to be the target access device; The changes in the target access device and its device identity information are written into the status change device message queue, and the status change device message queue is pushed to the service end according to a preset period.
[0017] The present invention also provides an online / offline sensing device for lighting fixtures, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the steps of any of the above-described online / offline sensing methods for the device.
[0018] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the online and offline sensing methods for devices as described above.
[0019] The device online / offline sensing method and apparatus provided by the present invention generate a first access device status compressed bitmap and a second access device status compressed bitmap based on the online / offline status cache information of each access device. The compressed bitmap data structure can efficiently store and process the status information of a large number of devices. Then, by periodically scanning and comparing the first access device status compressed bitmap and the second access device status compressed bitmap, the amount of data analysis can be effectively reduced, and the changes in the online / offline status of access devices can be quickly and accurately sensed. Attached Figure Description
[0020] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0021] Figure 1 A schematic diagram of the online and offline sensing method for devices provided by the present invention; Figure 2 This is a schematic diagram of the compressed bitmap structure provided by the present invention; Figure 3 This invention provides a framework diagram for online and offline sensing services for devices. Figure 4 A schematic diagram of the online and offline sensing device provided by the present invention; Figure 5 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0022] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0023] Figure 1 This is a schematic diagram of the online and offline sensing method for devices provided by the present invention, as shown below. Figure 1 As shown, it includes: Step 110: Generate a compressed bitmap of the status of the first access device based on the online and offline status cache information of each access device at the first moment; In this invention, online / offline service is a system for monitoring and managing the online status of devices. It can sense the online or offline status of devices in real time and take corresponding actions accordingly.
[0024] In this invention, the access device can specifically refer to a device that accesses the Internet of Things through an access service, such as a lamp or a lamp control device.
[0025] In this invention, the online / offline status cache information at the first moment refers to data about the device's online or offline status collected and stored at the first moment. This information is obtained through communication between the device and the online / offline service.
[0026] In this invention, after receiving the device status, the online and offline services cache this status information. The cache is typically located in memory for fast access and processing.
[0027] The compressed bitmaps in this invention may specifically include roar bitmaps, word-aligned hybrid compressed bitmaps, COMPAX bitmaps, etc. Specifically, in this invention, bitmaps can be generated using the Roaring Bitmap data structure. Roaring Bitmap is an efficient compressed bitmap representation method, particularly suitable for bitmap operations on large-scale datasets.
[0028] Specifically, a unique bit position can be assigned to each device, and the value of this bit can be set according to the device's online / offline status (1 indicates online, 0 indicates offline). Based on the data distribution characteristics, the most suitable container type (BitmapContainer, ArrayContainer, RunContainer) will be automatically selected to store the bitmap to optimize storage space usage.
[0029] Step 120: Obtain the online and offline status cache information of each access device at the current moment, and generate a second access device status compressed bitmap; wherein, the first moment is one device status scan cycle earlier than the current moment; In this invention, the device status scan cycle refers to the time interval at which the system periodically checks the online status of devices. This cycle can be a few minutes, a few hours, or any other time length suitable for the system's needs. At the beginning of each scan cycle, the system collects the current status of all devices and compares it with the status of the previous scan cycle.
[0030] At the beginning of each scan cycle, i.e., the first moment, the system records the online / offline status of all devices and generates a bitmap (first access device status compressed bitmap). At the current moment, the system again records the online / offline status of all devices and generates another bitmap (second access device status compressed bitmap).
[0031] Step 130: By performing an XOR operation, the first access device status compressed bitmap and the second access device status compressed bitmap are compared and analyzed to obtain the online and offline status of the access device.
[0032] In this invention, by performing an XOR operation between the bitmap generated at the first moment and the bitmap generated at the current moment, devices whose states have changed between these two points in time can be detected. In the result of the XOR operation, a bit with a value of 1 indicates that the device state has changed (from online to offline, or from offline to online). The online / offline status of the accessed device is thus obtained.
[0033] In this invention, access devices refer to those devices that are in a state during the monitoring period.
[0034] The online / offline status can specifically refer to a change in online / offline status, or a unchanged online / offline status. The status of a call occurring online / offline specifically refers to a change from online to offline or from offline to online.
[0035] In this invention, the status information of a large number of devices can be efficiently stored and processed by using a roaring bitmap data structure. Then, by periodically scanning and comparing the first access device status compressed bitmap with the second access device status compressed bitmap, the changes in the online and offline status of the access devices can be quickly and accurately detected.
[0036] Optionally, before the step of generating a first access device status compressed bitmap based on the online / offline status cache information of each access device at the first moment, the method further includes: Obtain device status information reported by each access device, and hash and cache the device status information in the memory data storage system through range routing; The device status information of each memory data storage system is scanned to obtain online and offline status cache information from each device status information.
[0037] In this invention, the in-memory data storage system may include Memcached and Redis, which are used as databases, caches, and message brokers.
[0038] In this invention, each access device periodically or when its status changes, reports its status information to the access service. This information typically includes the device's unique identifier (such as a device ID) and its current online status (online or offline).
[0039] In this invention, the access service uses range routing to hash and store device status information in an in-memory data storage system. Range routing is a data sharding strategy that distributes data to different in-memory data storage systems based on a range of device IDs.
[0040] Each in-memory data storage system is responsible for storing device status information within a certain range. This distributed storage can improve the parallelism and efficiency of data processing.
[0041] More specifically, the online and offline services scan the device status information of each memory data storage system to obtain the online and offline status cache information in each device status information.
[0042] To improve efficiency, scanning tasks can be fragmented, meaning each instance is only responsible for scanning a portion of the database in the in-memory data storage system. This allows for parallel data processing, accelerating the detection of online and offline status.
[0043] The online / offline service generates a compressed bitmap of the first access device status based on the scanned device status information. This bitmap is stored using a Roaring Bitmap data structure, where each bit represents the online or offline status of a device.
[0044] In this invention, the status of a large number of devices can be efficiently managed and queried through range routing and memory data storage systems.
[0045] Optionally, the step of obtaining the device status information reported by each access device and hashing and caching the device status information in the memory data storage system through range routing includes: Based on the range mapping relationship, the target sharding unit corresponding to the device status information is determined in the memory data storage system. The online and offline status cache information is obtained by performing a task scanning operation through the target shard unit and stored in the corresponding target shard unit.
[0046] In this invention, the system determines the target sharding unit corresponding to the device status information in the memory data storage system based on the device status information and the preset range mapping relationship.
[0047] The range mapping relationship in this invention is a logical correspondence rule used to quickly locate device status information to a specific storage location.
[0048] After identifying the target shard units, task scanning operations are performed through these units to collect and update the device's online / offline status cache information. Specifically, this involves reading the device status, analyzing changes, and comparing it with the previous status to determine whether the device has transitioned from online to offline.
[0049] In this invention, the collected online and offline status cache information is then stored in the corresponding target shard unit to support rapid data updates and queries, thereby significantly improving the efficiency of data retrieval and updates.
[0050] This invention also employs a compressed bitmap scheme, Roaring Bitmap, to further optimize data storage. Roaring Bitmap divides values into high 16 bits and low 16 bits using a bucketing method, and uses different containers to store data according to different data distributions, thereby greatly reducing the data storage space requirements while maintaining high performance.
[0051] Optionally, the access device status compressed bitmap includes: a running container, a bitmap container, and an array container.
[0052] Figure 2 This is a schematic diagram of the compressed bitmap structure provided by the present invention, such as... Figure 2 As shown, Roaring Bitmap achieves efficient storage and retrieval by dividing the value into high 16 bits and low 16 bits.
[0053] The high 16 bits are used for bucketing, which divides the data into multiple buckets, each responsible for a relatively large range of values. The low 16 bits are used to store the specific value, i.e., the online / offline status of the device.
[0054] This bucketing mechanism allows Roaring Bitmap to select the most suitable storage method for each bucket, thereby optimizing the use of storage space.
[0055] Roaring Bitmap selects different container types to store data based on the data distribution characteristics in each bucket: BitmapContainer: Suitable for densely distributed data, i.e., a bucket with a large number of online devices. BitmapContainer uses a long integer array to represent the bitmap, with each long integer storing 64 bits, suitable for situations with a large number of consecutive 1s.
[0056] ArrayContainer: Suitable for sparse data distribution, where only a small number of devices are online in a bucket. ArrayContainer uses a short integer array to store the positions of all bits that are 1, suitable for situations where the distribution of 1s is relatively scattered.
[0057] RunContainer: Suitable for situations where data is highly sequential, i.e., a bucket contains a large number of consecutive online devices. RunContainer uses a short integer array to store the starting position and length of consecutive 1s, suitable for situations with a large number of consecutive 1s.
[0058] Optionally, generating a first access device status compressed bitmap based on the online / offline status cache information of each access device at the first moment includes: If the data distribution of the online and offline status cache information at the first moment is a dense data distribution, the online and offline status cache information is stored in the bitmap container; If the data distribution of the online and offline status cache information at the first moment is sparse, the online and offline status cache information is stored in the array container; If the online / offline status cache information is continuous data at the first moment, the online / offline status cache information is stored in the running container.
[0059] In this invention, if the online / offline status cache information collected at the first moment shows that most devices are online, i.e., the data distribution is dense, the service stores the online / offline status cache information in a BitmapContainer.
[0060] The BitmapContainer uses a long integer array to represent a bitmap, with each long integer storing 64 bits. It is suitable for storing a large number of consecutive 1s, i.e., when most devices are online.
[0061] In this invention, if the online and offline status cache information collected at the first moment shows that only a few devices are online, that is, the data distribution is sparse.
[0062] In this scenario, the service stores online / offline status cache information in an ArrayContainer. An ArrayContainer uses a short integer array to store the positions of all bits that are 1. This is suitable for storing a small number of scattered 1s, i.e., when only a few devices are online, thus saving storage space.
[0063] In this invention, if the online / offline status cache information collected at the first moment shows that the online status of the device is continuous, that is, there is a continuous period of time during which all devices are online, then the service stores the online / offline status cache information in the RunContainer.
[0064] RunContainer is a container that uses a short integer array to store the starting position and length of consecutive 1s. It is suitable for storing consecutive 1s, i.e., when there is a continuous range of devices online, thereby further reducing storage space usage.
[0065] In this invention, Roaring Bitmap can adapt to various data distributions, achieving efficient storage and retrieval regardless of whether the dataset is dense or sparse. By selecting the most suitable container type based on the data distribution characteristics, Roaring Bitmap can significantly reduce storage space usage, especially in cases of uneven data distribution.
[0066] Optionally, the step of comparing and analyzing the first and second access device status compressed bitmaps through an XOR operation to obtain the online / offline status of the access device includes: The change is obtained by comparing the first and second access device state compressed bitmaps bit by bit using an XOR operation. Based on the change amount, determine whether each access device corresponding to the bit has experienced an online / offline change.
[0067] In this invention, the XOR operation is a bitwise operation that compares two bits. If the two bits are the same (both are 0 or both are 1), the result is 0; if the two bits are different (one is 0 and the other is 1), the result is 1.
[0068] At the first moment and the current moment, two bitmaps are generated respectively: a first access device status compressed bitmap and a second access device status compressed bitmap. These two bitmaps represent the online and offline status of the device at two different points in time.
[0069] Perform an XOR operation on the two bitmaps. Specifically, compare each bit in the two bitmaps bit by bit. For example, if the bitmap at the first moment is 1010 and the bitmap at the current moment is 1100, then the result of the XOR operation will be 0110.
[0070] If the two bits being compared are the same (i.e., the XOR result is 0), it is determined that the access device corresponding to that bit has not changed its online / offline status.
[0071] If the two bits being compared are different (i.e., the XOR result is 1), it is determined that the access device corresponding to that bit has undergone an online / offline change.
[0072] In the solution of this invention, changes in device status can be quickly detected through an XOR operation, without needing to check the status of each device individually. This method enables real-time monitoring of device status changes, which is crucial for systems requiring rapid response.
[0073] Optionally, after obtaining the change by comparing the first access device state compressed bitmap and the second access device state compressed bitmap bitmap bit-by-bit through an XOR operation, the method further includes: When the change is not zero, the current device is determined to be the target access device; The changes in the target access device and its device identity information are written into the status change device message queue, and the status change device message queue is pushed to the service end according to a preset period.
[0074] In this invention, devices whose states have changed (i.e., those with a non-zero change value) are identified from the XOR operation result. These devices are then determined to be target access devices, and their identity information (such as device ID) is extracted. This identity information is written into a dedicated state change device message queue. The message queue is a middleware used to transmit messages between different services or systems.
[0075] A preset period is set according to system requirements. This period can be real-time or at regular intervals (such as every minute or every hour). During each preset period, the system reads messages from the message queue and pushes status change information to the business side.
[0076] In this invention, by writing the device identity information corresponding to the online / offline change access device into the status change device message queue and pushing the status change device message queue according to a preset period, the system can efficiently process and store the online / offline status of a large number of devices, while ensuring fast data access and system scalability.
[0077] Figure 3 The device online and offline sensing service framework diagram provided by the present invention is as follows: Figure 3 As shown, each device (such as a light fixture) periodically or proactively reports its status (online or offline) to the system when its status changes. This is typically achieved through a communication module built into the device, such as Wi-Fi, Bluetooth, or a dedicated IoT communication protocol.
[0078] The system's access service is responsible for receiving status information reported by devices. This service may run on a server or cloud platform and is responsible for handling all communication from devices. The access service hashes the status information from different devices and writes it to different Redis databases. Redis is a high-performance key-value store, ideally suited for storing and querying status information from large numbers of devices.
[0079] Redis offers a variety of data structures for storing state information, such as strings, hash tables, or bitmaps. Bitmaps are particularly well-suited for representing the online / offline status of a large number of devices.
[0080] The online / offline service periodically scans the Redis database for device status information. It compares the current status with previous states to detect changes (such as a device changing from online to offline). To improve query efficiency, the service may cache device status for faster response to query requests.
[0081] The device online / offline sensing device provided in this embodiment is described below. The device online / offline sensing device described below can be referred to in correspondence with the device online / offline sensing method described above.
[0082] Figure 4 This is a schematic diagram of the online and offline sensing device structure provided by the present invention, as shown below. Figure 4 As shown, it includes: The first generation module 410 is used to generate a compressed bitmap of the status of the first access device based on the online and offline status cache information of each access device at the first moment. The second generation module 420 is used to obtain the online and offline status cache information of each access device at the current time and generate a second access device status compressed bitmap; wherein, the first time is earlier than the current time by one device status scan cycle; The sensing module 430 is used to compare and analyze the first access device status compressed bitmap and the second access device status compressed bitmap through an XOR operation to obtain the online and offline status of the access device.
[0083] Optionally, the device is further used for: Obtain device status information reported by each access device, and hash and cache the device status information in the memory data storage system through range routing; The device status information of each memory data storage system is scanned to obtain online and offline status cache information from each device status information.
[0084] Optionally, the device is further used for: Based on the range mapping relationship, the target sharding unit corresponding to the device status information is determined in the memory data storage system. The online and offline status cache information is obtained by performing a task scanning operation through the target shard unit and stored in the corresponding target shard unit.
[0085] Optionally, the device is further used for: If the data distribution of the online and offline status cache information at the first moment is a dense data distribution, the online and offline status cache information is stored in the bitmap container; If the data distribution of the online and offline status cache information at the first moment is sparse, the online and offline status cache information is stored in the array container; If the online / offline status cache information is continuous data at the first moment, the online / offline status cache information is stored in the running container.
[0086] Optionally, the device is further used for: The change is obtained by comparing the first and second access device state compressed bitmaps bit by bit using an XOR operation. Based on the change amount, determine whether each access device corresponding to the bit has experienced an online / offline change.
[0087] Optionally, the device is further used for: When the change is not zero, the current device is determined to be the target access device; The changes in the target access device and its device identity information are written into the status change device message queue, and the status change device message queue is pushed to the service end according to a preset period.
[0088] In this invention, a first access device status compressed bitmap and a second access device status compressed bitmap are generated based on the online and offline status cache information of each access device. The compressed bitmap data structure can efficiently store and process the status information of a large number of devices. Then, by periodically scanning and comparing the first access device status compressed bitmap and the second access device status compressed bitmap, the amount of data analysis can be effectively reduced, and the changes in the online and offline status of access devices can be quickly and accurately perceived.
[0089] Figure 5 This is a schematic diagram of the structure of the electronic device provided by the present invention, such as... Figure 5 As shown, the online / offline sensing device for the lighting fixture may include: a processor 510, a communication interface 520, a memory 530, and a communication bus 540. The processor 510, communication interface 520, and memory 530 communicate with each other via the communication bus 540. The processor 510 can call logical instructions from the memory 530 to execute the device's online / offline sensing method, which includes: Based on the online and offline status cache information of each access device at the first moment, a compressed bitmap of the status of the first access device is generated; Obtain the online / offline status cache information of each access device at the current moment, and generate a second access device status compressed bitmap; wherein, the first moment is one device status scan cycle earlier than the current moment; By performing an XOR operation, the compressed bitmaps of the first and second access device statuses are compared and analyzed to obtain the online and offline status of the access devices.
[0090] Furthermore, the logical instructions in the aforementioned memory 530 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this embodiment, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this embodiment. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0091] On the other hand, this embodiment also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium. The computer program includes program instructions, and when the program instructions are executed by a computer, the computer can execute the online and offline device sensing methods provided by the above methods, which include: Based on the online and offline status cache information of each access device at the first moment, a compressed bitmap of the status of the first access device is generated; Obtain the online / offline status cache information of each access device at the current moment, and generate a second access device status compressed bitmap; wherein, the first moment is one device status scan cycle earlier than the current moment; By performing an XOR operation, the compressed bitmaps of the first and second access device statuses are compared and analyzed to obtain the online and offline status of the access devices.
[0092] In another aspect, this embodiment also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the above-described online and offline sensing methods for devices, the method comprising: Based on the online and offline status cache information of each access device at the first moment, a compressed bitmap of the status of the first access device is generated; Obtain the online / offline status cache information of each access device at the current moment, and generate a second access device status compressed bitmap; wherein, the first moment is one device status scan cycle earlier than the current moment; By performing an XOR operation, the compressed bitmaps of the first and second access device statuses are compared and analyzed to obtain the online and offline status of the access devices.
[0093] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0094] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0095] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this embodiment, and not to limit them; although this embodiment has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this embodiment.
Claims
1. A method for online and offline sensing of a device, characterized in that, include: Based on the online and offline status cache information of each access device at the first moment, a compressed bitmap of the status of the first access device is generated; Obtain the online / offline status cache information of each access device at the current moment, and generate a second access device status compressed bitmap; wherein, the first moment is one device status scan cycle earlier than the current moment; By performing an XOR operation, the compressed bitmaps of the first and second access device statuses are compared and analyzed to obtain the online and offline status of the access devices.
2. The online and offline sensing method for devices according to claim 1, characterized in that, Before the step of generating a first access device status compressed bitmap based on the online / offline status cache information of each access device at the first moment, the method further includes: Obtain device status information reported by each access device, and hash and cache the device status information in the memory data storage system through range routing; The device status information of each memory data storage system is scanned to obtain online and offline status cache information from each device status information.
3. The online and offline sensing method for devices according to claim 2, characterized in that, The step of obtaining device status information reported by each access device and hashing and caching the device status information in the memory data storage system through range routing includes: Based on the range mapping relationship, the target sharding unit corresponding to the device status information is determined in the memory data storage system. The online and offline status cache information is obtained by performing a task scanning operation through the target shard unit and stored in the corresponding target shard unit.
4. The online and offline sensing method for devices according to claim 1, characterized in that, The access device status compressed bitmap includes: a running container, a bitmap container, and an array container.
5. The online and offline sensing method for devices according to claim 4, characterized in that, The step of generating a compressed bitmap of the first access device status based on the online / offline status cache information of each access device at the first moment includes: If the data distribution of the online and offline status cache information at the first moment is a dense data distribution, the online and offline status cache information is stored in the bitmap container; If the data distribution of the online and offline status cache information at the first moment is sparse, the online and offline status cache information is stored in the array container; If the online / offline status cache information is continuous data at the first moment, the online / offline status cache information is stored in the running container.
6. The online and offline sensing method for devices according to claim 1, characterized in that, The step of comparing and analyzing the first and second access device status compressed bitmaps through an XOR operation to obtain the online / offline status of the access device includes: The change is obtained by comparing the first and second access device state compressed bitmaps bit by bit using an XOR operation. Based on the change amount, determine whether each access device corresponding to the bit has experienced an online / offline change.
7. The online and offline sensing method for devices according to claim 6, characterized in that, After obtaining the change by comparing the first access device state compressed bitmap and the second access device state compressed bitmap bitmap bit-by-bit through an XOR operation, the method further includes: When the change is not zero, the current device is determined to be the target access device; The changes in the target access device and its device identity information are written into the status change device message queue, and the status change device message queue is pushed to the service end according to a preset period.
8. An online / offline sensing device for equipment, characterized in that, include: The first generation module is used to generate a compressed bitmap of the status of the first access device based on the online and offline status cache information of each access device at the first moment. The second generation module is used to obtain the online and offline status cache information of each access device at the current moment and generate a second access device status compressed bitmap; wherein, the first moment is earlier than the current moment by one device status scan cycle; The sensing module is used to compare and analyze the compressed bitmap of the first access device status and the compressed bitmap of the second access device status through an XOR operation to obtain the online and offline status of the access device.
9. A lighting fixture online / offline sensing device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the online / offline sensing method for the device as described in any one of claims 1 to 7.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the online and offline sensing method for the device as described in any one of claims 1 to 7.